summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliot Lee <sopwith@src.gnome.org>1999-12-06 18:33:28 +0000
committerElliot Lee <sopwith@src.gnome.org>1999-12-06 18:33:28 +0000
commit44302b3c22f7b27bce0d7d9ca1c8189f14526195 (patch)
treeee472bf5c75bc4b6b925a1a36aa057fc140b6d42
parent24997abbdd38ffec958fa88a8f8b24e798a03991 (diff)
downloadnautilus-44302b3c22f7b27bce0d7d9ca1c8189f14526195.tar.gz
Theoretically does URI mapping now. (Need OAF).
Theoretically does URI mapping now. (Need OAF).
-rw-r--r--src/.cvsignore1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/nautilus-applicable-views.c23
-rw-r--r--src/nautilus-applicable-views.h12
-rw-r--r--src/nautilus-navigation-window.c123
-rw-r--r--src/nautilus-navigation-window.h3
-rw-r--r--src/nautilus-object-window.c123
-rw-r--r--src/nautilus-object-window.h3
-rw-r--r--src/nautilus-spatial-window.c123
-rw-r--r--src/nautilus-spatial-window.h3
-rw-r--r--src/nautilus-view-frame.h24
-rw-r--r--src/nautilus-window.c123
-rw-r--r--src/nautilus-window.h3
-rw-r--r--src/nautilus.h1
-rw-r--r--src/ntl-types.h5
-rw-r--r--src/ntl-uri-map.c23
-rw-r--r--src/ntl-uri-map.h12
-rw-r--r--src/ntl-view.h24
-rw-r--r--src/ntl-window.c123
-rw-r--r--src/ntl-window.h3
20 files changed, 642 insertions, 115 deletions
diff --git a/src/.cvsignore b/src/.cvsignore
new file mode 100644
index 000000000..70845e08e
--- /dev/null
+++ b/src/.cvsignore
@@ -0,0 +1 @@
+Makefile.in
diff --git a/src/Makefile.am b/src/Makefile.am
index a68e8f9bf..de99afb80 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,8 @@ nautilus_SOURCES= \
ntl-meta-view.h \
ntl-meta-view.c \
ntl-types.h \
+ ntl-uri-map.h \
+ ntl-uri-map.c \
ntl-view.h \
ntl-view.c \
ntl-window.h \
diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c
new file mode 100644
index 000000000..b2c4a94ba
--- /dev/null
+++ b/src/nautilus-applicable-views.c
@@ -0,0 +1,23 @@
+#include "ntl-uri-map.h"
+#include <libgnorba/gnorba.h>
+
+NautilusNavigationInfo *
+nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri,
+ NautilusLocationReference referring_uri,
+ NautilusLocationReference actual_referring_uri,
+ const char *referring_content_type)
+{
+ navinfo->requested_uri = uri;
+ navinfo->referring_uri = referring_uri;
+ navinfo->actual_referring_uri = actual_referring_uri;
+ navinfo->referring_content_type = (char *)referring_content_type;
+
+ /* XXX turn the provided information into some activateable IID's */
+
+ return NULL;
+}
+
+void
+nautilus_navinfo_free(NautilusNavigationInfo *navinfo)
+{
+}
diff --git a/src/nautilus-applicable-views.h b/src/nautilus-applicable-views.h
new file mode 100644
index 000000000..d01e0c617
--- /dev/null
+++ b/src/nautilus-applicable-views.h
@@ -0,0 +1,12 @@
+#ifndef NAUTILUS_URI_MAP_H
+#define NAUTILUS_URI_MAP_H 1
+
+#include "ntl-types.h"
+
+NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri,
+ NautilusLocationReference referring_uri,
+ NautilusLocationReference actual_referring_uri,
+ const char *referring_content_type);
+void nautilus_navinfo_free(NautilusNavigationInfo *navinfo);
+
+#endif
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index e2398492c..62e824628 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -4,6 +4,7 @@
static void nautilus_window_class_init (NautilusWindowClass *klass);
static void nautilus_window_init (NautilusWindow *window);
+static void nautilus_window_destroy (NautilusWindow *window);
static void nautilus_window_back (NautilusWindow *window);
static void nautilus_window_fwd (NautilusWindow *window);
static void nautilus_window_set_arg (GtkObject *object,
@@ -19,6 +20,8 @@ static void nautilus_window_real_request_location_change (NautilusWindow *window
GtkWidget *requesting_view);
#define CONTENTS_AS_HBOX
+/* six seconds */
+#define STATUSBAR_CLEAR_TIMEOUT 6000
GtkType
nautilus_window_get_type(void)
@@ -73,6 +76,7 @@ nautilus_window_class_init (NautilusWindowClass *klass)
int i;
object_class = (GtkObjectClass*) klass;
+ object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
object_class->set_arg = nautilus_window_set_arg;
@@ -100,6 +104,30 @@ nautilus_window_class_init (NautilusWindowClass *klass)
ARG_CONTENT_VIEW);
}
+static gboolean
+nautilus_window_clear_status(NautilusWindow *window)
+{
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ window->statusbar_clear_id = 0;
+ return FALSE;
+}
+
+static void
+nautilus_window_set_status(NautilusWindow *window, const char *txt)
+{
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ if(txt)
+ {
+ window->statusbar_clear_id = g_timeout_add(STATUSBAR_CLEAR_TIMEOUT, (GSourceFunc)nautilus_window_clear_status, window);
+ gtk_statusbar_push(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx, txt);
+ }
+ else
+ window->statusbar_clear_id = 0;
+}
+
static void
nautilus_window_constructed(NautilusWindow *window)
{
@@ -109,7 +137,7 @@ nautilus_window_constructed(NautilusWindow *window)
};
GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_CLOSE_ITEM(nautilus_window_close, NULL),
- GNOMEUIINFO_SUBTREE_STOCK(N_("Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
+ GNOMEUIINFO_SUBTREE_STOCK(N_("_Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
GNOMEUIINFO_END
};
#if 0
@@ -118,14 +146,14 @@ nautilus_window_constructed(NautilusWindow *window)
GNOMEUIINFO_END
};
#endif
- GtkWidget *menu_hbox, *menubar, *wtmp;
+ GtkWidget *menu_hbox, *menubar, *wtmp, *statusbar;
GtkAccelGroup *ag;
app = GNOME_APP(window);
- ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
- if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
- gtk_window_add_accel_group(GTK_WINDOW(app), ag);
+ ag = gtk_accel_group_new();
+ gtk_object_set_data(GTK_OBJECT(app), "GtkAccelGroup", ag);
+ gtk_window_add_accel_group(GTK_WINDOW(app), ag);
menu_hbox = gtk_hbox_new(FALSE, GNOME_PAD);
menubar = gtk_menu_bar_new();
@@ -181,7 +209,9 @@ nautilus_window_constructed(NautilusWindow *window)
}
gtk_widget_show (menu_hbox);
- gnome_app_set_statusbar(app, gtk_statusbar_new());
+ gnome_app_set_statusbar(app, (statusbar = gtk_statusbar_new()));
+ window->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "IhateGtkStatusbar");
+
gnome_app_install_menu_hints(app, main_menu); /* This needs a statusbar in order to work */
wtmp = gnome_stock_pixmap_widget(GTK_WIDGET(window), GNOME_STOCK_PIXMAP_BACK);
@@ -265,7 +295,8 @@ nautilus_window_set_arg (GtkObject *object,
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
#endif
- gtk_widget_queue_resize(window->content_hbox);
+
+ gtk_widget_queue_resize(window->content_hbox);
window->content_view = new_cv;
break;
}
@@ -293,6 +324,21 @@ 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);
+ 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);
+ g_slist_free(window->uris_next);
+
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+}
+
GtkWidget *
nautilus_window_new(const char *app_id)
{
@@ -390,8 +436,20 @@ nautilus_window_change_location(NautilusWindow *window,
{
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);
+
+ if(!loci)
+ {
+ char cbuf[1024];
+ g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc);
+ nautilus_window_set_status(window, cbuf);
+ return;
+ }
+
/* Update history */
if(is_back)
{
@@ -410,30 +468,59 @@ nautilus_window_change_location(NautilusWindow *window,
{
append_val = g_strdup(loc);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
- g_slist_free(window->uris_next);
+ g_slist_free(window->uris_next); window->uris_next = NULL;
}
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);
- memset(&loci_spot, 0, sizeof(loci_spot));
- loci = &loci_spot;
- loci->requested_uri = loci->actual_uri = loc;
- loci->referring_uri = window->current_uri;
- loci->actual_referring_uri = window->actual_current_uri;
-
signum = gtk_signal_lookup("notify_location_change", nautilus_view_get_type());
- for(cur = window->meta_views; cur; cur = cur->next)
- gtk_signal_emit(GTK_OBJECT(cur->data), signum, loci, window->content_view, requesting_view);
+ /* If we need to load a different IID, do that before sending the location change request */
+ if(strcmp(NAUTILUS_VIEW(window->content_view)->iid, loci->content_iid))
+ nautilus_view_load_client(NAUTILUS_VIEW(window->content_view), loci->content_iid);
gtk_signal_emit(GTK_OBJECT(window->content_view), signum, loci, window->content_view, requesting_view);
+ notfound_views = keep_views = discard_views = NULL;
+ for(cur = window->meta_views; cur; cur = cur->next)
+ {
+ NautilusView *view = cur->data;
+
+ if(g_slist_find_custom(loci->meta_iids, view->iid, (GCompareFunc)strcmp))
+ gtk_signal_emit(GTK_OBJECT(view), signum, loci, window->content_view, requesting_view);
+ else
+ discard_views = g_slist_prepend(discard_views, view);
+ }
+ for(cur = loci->meta_iids; cur; cur = cur->next)
+ {
+ GSList *curview;
+ for(curview = window->meta_views; curview; curview = curview->next)
+ {
+ if(!strcmp(NAUTILUS_VIEW(curview->data)->iid, cur->data))
+ break;
+ }
+ if(!curview)
+ {
+ NautilusView *view;
+ view = NAUTILUS_VIEW(gtk_widget_new(nautilus_meta_view_get_type(), "main_window", window, NULL));
+ nautilus_view_load_client(view, cur->data);
+ nautilus_window_add_meta_view(window, view);
+ }
+ }
+ for(cur = discard_views; cur; cur = cur->next)
+ nautilus_window_remove_meta_view(window, cur->data);
+ g_slist_free(discard_views);
+
+ g_free(window->current_content_type);
+ window->current_content_type = g_strdup(loci->content_type);
g_free(window->current_uri);
- window->current_uri = loci->requested_uri;
+ window->current_uri = g_strdup(loci->requested_uri);
g_free(window->actual_current_uri);
- window->actual_current_uri = loci->actual_uri;
+ window->actual_current_uri = g_strdup(loci->actual_uri);
+
+ nautilus_navinfo_free(loci);
}
static void
diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h
index 5f0c291b7..d69ecabfe 100644
--- a/src/nautilus-navigation-window.h
+++ b/src/nautilus-navigation-window.h
@@ -32,8 +32,11 @@ struct _NautilusWindow {
GSList *meta_views;
GtkWidget *meta_notebook, *content_hbox, *btn_back, *btn_fwd;
NautilusLocationReference current_uri, actual_current_uri;
+ char *current_content_type;
GSList *uris_prev, *uris_next;
+
+ guint statusbar_ctx, statusbar_clear_id;
};
GtkType nautilus_window_get_type(void);
diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c
index e2398492c..62e824628 100644
--- a/src/nautilus-object-window.c
+++ b/src/nautilus-object-window.c
@@ -4,6 +4,7 @@
static void nautilus_window_class_init (NautilusWindowClass *klass);
static void nautilus_window_init (NautilusWindow *window);
+static void nautilus_window_destroy (NautilusWindow *window);
static void nautilus_window_back (NautilusWindow *window);
static void nautilus_window_fwd (NautilusWindow *window);
static void nautilus_window_set_arg (GtkObject *object,
@@ -19,6 +20,8 @@ static void nautilus_window_real_request_location_change (NautilusWindow *window
GtkWidget *requesting_view);
#define CONTENTS_AS_HBOX
+/* six seconds */
+#define STATUSBAR_CLEAR_TIMEOUT 6000
GtkType
nautilus_window_get_type(void)
@@ -73,6 +76,7 @@ nautilus_window_class_init (NautilusWindowClass *klass)
int i;
object_class = (GtkObjectClass*) klass;
+ object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
object_class->set_arg = nautilus_window_set_arg;
@@ -100,6 +104,30 @@ nautilus_window_class_init (NautilusWindowClass *klass)
ARG_CONTENT_VIEW);
}
+static gboolean
+nautilus_window_clear_status(NautilusWindow *window)
+{
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ window->statusbar_clear_id = 0;
+ return FALSE;
+}
+
+static void
+nautilus_window_set_status(NautilusWindow *window, const char *txt)
+{
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ if(txt)
+ {
+ window->statusbar_clear_id = g_timeout_add(STATUSBAR_CLEAR_TIMEOUT, (GSourceFunc)nautilus_window_clear_status, window);
+ gtk_statusbar_push(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx, txt);
+ }
+ else
+ window->statusbar_clear_id = 0;
+}
+
static void
nautilus_window_constructed(NautilusWindow *window)
{
@@ -109,7 +137,7 @@ nautilus_window_constructed(NautilusWindow *window)
};
GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_CLOSE_ITEM(nautilus_window_close, NULL),
- GNOMEUIINFO_SUBTREE_STOCK(N_("Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
+ GNOMEUIINFO_SUBTREE_STOCK(N_("_Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
GNOMEUIINFO_END
};
#if 0
@@ -118,14 +146,14 @@ nautilus_window_constructed(NautilusWindow *window)
GNOMEUIINFO_END
};
#endif
- GtkWidget *menu_hbox, *menubar, *wtmp;
+ GtkWidget *menu_hbox, *menubar, *wtmp, *statusbar;
GtkAccelGroup *ag;
app = GNOME_APP(window);
- ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
- if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
- gtk_window_add_accel_group(GTK_WINDOW(app), ag);
+ ag = gtk_accel_group_new();
+ gtk_object_set_data(GTK_OBJECT(app), "GtkAccelGroup", ag);
+ gtk_window_add_accel_group(GTK_WINDOW(app), ag);
menu_hbox = gtk_hbox_new(FALSE, GNOME_PAD);
menubar = gtk_menu_bar_new();
@@ -181,7 +209,9 @@ nautilus_window_constructed(NautilusWindow *window)
}
gtk_widget_show (menu_hbox);
- gnome_app_set_statusbar(app, gtk_statusbar_new());
+ gnome_app_set_statusbar(app, (statusbar = gtk_statusbar_new()));
+ window->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "IhateGtkStatusbar");
+
gnome_app_install_menu_hints(app, main_menu); /* This needs a statusbar in order to work */
wtmp = gnome_stock_pixmap_widget(GTK_WIDGET(window), GNOME_STOCK_PIXMAP_BACK);
@@ -265,7 +295,8 @@ nautilus_window_set_arg (GtkObject *object,
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
#endif
- gtk_widget_queue_resize(window->content_hbox);
+
+ gtk_widget_queue_resize(window->content_hbox);
window->content_view = new_cv;
break;
}
@@ -293,6 +324,21 @@ 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);
+ 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);
+ g_slist_free(window->uris_next);
+
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+}
+
GtkWidget *
nautilus_window_new(const char *app_id)
{
@@ -390,8 +436,20 @@ nautilus_window_change_location(NautilusWindow *window,
{
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);
+
+ if(!loci)
+ {
+ char cbuf[1024];
+ g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc);
+ nautilus_window_set_status(window, cbuf);
+ return;
+ }
+
/* Update history */
if(is_back)
{
@@ -410,30 +468,59 @@ nautilus_window_change_location(NautilusWindow *window,
{
append_val = g_strdup(loc);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
- g_slist_free(window->uris_next);
+ g_slist_free(window->uris_next); window->uris_next = NULL;
}
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);
- memset(&loci_spot, 0, sizeof(loci_spot));
- loci = &loci_spot;
- loci->requested_uri = loci->actual_uri = loc;
- loci->referring_uri = window->current_uri;
- loci->actual_referring_uri = window->actual_current_uri;
-
signum = gtk_signal_lookup("notify_location_change", nautilus_view_get_type());
- for(cur = window->meta_views; cur; cur = cur->next)
- gtk_signal_emit(GTK_OBJECT(cur->data), signum, loci, window->content_view, requesting_view);
+ /* If we need to load a different IID, do that before sending the location change request */
+ if(strcmp(NAUTILUS_VIEW(window->content_view)->iid, loci->content_iid))
+ nautilus_view_load_client(NAUTILUS_VIEW(window->content_view), loci->content_iid);
gtk_signal_emit(GTK_OBJECT(window->content_view), signum, loci, window->content_view, requesting_view);
+ notfound_views = keep_views = discard_views = NULL;
+ for(cur = window->meta_views; cur; cur = cur->next)
+ {
+ NautilusView *view = cur->data;
+
+ if(g_slist_find_custom(loci->meta_iids, view->iid, (GCompareFunc)strcmp))
+ gtk_signal_emit(GTK_OBJECT(view), signum, loci, window->content_view, requesting_view);
+ else
+ discard_views = g_slist_prepend(discard_views, view);
+ }
+ for(cur = loci->meta_iids; cur; cur = cur->next)
+ {
+ GSList *curview;
+ for(curview = window->meta_views; curview; curview = curview->next)
+ {
+ if(!strcmp(NAUTILUS_VIEW(curview->data)->iid, cur->data))
+ break;
+ }
+ if(!curview)
+ {
+ NautilusView *view;
+ view = NAUTILUS_VIEW(gtk_widget_new(nautilus_meta_view_get_type(), "main_window", window, NULL));
+ nautilus_view_load_client(view, cur->data);
+ nautilus_window_add_meta_view(window, view);
+ }
+ }
+ for(cur = discard_views; cur; cur = cur->next)
+ nautilus_window_remove_meta_view(window, cur->data);
+ g_slist_free(discard_views);
+
+ g_free(window->current_content_type);
+ window->current_content_type = g_strdup(loci->content_type);
g_free(window->current_uri);
- window->current_uri = loci->requested_uri;
+ window->current_uri = g_strdup(loci->requested_uri);
g_free(window->actual_current_uri);
- window->actual_current_uri = loci->actual_uri;
+ window->actual_current_uri = g_strdup(loci->actual_uri);
+
+ nautilus_navinfo_free(loci);
}
static void
diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h
index 5f0c291b7..d69ecabfe 100644
--- a/src/nautilus-object-window.h
+++ b/src/nautilus-object-window.h
@@ -32,8 +32,11 @@ struct _NautilusWindow {
GSList *meta_views;
GtkWidget *meta_notebook, *content_hbox, *btn_back, *btn_fwd;
NautilusLocationReference current_uri, actual_current_uri;
+ char *current_content_type;
GSList *uris_prev, *uris_next;
+
+ guint statusbar_ctx, statusbar_clear_id;
};
GtkType nautilus_window_get_type(void);
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index e2398492c..62e824628 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -4,6 +4,7 @@
static void nautilus_window_class_init (NautilusWindowClass *klass);
static void nautilus_window_init (NautilusWindow *window);
+static void nautilus_window_destroy (NautilusWindow *window);
static void nautilus_window_back (NautilusWindow *window);
static void nautilus_window_fwd (NautilusWindow *window);
static void nautilus_window_set_arg (GtkObject *object,
@@ -19,6 +20,8 @@ static void nautilus_window_real_request_location_change (NautilusWindow *window
GtkWidget *requesting_view);
#define CONTENTS_AS_HBOX
+/* six seconds */
+#define STATUSBAR_CLEAR_TIMEOUT 6000
GtkType
nautilus_window_get_type(void)
@@ -73,6 +76,7 @@ nautilus_window_class_init (NautilusWindowClass *klass)
int i;
object_class = (GtkObjectClass*) klass;
+ object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
object_class->set_arg = nautilus_window_set_arg;
@@ -100,6 +104,30 @@ nautilus_window_class_init (NautilusWindowClass *klass)
ARG_CONTENT_VIEW);
}
+static gboolean
+nautilus_window_clear_status(NautilusWindow *window)
+{
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ window->statusbar_clear_id = 0;
+ return FALSE;
+}
+
+static void
+nautilus_window_set_status(NautilusWindow *window, const char *txt)
+{
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ if(txt)
+ {
+ window->statusbar_clear_id = g_timeout_add(STATUSBAR_CLEAR_TIMEOUT, (GSourceFunc)nautilus_window_clear_status, window);
+ gtk_statusbar_push(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx, txt);
+ }
+ else
+ window->statusbar_clear_id = 0;
+}
+
static void
nautilus_window_constructed(NautilusWindow *window)
{
@@ -109,7 +137,7 @@ nautilus_window_constructed(NautilusWindow *window)
};
GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_CLOSE_ITEM(nautilus_window_close, NULL),
- GNOMEUIINFO_SUBTREE_STOCK(N_("Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
+ GNOMEUIINFO_SUBTREE_STOCK(N_("_Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
GNOMEUIINFO_END
};
#if 0
@@ -118,14 +146,14 @@ nautilus_window_constructed(NautilusWindow *window)
GNOMEUIINFO_END
};
#endif
- GtkWidget *menu_hbox, *menubar, *wtmp;
+ GtkWidget *menu_hbox, *menubar, *wtmp, *statusbar;
GtkAccelGroup *ag;
app = GNOME_APP(window);
- ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
- if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
- gtk_window_add_accel_group(GTK_WINDOW(app), ag);
+ ag = gtk_accel_group_new();
+ gtk_object_set_data(GTK_OBJECT(app), "GtkAccelGroup", ag);
+ gtk_window_add_accel_group(GTK_WINDOW(app), ag);
menu_hbox = gtk_hbox_new(FALSE, GNOME_PAD);
menubar = gtk_menu_bar_new();
@@ -181,7 +209,9 @@ nautilus_window_constructed(NautilusWindow *window)
}
gtk_widget_show (menu_hbox);
- gnome_app_set_statusbar(app, gtk_statusbar_new());
+ gnome_app_set_statusbar(app, (statusbar = gtk_statusbar_new()));
+ window->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "IhateGtkStatusbar");
+
gnome_app_install_menu_hints(app, main_menu); /* This needs a statusbar in order to work */
wtmp = gnome_stock_pixmap_widget(GTK_WIDGET(window), GNOME_STOCK_PIXMAP_BACK);
@@ -265,7 +295,8 @@ nautilus_window_set_arg (GtkObject *object,
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
#endif
- gtk_widget_queue_resize(window->content_hbox);
+
+ gtk_widget_queue_resize(window->content_hbox);
window->content_view = new_cv;
break;
}
@@ -293,6 +324,21 @@ 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);
+ 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);
+ g_slist_free(window->uris_next);
+
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+}
+
GtkWidget *
nautilus_window_new(const char *app_id)
{
@@ -390,8 +436,20 @@ nautilus_window_change_location(NautilusWindow *window,
{
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);
+
+ if(!loci)
+ {
+ char cbuf[1024];
+ g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc);
+ nautilus_window_set_status(window, cbuf);
+ return;
+ }
+
/* Update history */
if(is_back)
{
@@ -410,30 +468,59 @@ nautilus_window_change_location(NautilusWindow *window,
{
append_val = g_strdup(loc);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
- g_slist_free(window->uris_next);
+ g_slist_free(window->uris_next); window->uris_next = NULL;
}
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);
- memset(&loci_spot, 0, sizeof(loci_spot));
- loci = &loci_spot;
- loci->requested_uri = loci->actual_uri = loc;
- loci->referring_uri = window->current_uri;
- loci->actual_referring_uri = window->actual_current_uri;
-
signum = gtk_signal_lookup("notify_location_change", nautilus_view_get_type());
- for(cur = window->meta_views; cur; cur = cur->next)
- gtk_signal_emit(GTK_OBJECT(cur->data), signum, loci, window->content_view, requesting_view);
+ /* If we need to load a different IID, do that before sending the location change request */
+ if(strcmp(NAUTILUS_VIEW(window->content_view)->iid, loci->content_iid))
+ nautilus_view_load_client(NAUTILUS_VIEW(window->content_view), loci->content_iid);
gtk_signal_emit(GTK_OBJECT(window->content_view), signum, loci, window->content_view, requesting_view);
+ notfound_views = keep_views = discard_views = NULL;
+ for(cur = window->meta_views; cur; cur = cur->next)
+ {
+ NautilusView *view = cur->data;
+
+ if(g_slist_find_custom(loci->meta_iids, view->iid, (GCompareFunc)strcmp))
+ gtk_signal_emit(GTK_OBJECT(view), signum, loci, window->content_view, requesting_view);
+ else
+ discard_views = g_slist_prepend(discard_views, view);
+ }
+ for(cur = loci->meta_iids; cur; cur = cur->next)
+ {
+ GSList *curview;
+ for(curview = window->meta_views; curview; curview = curview->next)
+ {
+ if(!strcmp(NAUTILUS_VIEW(curview->data)->iid, cur->data))
+ break;
+ }
+ if(!curview)
+ {
+ NautilusView *view;
+ view = NAUTILUS_VIEW(gtk_widget_new(nautilus_meta_view_get_type(), "main_window", window, NULL));
+ nautilus_view_load_client(view, cur->data);
+ nautilus_window_add_meta_view(window, view);
+ }
+ }
+ for(cur = discard_views; cur; cur = cur->next)
+ nautilus_window_remove_meta_view(window, cur->data);
+ g_slist_free(discard_views);
+
+ g_free(window->current_content_type);
+ window->current_content_type = g_strdup(loci->content_type);
g_free(window->current_uri);
- window->current_uri = loci->requested_uri;
+ window->current_uri = g_strdup(loci->requested_uri);
g_free(window->actual_current_uri);
- window->actual_current_uri = loci->actual_uri;
+ window->actual_current_uri = g_strdup(loci->actual_uri);
+
+ nautilus_navinfo_free(loci);
}
static void
diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h
index 5f0c291b7..d69ecabfe 100644
--- a/src/nautilus-spatial-window.h
+++ b/src/nautilus-spatial-window.h
@@ -32,8 +32,11 @@ struct _NautilusWindow {
GSList *meta_views;
GtkWidget *meta_notebook, *content_hbox, *btn_back, *btn_fwd;
NautilusLocationReference current_uri, actual_current_uri;
+ char *current_content_type;
GSList *uris_prev, *uris_next;
+
+ guint statusbar_ctx, statusbar_clear_id;
};
GtkType nautilus_window_get_type(void);
diff --git a/src/nautilus-view-frame.h b/src/nautilus-view-frame.h
index 53e60e4ee..3581b6cf3 100644
--- a/src/nautilus-view-frame.h
+++ b/src/nautilus-view-frame.h
@@ -37,18 +37,6 @@ extern "C" {
typedef struct _NautilusView NautilusView;
typedef struct _NautilusViewClass NautilusViewClass;
-struct _NautilusView
-{
- GtkBin parent;
-
- GtkWidget *main_window;
-
- char *iid;
- GtkWidget *client;
-
- guint construct_arg_count;
-};
-
struct _NautilusViewClass
{
GtkBinClass parent_spot;
@@ -66,6 +54,18 @@ struct _NautilusViewClass
guint num_construct_args;
};
+struct _NautilusView
+{
+ GtkBin parent;
+
+ GtkWidget *main_window;
+
+ char *iid;
+ GtkWidget *client;
+
+ guint construct_arg_count;
+};
+
GtkType nautilus_view_get_type (void);
void nautilus_view_request_location_change (NautilusView *view,
NautilusLocationReference loc);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index e2398492c..62e824628 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -4,6 +4,7 @@
static void nautilus_window_class_init (NautilusWindowClass *klass);
static void nautilus_window_init (NautilusWindow *window);
+static void nautilus_window_destroy (NautilusWindow *window);
static void nautilus_window_back (NautilusWindow *window);
static void nautilus_window_fwd (NautilusWindow *window);
static void nautilus_window_set_arg (GtkObject *object,
@@ -19,6 +20,8 @@ static void nautilus_window_real_request_location_change (NautilusWindow *window
GtkWidget *requesting_view);
#define CONTENTS_AS_HBOX
+/* six seconds */
+#define STATUSBAR_CLEAR_TIMEOUT 6000
GtkType
nautilus_window_get_type(void)
@@ -73,6 +76,7 @@ nautilus_window_class_init (NautilusWindowClass *klass)
int i;
object_class = (GtkObjectClass*) klass;
+ object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
object_class->set_arg = nautilus_window_set_arg;
@@ -100,6 +104,30 @@ nautilus_window_class_init (NautilusWindowClass *klass)
ARG_CONTENT_VIEW);
}
+static gboolean
+nautilus_window_clear_status(NautilusWindow *window)
+{
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ window->statusbar_clear_id = 0;
+ return FALSE;
+}
+
+static void
+nautilus_window_set_status(NautilusWindow *window, const char *txt)
+{
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ if(txt)
+ {
+ window->statusbar_clear_id = g_timeout_add(STATUSBAR_CLEAR_TIMEOUT, (GSourceFunc)nautilus_window_clear_status, window);
+ gtk_statusbar_push(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx, txt);
+ }
+ else
+ window->statusbar_clear_id = 0;
+}
+
static void
nautilus_window_constructed(NautilusWindow *window)
{
@@ -109,7 +137,7 @@ nautilus_window_constructed(NautilusWindow *window)
};
GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_CLOSE_ITEM(nautilus_window_close, NULL),
- GNOMEUIINFO_SUBTREE_STOCK(N_("Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
+ GNOMEUIINFO_SUBTREE_STOCK(N_("_Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
GNOMEUIINFO_END
};
#if 0
@@ -118,14 +146,14 @@ nautilus_window_constructed(NautilusWindow *window)
GNOMEUIINFO_END
};
#endif
- GtkWidget *menu_hbox, *menubar, *wtmp;
+ GtkWidget *menu_hbox, *menubar, *wtmp, *statusbar;
GtkAccelGroup *ag;
app = GNOME_APP(window);
- ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
- if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
- gtk_window_add_accel_group(GTK_WINDOW(app), ag);
+ ag = gtk_accel_group_new();
+ gtk_object_set_data(GTK_OBJECT(app), "GtkAccelGroup", ag);
+ gtk_window_add_accel_group(GTK_WINDOW(app), ag);
menu_hbox = gtk_hbox_new(FALSE, GNOME_PAD);
menubar = gtk_menu_bar_new();
@@ -181,7 +209,9 @@ nautilus_window_constructed(NautilusWindow *window)
}
gtk_widget_show (menu_hbox);
- gnome_app_set_statusbar(app, gtk_statusbar_new());
+ gnome_app_set_statusbar(app, (statusbar = gtk_statusbar_new()));
+ window->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "IhateGtkStatusbar");
+
gnome_app_install_menu_hints(app, main_menu); /* This needs a statusbar in order to work */
wtmp = gnome_stock_pixmap_widget(GTK_WIDGET(window), GNOME_STOCK_PIXMAP_BACK);
@@ -265,7 +295,8 @@ nautilus_window_set_arg (GtkObject *object,
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
#endif
- gtk_widget_queue_resize(window->content_hbox);
+
+ gtk_widget_queue_resize(window->content_hbox);
window->content_view = new_cv;
break;
}
@@ -293,6 +324,21 @@ 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);
+ 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);
+ g_slist_free(window->uris_next);
+
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+}
+
GtkWidget *
nautilus_window_new(const char *app_id)
{
@@ -390,8 +436,20 @@ nautilus_window_change_location(NautilusWindow *window,
{
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);
+
+ if(!loci)
+ {
+ char cbuf[1024];
+ g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc);
+ nautilus_window_set_status(window, cbuf);
+ return;
+ }
+
/* Update history */
if(is_back)
{
@@ -410,30 +468,59 @@ nautilus_window_change_location(NautilusWindow *window,
{
append_val = g_strdup(loc);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
- g_slist_free(window->uris_next);
+ g_slist_free(window->uris_next); window->uris_next = NULL;
}
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);
- memset(&loci_spot, 0, sizeof(loci_spot));
- loci = &loci_spot;
- loci->requested_uri = loci->actual_uri = loc;
- loci->referring_uri = window->current_uri;
- loci->actual_referring_uri = window->actual_current_uri;
-
signum = gtk_signal_lookup("notify_location_change", nautilus_view_get_type());
- for(cur = window->meta_views; cur; cur = cur->next)
- gtk_signal_emit(GTK_OBJECT(cur->data), signum, loci, window->content_view, requesting_view);
+ /* If we need to load a different IID, do that before sending the location change request */
+ if(strcmp(NAUTILUS_VIEW(window->content_view)->iid, loci->content_iid))
+ nautilus_view_load_client(NAUTILUS_VIEW(window->content_view), loci->content_iid);
gtk_signal_emit(GTK_OBJECT(window->content_view), signum, loci, window->content_view, requesting_view);
+ notfound_views = keep_views = discard_views = NULL;
+ for(cur = window->meta_views; cur; cur = cur->next)
+ {
+ NautilusView *view = cur->data;
+
+ if(g_slist_find_custom(loci->meta_iids, view->iid, (GCompareFunc)strcmp))
+ gtk_signal_emit(GTK_OBJECT(view), signum, loci, window->content_view, requesting_view);
+ else
+ discard_views = g_slist_prepend(discard_views, view);
+ }
+ for(cur = loci->meta_iids; cur; cur = cur->next)
+ {
+ GSList *curview;
+ for(curview = window->meta_views; curview; curview = curview->next)
+ {
+ if(!strcmp(NAUTILUS_VIEW(curview->data)->iid, cur->data))
+ break;
+ }
+ if(!curview)
+ {
+ NautilusView *view;
+ view = NAUTILUS_VIEW(gtk_widget_new(nautilus_meta_view_get_type(), "main_window", window, NULL));
+ nautilus_view_load_client(view, cur->data);
+ nautilus_window_add_meta_view(window, view);
+ }
+ }
+ for(cur = discard_views; cur; cur = cur->next)
+ nautilus_window_remove_meta_view(window, cur->data);
+ g_slist_free(discard_views);
+
+ g_free(window->current_content_type);
+ window->current_content_type = g_strdup(loci->content_type);
g_free(window->current_uri);
- window->current_uri = loci->requested_uri;
+ window->current_uri = g_strdup(loci->requested_uri);
g_free(window->actual_current_uri);
- window->actual_current_uri = loci->actual_uri;
+ window->actual_current_uri = g_strdup(loci->actual_uri);
+
+ nautilus_navinfo_free(loci);
}
static void
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 5f0c291b7..d69ecabfe 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -32,8 +32,11 @@ struct _NautilusWindow {
GSList *meta_views;
GtkWidget *meta_notebook, *content_hbox, *btn_back, *btn_fwd;
NautilusLocationReference current_uri, actual_current_uri;
+ char *current_content_type;
GSList *uris_prev, *uris_next;
+
+ guint statusbar_ctx, statusbar_clear_id;
};
GtkType nautilus_window_get_type(void);
diff --git a/src/nautilus.h b/src/nautilus.h
index 8303a73e5..608229748 100644
--- a/src/nautilus.h
+++ b/src/nautilus.h
@@ -6,5 +6,6 @@
#include "ntl-view.h"
#include "ntl-meta-view.h"
#include "ntl-content-view.h"
+#include "ntl-uri-map.h"
#endif
diff --git a/src/ntl-types.h b/src/ntl-types.h
index 1d3ae88a7..f712448d9 100644
--- a/src/ntl-types.h
+++ b/src/ntl-types.h
@@ -8,8 +8,11 @@ typedef char *NautilusLocationReference;
typedef struct {
NautilusLocationReference requested_uri, actual_uri;
NautilusLocationReference referring_uri, actual_referring_uri;
- char *content_type;
+ char *content_type, *referring_content_type;
GtkWidget *requesting_view;
+
+ char *content_iid;
+ GSList *meta_iids;
} NautilusNavigationInfo;
#endif
diff --git a/src/ntl-uri-map.c b/src/ntl-uri-map.c
new file mode 100644
index 000000000..b2c4a94ba
--- /dev/null
+++ b/src/ntl-uri-map.c
@@ -0,0 +1,23 @@
+#include "ntl-uri-map.h"
+#include <libgnorba/gnorba.h>
+
+NautilusNavigationInfo *
+nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri,
+ NautilusLocationReference referring_uri,
+ NautilusLocationReference actual_referring_uri,
+ const char *referring_content_type)
+{
+ navinfo->requested_uri = uri;
+ navinfo->referring_uri = referring_uri;
+ navinfo->actual_referring_uri = actual_referring_uri;
+ navinfo->referring_content_type = (char *)referring_content_type;
+
+ /* XXX turn the provided information into some activateable IID's */
+
+ return NULL;
+}
+
+void
+nautilus_navinfo_free(NautilusNavigationInfo *navinfo)
+{
+}
diff --git a/src/ntl-uri-map.h b/src/ntl-uri-map.h
new file mode 100644
index 000000000..d01e0c617
--- /dev/null
+++ b/src/ntl-uri-map.h
@@ -0,0 +1,12 @@
+#ifndef NAUTILUS_URI_MAP_H
+#define NAUTILUS_URI_MAP_H 1
+
+#include "ntl-types.h"
+
+NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo, NautilusLocationReference uri,
+ NautilusLocationReference referring_uri,
+ NautilusLocationReference actual_referring_uri,
+ const char *referring_content_type);
+void nautilus_navinfo_free(NautilusNavigationInfo *navinfo);
+
+#endif
diff --git a/src/ntl-view.h b/src/ntl-view.h
index 53e60e4ee..3581b6cf3 100644
--- a/src/ntl-view.h
+++ b/src/ntl-view.h
@@ -37,18 +37,6 @@ extern "C" {
typedef struct _NautilusView NautilusView;
typedef struct _NautilusViewClass NautilusViewClass;
-struct _NautilusView
-{
- GtkBin parent;
-
- GtkWidget *main_window;
-
- char *iid;
- GtkWidget *client;
-
- guint construct_arg_count;
-};
-
struct _NautilusViewClass
{
GtkBinClass parent_spot;
@@ -66,6 +54,18 @@ struct _NautilusViewClass
guint num_construct_args;
};
+struct _NautilusView
+{
+ GtkBin parent;
+
+ GtkWidget *main_window;
+
+ char *iid;
+ GtkWidget *client;
+
+ guint construct_arg_count;
+};
+
GtkType nautilus_view_get_type (void);
void nautilus_view_request_location_change (NautilusView *view,
NautilusLocationReference loc);
diff --git a/src/ntl-window.c b/src/ntl-window.c
index e2398492c..62e824628 100644
--- a/src/ntl-window.c
+++ b/src/ntl-window.c
@@ -4,6 +4,7 @@
static void nautilus_window_class_init (NautilusWindowClass *klass);
static void nautilus_window_init (NautilusWindow *window);
+static void nautilus_window_destroy (NautilusWindow *window);
static void nautilus_window_back (NautilusWindow *window);
static void nautilus_window_fwd (NautilusWindow *window);
static void nautilus_window_set_arg (GtkObject *object,
@@ -19,6 +20,8 @@ static void nautilus_window_real_request_location_change (NautilusWindow *window
GtkWidget *requesting_view);
#define CONTENTS_AS_HBOX
+/* six seconds */
+#define STATUSBAR_CLEAR_TIMEOUT 6000
GtkType
nautilus_window_get_type(void)
@@ -73,6 +76,7 @@ nautilus_window_class_init (NautilusWindowClass *klass)
int i;
object_class = (GtkObjectClass*) klass;
+ object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
object_class->set_arg = nautilus_window_set_arg;
@@ -100,6 +104,30 @@ nautilus_window_class_init (NautilusWindowClass *klass)
ARG_CONTENT_VIEW);
}
+static gboolean
+nautilus_window_clear_status(NautilusWindow *window)
+{
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ window->statusbar_clear_id = 0;
+ return FALSE;
+}
+
+static void
+nautilus_window_set_status(NautilusWindow *window, const char *txt)
+{
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+
+ gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx);
+ if(txt)
+ {
+ window->statusbar_clear_id = g_timeout_add(STATUSBAR_CLEAR_TIMEOUT, (GSourceFunc)nautilus_window_clear_status, window);
+ gtk_statusbar_push(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx, txt);
+ }
+ else
+ window->statusbar_clear_id = 0;
+}
+
static void
nautilus_window_constructed(NautilusWindow *window)
{
@@ -109,7 +137,7 @@ nautilus_window_constructed(NautilusWindow *window)
};
GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_CLOSE_ITEM(nautilus_window_close, NULL),
- GNOMEUIINFO_SUBTREE_STOCK(N_("Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
+ GNOMEUIINFO_SUBTREE_STOCK(N_("_Actions"), dummy_menu, GNOME_STOCK_MENU_JUMP_TO),
GNOMEUIINFO_END
};
#if 0
@@ -118,14 +146,14 @@ nautilus_window_constructed(NautilusWindow *window)
GNOMEUIINFO_END
};
#endif
- GtkWidget *menu_hbox, *menubar, *wtmp;
+ GtkWidget *menu_hbox, *menubar, *wtmp, *statusbar;
GtkAccelGroup *ag;
app = GNOME_APP(window);
- ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
- if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
- gtk_window_add_accel_group(GTK_WINDOW(app), ag);
+ ag = gtk_accel_group_new();
+ gtk_object_set_data(GTK_OBJECT(app), "GtkAccelGroup", ag);
+ gtk_window_add_accel_group(GTK_WINDOW(app), ag);
menu_hbox = gtk_hbox_new(FALSE, GNOME_PAD);
menubar = gtk_menu_bar_new();
@@ -181,7 +209,9 @@ nautilus_window_constructed(NautilusWindow *window)
}
gtk_widget_show (menu_hbox);
- gnome_app_set_statusbar(app, gtk_statusbar_new());
+ gnome_app_set_statusbar(app, (statusbar = gtk_statusbar_new()));
+ window->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "IhateGtkStatusbar");
+
gnome_app_install_menu_hints(app, main_menu); /* This needs a statusbar in order to work */
wtmp = gnome_stock_pixmap_widget(GTK_WIDGET(window), GNOME_STOCK_PIXMAP_BACK);
@@ -265,7 +295,8 @@ nautilus_window_set_arg (GtkObject *object,
#else
gtk_paned_pack1(GTK_PANED(window->content_hbox), new_cv, TRUE, FALSE);
#endif
- gtk_widget_queue_resize(window->content_hbox);
+
+ gtk_widget_queue_resize(window->content_hbox);
window->content_view = new_cv;
break;
}
@@ -293,6 +324,21 @@ 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);
+ 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);
+ g_slist_free(window->uris_next);
+
+ if(window->statusbar_clear_id)
+ g_source_remove(window->statusbar_clear_id);
+}
+
GtkWidget *
nautilus_window_new(const char *app_id)
{
@@ -390,8 +436,20 @@ nautilus_window_change_location(NautilusWindow *window,
{
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);
+
+ if(!loci)
+ {
+ char cbuf[1024];
+ g_snprintf(cbuf, sizeof(cbuf), _("Cannot load %s"), loc);
+ nautilus_window_set_status(window, cbuf);
+ return;
+ }
+
/* Update history */
if(is_back)
{
@@ -410,30 +468,59 @@ nautilus_window_change_location(NautilusWindow *window,
{
append_val = g_strdup(loc);
g_slist_foreach(window->uris_next, (GFunc)g_free, NULL);
- g_slist_free(window->uris_next);
+ g_slist_free(window->uris_next); window->uris_next = NULL;
}
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);
- memset(&loci_spot, 0, sizeof(loci_spot));
- loci = &loci_spot;
- loci->requested_uri = loci->actual_uri = loc;
- loci->referring_uri = window->current_uri;
- loci->actual_referring_uri = window->actual_current_uri;
-
signum = gtk_signal_lookup("notify_location_change", nautilus_view_get_type());
- for(cur = window->meta_views; cur; cur = cur->next)
- gtk_signal_emit(GTK_OBJECT(cur->data), signum, loci, window->content_view, requesting_view);
+ /* If we need to load a different IID, do that before sending the location change request */
+ if(strcmp(NAUTILUS_VIEW(window->content_view)->iid, loci->content_iid))
+ nautilus_view_load_client(NAUTILUS_VIEW(window->content_view), loci->content_iid);
gtk_signal_emit(GTK_OBJECT(window->content_view), signum, loci, window->content_view, requesting_view);
+ notfound_views = keep_views = discard_views = NULL;
+ for(cur = window->meta_views; cur; cur = cur->next)
+ {
+ NautilusView *view = cur->data;
+
+ if(g_slist_find_custom(loci->meta_iids, view->iid, (GCompareFunc)strcmp))
+ gtk_signal_emit(GTK_OBJECT(view), signum, loci, window->content_view, requesting_view);
+ else
+ discard_views = g_slist_prepend(discard_views, view);
+ }
+ for(cur = loci->meta_iids; cur; cur = cur->next)
+ {
+ GSList *curview;
+ for(curview = window->meta_views; curview; curview = curview->next)
+ {
+ if(!strcmp(NAUTILUS_VIEW(curview->data)->iid, cur->data))
+ break;
+ }
+ if(!curview)
+ {
+ NautilusView *view;
+ view = NAUTILUS_VIEW(gtk_widget_new(nautilus_meta_view_get_type(), "main_window", window, NULL));
+ nautilus_view_load_client(view, cur->data);
+ nautilus_window_add_meta_view(window, view);
+ }
+ }
+ for(cur = discard_views; cur; cur = cur->next)
+ nautilus_window_remove_meta_view(window, cur->data);
+ g_slist_free(discard_views);
+
+ g_free(window->current_content_type);
+ window->current_content_type = g_strdup(loci->content_type);
g_free(window->current_uri);
- window->current_uri = loci->requested_uri;
+ window->current_uri = g_strdup(loci->requested_uri);
g_free(window->actual_current_uri);
- window->actual_current_uri = loci->actual_uri;
+ window->actual_current_uri = g_strdup(loci->actual_uri);
+
+ nautilus_navinfo_free(loci);
}
static void
diff --git a/src/ntl-window.h b/src/ntl-window.h
index 5f0c291b7..d69ecabfe 100644
--- a/src/ntl-window.h
+++ b/src/ntl-window.h
@@ -32,8 +32,11 @@ struct _NautilusWindow {
GSList *meta_views;
GtkWidget *meta_notebook, *content_hbox, *btn_back, *btn_fwd;
NautilusLocationReference current_uri, actual_current_uri;
+ char *current_content_type;
GSList *uris_prev, *uris_next;
+
+ guint statusbar_ctx, statusbar_clear_id;
};
GtkType nautilus_window_get_type(void);