Commit c45c00a7 authored by John Sullivan's avatar John Sullivan

Enabled "Open" and added "Open in New Window" context menu items; added

beginnings of Go menu.
parent 05847375
2000-02-11 John Sullivan <sullivan@eazel.com>
Sensitized "Open" context menu item, and added
"Open in New Window". Extended the framework as
required to support opening into a new window.
* src/ntl-types.h: Added use_new_window gboolean
to NautilusNavigationInfo struct. (Nautilus_
NavigationRequestInfo already had a concept of using
a new window, but it was never passed on to the
window-managing code).
* src/ntl-uri-map.c: (nautilus_navinfo_new): Set the
use_new_window field of the new object based on the
new_window_default/suggested/enforced settings from
the NavigationRequestInfo.
* src/ntl-window-msgs.c: (nautilus_window_change_location_2):
Create a new window if passed-in NautilusNavigationInfo says so.
* src/file-manager/fm-directory-view.h:
(fm_directory_view_activate_entry): Added gboolean
request_new_window parameter.
* src/file-manager/fm-directory-view.c:
(fm_directory_view_activate_entry): Set new_window_suggested
of NavigationRequestInfo based on value of new
request_new_window parameter.
(open_cb): New function, calls fm_directory_view_activate_entry
with request_new_window FALSE.
(open_in_new_window_cb): New function, calls
fm_directory_view_activate_entry with request_new_window TRUE.
(append_item_context_menu_items): Sensitize "Open" item, add
"Open in New Window" item, wire 'em up.
* src/file-manager/fm-directory-view-icons.c:
(icon_container_activate_cb): pass FALSE for request_new_window.
* src/file-manager/fm-directory-view-list.c:
(flist_activate_cb): pass FALSE for request_new_window.
Added beginnings of Go menu, and cleaned up some
cruft found in the process. Holler now if you think
the Go menu is a bad idea.
* src/ntl-window.h:
Removed btn_back and btn_fwd fields, as they were being
initialized and then ignored.
* src/ntl-window.c:
Added go_menu_info array and filled it with Back, Forward,
Up, and Home, all with keyboard equivalents. (Later this menu
will also contain dynamic history list.)
Added #defines for toolbar button indices.
(nautilus_window_constructed): Removed mentions of btn_back
and btn_fwd; moved nautilus_window_allow_stop to after the
menus are set up; added nautilus_window_allow_back and
nautilus_window_allow_forward calls.
(nautilus_window_allow_back): Use #define for Back button index
instead of hardcoded magic number; set Back menu item sensitivity.
(nautilus_window_allow_forward): Use #define for Forward button index
instead of hardcoded magic number; set Forward menu item sensitivity.
(nautilus_window_allow_up): Use #define for Up button index
instead of hardcoded magic number; set Up menu item sensitivity.
(nautilus_window_allow_reload): Use #define for Reload button index
instead of hardcoded magic number (which was incorrect).
(nautilus_window_allow_stop): Use #define for Stop button index
instead of hardcoded magic number.
2000-02-10 Andy Hertzfeld <andy@eazel.com>
* src/ntl-index-panel.c:
......
......@@ -601,7 +601,7 @@ icon_container_activate_cb (GnomeIconContainer *container,
g_assert (container == get_icon_container (icon_view));
g_assert (file != NULL);
fm_directory_view_activate_entry (FM_DIRECTORY_VIEW (icon_view), file);
fm_directory_view_activate_entry (FM_DIRECTORY_VIEW (icon_view), file, FALSE);
}
static void
......
......@@ -435,7 +435,7 @@ flist_activate_cb (GtkFList *flist,
g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (data));
g_return_if_fail (entry_data != NULL);
fm_directory_view_activate_entry (FM_DIRECTORY_VIEW (data), entry_data);
fm_directory_view_activate_entry (FM_DIRECTORY_VIEW (data), entry_data, FALSE);
}
static void
......
......@@ -92,6 +92,8 @@ static void stop_location_change_cb (NautilusViewFrame *view_frame,
static void notify_location_change_cb (NautilusViewFrame *view_frame,
Nautilus_NavigationInfo *nav_context,
FMDirectoryView *directory_view);
static void open_cb (GtkMenuItem *item, NautilusFile *file);
static void open_in_new_window_cb (GtkMenuItem *item, NautilusFile *file);
static void select_all_cb (GtkMenuItem *item, FMDirectoryView *directory_view);
static void zoom_in_cb (GtkMenuItem *item, FMDirectoryView *directory_view);
static void zoom_out_cb (GtkMenuItem *item, FMDirectoryView *directory_view);
......@@ -754,6 +756,27 @@ fm_directory_view_get_model (FMDirectoryView *view)
return view->details->model;
}
static void
open_cb (GtkMenuItem *item, NautilusFile *file)
{
FMDirectoryView *directory_view;
directory_view = FM_DIRECTORY_VIEW (gtk_object_get_data (GTK_OBJECT (item), "directory_view"));
fm_directory_view_activate_entry (directory_view, file, FALSE);
}
static void
open_in_new_window_cb (GtkMenuItem *item, NautilusFile *file)
{
FMDirectoryView *directory_view;
directory_view = FM_DIRECTORY_VIEW (gtk_object_get_data (GTK_OBJECT (item), "directory_view"));
fm_directory_view_activate_entry (directory_view, file, TRUE);
}
static void
popup_context_menu (GtkMenu *menu)
{
......@@ -803,7 +826,22 @@ append_item_context_menu_items (FMDirectoryView *view, GtkMenu *menu, NautilusFi
GtkWidget *menu_item;
menu_item = gtk_menu_item_new_with_label ("Open");
gtk_widget_set_sensitive (menu_item, FALSE);
/* Store directory view in menu item so callback can access it. */
gtk_object_set_data_full (GTK_OBJECT (menu_item), "directory_view",
view, (GtkDestroyNotify) gtk_object_unref);
gtk_object_ref (GTK_OBJECT (view));
gtk_signal_connect(GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (open_cb), file);
gtk_widget_show (menu_item);
gtk_menu_append (menu, menu_item);
menu_item = gtk_menu_item_new_with_label ("Open in New Window");
/* Store directory view in menu item so callback can access it. */
gtk_object_set_data_full (GTK_OBJECT (menu_item), "directory_view",
view, (GtkDestroyNotify) gtk_object_unref);
gtk_object_ref (GTK_OBJECT (view));
gtk_signal_connect(GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (open_in_new_window_cb), file);
gtk_widget_show (menu_item);
gtk_menu_append (menu, menu_item);
......@@ -942,10 +980,13 @@ fm_directory_view_notify_selection_changed (FMDirectoryView *view)
* called only by subclasses.
* @view: FMDirectoryView in question.
* @file: A NautilusFile representing the entry in this view to activate.
* @request_new_window: Should this item be opened in a new window?
*
**/
void
fm_directory_view_activate_entry (FMDirectoryView *view, NautilusFile *file)
fm_directory_view_activate_entry (FMDirectoryView *view,
NautilusFile *file,
gboolean request_new_window)
{
Nautilus_NavigationRequestInfo request;
......@@ -954,7 +995,9 @@ fm_directory_view_activate_entry (FMDirectoryView *view, NautilusFile *file)
request.requested_uri = nautilus_file_get_uri (file);
request.new_window_default = Nautilus_V_FALSE;
request.new_window_suggested = Nautilus_V_FALSE;
request.new_window_suggested = request_new_window ?
Nautilus_V_TRUE :
Nautilus_V_FALSE;
request.new_window_enforced = Nautilus_V_UNKNOWN;
nautilus_view_frame_request_location_change
(NAUTILUS_VIEW_FRAME (view->details->view_frame), &request);
......
......@@ -153,7 +153,8 @@ void fm_directory_view_begin_loading (FMDirector
* FMDirectoryView and its subclasses
*/
void fm_directory_view_activate_entry (FMDirectoryView *view,
NautilusFile *file);
NautilusFile *file,
gboolean request_new_window);
void fm_directory_view_notify_selection_changed (FMDirectoryView *view);
......
......@@ -180,6 +180,13 @@ nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
navinfo->navinfo.requested_uri = g_strdup(nri->requested_uri);
/* FIXME: Either remove distinctions between default, suggested, & enforced, or
* deal with them somehow.
*/
navinfo->use_new_window = (nri->new_window_default == Nautilus_V_TRUE ||
nri->new_window_suggested == Nautilus_V_TRUE ||
nri->new_window_enforced == Nautilus_V_TRUE);
res = gnome_vfs_async_get_file_info(&navinfo->ah, navinfo->navinfo.requested_uri,
GNOME_VFS_FILE_INFO_GETMIMETYPE
|GNOME_VFS_FILE_INFO_FOLLOWLINKS,
......
......@@ -218,6 +218,43 @@ static GnomeUIInfo edit_menu_info[] = {
GNOMEUIINFO_END
};
#define GO_MENU_BACK_ITEM_INDEX 0
#define GO_MENU_FORWARD_ITEM_INDEX 1
#define GO_MENU_UP_ITEM_INDEX 2
#define GO_MENU_HOME_ITEM_INDEX 3
static GnomeUIInfo go_menu_info[] = {
{
GNOME_APP_UI_ITEM,
N_("Back"), N_("Go to the previous visited location"),
nautilus_window_back, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'B', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Forward"), N_("Go to the next visited location"),
nautilus_window_fwd, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'F', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Up"), N_("Go to the location that contains this one"),
nautilus_window_up, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'U', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Home"), N_("Go to the home location"),
nautilus_window_home, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'H', GDK_CONTROL_MASK, NULL
},
/* GNOMEUIINFO_SEPARATOR, */ /* FIXME: Uncomment separator when history list added. */
GNOMEUIINFO_END
};
static GnomeUIInfo bookmarks_menu_info[] = {
GNOMEUIINFO_END
};
......@@ -239,10 +276,11 @@ static GnomeUIInfo debug_menu_info [] = {
};
#define BOOKMARKS_MENU_INDEX 2
#define BOOKMARKS_MENU_INDEX 3
static GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_FILE_TREE (file_menu_info),
GNOMEUIINFO_MENU_EDIT_TREE (edit_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Go"), go_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Bookmarks"), bookmarks_menu_info),
GNOMEUIINFO_MENU_HELP_TREE (help_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Debug"), debug_menu_info),
......@@ -251,6 +289,14 @@ static GnomeUIInfo main_menu[] = {
/* toolbar definitions */
#define TOOLBAR_BACK_BUTTON_INDEX 0
#define TOOLBAR_FORWARD_BUTTON_INDEX 1
#define TOOLBAR_UP_BUTTON_INDEX 2
#define TOOLBAR_RELOAD_BUTTON_INDEX 3
/* separator */
#define TOOLBAR_HOME_BUTTON_INDEX 5
/* separator */
#define TOOLBAR_STOP_BUTTON_INDEX 7
static GnomeUIInfo toolbar_info[] = {
GNOMEUIINFO_ITEM_STOCK
(N_("Back"), N_("Go to the previously visited directory"),
......@@ -425,11 +471,6 @@ nautilus_window_constructed(NautilusWindow *window)
toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gnome_app_fill_toolbar_with_data(GTK_TOOLBAR(toolbar), toolbar_info, app->accel_group, app);
gnome_app_set_toolbar(app, GTK_TOOLBAR(toolbar));
window->btn_back = toolbar_info[0].widget;
window->btn_fwd = toolbar_info[1].widget;
nautilus_window_allow_stop(window, FALSE);
gtk_widget_set_sensitive(window->btn_back, FALSE);
gtk_widget_set_sensitive(window->btn_fwd, FALSE);
/* set up location bar */
......@@ -522,6 +563,13 @@ nautilus_window_constructed(NautilusWindow *window)
after the statusbar
creation */
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
*/
nautilus_window_allow_back(window, FALSE);
nautilus_window_allow_forward(window, FALSE);
nautilus_window_allow_stop(window, FALSE);
bonobo_ui_handler_set_menubar(window->uih, app->menubar);
bonobo_ui_handler_set_app(window->uih, app);
bonobo_ui_handler_set_statusbar(window->uih, statusbar);
......@@ -895,31 +943,34 @@ nautilus_window_about_cb (GtkWidget *widget,
void
nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[0].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_BACK_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_BACK_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[1].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_FORWARD_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_FORWARD_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[2].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_UP_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_UP_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[5].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_RELOAD_BUTTON_INDEX].widget, allow);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[7].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_STOP_BUTTON_INDEX].widget, allow);
}
......
......@@ -56,7 +56,7 @@ struct _NautilusWindow {
/** UI stuff **/
NautilusIndexPanel *index_panel;
GtkWidget *content_hbox, *btn_back, *btn_fwd;
GtkWidget *content_hbox;
GtkWidget *option_cvtype, *ent_uri;
guint statusbar_ctx, statusbar_clear_id;
......
......@@ -218,6 +218,43 @@ static GnomeUIInfo edit_menu_info[] = {
GNOMEUIINFO_END
};
#define GO_MENU_BACK_ITEM_INDEX 0
#define GO_MENU_FORWARD_ITEM_INDEX 1
#define GO_MENU_UP_ITEM_INDEX 2
#define GO_MENU_HOME_ITEM_INDEX 3
static GnomeUIInfo go_menu_info[] = {
{
GNOME_APP_UI_ITEM,
N_("Back"), N_("Go to the previous visited location"),
nautilus_window_back, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'B', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Forward"), N_("Go to the next visited location"),
nautilus_window_fwd, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'F', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Up"), N_("Go to the location that contains this one"),
nautilus_window_up, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'U', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Home"), N_("Go to the home location"),
nautilus_window_home, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'H', GDK_CONTROL_MASK, NULL
},
/* GNOMEUIINFO_SEPARATOR, */ /* FIXME: Uncomment separator when history list added. */
GNOMEUIINFO_END
};
static GnomeUIInfo bookmarks_menu_info[] = {
GNOMEUIINFO_END
};
......@@ -239,10 +276,11 @@ static GnomeUIInfo debug_menu_info [] = {
};
#define BOOKMARKS_MENU_INDEX 2
#define BOOKMARKS_MENU_INDEX 3
static GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_FILE_TREE (file_menu_info),
GNOMEUIINFO_MENU_EDIT_TREE (edit_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Go"), go_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Bookmarks"), bookmarks_menu_info),
GNOMEUIINFO_MENU_HELP_TREE (help_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Debug"), debug_menu_info),
......@@ -251,6 +289,14 @@ static GnomeUIInfo main_menu[] = {
/* toolbar definitions */
#define TOOLBAR_BACK_BUTTON_INDEX 0
#define TOOLBAR_FORWARD_BUTTON_INDEX 1
#define TOOLBAR_UP_BUTTON_INDEX 2
#define TOOLBAR_RELOAD_BUTTON_INDEX 3
/* separator */
#define TOOLBAR_HOME_BUTTON_INDEX 5
/* separator */
#define TOOLBAR_STOP_BUTTON_INDEX 7
static GnomeUIInfo toolbar_info[] = {
GNOMEUIINFO_ITEM_STOCK
(N_("Back"), N_("Go to the previously visited directory"),
......@@ -425,11 +471,6 @@ nautilus_window_constructed(NautilusWindow *window)
toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gnome_app_fill_toolbar_with_data(GTK_TOOLBAR(toolbar), toolbar_info, app->accel_group, app);
gnome_app_set_toolbar(app, GTK_TOOLBAR(toolbar));
window->btn_back = toolbar_info[0].widget;
window->btn_fwd = toolbar_info[1].widget;
nautilus_window_allow_stop(window, FALSE);
gtk_widget_set_sensitive(window->btn_back, FALSE);
gtk_widget_set_sensitive(window->btn_fwd, FALSE);
/* set up location bar */
......@@ -522,6 +563,13 @@ nautilus_window_constructed(NautilusWindow *window)
after the statusbar
creation */
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
*/
nautilus_window_allow_back(window, FALSE);
nautilus_window_allow_forward(window, FALSE);
nautilus_window_allow_stop(window, FALSE);
bonobo_ui_handler_set_menubar(window->uih, app->menubar);
bonobo_ui_handler_set_app(window->uih, app);
bonobo_ui_handler_set_statusbar(window->uih, statusbar);
......@@ -895,31 +943,34 @@ nautilus_window_about_cb (GtkWidget *widget,
void
nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[0].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_BACK_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_BACK_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[1].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_FORWARD_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_FORWARD_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[2].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_UP_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_UP_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[5].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_RELOAD_BUTTON_INDEX].widget, allow);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[7].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_STOP_BUTTON_INDEX].widget, allow);
}
......
......@@ -56,7 +56,7 @@ struct _NautilusWindow {
/** UI stuff **/
NautilusIndexPanel *index_panel;
GtkWidget *content_hbox, *btn_back, *btn_fwd;
GtkWidget *content_hbox;
GtkWidget *option_cvtype, *ent_uri;
guint statusbar_ctx, statusbar_clear_id;
......
......@@ -218,6 +218,43 @@ static GnomeUIInfo edit_menu_info[] = {
GNOMEUIINFO_END
};
#define GO_MENU_BACK_ITEM_INDEX 0
#define GO_MENU_FORWARD_ITEM_INDEX 1
#define GO_MENU_UP_ITEM_INDEX 2
#define GO_MENU_HOME_ITEM_INDEX 3
static GnomeUIInfo go_menu_info[] = {
{
GNOME_APP_UI_ITEM,
N_("Back"), N_("Go to the previous visited location"),
nautilus_window_back, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'B', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Forward"), N_("Go to the next visited location"),
nautilus_window_fwd, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'F', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Up"), N_("Go to the location that contains this one"),
nautilus_window_up, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'U', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
N_("Home"), N_("Go to the home location"),
nautilus_window_home, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'H', GDK_CONTROL_MASK, NULL
},
/* GNOMEUIINFO_SEPARATOR, */ /* FIXME: Uncomment separator when history list added. */
GNOMEUIINFO_END
};
static GnomeUIInfo bookmarks_menu_info[] = {
GNOMEUIINFO_END
};
......@@ -239,10 +276,11 @@ static GnomeUIInfo debug_menu_info [] = {
};
#define BOOKMARKS_MENU_INDEX 2
#define BOOKMARKS_MENU_INDEX 3
static GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_FILE_TREE (file_menu_info),
GNOMEUIINFO_MENU_EDIT_TREE (edit_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Go"), go_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Bookmarks"), bookmarks_menu_info),
GNOMEUIINFO_MENU_HELP_TREE (help_menu_info),
GNOMEUIINFO_SUBTREE(N_("_Debug"), debug_menu_info),
......@@ -251,6 +289,14 @@ static GnomeUIInfo main_menu[] = {
/* toolbar definitions */
#define TOOLBAR_BACK_BUTTON_INDEX 0
#define TOOLBAR_FORWARD_BUTTON_INDEX 1
#define TOOLBAR_UP_BUTTON_INDEX 2
#define TOOLBAR_RELOAD_BUTTON_INDEX 3
/* separator */
#define TOOLBAR_HOME_BUTTON_INDEX 5
/* separator */
#define TOOLBAR_STOP_BUTTON_INDEX 7
static GnomeUIInfo toolbar_info[] = {
GNOMEUIINFO_ITEM_STOCK
(N_("Back"), N_("Go to the previously visited directory"),
......@@ -425,11 +471,6 @@ nautilus_window_constructed(NautilusWindow *window)
toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gnome_app_fill_toolbar_with_data(GTK_TOOLBAR(toolbar), toolbar_info, app->accel_group, app);
gnome_app_set_toolbar(app, GTK_TOOLBAR(toolbar));
window->btn_back = toolbar_info[0].widget;
window->btn_fwd = toolbar_info[1].widget;
nautilus_window_allow_stop(window, FALSE);
gtk_widget_set_sensitive(window->btn_back, FALSE);
gtk_widget_set_sensitive(window->btn_fwd, FALSE);
/* set up location bar */
......@@ -522,6 +563,13 @@ nautilus_window_constructed(NautilusWindow *window)
after the statusbar
creation */
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
*/
nautilus_window_allow_back(window, FALSE);
nautilus_window_allow_forward(window, FALSE);
nautilus_window_allow_stop(window, FALSE);
bonobo_ui_handler_set_menubar(window->uih, app->menubar);
bonobo_ui_handler_set_app(window->uih, app);
bonobo_ui_handler_set_statusbar(window->uih, statusbar);
......@@ -895,31 +943,34 @@ nautilus_window_about_cb (GtkWidget *widget,
void
nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[0].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_BACK_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_BACK_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[1].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_FORWARD_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_FORWARD_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[2].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_UP_BUTTON_INDEX].widget, allow);
gtk_widget_set_sensitive(go_menu_info[GO_MENU_UP_ITEM_INDEX].widget, allow);
}
void
nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[5].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_RELOAD_BUTTON_INDEX].widget, allow);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive(toolbar_info[7].widget, allow);
gtk_widget_set_sensitive(toolbar_info[TOOLBAR_STOP_BUTTON_INDEX].widget, allow);
}
......
......@@ -56,7 +56,7 @@ struct _NautilusWindow {
/** UI stuff **/
NautilusIndexPanel *index_panel;
GtkWidget *content_hbox, *btn_back, *btn_fwd;
GtkWidget *content_hbox;
GtkWidget *option_cvtype, *ent_uri;
guint statusbar_ctx, statusbar_clear_id;
......
......@@ -869,6 +869,18 @@ nautilus_window_change_location_2(NautilusNavigationInfo *navi, gpointer data)
goto errout;