From 48159840ba3160f730b84f02eec9adfd891b5769 Mon Sep 17 00:00:00 2001 From: Maciej Stachowiak Date: Sat, 18 Dec 1999 02:35:48 +0000 Subject: [PATCH] Added up, reload, home, stop toolbar buttons. Stop is not implemented yet. * src/ntl-window.c, src/ntl-window-msgs.c: Added up, reload, home, stop toolbar buttons. Stop is not implemented yet. Up needs more thought with respect to various protocols. * src/ntl-window.c, src/ntl-window.h: Added calls to allow/disallow some of the toolbar operations. --- ChangeLog-20000414 | 9 +++ src/nautilus-navigation-window.c | 97 +++++++++++++++++++++++++++++- src/nautilus-navigation-window.h | 8 +++ src/nautilus-object-window.c | 97 +++++++++++++++++++++++++++++- src/nautilus-object-window.h | 8 +++ src/nautilus-spatial-window.c | 97 +++++++++++++++++++++++++++++- src/nautilus-spatial-window.h | 8 +++ src/nautilus-window-manage-views.c | 11 +++- src/nautilus-window.c | 97 +++++++++++++++++++++++++++++- src/nautilus-window.h | 8 +++ src/ntl-window-msgs.c | 11 +++- src/ntl-window.c | 97 +++++++++++++++++++++++++++++- src/ntl-window.h | 8 +++ 13 files changed, 547 insertions(+), 9 deletions(-) diff --git a/ChangeLog-20000414 b/ChangeLog-20000414 index fec4e3db0..78635b3dc 100644 --- a/ChangeLog-20000414 +++ b/ChangeLog-20000414 @@ -1,3 +1,12 @@ +1999-12-17 Maciej Stachowiak + + * src/ntl-window.c, src/ntl-window-msgs.c: Added up, reload, home, + stop toolbar buttons. Stop is not implemented yet. Up needs more + thought with respect to various protocols. + + * src/ntl-window.c, src/ntl-window.h: Added calls to + allow/disallow some of the toolbar operations. + 1999-12-17 Havoc Pennington * src/ntl-window.c (nautilus_window_realize): set the mini icon. diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index ac5ad28e3..4ecab045a 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -106,6 +106,10 @@ static void nautilus_window_init (NautilusWindow *window); static void nautilus_window_destroy (NautilusWindow *window); static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_up (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_reload (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_stop (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -242,9 +246,24 @@ static GnomeUIInfo toolbar_info[] = { GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"), nautilus_window_fwd, GNOME_STOCK_PIXMAP_FORWARD), - GNOMEUIINFO_END + GNOMEUIINFO_ITEM_STOCK + (N_("Up"), N_("Go up a level in the directory heirarchy"), + nautilus_window_up, GNOME_STOCK_PIXMAP_UP), + GNOMEUIINFO_ITEM_STOCK + (N_("Reload"), N_("Reload this view"), + nautilus_window_reload, GNOME_STOCK_PIXMAP_REFRESH), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Home"), N_("Go to your home directory"), + nautilus_window_home, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Stop"), N_("Interrupt loading"), + nautilus_window_stop, GNOME_STOCK_PIXMAP_STOP), + GNOMEUIINFO_END }; + GtkType nautilus_window_get_type(void) { @@ -384,6 +403,7 @@ nautilus_window_goto_uri(NautilusWindow *window, const char *uri) navinfo.new_window_enforced = Nautilus_V_UNKNOWN; nautilus_window_request_location_change(window, &navinfo, NULL); + } static void @@ -441,6 +461,8 @@ nautilus_window_constructed(NautilusWindow *window) gtk_widget_set_sensitive(help_menu_info[0].widget, FALSE); /* About */ + nautilus_window_allow_stop(window, FALSE); + /* set up toolbar */ gnome_app_create_toolbar_with_data(app, toolbar_info, window); @@ -786,6 +808,8 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum); } +/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ + static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { @@ -812,3 +836,74 @@ nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; nautilus_window_change_location(window, &nri, NULL, FALSE); } + + +static void +nautilus_window_up (GtkWidget *btn, NautilusWindow *window) +{ + GnomeVFSURI *current_uri; + GnomeVFSURI *parent_uri; + char *parent_uri_string; + + current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window)); + parent_uri = gnome_vfs_uri_get_parent (current_uri); + parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); + + nautilus_window_goto_uri (window, parent_uri_string); + + g_free (parent_uri_string); + gnome_vfs_uri_destroy (current_uri); + gnome_vfs_uri_destroy (parent_uri); +} + + +static void +nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) +{ + /* Should enforce same window! */ + nautilus_window_goto_uri (window, + nautilus_window_get_requested_uri(window)); +} + +static void +nautilus_window_home (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_set_initial_state(window); +} + +static void +nautilus_window_stop (GtkWidget *btn, NautilusWindow *window) +{ + +} + + +void +nautilus_window_allow_back (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[0].widget, allow); +} + +void +nautilus_window_allow_forward (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[1].widget, allow); +} + +void +nautilus_window_allow_up (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[2].widget, allow); +} + +void +nautilus_window_allow_reload (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[5].widget, allow); +} + +void +nautilus_window_allow_stop (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[7].widget, allow); +} diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index 5e6870c7d..fc206cb5e 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -90,4 +90,12 @@ void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta void nautilus_window_goto_uri(NautilusWindow *window, const char *uri); const char *nautilus_window_get_requested_uri(NautilusWindow *window); +void nautilus_window_allow_back (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_forward (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_up (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_reload (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_stop (NautilusWindow *window, gboolean allow); + + + #endif diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index ac5ad28e3..4ecab045a 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -106,6 +106,10 @@ static void nautilus_window_init (NautilusWindow *window); static void nautilus_window_destroy (NautilusWindow *window); static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_up (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_reload (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_stop (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -242,9 +246,24 @@ static GnomeUIInfo toolbar_info[] = { GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"), nautilus_window_fwd, GNOME_STOCK_PIXMAP_FORWARD), - GNOMEUIINFO_END + GNOMEUIINFO_ITEM_STOCK + (N_("Up"), N_("Go up a level in the directory heirarchy"), + nautilus_window_up, GNOME_STOCK_PIXMAP_UP), + GNOMEUIINFO_ITEM_STOCK + (N_("Reload"), N_("Reload this view"), + nautilus_window_reload, GNOME_STOCK_PIXMAP_REFRESH), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Home"), N_("Go to your home directory"), + nautilus_window_home, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Stop"), N_("Interrupt loading"), + nautilus_window_stop, GNOME_STOCK_PIXMAP_STOP), + GNOMEUIINFO_END }; + GtkType nautilus_window_get_type(void) { @@ -384,6 +403,7 @@ nautilus_window_goto_uri(NautilusWindow *window, const char *uri) navinfo.new_window_enforced = Nautilus_V_UNKNOWN; nautilus_window_request_location_change(window, &navinfo, NULL); + } static void @@ -441,6 +461,8 @@ nautilus_window_constructed(NautilusWindow *window) gtk_widget_set_sensitive(help_menu_info[0].widget, FALSE); /* About */ + nautilus_window_allow_stop(window, FALSE); + /* set up toolbar */ gnome_app_create_toolbar_with_data(app, toolbar_info, window); @@ -786,6 +808,8 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum); } +/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ + static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { @@ -812,3 +836,74 @@ nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; nautilus_window_change_location(window, &nri, NULL, FALSE); } + + +static void +nautilus_window_up (GtkWidget *btn, NautilusWindow *window) +{ + GnomeVFSURI *current_uri; + GnomeVFSURI *parent_uri; + char *parent_uri_string; + + current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window)); + parent_uri = gnome_vfs_uri_get_parent (current_uri); + parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); + + nautilus_window_goto_uri (window, parent_uri_string); + + g_free (parent_uri_string); + gnome_vfs_uri_destroy (current_uri); + gnome_vfs_uri_destroy (parent_uri); +} + + +static void +nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) +{ + /* Should enforce same window! */ + nautilus_window_goto_uri (window, + nautilus_window_get_requested_uri(window)); +} + +static void +nautilus_window_home (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_set_initial_state(window); +} + +static void +nautilus_window_stop (GtkWidget *btn, NautilusWindow *window) +{ + +} + + +void +nautilus_window_allow_back (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[0].widget, allow); +} + +void +nautilus_window_allow_forward (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[1].widget, allow); +} + +void +nautilus_window_allow_up (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[2].widget, allow); +} + +void +nautilus_window_allow_reload (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[5].widget, allow); +} + +void +nautilus_window_allow_stop (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[7].widget, allow); +} diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h index 5e6870c7d..fc206cb5e 100644 --- a/src/nautilus-object-window.h +++ b/src/nautilus-object-window.h @@ -90,4 +90,12 @@ void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta void nautilus_window_goto_uri(NautilusWindow *window, const char *uri); const char *nautilus_window_get_requested_uri(NautilusWindow *window); +void nautilus_window_allow_back (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_forward (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_up (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_reload (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_stop (NautilusWindow *window, gboolean allow); + + + #endif diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index ac5ad28e3..4ecab045a 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -106,6 +106,10 @@ static void nautilus_window_init (NautilusWindow *window); static void nautilus_window_destroy (NautilusWindow *window); static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_up (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_reload (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_stop (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -242,9 +246,24 @@ static GnomeUIInfo toolbar_info[] = { GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"), nautilus_window_fwd, GNOME_STOCK_PIXMAP_FORWARD), - GNOMEUIINFO_END + GNOMEUIINFO_ITEM_STOCK + (N_("Up"), N_("Go up a level in the directory heirarchy"), + nautilus_window_up, GNOME_STOCK_PIXMAP_UP), + GNOMEUIINFO_ITEM_STOCK + (N_("Reload"), N_("Reload this view"), + nautilus_window_reload, GNOME_STOCK_PIXMAP_REFRESH), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Home"), N_("Go to your home directory"), + nautilus_window_home, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Stop"), N_("Interrupt loading"), + nautilus_window_stop, GNOME_STOCK_PIXMAP_STOP), + GNOMEUIINFO_END }; + GtkType nautilus_window_get_type(void) { @@ -384,6 +403,7 @@ nautilus_window_goto_uri(NautilusWindow *window, const char *uri) navinfo.new_window_enforced = Nautilus_V_UNKNOWN; nautilus_window_request_location_change(window, &navinfo, NULL); + } static void @@ -441,6 +461,8 @@ nautilus_window_constructed(NautilusWindow *window) gtk_widget_set_sensitive(help_menu_info[0].widget, FALSE); /* About */ + nautilus_window_allow_stop(window, FALSE); + /* set up toolbar */ gnome_app_create_toolbar_with_data(app, toolbar_info, window); @@ -786,6 +808,8 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum); } +/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ + static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { @@ -812,3 +836,74 @@ nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; nautilus_window_change_location(window, &nri, NULL, FALSE); } + + +static void +nautilus_window_up (GtkWidget *btn, NautilusWindow *window) +{ + GnomeVFSURI *current_uri; + GnomeVFSURI *parent_uri; + char *parent_uri_string; + + current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window)); + parent_uri = gnome_vfs_uri_get_parent (current_uri); + parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); + + nautilus_window_goto_uri (window, parent_uri_string); + + g_free (parent_uri_string); + gnome_vfs_uri_destroy (current_uri); + gnome_vfs_uri_destroy (parent_uri); +} + + +static void +nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) +{ + /* Should enforce same window! */ + nautilus_window_goto_uri (window, + nautilus_window_get_requested_uri(window)); +} + +static void +nautilus_window_home (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_set_initial_state(window); +} + +static void +nautilus_window_stop (GtkWidget *btn, NautilusWindow *window) +{ + +} + + +void +nautilus_window_allow_back (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[0].widget, allow); +} + +void +nautilus_window_allow_forward (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[1].widget, allow); +} + +void +nautilus_window_allow_up (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[2].widget, allow); +} + +void +nautilus_window_allow_reload (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[5].widget, allow); +} + +void +nautilus_window_allow_stop (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[7].widget, allow); +} diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h index 5e6870c7d..fc206cb5e 100644 --- a/src/nautilus-spatial-window.h +++ b/src/nautilus-spatial-window.h @@ -90,4 +90,12 @@ void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta void nautilus_window_goto_uri(NautilusWindow *window, const char *uri); const char *nautilus_window_get_requested_uri(NautilusWindow *window); +void nautilus_window_allow_back (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_forward (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_up (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_reload (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_stop (NautilusWindow *window, gboolean allow); + + + #endif diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 5ed2e7bd2..2d1882027 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -83,6 +83,8 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location_internal(NautilusWindow *window, NautilusNavigationInfo *loci, gboolean is_back) { + GnomeVFSURI *new_uri; + CORBA_free(window->si); window->si = NULL; /* Maintain history lists. */ @@ -118,8 +120,13 @@ nautilus_window_change_location_internal(NautilusWindow *window, NautilusNavigat window->uris_prev = g_slist_prepend(window->uris_prev, g_strdup(window->ni->requested_uri)); } - gtk_widget_set_sensitive(window->btn_back, window->uris_prev?TRUE:FALSE); - gtk_widget_set_sensitive(window->btn_fwd, window->uris_next?TRUE:FALSE); + nautilus_window_allow_back(window, window->uris_prev?TRUE:FALSE); + nautilus_window_allow_forward(window, window->uris_next?TRUE:FALSE); + + new_uri = gnome_vfs_uri_new (loci->navinfo.requested_uri); + nautilus_window_allow_up(window, + gnome_vfs_uri_has_parent(new_uri)); + gnome_vfs_uri_destroy(new_uri); CORBA_free(window->ni); window->ni = Nautilus_NavigationInfo__alloc(); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index ac5ad28e3..4ecab045a 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -106,6 +106,10 @@ static void nautilus_window_init (NautilusWindow *window); static void nautilus_window_destroy (NautilusWindow *window); static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_up (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_reload (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_stop (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -242,9 +246,24 @@ static GnomeUIInfo toolbar_info[] = { GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"), nautilus_window_fwd, GNOME_STOCK_PIXMAP_FORWARD), - GNOMEUIINFO_END + GNOMEUIINFO_ITEM_STOCK + (N_("Up"), N_("Go up a level in the directory heirarchy"), + nautilus_window_up, GNOME_STOCK_PIXMAP_UP), + GNOMEUIINFO_ITEM_STOCK + (N_("Reload"), N_("Reload this view"), + nautilus_window_reload, GNOME_STOCK_PIXMAP_REFRESH), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Home"), N_("Go to your home directory"), + nautilus_window_home, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Stop"), N_("Interrupt loading"), + nautilus_window_stop, GNOME_STOCK_PIXMAP_STOP), + GNOMEUIINFO_END }; + GtkType nautilus_window_get_type(void) { @@ -384,6 +403,7 @@ nautilus_window_goto_uri(NautilusWindow *window, const char *uri) navinfo.new_window_enforced = Nautilus_V_UNKNOWN; nautilus_window_request_location_change(window, &navinfo, NULL); + } static void @@ -441,6 +461,8 @@ nautilus_window_constructed(NautilusWindow *window) gtk_widget_set_sensitive(help_menu_info[0].widget, FALSE); /* About */ + nautilus_window_allow_stop(window, FALSE); + /* set up toolbar */ gnome_app_create_toolbar_with_data(app, toolbar_info, window); @@ -786,6 +808,8 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum); } +/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ + static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { @@ -812,3 +836,74 @@ nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; nautilus_window_change_location(window, &nri, NULL, FALSE); } + + +static void +nautilus_window_up (GtkWidget *btn, NautilusWindow *window) +{ + GnomeVFSURI *current_uri; + GnomeVFSURI *parent_uri; + char *parent_uri_string; + + current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window)); + parent_uri = gnome_vfs_uri_get_parent (current_uri); + parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); + + nautilus_window_goto_uri (window, parent_uri_string); + + g_free (parent_uri_string); + gnome_vfs_uri_destroy (current_uri); + gnome_vfs_uri_destroy (parent_uri); +} + + +static void +nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) +{ + /* Should enforce same window! */ + nautilus_window_goto_uri (window, + nautilus_window_get_requested_uri(window)); +} + +static void +nautilus_window_home (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_set_initial_state(window); +} + +static void +nautilus_window_stop (GtkWidget *btn, NautilusWindow *window) +{ + +} + + +void +nautilus_window_allow_back (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[0].widget, allow); +} + +void +nautilus_window_allow_forward (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[1].widget, allow); +} + +void +nautilus_window_allow_up (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[2].widget, allow); +} + +void +nautilus_window_allow_reload (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[5].widget, allow); +} + +void +nautilus_window_allow_stop (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[7].widget, allow); +} diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 5e6870c7d..fc206cb5e 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -90,4 +90,12 @@ void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta void nautilus_window_goto_uri(NautilusWindow *window, const char *uri); const char *nautilus_window_get_requested_uri(NautilusWindow *window); +void nautilus_window_allow_back (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_forward (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_up (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_reload (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_stop (NautilusWindow *window, gboolean allow); + + + #endif diff --git a/src/ntl-window-msgs.c b/src/ntl-window-msgs.c index 5ed2e7bd2..2d1882027 100644 --- a/src/ntl-window-msgs.c +++ b/src/ntl-window-msgs.c @@ -83,6 +83,8 @@ nautilus_window_request_location_change(NautilusWindow *window, static void nautilus_window_change_location_internal(NautilusWindow *window, NautilusNavigationInfo *loci, gboolean is_back) { + GnomeVFSURI *new_uri; + CORBA_free(window->si); window->si = NULL; /* Maintain history lists. */ @@ -118,8 +120,13 @@ nautilus_window_change_location_internal(NautilusWindow *window, NautilusNavigat window->uris_prev = g_slist_prepend(window->uris_prev, g_strdup(window->ni->requested_uri)); } - gtk_widget_set_sensitive(window->btn_back, window->uris_prev?TRUE:FALSE); - gtk_widget_set_sensitive(window->btn_fwd, window->uris_next?TRUE:FALSE); + nautilus_window_allow_back(window, window->uris_prev?TRUE:FALSE); + nautilus_window_allow_forward(window, window->uris_next?TRUE:FALSE); + + new_uri = gnome_vfs_uri_new (loci->navinfo.requested_uri); + nautilus_window_allow_up(window, + gnome_vfs_uri_has_parent(new_uri)); + gnome_vfs_uri_destroy(new_uri); CORBA_free(window->ni); window->ni = Nautilus_NavigationInfo__alloc(); diff --git a/src/ntl-window.c b/src/ntl-window.c index ac5ad28e3..4ecab045a 100644 --- a/src/ntl-window.c +++ b/src/ntl-window.c @@ -106,6 +106,10 @@ static void nautilus_window_init (NautilusWindow *window); static void nautilus_window_destroy (NautilusWindow *window); static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_up (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_reload (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window); +static void nautilus_window_stop (GtkWidget *btn, NautilusWindow *window); static void nautilus_window_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -242,9 +246,24 @@ static GnomeUIInfo toolbar_info[] = { GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"), nautilus_window_fwd, GNOME_STOCK_PIXMAP_FORWARD), - GNOMEUIINFO_END + GNOMEUIINFO_ITEM_STOCK + (N_("Up"), N_("Go up a level in the directory heirarchy"), + nautilus_window_up, GNOME_STOCK_PIXMAP_UP), + GNOMEUIINFO_ITEM_STOCK + (N_("Reload"), N_("Reload this view"), + nautilus_window_reload, GNOME_STOCK_PIXMAP_REFRESH), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Home"), N_("Go to your home directory"), + nautilus_window_home, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK + (N_("Stop"), N_("Interrupt loading"), + nautilus_window_stop, GNOME_STOCK_PIXMAP_STOP), + GNOMEUIINFO_END }; + GtkType nautilus_window_get_type(void) { @@ -384,6 +403,7 @@ nautilus_window_goto_uri(NautilusWindow *window, const char *uri) navinfo.new_window_enforced = Nautilus_V_UNKNOWN; nautilus_window_request_location_change(window, &navinfo, NULL); + } static void @@ -441,6 +461,8 @@ nautilus_window_constructed(NautilusWindow *window) gtk_widget_set_sensitive(help_menu_info[0].widget, FALSE); /* About */ + nautilus_window_allow_stop(window, FALSE); + /* set up toolbar */ gnome_app_create_toolbar_with_data(app, toolbar_info, window); @@ -786,6 +808,8 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum); } +/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ + static void nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { @@ -812,3 +836,74 @@ nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; nautilus_window_change_location(window, &nri, NULL, FALSE); } + + +static void +nautilus_window_up (GtkWidget *btn, NautilusWindow *window) +{ + GnomeVFSURI *current_uri; + GnomeVFSURI *parent_uri; + char *parent_uri_string; + + current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window)); + parent_uri = gnome_vfs_uri_get_parent (current_uri); + parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); + + nautilus_window_goto_uri (window, parent_uri_string); + + g_free (parent_uri_string); + gnome_vfs_uri_destroy (current_uri); + gnome_vfs_uri_destroy (parent_uri); +} + + +static void +nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) +{ + /* Should enforce same window! */ + nautilus_window_goto_uri (window, + nautilus_window_get_requested_uri(window)); +} + +static void +nautilus_window_home (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_set_initial_state(window); +} + +static void +nautilus_window_stop (GtkWidget *btn, NautilusWindow *window) +{ + +} + + +void +nautilus_window_allow_back (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[0].widget, allow); +} + +void +nautilus_window_allow_forward (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[1].widget, allow); +} + +void +nautilus_window_allow_up (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[2].widget, allow); +} + +void +nautilus_window_allow_reload (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[5].widget, allow); +} + +void +nautilus_window_allow_stop (NautilusWindow *window, gboolean allow) +{ + gtk_widget_set_sensitive(toolbar_info[7].widget, allow); +} diff --git a/src/ntl-window.h b/src/ntl-window.h index 5e6870c7d..fc206cb5e 100644 --- a/src/ntl-window.h +++ b/src/ntl-window.h @@ -90,4 +90,12 @@ void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta void nautilus_window_goto_uri(NautilusWindow *window, const char *uri); const char *nautilus_window_get_requested_uri(NautilusWindow *window); +void nautilus_window_allow_back (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_forward (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_up (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_reload (NautilusWindow *window, gboolean allow); +void nautilus_window_allow_stop (NautilusWindow *window, gboolean allow); + + + #endif