Commit 80bfd80a authored by Elliot Lee's avatar Elliot Lee

Restructure the whole NautilusWindow code for sanity's sake.



* src/*.c: Restructure the whole NautilusWindow code for sanity's sake.

* src/ntl-uri-map.[ch]: Instead of just passing in various pieces of information about
  the old URL, pass in the Nautilus_NavigationInfo that has to be kept around anyways.

* idl/nautilus.idl: Allow a selection to be multiple URI's.
parent 8585f2c4
1999-12-14 Elliot Lee <sopwith@redhat.com>
* src/*.c: Restructure the whole NautilusWindow code for sanity's sake.
* src/ntl-uri-map.[ch]: Instead of just passing in various pieces of information about the old URL,
pass in the Nautilus_NavigationInfo that has to be kept around anyways.
* idl/nautilus.idl: Allow a selection to be multiple URI's.
1999-12-14 Darin Adler <darin@eazel.com>
* src/ntl-window.c: (nautilus-window-constructed): Forward-button signal
......
......@@ -16,14 +16,14 @@ module Nautilus {
};
struct SelectionInfo {
string selected_uri;
sequence<string> selected_uris;
Object content_view;
boolean self_originated;
};
struct SelectionRequestInfo {
string selected_uri;
sequence<string> selected_uris;
};
struct StatusRequestInfo {
......
......@@ -626,6 +626,7 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
if (priv->hsb_visible) {
GtkRequisition hsb_requisition;
gint possible_new_height;
gtk_widget_get_child_requisition (priv->hsb, &hsb_requisition);
......@@ -633,8 +634,10 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
|| priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += hsb_requisition.height + priv->sb_spacing;
allocation->height = MAX (1, ((gint) allocation->height
- ((gint) hsb_requisition.height + priv->sb_spacing)));
possible_new_height =
( ((gint)allocation->height)
- ((gint)hsb_requisition.height) + ((gint)priv->sb_spacing));
allocation->height = MAX (1, possible_new_height);
}
}
......@@ -692,8 +695,8 @@ gtk_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
child_allocation.x = priv->frame_x + xthickness;
child_allocation.y = priv->frame_y + ythickness;
child_allocation.width = priv->frame_w - 2 * xthickness;
child_allocation.height = priv->frame_h - 2 * ythickness;
child_allocation.width = MAX(1, priv->frame_w - 2 * xthickness);
child_allocation.height = MAX(1, priv->frame_h - 2 * ythickness);
previous_hvis = priv->hsb_visible;
previous_vvis = priv->vsb_visible;
......
......@@ -28,10 +28,11 @@
#include <libgnomevfs/gnome-vfs.h>
#include "dfos.h"
#include "error.h"
#include "dfos-xfer.h"
#define error(x...)
struct _XferInfo {
GnomeVFSAsyncHandle *handle;
......@@ -69,7 +70,7 @@ xfer_info_destroy (XferInfo *info)
g_free (info);
}
static void
xfer_dialog_clicked_callback (DFOSXferProgressDialog *dialog,
gint button_number,
......
......@@ -626,6 +626,7 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
if (priv->hsb_visible) {
GtkRequisition hsb_requisition;
gint possible_new_height;
gtk_widget_get_child_requisition (priv->hsb, &hsb_requisition);
......@@ -633,8 +634,10 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
|| priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += hsb_requisition.height + priv->sb_spacing;
allocation->height = MAX (1, ((gint) allocation->height
- ((gint) hsb_requisition.height + priv->sb_spacing)));
possible_new_height =
( ((gint)allocation->height)
- ((gint)hsb_requisition.height) + ((gint)priv->sb_spacing));
allocation->height = MAX (1, possible_new_height);
}
}
......@@ -692,8 +695,8 @@ gtk_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
child_allocation.x = priv->frame_x + xthickness;
child_allocation.y = priv->frame_y + ythickness;
child_allocation.width = priv->frame_w - 2 * xthickness;
child_allocation.height = priv->frame_h - 2 * ythickness;
child_allocation.width = MAX(1, priv->frame_w - 2 * xthickness);
child_allocation.height = MAX(1, priv->frame_h - 2 * ythickness);
previous_hvis = priv->hsb_visible;
previous_vvis = priv->vsb_visible;
......
......@@ -626,6 +626,7 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
if (priv->hsb_visible) {
GtkRequisition hsb_requisition;
gint possible_new_height;
gtk_widget_get_child_requisition (priv->hsb, &hsb_requisition);
......@@ -633,8 +634,10 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
|| priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += hsb_requisition.height + priv->sb_spacing;
allocation->height = MAX (1, ((gint) allocation->height
- ((gint) hsb_requisition.height + priv->sb_spacing)));
possible_new_height =
( ((gint)allocation->height)
- ((gint)hsb_requisition.height) + ((gint)priv->sb_spacing));
allocation->height = MAX (1, possible_new_height);
}
}
......@@ -692,8 +695,8 @@ gtk_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
child_allocation.x = priv->frame_x + xthickness;
child_allocation.y = priv->frame_y + ythickness;
child_allocation.width = priv->frame_w - 2 * xthickness;
child_allocation.height = priv->frame_h - 2 * ythickness;
child_allocation.width = MAX(1, priv->frame_w - 2 * xthickness);
child_allocation.height = MAX(1, priv->frame_h - 2 * ythickness);
previous_hvis = priv->hsb_visible;
previous_vvis = priv->vsb_visible;
......
......@@ -28,10 +28,11 @@
#include <libgnomevfs/gnome-vfs.h>
#include "dfos.h"
#include "error.h"
#include "dfos-xfer.h"
#define error(x...)
struct _XferInfo {
GnomeVFSAsyncHandle *handle;
......@@ -69,7 +70,7 @@ xfer_info_destroy (XferInfo *info)
g_free (info);
}
static void
xfer_dialog_clicked_callback (DFOSXferProgressDialog *dialog,
gint button_number,
......
......@@ -626,6 +626,7 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
if (priv->hsb_visible) {
GtkRequisition hsb_requisition;
gint possible_new_height;
gtk_widget_get_child_requisition (priv->hsb, &hsb_requisition);
......@@ -633,8 +634,10 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
|| priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += hsb_requisition.height + priv->sb_spacing;
allocation->height = MAX (1, ((gint) allocation->height
- ((gint) hsb_requisition.height + priv->sb_spacing)));
possible_new_height =
( ((gint)allocation->height)
- ((gint)hsb_requisition.height) + ((gint)priv->sb_spacing));
allocation->height = MAX (1, possible_new_height);
}
}
......@@ -692,8 +695,8 @@ gtk_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
child_allocation.x = priv->frame_x + xthickness;
child_allocation.y = priv->frame_y + ythickness;
child_allocation.width = priv->frame_w - 2 * xthickness;
child_allocation.height = priv->frame_h - 2 * ythickness;
child_allocation.width = MAX(1, priv->frame_w - 2 * xthickness);
child_allocation.height = MAX(1, priv->frame_h - 2 * ythickness);
previous_hvis = priv->hsb_visible;
previous_vvis = priv->vsb_visible;
......
......@@ -626,6 +626,7 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
if (priv->hsb_visible) {
GtkRequisition hsb_requisition;
gint possible_new_height;
gtk_widget_get_child_requisition (priv->hsb, &hsb_requisition);
......@@ -633,8 +634,10 @@ compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation)
|| priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += hsb_requisition.height + priv->sb_spacing;
allocation->height = MAX (1, ((gint) allocation->height
- ((gint) hsb_requisition.height + priv->sb_spacing)));
possible_new_height =
( ((gint)allocation->height)
- ((gint)hsb_requisition.height) + ((gint)priv->sb_spacing));
allocation->height = MAX (1, possible_new_height);
}
}
......@@ -692,8 +695,8 @@ gtk_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
child_allocation.x = priv->frame_x + xthickness;
child_allocation.y = priv->frame_y + ythickness;
child_allocation.width = priv->frame_w - 2 * xthickness;
child_allocation.height = priv->frame_h - 2 * ythickness;
child_allocation.width = MAX(1, priv->frame_w - 2 * xthickness);
child_allocation.height = MAX(1, priv->frame_h - 2 * ythickness);
previous_hvis = priv->hsb_visible;
previous_vvis = priv->vsb_visible;
......
......@@ -29,9 +29,14 @@ nautilus_SOURCES= \
ntl-view.c \
ntl-window.h \
ntl-window.c \
ntl-window-msgs.c \
ntl-window-msgs.h \
ntl-window-private.h \
ntl-window-state.h \
ntl-window-state.c \
explorer-location-bar.h \
explorer-location-bar.c
goaddir=$(sysconfdir)/CORBA/servers
goad_DATA=nautilus.goad
EXTRA_DIST=$(goad_DATA)
\ No newline at end of file
EXTRA_DIST=$(goad_DATA)
......@@ -28,10 +28,11 @@
#include <libgnomevfs/gnome-vfs.h>
#include "dfos.h"
#include "error.h"
#include "dfos-xfer.h"
#define error(x...)
struct _XferInfo {
GnomeVFSAsyncHandle *handle;
......@@ -69,7 +70,7 @@ xfer_info_destroy (XferInfo *info)
g_free (info);
}
static void
xfer_dialog_clicked_callback (DFOSXferProgressDialog *dialog,
gint button_number,
......
......@@ -874,6 +874,11 @@ fm_directory_view_load_uri (FMDirectoryView *view,
fm_directory_view_stop (view);
if(view_has_icon_container(view))
gnome_icon_container_clear(get_icon_container(view));
if(view_has_flist(view))
gtk_clist_clear(GTK_CLIST(get_flist(view)));
if (view->uri != NULL)
gnome_vfs_uri_unref (view->uri);
view->uri = gnome_vfs_uri_new (uri);
......@@ -895,6 +900,7 @@ fm_directory_view_load_uri (FMDirectoryView *view,
directory_load_cb, /* callback */
view); /* callback_data */
g_return_if_fail(result == GNOME_VFS_OK);
/*
if (result != GNOME_VFS_OK)
gtk_signal_emit (GTK_OBJECT (view), signals[OPEN_FAILED],
......
......@@ -31,18 +31,19 @@
NautilusNavigationInfo *
nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
Nautilus_NavigationRequestInfo *nri,
NautilusLocationReference referring_uri,
NautilusLocationReference actual_referring_uri,
const char *referring_content_type,
GtkWidget *requesting_view)
Nautilus_NavigationInfo *old_navinfo,
NautilusView *requesting_view)
{
const char *meta_keys[] = {"icon-filename", NULL};
memset(navinfo, 0, sizeof(*navinfo));
navinfo->navinfo.requested_uri = nri->requested_uri;
navinfo->navinfo.referring_uri = referring_uri;
navinfo->navinfo.actual_referring_uri = actual_referring_uri;
navinfo->navinfo.referring_content_type = (char *)referring_content_type;
if(old_navinfo)
{
navinfo->navinfo.referring_uri = old_navinfo->requested_uri;
navinfo->navinfo.actual_referring_uri = old_navinfo->actual_uri;
navinfo->navinfo.referring_content_type = old_navinfo->content_type;
}
navinfo->requesting_view = requesting_view;
......@@ -52,7 +53,7 @@ nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
GNOME_VFS_FILE_INFO_GETMIMETYPE
|GNOME_VFS_FILE_INFO_FOLLOWLINKS,
meta_keys);
navinfo->navinfo.content_type = gnome_vfs_file_info_get_mime_type(navinfo->vfs_fileinfo);
navinfo->navinfo.content_type = (char *)gnome_vfs_file_info_get_mime_type(navinfo->vfs_fileinfo);
/* Given a content type and a URI, what do we do? Basically the "expert system" below
tries to answer that question
......
......@@ -28,13 +28,12 @@
#define NAUTILUS_URI_MAP_H 1
#include "ntl-types.h"
#include "ntl-view.h"
NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
Nautilus_NavigationRequestInfo *nri,
NautilusLocationReference referring_uri,
NautilusLocationReference actual_referring_uri,
const char *referring_content_type,
GtkWidget *requesting_view);
Nautilus_NavigationInfo *old_navinfo,
NautilusView *requesting_view);
void nautilus_navinfo_free(NautilusNavigationInfo *navinfo);
#endif
......@@ -28,8 +28,9 @@
#include <gnome.h>
#include "nautilus.h"
#include "explorer-location-bar.h"
#include "ntl-window-private.h"
/* Stuff for handling the CORBA interface */
typedef struct {
POA_Nautilus_ViewWindow servant;
gpointer gnome_object;
......@@ -102,18 +103,9 @@ static void nautilus_window_set_arg (GtkObject *object,
static void nautilus_window_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_window_goto_url (GtkWidget *widget,
const char *url,
GtkWidget *window);
static void nautilus_window_real_request_location_change (NautilusWindow *window,
Nautilus_NavigationRequestInfo *loc,
GtkWidget *requesting_view);
static void nautilus_window_real_request_selection_change(NautilusWindow *window,
Nautilus_SelectionRequestInfo *loc,
GtkWidget *requesting_view);
static void nautilus_window_real_request_status_change(NautilusWindow *window,
Nautilus_StatusRequestInfo *loc,
GtkWidget *requesting_view);
static void nautilus_window_goto_url_cb (GtkWidget *widget,
const char *url,
GtkWidget *window);
#define CONTENTS_AS_HBOX
/* milliseconds */
......@@ -224,7 +216,7 @@ nautilus_window_clear_status(NautilusWindow *window)
return FALSE;
}
static void
void
nautilus_window_set_status(NautilusWindow *window, const char *txt)
{
if(window->statusbar_clear_id)
......@@ -240,10 +232,8 @@ nautilus_window_set_status(NautilusWindow *window, const char *txt)
window->statusbar_clear_id = 0;
}
static void
nautilus_window_goto_url (GtkWidget *widget,
const char *url,
GtkWidget *window)
void
nautilus_window_goto_url(NautilusWindow *window, const char *url)
{
Nautilus_NavigationRequestInfo navinfo;
......@@ -256,6 +246,14 @@ nautilus_window_goto_url (GtkWidget *widget,
NULL);
}
static void
nautilus_window_goto_url_cb (GtkWidget *widget,
const char *url,
GtkWidget *window)
{
nautilus_window_goto_url(window, url);
}
static void
gtk_option_menu_do_resize(GtkWidget *widget, GtkWidget *child, GtkWidget *optmenu)
{
......@@ -428,7 +426,7 @@ nautilus_window_set_arg (GtkObject *object,
{
GnomeApp *app = (GnomeApp *) object;
char *old_app_name;
GtkWidget *new_cv;
NautilusView *new_cv;
NautilusWindow *window = (NautilusWindow *) object;
switch(arg_id) {
......@@ -446,21 +444,21 @@ nautilus_window_set_arg (GtkObject *object,
nautilus_window_constructed(NAUTILUS_WINDOW(object));
break;
case ARG_CONTENT_VIEW:
new_cv = GTK_WIDGET(GTK_VALUE_OBJECT(*arg));
new_cv = NAUTILUS_VIEW(GTK_VALUE_OBJECT(*arg));
if(window->content_view)
{
gtk_widget_ref(GTK_WIDGET(window->content_view));
gtk_container_remove(GTK_CONTAINER(window->content_hbox), GTK_WIDGET(window->content_view));
#ifdef CONTENTS_AS_HBOX
gtk_box_pack_start(GTK_BOX(window->content_hbox), new_cv, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(window->content_hbox), GTK_WIDGET(new_cv), TRUE, TRUE, GNOME_PAD);
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
gtk_paned_pack1(GTK_PANED(window->content_hbox), GTK_WIDGET(new_cv), TRUE, FALSE);
#endif
gtk_widget_unref(GTK_WIDGET(window->content_view));
}
else
#ifdef CONTENTS_AS_HBOX
gtk_box_pack_start(GTK_BOX(window->content_hbox), new_cv, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(window->content_hbox), GTK_WIDGET(new_cv), TRUE, TRUE, GNOME_PAD);
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
#endif
......@@ -496,9 +494,8 @@ nautilus_window_init (NautilusWindow *window)
static void nautilus_window_destroy (NautilusWindow *window)
{
g_slist_free(window->meta_views);
g_free(window->current_uri);
g_free(window->actual_current_uri);
g_free(window->current_content_type);
CORBA_free(window->ni);
CORBA_free(window->si);
g_slist_foreach(window->uris_prev, (GFunc)g_free, NULL);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
g_slist_free(window->uris_prev);
......@@ -514,13 +511,6 @@ nautilus_window_new(const char *app_id)
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
}
void
nautilus_window_set_content_view(NautilusWindow *window, NautilusView *content_view)
{
gtk_object_set(GTK_OBJECT(window), "content_view", content_view, NULL);
gtk_widget_show(GTK_WIDGET(content_view));
}
static gboolean
nautilus_window_send_show_properties(GtkWidget *dockitem, GdkEventButton *event, NautilusView *meta_view)
{
......@@ -534,6 +524,13 @@ nautilus_window_send_show_properties(GtkWidget *dockitem, GdkEventButton *event,
return TRUE;
}
void
nautilus_window_set_content_view(NautilusWindow *window, NautilusView *content_view)
{
gtk_object_set(GTK_OBJECT(window), "content_view", content_view, NULL);
gtk_widget_show(GTK_WIDGET(content_view));
}
void
nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view)
{
......@@ -576,357 +573,6 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view
gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum);
}
void
nautilus_window_request_status_change(NautilusWindow *window,
Nautilus_StatusRequestInfo *loc,
GtkWidget *requesting_view)
{
NautilusWindowClass *klass;
GtkObject *obj;
obj = GTK_OBJECT(window);
klass = NAUTILUS_WINDOW_CLASS(obj->klass);
gtk_signal_emit(obj, klass->window_signals[2], loc, requesting_view);
}
void
nautilus_window_request_selection_change(NautilusWindow *window,
Nautilus_SelectionRequestInfo *loc,
GtkWidget *requesting_view)
{
NautilusWindowClass *klass;
GtkObject *obj;
obj = GTK_OBJECT(window);
klass = NAUTILUS_WINDOW_CLASS(obj->klass);
gtk_signal_emit(obj, klass->window_signals[1], loc, requesting_view);
}
void
nautilus_window_request_location_change(NautilusWindow *window,
Nautilus_NavigationRequestInfo *loc,
GtkWidget *requesting_view)
{
NautilusWindowClass *klass;
GtkObject *obj;
obj = GTK_OBJECT(window);
klass = NAUTILUS_WINDOW_CLASS(obj->klass);
gtk_signal_emit(obj, klass->window_signals[0], loc, requesting_view);
}
static void
nautilus_window_change_location(NautilusWindow *window,
Nautilus_NavigationRequestInfo *loc,
GtkWidget *requesting_view,
gboolean is_back)
{
guint signum;
GSList *cur;
GSList *discard_views, *keep_views, *notfound_views;
NautilusNavigationInfo loci_spot, *loci;
loci = nautilus_navinfo_new(&loci_spot, loc, window->current_uri, window->actual_current_uri, window->current_content_type,
requesting_view);
if(!loci)
{
char cbuf[1024];
g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc->requested_uri);
nautilus_window_set_status(window, cbuf);
return;
}
/* Update history */
if(is_back)
{
window->uris_next = g_slist_prepend(window->uris_next, window->uris_prev->data);
window->uris_prev = g_slist_remove(window->uris_prev, window->uris_prev->data);
}
else
{
char *append_val;
if(window->uris_next && !strcmp(loc->requested_uri, window->uris_next->data))
{
append_val = window->uris_next->data;
window->uris_next = g_slist_remove(window->uris_next, window->uris_next->data);
}
else
{
append_val = g_strdup(loc->requested_uri);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
g_slist_free(window->uris_next); window->uris_next = NULL;
}
if(append_val)
window->uris_prev = g_slist_prepend(window->uris_prev, append_val);
}
gtk_widget_set_sensitive(window->btn_back, window->uris_prev?TRUE:FALSE);
gtk_widget_set_sensitive(window->btn_fwd, window->uris_next?TRUE:FALSE);
explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_url),
loci->navinfo.requested_uri);
signum = gtk_signal_lookup("notify_location_change", nautilus_view_get_type());
/* If we need to load a different IID, do that before sending the location change request */
if(!window->content_view || strcmp(NAUTILUS_VIEW(window->content_view)->iid, loci->content_iid)) {
NautilusView *new_view;
if(requesting_view == window->content_view)
requesting_view = NULL;
new_view = NAUTILUS_VIEW(gtk_widget_new(nautilus_content_view_get_type(), "main_window", window, NULL));
nautilus_view_load_client(new_view, loci->content_iid);
nautilus_window_set_content_view(window, new_view);
}
loci->navinfo.content_view = NAUTILUS_VIEW(window->content_view)->view_client;