summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Camp <dave@ximian.com>2003-09-30 20:38:01 +0000
committerDave Camp <campd@src.gnome.org>2003-09-30 20:38:01 +0000
commitc42ab00ac67db2dc5bd22bff65e1c0a3414fe113 (patch)
tree636294d9aadd0aecaa9bf0858a40e49399a224e3
parent1f859c83a9c2734ce3645657a065d7faa8c69560 (diff)
downloadnautilus-c42ab00ac67db2dc5bd22bff65e1c0a3414fe113.tar.gz
Merge the nautilus-spatial-playground branch to HEAD.
2003-09-30 Dave Camp <dave@ximian.com> * Merge the nautilus-spatial-playground branch to HEAD.
-rw-r--r--ChangeLog446
-rw-r--r--components/adapter/nautilus-adapter.c5
-rw-r--r--components/history/nautilus-history-view.c5
-rw-r--r--components/tree/nautilus-tree-view.c14
-rw-r--r--libnautilus-private/nautilus-global-preferences.c8
-rw-r--r--libnautilus-private/nautilus-global-preferences.h4
-rw-r--r--libnautilus-private/nautilus-icon-container.c45
-rw-r--r--libnautilus-private/nautilus-icon-container.h2
-rw-r--r--libnautilus-private/nautilus-metadata.h1
-rw-r--r--libnautilus/nautilus-view-component.idl25
-rw-r--r--libnautilus/nautilus-view.c78
-rw-r--r--libnautilus/nautilus-view.h10
-rw-r--r--src/Makefile.am9
-rw-r--r--src/file-manager/fm-directory-view.c140
-rw-r--r--src/file-manager/fm-directory-view.h4
-rw-r--r--src/file-manager/fm-icon-view.c20
-rw-r--r--src/file-manager/fm-list-view.c39
-rw-r--r--src/file-manager/fm-search-list-view.c5
-rw-r--r--src/file-manager/nautilus-desktop-icon-view-ui.xml1
-rw-r--r--src/file-manager/nautilus-directory-view-ui.xml16
-rw-r--r--src/nautilus-application.c288
-rw-r--r--src/nautilus-application.h19
-rw-r--r--src/nautilus-desktop-window.c31
-rw-r--r--src/nautilus-desktop-window.h5
-rw-r--r--src/nautilus-file-management-properties.c3
-rw-r--r--src/nautilus-file-management-properties.glade18
-rw-r--r--src/nautilus-location-bar.c14
-rw-r--r--src/nautilus-location-bar.h4
-rw-r--r--src/nautilus-navigation-window-menus.c1118
-rw-r--r--src/nautilus-navigation-window-ui.xml163
-rw-r--r--src/nautilus-navigation-window.c2201
-rw-r--r--src/nautilus-navigation-window.h144
-rw-r--r--src/nautilus-object-window.c2297
-rw-r--r--src/nautilus-object-window.h166
-rw-r--r--src/nautilus-shell-ui.xml166
-rw-r--r--src/nautilus-shell.c40
-rw-r--r--src/nautilus-spatial-window-ui.xml47
-rw-r--r--src/nautilus-spatial-window.c2235
-rw-r--r--src/nautilus-spatial-window.h157
-rw-r--r--src/nautilus-switchable-navigation-bar.c6
-rw-r--r--src/nautilus-switchable-navigation-bar.h2
-rw-r--r--src/nautilus-view-frame-corba.c67
-rw-r--r--src/nautilus-view-frame-private.h9
-rw-r--r--src/nautilus-view-frame.c138
-rw-r--r--src/nautilus-view-frame.h11
-rw-r--r--src/nautilus-window-manage-views.c924
-rw-r--r--src/nautilus-window-manage-views.h19
-rw-r--r--src/nautilus-window-menus.c965
-rw-r--r--src/nautilus-window-private.h77
-rw-r--r--src/nautilus-window-toolbars.c66
-rw-r--r--src/nautilus-window.c1480
-rw-r--r--src/nautilus-window.h86
52 files changed, 3317 insertions, 10526 deletions
diff --git a/ChangeLog b/ChangeLog
index 239869d14..2e5e725ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,447 @@
+2003-09-30 Dave Camp <dave@ximian.com>
+
+ * Merge the nautilus-spatial-playground branch to HEAD.
+
+2003-09-30 Dave Camp <dave@ximian.com>
+
+ * src/Makefile.am:
+ * src/nautilus-application.c:
+ (nautilus_application_get_spatial_window_list),
+ (nautilus_application_get_existing_spatial_window),
+ (find_parent_spatial_window),
+ (nautilus_application_close_with_parent_windows),
+ (spatial_window_destroyed_callback),
+ (nautilus_application_present_spatial_window):
+ * src/nautilus-application.h:
+ * src/nautilus-desktop-window.c:
+ (nautilus_desktop_window_update_directory):
+ * src/nautilus-desktop-window.h:
+ * src/nautilus-object-window.c:
+ * src/nautilus-object-window.h:
+ * src/nautilus-shell.c: (open_window),
+ (restore_one_window_callback):
+ * src/nautilus-spatial-window.c: (save_window_geometry_timeout),
+ (nautilus_spatial_window_configure_event),
+ (nautilus_spatial_window_unrealize),
+ (nautilus_spatial_window_destroy),
+ (nautilus_spatial_window_finalize),
+ (nautilus_spatial_window_save_geometry),
+ (nautilus_spatial_window_save_scroll_position),
+ (nautilus_spatial_window_show),
+ (file_menu_close_with_parent_windows_callback), (real_merge_menus),
+ (real_set_content_view_widget), (real_delete_event),
+ (nautilus_spatial_window_instance_init),
+ (nautilus_spatial_window_class_init):
+ * src/nautilus-spatial-window.h:
+ * src/nautilus-window-manage-views.c: (open_location),
+ (position_and_show_window_callback):
+ * src/nautilus-window-private.h: Renamed NautilusObjectWindow
+ to NautilusSpatialWindow.
+
+2003-09-30 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-window-manage-views.c (load_new_location_in_all_views):
+ Don't load from window->new_content_view in the view list.
+
+2003-09-29 Dave Camp <dave@ximian.com>
+
+ * src/nautilus-navigation-window.c:
+ (nautilus_navigation_window_tear_down_sidebar),
+ (nautilus_navigation_window_clear_back_list),
+ (compare_view_identifier_with_iid),
+ (disconnect_and_destroy_sidebar_panel), (set_side_panel_image),
+ (side_panel_image_changed_callback),
+ (report_side_panel_failure_to_user),
+ (side_panel_view_failed_callback), (connect_side_panel),
+ (side_panel_view_loaded_callback),
+ (nautilus_navigation_window_set_sidebar_panels):
+ * src/nautilus-window-manage-views.c: (change_selection),
+ (update_title), (view_frame_info_new), (set_view_frame_info),
+ (nautilus_window_get_view_frame_label),
+ (report_content_view_failure_to_user_internal),
+ (load_new_location_in_all_views), (load_content_view),
+ (handle_view_failure), (position_and_show_window_callback),
+ (nautilus_window_stop_loading),
+ (nautilus_window_connect_extra_view),
+ (nautilus_window_disconnect_extra_view),
+ (content_view_failed_callback), (view_loaded_callback),
+ (connect_view), (disconnect_view), (disconnect_view_callback),
+ (nautilus_window_manage_views_destroy):
+ * src/nautilus-window-manage-views.h:
+ * src/nautilus-window.h: Move side-panel specific code into
+ the navigation window.
+
+2003-09-28 James Willcox <james@ximian.com>
+
+ * libnautilus-private/nautilus-metadata.h:
+ * src/nautilus-object-window.c: (nautilus_object_window_destroy),
+ (nautilus_object_window_save_scroll_position), (delete_event_cb),
+ (nautilus_object_window_instance_init):
+ * src/nautilus-object-window.h:
+ * src/nautilus-view-frame.c:
+ (nautilus_view_frame_get_first_visible_file):
+ * src/nautilus-window-manage-views.c:
+ (position_and_show_window_callback):
+
+ Save the scroll position in object windows.
+
+2003-09-24 Dave Camp <dave@ximian.com>
+
+ * src/nautilus-desktop-window.c: (real_get_title),
+ (nautilus_desktop_window_class_init): Return "Desktop" for everything.
+ * src/nautilus-navigation-window.c: (real_set_title),
+ (nautilus_navigation_window_class_init): Set the title to
+ "File Browser: foo"
+ * src/nautilus-object-window.c: (real_set_title),
+ (nautilus_object_window_class_init): Set the title to the object
+ name.
+ * src/nautilus-window-manage-views.c: (update_title): Moved
+ title handling to NautilusWindow.
+ (nautilus_window_manage_views_destroy): Destroy side panes.
+ * src/nautilus-window.h:
+ * src/nautilus-window.c: (compute_default_title), (real_get_title),
+ (nautilus_window_get_title), (real_set_title),
+ (nautilus_window_set_title), (nautilus_window_update_title),
+ (nautilus_window_class_init): Moved title handling here.
+
+2003-09-24 Dave Camp <dave@ximian.com>
+
+ * src/nautilus-navigation-window.c: (activate_nth_short_list_item),
+ (activate_extra_viewer), (view_as_menu_switch_views_callback),
+ (create_view_as_menu_item), (new_gtk_separator),
+ (view_as_menu_choose_view_callback), (load_view_as_menu),
+ (real_load_view_as_menu), (real_set_content_view_widget),
+ (nautilus_navigation_window_class_init):
+ * src/nautilus-window-manage-views.c:
+ (location_has_really_changed):
+ * src/nautilus-window-private.h:
+ * src/nautilus-window.c: (update_extra_viewer_in_view_as_menus),
+ (nautilus_window_synch_view_as_menus), (real_load_view_as_menu),
+ (load_view_as_menus_callback), (real_set_content_view_widget),
+ (nautilus_window_class_init):
+ * src/nautilus-window.h: Fixed up the View As optionmenu for
+ the navigation window.
+
+2003-09-23 Dave Camp <dave@ximian.com>
+
+ * src/nautilus-navigation-window-menus.c: (forget_history_if_yes),
+ (forget_history_if_confirmed), (go_menu_forget_history_callback),
+ (nautilus_window_remove_go_menu_callback),
+ (nautilus_window_remove_go_menu_items), (refresh_go_menu),
+ (refresh_go_menu_idle_callback), (schedule_refresh_go_menu),
+ (nautilus_navigation_window_initialize_go_menu),
+ (nautilus_navigation_window_initialize_menus_part_1),
+ (nautilus_navigation_window_initialize_menus_part_2):
+ * src/nautilus-navigation-window-ui.xml:
+ * src/nautilus-shell-ui.xml:
+ * src/nautilus-spatial-window-ui.xml:
+ * src/nautilus-window-menus.c:
+ (nautilus_window_initialize_menus_part_1):
+ * src/nautilus-window.c: (ui_idle_handler): Moved the Go menu
+ and history to the navigation window. In the spatial window,
+ moved Open Parent and Open Location to the File menu, and added
+ a Places menu with a few static bookmarks.
+
+2003-09-23 Dave Camp <dave@ximian.com>
+
+ * libnautilus/nautilus-view-component.idl:
+ * libnautilus/nautilus-view.c: (call_open_location),
+ (nautilus_view_open_location):
+ * libnautilus/nautilus-view.h:
+ * src/nautilus-view-frame-corba.c: (open_location), (close_window),
+ (impl_Nautilus_ViewFrame_open_location),
+ (nautilus_view_frame_corba_part_class_init):
+ * src/nautilus-view-frame-private.h:
+ * src/nautilus-view-frame.c: (nautilus_view_frame_open_location),
+ (nautilus_view_frame_class_init):
+ * src/nautilus-view-frame.h:
+ * src/nautilus-window-manage-views.c: (new_window_show_callback),
+ (open_location), (nautilus_window_open_location),
+ (nautilus_window_open_location_with_selection),
+ (open_location_callback): Implemented a new open_location API.
+
+ * libnautilus-private/nautilus-icon-container.c:
+ (nautilus_icon_container_did_not_drag),
+ (nautilus_icon_container_class_init), (handle_icon_button_press),
+ (activate_selected_items), (activate_selected_items_alternate):
+ * libnautilus-private/nautilus-icon-container.h:
+ * src/file-manager/fm-directory-view.c: (open_callback),
+ (open_location), (switch_location_and_view),
+ (open_one_in_new_window), (open_scripts_folder_callback),
+ (activate_callback), (fm_directory_view_activate_file),
+ (fm_directory_view_activate_files):
+ * src/file-manager/fm-directory-view.h:
+ * src/file-manager/fm-icon-view.c:
+ (icon_container_activate_callback),
+ (icon_container_activate_alternate_callback),
+ (create_icon_container):
+ * src/file-manager/fm-list-view.c: (activate_selected_items),
+ (activate_selected_items_alternate), (fm_list_view_did_not_drag),
+ (button_press_callback): Use new open_location API, if an
+ item is middle-clicked to activate, close the window
+ behind it.
+
+ * src/file-manager/fm-search-list-view.c:
+ (reveal_selected_items_callback):
+ * components/adapter/nautilus-adapter.c:
+ (nautilus_adapter_open_location_callback):
+ * components/history/nautilus-history-view.c:
+ (row_activated_callback):
+ * components/tree/nautilus-tree-view.c:
+ (got_activation_uri_callback): Updated for new open_location API.
+
+2003-09-21 Dave Camp <dave@ximian.com>
+
+ * src/nautilus-shell-ui.xml: Get rid of the find menu item for
+ now.
+
+2003-09-21 Dave Camp <dave@ximian.com>
+
+ * src/Makefile.am: Added nautilus-spatial-window-ui.xml.
+ * src/nautilus-application.h:
+ * src/nautilus-application.c:
+ (nautilus_application_close_all_navigation_windows): Moved
+ here from nautilus_application_close_all_windows, only
+ close navigation windows.
+ (nautilus_application_get_existing_object_window),
+ (find_parent_object_window),
+ (nautilus_application_close_with_parent_windows): New functions.
+ * src/nautilus-navigation-window-menus.c:
+ (file_menu_close_all_windows_callback),
+ (nautilus_navigation_window_initialize_menus_part_1):
+ * src/nautilus-navigation-window-ui.xml: Move "Close All Windows"
+ to the navigation window.
+ * src/nautilus-object-window.h:
+ * src/nautilus-object-window.c:
+ (file_menu_close_with_parent_windows_callback), (real_merge_menus),
+ (nautilus_object_window_class_init): Added a "Close With Parents"
+ command to the spatial windows.
+ * src/nautilus-shell-ui.xml:
+ * src/nautilus-window-menus.c:
+ (nautilus_window_initialize_menus_part_1): Took out "close all
+ windows"
+
+2003-09-18 Dave Camp <dcamp@novell.com>
+
+ * libnautilus-private/nautilus-global-preferences.c:
+ * libnautilus-private/nautilus-global-preferences.h: Removed
+ the "start with toolbar" preference.
+ * src/nautilus-navigation-window-menus.c:
+ (nautilus_navigation_window_update_show_hide_menu_items),
+ (nautilus_navigation_window_initialize_menus_part_1):
+ * src/nautilus-navigation-window-ui.xml: Removed the toolbar
+ toggle.
+ * src/nautilus-window-private.h: Removed the unused
+ throbber bits.
+ * src/nautilus-window-toolbars.c:
+ (nautilus_navigation_window_initialize_toolbars): Ignore the
+ "start with toolbar" preference.
+ * src/nautilus-navigation-window.c:
+ (nautilus_navigation_window_show): Show or hide the dock
+ items before showing the window.
+
+2003-09-14 Dave Camp <dave@ximian.com>
+
+ * src/nautilus-file-management-properties.c:
+ (nautilus_file_management_properties_dialog_setup):
+ * src/nautilus-file-management-properties.glade:
+ * libnautilus-private/nautilus-global-preferences.c:
+ * libnautilus-private/nautilus-global-preferences.h: Removed the
+ "always use new window" preference.
+ * libnautilus/nautilus-view-component.idl: Updated the
+ documentation for the open_location functions.
+ * src/Makefile.am: Added new files.
+ * src/file-manager/fm-directory-view.c: (open_alternate_callback),
+ (open_location), (switch_location_and_view),
+ (fm_directory_view_init), (fm_directory_view_finalize),
+ (open_one_in_new_window), (open_scripts_folder_callback),
+ (real_update_menus), (fm_directory_view_activate_files): Use new
+ window-opening logic.
+ * src/file-manager/nautilus-desktop-icon-view-ui.xml:
+ * src/file-manager/nautilus-directory-view-ui.xml: Moved "open
+ in new window" to Open With.
+ * src/nautilus-application.h:
+ * src/nautilus-application.c:
+ (nautilus_application_get_object_window_list), (create_window),
+ (object_window_destroyed_callback),
+ (nautilus_application_present_object_window): New functions.
+ (nautilus_application_create_navigation_window): Moved here
+ from nautilus_application_create_window().
+ (volume_unmounted_callback): Close the window if it's the last
+ one.
+ * src/nautilus-desktop-window.h:
+ * src/nautilus-desktop-window.c:
+ (nautilus_desktop_window_update_directory), (real_merge_menus),
+ (nautilus_desktop_window_class_init): Derive from
+ NautilusObjectWindow.
+ * src/nautilus-location-bar.h:
+ * src/nautilus-location-bar.c: (nautilus_location_bar_get_window),
+ (drag_data_received_callback), (nautilus_location_bar_new): Take
+ a NautilusNavigationWindow.
+ * src/nautilus-navigation-window-menus.c: (go_menu_back_callback),
+ (go_menu_forward_callback),
+ (view_menu_show_hide_sidebar_state_changed_callback),
+ (view_menu_show_hide_toolbar_state_changed_callback),
+ (view_menu_show_hide_location_bar_state_changed_callback),
+ (nautilus_navigation_window_update_show_hide_menu_items),
+ (bookmarks_menu_add_bookmark_callback),
+ (bookmarks_menu_edit_bookmarks_callback), (append_separator),
+ (free_bookmark_list), (get_bookmark_list),
+ (remove_bookmarks_for_uri_if_yes), (show_bogus_bookmark_window),
+ (create_menu_item_from_node), (add_bookmark_for_current_location),
+ (edit_bookmarks),
+ (nautilus_window_bookmarks_preference_changed_callback),
+ (refresh_bookmarks_menu),
+ (nautilus_navigation_window_initialize_bookmarks_menu),
+ (nautilus_navigation_window_initialize_menus_part_1),
+ (nautilus_navigation_window_initialize_menus_part_2),
+ (nautilus_navigation_window_remove_bookmarks_menu_callback),
+ (nautilus_navigation_window_remove_bookmarks_menu_items),
+ (append_dynamic_bookmarks), (refresh_bookmarks_menu_idle_callback),
+ (schedule_refresh_bookmarks_menu): Moved all of the
+ navigation-window-specific menu code here.
+ * src/nautilus-shell-ui.xml:
+ * src/nautilus-shell.c: (open_window),
+ (restore_one_window_callback): Open navigation windows (this
+ needs work).
+ * src/nautilus-switchable-navigation-bar.c:
+ (create_search_bar_if_non_existant),
+ (nautilus_switchable_navigation_bar_new):
+ * src/nautilus-switchable-navigation-bar.h: Take a
+ NautilusNavigationWindow.
+ * src/nautilus-view-frame.c: (emit_zoom_parameters_changed),
+ (emit_zoom_parameters_changed_callback),
+ (emit_zoom_level_changed_callback),
+ (nautilus_view_frame_get_zoom_level),
+ (nautilus_view_frame_get_min_zoom_level),
+ (nautilus_view_frame_get_max_zoom_level),
+ (nautilus_view_frame_get_has_min_zoom_level),
+ (nautilus_view_frame_get_has_max_zoom_level),
+ (nautilus_view_frame_get_can_zoom_in),
+ (nautilus_view_frame_get_can_zoom_out):
+ * src/nautilus-view-frame.h: Store zoom parameters in the
+ view frame so that it can be a model for the UI rather than
+ the zoom control.
+ * src/nautilus-navigation-window.c:
+ (nautilus_navigation_window_instance_init), (go_to_callback),
+ (navigation_bar_location_changed_callback),
+ (navigation_bar_mode_changed_callback),
+ (side_pane_close_requested_callback),
+ (side_pane_size_allocate_callback), (setup_side_pane_width),
+ (set_current_side_panel), (side_pane_switch_page_callback),
+ (nautilus_navigation_window_set_up_sidebar),
+ (nautilus_navigation_window_tear_down_sidebar),
+ (nautilus_navigation_window_unrealize),
+ (nautilus_navigation_window_destroy),
+ (nautilus_navigation_window_finalize),
+ (nautilus_navigation_window_add_sidebar_panel),
+ (nautilus_navigation_window_remove_sidebar_panel),
+ (nautilus_navigation_window_go_back),
+ (nautilus_navigation_window_go_forward),
+ (nautilus_navigation_window_set_search_mode),
+ (nautilus_navigation_window_get_search_mode),
+ (nautilus_navigation_window_go_home),
+ (nautilus_navigation_window_allow_back),
+ (nautilus_navigation_window_allow_forward), (real_merge_menus),
+ (zoom_level_changed_callback), (zoom_parameters_changed_callback),
+ (connect_view), (disconnect_view), (real_set_content_view_widget),
+ (real_set_throbber_active),
+ (nautilus_navigation_window_show_location_bar_temporarily),
+ (real_prompt_for_location),
+ (nautilus_navigation_window_clear_forward_list),
+ (nautilus_navigation_window_clear_back_list), (add_sidebar_panels),
+ (show_dock_item), (hide_dock_item), (dock_item_showing),
+ (nautilus_navigation_window_hide_location_bar),
+ (nautilus_navigation_window_show_location_bar),
+ (nautilus_navigation_window_location_bar_showing),
+ (nautilus_navigation_window_hide_toolbar),
+ (nautilus_navigation_window_show_toolbar),
+ (nautilus_navigation_window_toolbar_showing),
+ (nautilus_navigation_window_hide_sidebar),
+ (nautilus_navigation_window_show_sidebar),
+ (nautilus_navigation_window_sidebar_showing),
+ (nautilus_navigation_window_get_base_page_index),
+ (nautilus_navigation_window_show),
+ (nautilus_navigation_window_class_init):
+ * src/nautilus-navigation-window.h:
+ * src/nautilus-object-window.c: (save_window_geometry_timeout),
+ (nautilus_object_window_configure_event),
+ (nautilus_object_window_unrealize),
+ (nautilus_object_window_destroy),
+ (nautilus_object_window_finalize),
+ (nautilus_object_window_save_geometry),
+ (nautilus_object_window_show), (real_set_content_view_widget),
+ (nautilus_object_window_instance_init),
+ (nautilus_object_window_class_init):
+ * src/nautilus-object-window.h:
+ * src/nautilus-window-manage-views.c: (change_selection),
+ (update_title), (set_displayed_location), (handle_go_back),
+ (handle_go_forward), (handle_go_elsewhere), (update_up_button),
+ (viewed_file_changed_callback), (update_history),
+ (update_for_new_location), (open_location),
+ (nautilus_window_open_location),
+ (nautilus_window_open_location_with_selection),
+ (load_new_location_in_sidebar_panels),
+ (load_new_location_in_all_views),
+ (disconnect_and_destroy_sidebar_panel), (handle_view_failure),
+ (position_and_show_window_callback),
+ (nautilus_window_stop_loading),
+ (nautilus_navigation_window_set_sidebar_panels),
+ (zoom_level_changed_callback), (zoom_parameters_changed_callback),
+ (go_back_callback),
+ (open_location_prefer_existing_window_callback),
+ (open_location_force_new_window_callback),
+ (report_redirect_callback), (set_side_panel_image),
+ (view_loaded_callback), (nautilus_window_manage_views_destroy),
+ (nautilus_navigation_window_back_or_forward):
+ * src/nautilus-window-manage-views.h:
+ * src/nautilus-window-menus.c: (bookmark_holder_new),
+ (show_bogus_bookmark_window), (activate_bookmark_in_menu_item),
+ (nautilus_menus_append_bookmark_to_menu),
+ (file_menu_new_window_callback), (file_menu_burn_cd_callback),
+ (go_menu_location_callback),
+ (nautilus_window_update_show_hide_menu_items),
+ (nautilus_window_initialize_menus_part_1),
+ (nautilus_window_initialize_menus_part_2), (refresh_go_menu):
+ * src/nautilus-window-private.h:
+ * src/nautilus-window-toolbars.c:
+ (activate_back_or_forward_menu_item),
+ (activate_back_menu_item_callback),
+ (activate_forward_menu_item_callback),
+ (create_back_or_forward_menu), (get_back_button),
+ (get_forward_button), (back_or_forward_button_pressed_callback),
+ (create_back_or_forward_toolbar_item), (throbber_set_throbbing),
+ (throbber_created_callback),
+ (nautilus_navigation_window_set_throbber_active),
+ (nautilus_navigation_window_activate_throbber),
+ (nautilus_navigation_window_initialize_toolbars):
+ * src/nautilus-window.c: (nautilus_window_instance_init),
+ (ui_idle_handler), (nautilus_window_go_up),
+ (nautilus_window_allow_up), (nautilus_window_allow_stop),
+ (nautilus_window_allow_reload), (nautilus_window_allow_burn_cd),
+ (nautilus_window_go_home), (nautilus_window_launch_cd_burner),
+ (nautilus_window_prompt_for_location),
+ (nautilus_window_get_location), (real_merge_menus),
+ (nautilus_window_constructed), (nautilus_window_destroy),
+ (nautilus_window_finalize), (nautilus_window_close),
+ (update_extra_viewer_in_view_as_menus),
+ (nautilus_window_synch_view_as_menus),
+ (load_view_as_menus_callback), (nautilus_window_display_error),
+ (real_set_content_view_widget),
+ (nautilus_window_set_content_view_widget), (show_dock_item),
+ (hide_dock_item), (dock_item_showing),
+ (nautilus_window_hide_status_bar),
+ (nautilus_window_show_status_bar),
+ (nautilus_window_status_bar_showing), (nautilus_window_show),
+ (nautilus_window_get_ui_container),
+ (nautilus_window_set_viewed_file), (add_to_history_list),
+ (real_add_current_location_to_history_list),
+ (nautilus_window_add_current_location_to_history_list),
+ (nautilus_forget_history), (nautilus_window_class_init):
+ * src/nautilus-window.h: Split NautilusWindow into three
+ classes. A NautilusWindow base class, a NautilusObjectWindow
+ class, and a NautilusNavigationWindow class.
+
2003-09-30 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-icon-container.c (nautilus_icon_container_scroll_to_icon):
@@ -107,7 +551,7 @@
* cut-n-paste-code/gsequence/gsequence.c:
Patch from Soeren Sandmann to fix removes.
Thanks to Martin Wehner for tracking this down.
-
+
2003-09-11 Mathieu Lacage <mathieu@gnome.org>
* src/file-manager/fm-properties-window.c: add a wait cursor during
diff --git a/components/adapter/nautilus-adapter.c b/components/adapter/nautilus-adapter.c
index b38ac23eb..67502ee05 100644
--- a/components/adapter/nautilus-adapter.c
+++ b/components/adapter/nautilus-adapter.c
@@ -221,8 +221,9 @@ nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrategy *strategy
const char *uri,
NautilusAdapter *adapter)
{
- nautilus_view_open_location_in_this_window
- (adapter->details->nautilus_view, uri);
+ nautilus_view_open_location
+ (adapter->details->nautilus_view,
+ uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0, NULL);
}
diff --git a/components/history/nautilus-history-view.c b/components/history/nautilus-history-view.c
index 2823c00c7..f911de166 100644
--- a/components/history/nautilus-history-view.c
+++ b/components/history/nautilus-history-view.c
@@ -168,8 +168,9 @@ row_activated_callback (GtkTreeView *tree_view,
/* Navigate to the clicked location. */
uri = nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (bookmark));
- nautilus_view_open_location_in_this_window
- (NAUTILUS_VIEW (view), uri);
+ nautilus_view_open_location
+ (NAUTILUS_VIEW (view),
+ uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0, NULL);
g_free (uri);
}
diff --git a/components/tree/nautilus-tree-view.c b/components/tree/nautilus-tree-view.c
index edd3b980b..b570bf7fd 100644
--- a/components/tree/nautilus-tree-view.c
+++ b/components/tree/nautilus-tree-view.c
@@ -281,7 +281,12 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
/* Non-local executables don't get launched. They act like non-executables. */
if (file_uri == NULL) {
- nautilus_view_open_location_in_this_window (NAUTILUS_VIEW (view), uri);
+ nautilus_view_open_location
+ (NAUTILUS_VIEW (view),
+ uri,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ 0,
+ NULL);
} else {
nautilus_launch_application_from_command (screen, NULL, file_uri, NULL, FALSE);
g_free (file_uri);
@@ -294,7 +299,12 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
g_free (view->details->selection_location);
}
view->details->selection_location = g_strdup (uri);
- nautilus_view_open_location_in_this_window (NAUTILUS_VIEW (view), uri);
+ nautilus_view_open_location
+ (NAUTILUS_VIEW (view),
+ uri,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ 0,
+ NULL);
}
}
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 92c465dfb..252dd7889 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -393,10 +393,6 @@ static const PreferenceDefault preference_defaults[] = {
NULL, NULL,
"search_bar_type"
},
- { NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (FALSE)
- },
{ NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
PREFERENCE_STRING_LIST,
"size,date_modified,type",
@@ -412,10 +408,6 @@ static const PreferenceDefault preference_defaults[] = {
PREFERENCE_INTEGER,
GINT_TO_POINTER (148)
},
- { NAUTILUS_PREFERENCES_START_WITH_TOOLBAR,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (TRUE)
- },
{ NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR,
PREFERENCE_BOOLEAN,
GINT_TO_POINTER (TRUE)
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index bbecd9f90..3e1686566 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -46,9 +46,6 @@ G_BEGIN_DECLS
/* How wide the sidebar is (or how wide it will be when expanded) */
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width"
-/* Window options */
-#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"
-
/* Trash options */
#define NAUTILUS_PREFERENCES_CONFIRM_TRASH "preferences/confirm_trash"
#define NAUTILUS_PREFERENCES_ENABLE_DELETE "preferences/enable_delete"
@@ -77,7 +74,6 @@ G_BEGIN_DECLS
#define NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION "preferences/executable_text_activation"
/* Which views should be displayed for new windows */
-#define NAUTILUS_PREFERENCES_START_WITH_TOOLBAR "preferences/start_with_toolbar"
#define NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR "preferences/start_with_location_bar"
#define NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR "preferences/start_with_status_bar"
#define NAUTILUS_PREFERENCES_START_WITH_SIDEBAR "preferences/start_with_sidebar"
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 3c2ee0dde..b2a1cb303 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -148,6 +148,7 @@ typedef struct {
static GType nautilus_icon_container_accessible_get_type (void);
static void activate_selected_items (NautilusIconContainer *container);
+static void activate_selected_items_alternate (NautilusIconContainer *container);
static void nautilus_icon_container_theme_changed (gpointer user_data);
static void compute_stretch (StretchState *start,
StretchState *current);
@@ -204,6 +205,7 @@ GNOME_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container,
/* The NautilusIconContainer signals. */
enum {
ACTIVATE,
+ ACTIVATE_ALTERNATE,
BAND_SELECT_STARTED,
BAND_SELECT_ENDED,
BUTTON_PRESS,
@@ -3209,7 +3211,11 @@ nautilus_icon_container_did_not_drag (NautilusIconContainer *container,
* NautilusList goes the other way because its "links" seem
* much more link-like.
*/
- activate_selected_items (container);
+ if (event->button == MIDDLE_BUTTON) {
+ activate_selected_items_alternate (container);
+ } else {
+ activate_selected_items (container);
+ }
}
}
}
@@ -3827,6 +3833,16 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+ signals[ACTIVATE_ALTERNATE]
+ = g_signal_new ("activate_alternate",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NautilusIconContainerClass,
+ activate_alternate),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
signals[CONTEXT_CLICK_SELECTION]
= g_signal_new ("context_click_selection",
G_TYPE_FROM_CLASS (class),
@@ -4237,25 +4253,28 @@ handle_icon_button_press (NautilusIconContainer *container,
return TRUE;
}
- if (event->button == DRAG_BUTTON &&
+ if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) &&
event->type == GDK_BUTTON_PRESS) {
/* The next double click has to be on this icon */
details->double_click_icon[1] = details->double_click_icon[0];
details->double_click_icon[0] = icon;
}
if (event->type == GDK_2BUTTON_PRESS &&
- event->button == DRAG_BUTTON) {
+ (event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON)) {
/* Double clicking does not trigger a D&D action. */
details->drag_button = 0;
details->drag_icon = NULL;
if (icon == details->double_click_icon[1] &&
!button_event_modifies_selection (event)) {
- activate_selected_items (container);
+ if (event->button == MIDDLE_BUTTON) {
+ activate_selected_items_alternate (container);
+ } else {
+ activate_selected_items (container);
+ }
}
return TRUE;
}
-
if (event->button == DRAG_BUTTON
|| event->button == DRAG_MENU_BUTTON) {
details->drag_button = event->button;
@@ -4572,6 +4591,22 @@ activate_selected_items (NautilusIconContainer *container)
g_list_free (selection);
}
+static void
+activate_selected_items_alternate (NautilusIconContainer *container)
+{
+ GList *selection;
+
+ g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
+
+ selection = nautilus_icon_container_get_selection (container);
+ if (selection != NULL) {
+ g_signal_emit (container,
+ signals[ACTIVATE_ALTERNATE], 0,
+ selection);
+ }
+ g_list_free (selection);
+}
+
static NautilusIcon *
get_icon_being_renamed (NautilusIconContainer *container)
{
diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h
index 84a4d5daa..727f1c665 100644
--- a/libnautilus-private/nautilus-icon-container.h
+++ b/libnautilus-private/nautilus-icon-container.h
@@ -87,6 +87,8 @@ typedef struct {
/* Operations on icons. */
void (* activate) (NautilusIconContainer *container,
NautilusIconData *data);
+ void (* activate_alternate) (NautilusIconContainer *container,
+ NautilusIconData *data);
void (* context_click_selection) (NautilusIconContainer *container,
GdkEventButton *event);
void (* move_copy_items) (NautilusIconContainer *container,
diff --git a/libnautilus-private/nautilus-metadata.h b/libnautilus-private/nautilus-metadata.h
index a88e919e8..06a4014a7 100644
--- a/libnautilus-private/nautilus-metadata.h
+++ b/libnautilus-private/nautilus-metadata.h
@@ -60,6 +60,7 @@
#define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED "list_view_sort_reversed"
#define NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY "window_geometry"
+#define NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION "window_scroll_position"
#define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR "sidebar_background_color"
#define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE "sidebar_background_tile_image"
diff --git a/libnautilus/nautilus-view-component.idl b/libnautilus/nautilus-view-component.idl
index 334480d80..007beacba 100644
--- a/libnautilus/nautilus-view-component.idl
+++ b/libnautilus/nautilus-view-component.idl
@@ -87,18 +87,19 @@ module Nautilus {
* 'selection' - ro - URIList - the selection
*/
interface ViewFrame : ::Bonobo::Unknown {
- /* Called by the view component to change the location
- * shown in the window, or to open a window. The
- * "prefer existing window" variant will use an
- * existing window if one exists for that location and
- * will otherwise open a new window (with no
- * selection). In the case where you force a new
- * window, you can specify the initial selection.
- */
- oneway void open_location_in_this_window (in URI location);
- oneway void open_location_prefer_existing_window (in URI location);
- oneway void open_location_force_new_window (in URI location,
- in URIList selection);
+ enum OpenMode {
+ OPEN_ACCORDING_TO_MODE,
+ OPEN_IN_SPATIAL,
+ OPEN_IN_NAVIGATION
+ };
+
+ typedef long OpenFlags;
+ const OpenFlags OPEN_FLAG_CLOSE_BEHIND = 1;
+
+ oneway void open_location (in URI location,
+ in OpenMode mode,
+ in OpenFlags flags,
+ in URIList selection);
/* Called by a view component when the location
* changes, but the view component is handling it
diff --git a/libnautilus/nautilus-view.c b/libnautilus/nautilus-view.c
index 41ff7594a..2831b4740 100644
--- a/libnautilus/nautilus-view.c
+++ b/libnautilus/nautilus-view.c
@@ -76,6 +76,8 @@ typedef struct {
char *location;
GList *selection;
char *title;
+ Nautilus_ViewFrame_OpenMode mode;
+ Nautilus_ViewFrame_OpenFlags flags;
} LocationPlus;
BONOBO_CLASS_BOILERPLATE_FULL (NautilusView, nautilus_view, Nautilus_View,
@@ -556,38 +558,8 @@ free_location_plus_callback (gpointer callback_data)
}
static void
-call_open_location_in_this_window (NautilusView *view,
- gpointer callback_data)
-{
- CORBA_Environment ev;
- Nautilus_ViewFrame view_frame;
-
- view_frame = view_frame_call_begin (view, &ev);
- if (view_frame != CORBA_OBJECT_NIL) {
- Nautilus_ViewFrame_open_location_in_this_window
- (view_frame, callback_data, &ev);
- }
- view_frame_call_end (view_frame, &ev);
-}
-
-static void
-call_open_location_prefer_existing_window (NautilusView *view,
- gpointer callback_data)
-{
- CORBA_Environment ev;
- Nautilus_ViewFrame view_frame;
-
- view_frame = view_frame_call_begin (view, &ev);
- if (view_frame != CORBA_OBJECT_NIL) {
- Nautilus_ViewFrame_open_location_prefer_existing_window
- (view_frame, callback_data, &ev);
- }
- view_frame_call_end (view_frame, &ev);
-}
-
-static void
-call_open_location_force_new_window (NautilusView *view,
- gpointer callback_data)
+call_open_location (NautilusView *view,
+ gpointer callback_data)
{
LocationPlus *location_plus;
CORBA_Environment ev;
@@ -599,13 +571,14 @@ call_open_location_force_new_window (NautilusView *view,
view_frame = view_frame_call_begin (view, &ev);
if (view_frame != CORBA_OBJECT_NIL) {
uri_list = nautilus_uri_list_from_g_list (location_plus->selection);
- Nautilus_ViewFrame_open_location_force_new_window
- (view_frame, location_plus->location, uri_list, &ev);
+ Nautilus_ViewFrame_open_location
+ (view_frame, location_plus->location, location_plus->mode, location_plus->flags, uri_list, &ev);
CORBA_free (uri_list);
}
view_frame_call_end (view_frame, &ev);
}
+
static void
call_report_location_change (NautilusView *view,
gpointer callback_data)
@@ -788,40 +761,23 @@ call_close_window (NautilusView *view,
view_frame_call_end (view_frame, &ev);
}
-
void
-nautilus_view_open_location_in_this_window (NautilusView *view,
- const char *location)
-{
- queue_outgoing_call (view,
- call_open_location_in_this_window,
- g_strdup (location),
- g_free);
-}
-
-void
-nautilus_view_open_location_prefer_existing_window (NautilusView *view,
- const char *location)
-{
- queue_outgoing_call (view,
- call_open_location_prefer_existing_window,
- g_strdup (location),
- g_free);
-}
-
-void
-nautilus_view_open_location_force_new_window (NautilusView *view,
- const char *location,
- GList *selection)
+nautilus_view_open_location (NautilusView *view,
+ const char *location,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
+ GList *selection)
{
LocationPlus *location_plus;
-
+
location_plus = g_new0 (LocationPlus, 1);
location_plus->location = g_strdup (location);
location_plus->selection = str_list_copy (selection);
-
+ location_plus->mode = mode;
+ location_plus->flags = flags;
+
queue_outgoing_call (view,
- call_open_location_force_new_window,
+ call_open_location,
location_plus,
free_location_plus_callback);
}
diff --git a/libnautilus/nautilus-view.h b/libnautilus/nautilus-view.h
index 22a92168d..6b9b16a99 100644
--- a/libnautilus/nautilus-view.h
+++ b/libnautilus/nautilus-view.h
@@ -70,13 +70,11 @@ NautilusView * nautilus_view_new_from_bonobo_control (BonoboCon
BonoboControl * nautilus_view_get_bonobo_control (NautilusView *view);
/* Calls to the Nautilus shell via the view frame. See the IDL for detailed comments. */
-void nautilus_view_open_location_in_this_window (NautilusView *view,
- const char *location_uri);
-void nautilus_view_open_location_prefer_existing_window (NautilusView *view,
- const char *location_uri);
-void nautilus_view_open_location_force_new_window (NautilusView *view,
+void nautilus_view_open_location (NautilusView *view,
const char *location_uri,
- GList *selection); /* list of URI char *s */
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
+ GList *selection);
void nautilus_view_report_location_change (NautilusView *view,
const char *location_uri,
GList *selection, /* list of URI char *s */
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f98a4215..d7eb16f03 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,6 +72,8 @@ nautilus_SOURCES = \
nautilus-location-bar.c \
nautilus-main.c \
nautilus-navigation-bar.c \
+ nautilus-navigation-window.c \
+ nautilus-navigation-window-menus.c \
nautilus-profiler.c \
nautilus-property-browser.c \
nautilus-search-bar-criterion.c \
@@ -82,13 +84,14 @@ nautilus_SOURCES = \
nautilus-sidebar-title.c \
nautilus-signaller.c \
nautilus-simple-search-bar.c \
+ nautilus-spatial-window.c \
nautilus-switchable-navigation-bar.c \
nautilus-switchable-search-bar.c \
+ nautilus-window-toolbars.c \
nautilus-view-frame-corba.c \
nautilus-view-frame.c \
nautilus-window-manage-views.c \
nautilus-window-menus.c \
- nautilus-window-toolbars.c \
nautilus-window.c \
nautilus-zoom-control.c \
nautilus-applicable-views.h \
@@ -104,6 +107,7 @@ nautilus_SOURCES = \
nautilus-location-bar.h \
nautilus-main.h \
nautilus-navigation-bar.h \
+ nautilus-navigation-window.h \
nautilus-profiler.h \
nautilus-property-browser.h \
nautilus-search-bar-criterion-private.h \
@@ -116,6 +120,7 @@ nautilus_SOURCES = \
nautilus-sidebar-title.h \
nautilus-signaller.h \
nautilus-simple-search-bar.h \
+ nautilus-spatial-window.h \
nautilus-switchable-navigation-bar.h \
nautilus-switchable-search-bar.h \
nautilus-view-frame-private.h \
@@ -152,6 +157,8 @@ server_DATA = $(server_in_files:.server.in=.server)
uidir = $(datadir)/gnome-2.0/ui
ui_DATA = \
nautilus-shell-ui.xml \
+ nautilus-navigation-window-ui.xml \
+ nautilus-spatial-window-ui.xml \
$(NULL)
gladedir = $(datadir)/nautilus/glade
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index c797b5a8d..fc2ca463d 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -188,7 +188,6 @@ static GdkAtom copied_files_atom;
static gboolean show_delete_command_auto_value;
static gboolean confirm_trash_auto_value;
-static gboolean use_new_window_auto_value;
static char *scripts_directory_uri;
static int scripts_directory_uri_length;
@@ -250,12 +249,6 @@ struct FMDirectoryViewDetails
};
typedef enum {
- RESPECT_PREFERENCE,
- PREFER_EXISTING_WINDOW,
- FORCE_NEW_WINDOW
-} WindowChoice;
-
-typedef enum {
ACTIVATION_ACTION_LAUNCH,
ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
ACTIVATION_ACTION_DISPLAY,
@@ -265,7 +258,8 @@ typedef enum {
typedef struct {
FMDirectoryView *view;
NautilusFile *file;
- WindowChoice choice;
+ Nautilus_ViewFrame_OpenMode mode;
+ Nautilus_ViewFrame_OpenFlags flags;
NautilusFileCallback callback;
} ActivateParameters;
@@ -303,7 +297,8 @@ static void trash_or_delete_files (FMDirectoryView
const GList *files);
static void fm_directory_view_activate_file (FMDirectoryView *view,
NautilusFile *file,
- WindowChoice choice);
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags);
static void load_directory (FMDirectoryView *view,
NautilusDirectory *directory);
static void fm_directory_view_merge_menus (FMDirectoryView *view);
@@ -549,7 +544,7 @@ open_callback (BonoboUIComponent *component, gpointer callback_data, const char
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- fm_directory_view_activate_files (view, selection);
+ fm_directory_view_activate_files (view, selection, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0);
nautilus_file_list_free (selection);
}
@@ -558,25 +553,12 @@ open_alternate_callback (BonoboUIComponent *component, gpointer callback_data, c
{
FMDirectoryView *view;
GList *selection;
- char *uri;
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- if (use_new_window_auto_value) {
- /* UI should have prevented this from being called unless exactly
- * one item is selected.
- */
- if (selection_contains_one_item_in_menu_callback (view, selection)) {
- uri = nautilus_file_get_uri (NAUTILUS_FILE (selection->data));
- nautilus_view_open_location_in_this_window
- (view->details->nautilus_view, uri);
- g_free (uri);
- }
- } else {
- if (fm_directory_view_confirm_multiple_windows (view, g_list_length (selection))) {
- g_list_foreach (selection, open_one_in_new_window, view);
- }
+ if (fm_directory_view_confirm_multiple_windows (view, g_list_length (selection))) {
+ g_list_foreach (selection, open_one_in_new_window, view);
}
nautilus_file_list_free (selection);
@@ -628,30 +610,14 @@ fm_directory_view_chose_application_callback (GnomeVFSMimeApplication *applicati
static void
open_location (FMDirectoryView *directory_view,
const char *new_uri,
- WindowChoice choice)
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags)
{
g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
g_assert (new_uri != NULL);
- switch (choice) {
- case RESPECT_PREFERENCE:
- if (use_new_window_auto_value) {
- nautilus_view_open_location_prefer_existing_window
- (directory_view->details->nautilus_view, new_uri);
- } else {
- nautilus_view_open_location_in_this_window
- (directory_view->details->nautilus_view, new_uri);
- }
- break;
- case PREFER_EXISTING_WINDOW:
- nautilus_view_open_location_prefer_existing_window
- (directory_view->details->nautilus_view, new_uri);
- break;
- case FORCE_NEW_WINDOW:
- nautilus_view_open_location_force_new_window
- (directory_view->details->nautilus_view, new_uri, NULL);
- break;
- }
+ nautilus_view_open_location (directory_view->details->nautilus_view,
+ new_uri, mode, flags, NULL);
}
static void
@@ -676,7 +642,7 @@ switch_location_and_view (NautilusViewIdentifier *identifier,
nautilus_mime_set_default_component_for_file (file, identifier->iid);
nautilus_file_unref (file);
- open_location (directory_view, new_uri, RESPECT_PREFERENCE);
+ open_location (directory_view, new_uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0);
}
static void
@@ -1385,8 +1351,6 @@ fm_directory_view_init (FMDirectoryView *view)
&confirm_trash_auto_value);
eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_ENABLE_DELETE,
&show_delete_command_auto_value);
- eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
- &use_new_window_auto_value);
}
view->details = g_new0 (FMDirectoryViewDetails, 1);
@@ -1451,12 +1415,6 @@ fm_directory_view_init (FMDirectoryView *view)
filtering_changed_callback (view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
- schedule_update_menus_callback, view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
- filtering_changed_callback, view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
- filtering_changed_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
schedule_update_menus_callback, view);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ENABLE_DELETE,
@@ -1522,8 +1480,6 @@ fm_directory_view_finalize (GObject *object)
fm_directory_view_ignore_hidden_file_preferences (view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
- schedule_update_menus_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
filtering_changed_callback, view);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
@@ -3299,7 +3255,8 @@ open_one_in_new_window (gpointer data, gpointer callback_data)
fm_directory_view_activate_file (FM_DIRECTORY_VIEW (callback_data),
NAUTILUS_FILE (data),
- FORCE_NEW_WINDOW);
+ Nautilus_ViewFrame_OPEN_IN_NAVIGATION,
+ 0);
}
NautilusFile *
@@ -4356,7 +4313,7 @@ open_scripts_folder_callback (BonoboUIComponent *component,
view = FM_DIRECTORY_VIEW (callback_data);
- open_location (view, scripts_directory_uri, RESPECT_PREFERENCE);
+ open_location (view, scripts_directory_uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0);
eel_show_info_dialog_with_details
(_("All executable files in this folder will appear in the "
@@ -4828,31 +4785,20 @@ real_update_menus (FMDirectoryView *view)
FM_DIRECTORY_VIEW_COMMAND_OPEN,
selection_count != 0);
- if (use_new_window_auto_value) {
- nautilus_bonobo_set_sensitive (view->details->ui,
- FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
- selection_count == 1);
-
- nautilus_bonobo_set_label
- (view->details->ui,
- FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
- _("Open _in This Window"));
+ if (selection_count <= 1) {
+ label_with_underscore = g_strdup (_("Navigation Window"));
} else {
- if (selection_count <= 1) {
- label_with_underscore = g_strdup (_("Open _in New Window"));
- } else {
- label_with_underscore = g_strdup_printf (_("Open _in %d New Windows"), selection_count);
- }
- nautilus_bonobo_set_label
- (view->details->ui,
- FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
- label_with_underscore);
- g_free (label_with_underscore);
-
- nautilus_bonobo_set_sensitive (view->details->ui,
- FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
- selection_count != 0);
- }
+ label_with_underscore = g_strdup_printf (_("%d Navigation Windows"), selection_count);
+ }
+ nautilus_bonobo_set_label
+ (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
+ label_with_underscore);
+ g_free (label_with_underscore);
+
+ nautilus_bonobo_set_sensitive (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
+ selection_count != 0);
/* Broken into its own function just for convenience */
reset_bonobo_open_with_menu (view, selection);
@@ -5305,7 +5251,7 @@ activate_callback (NautilusFile *file, gpointer callback_data)
if (action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT &&
nautilus_mime_has_any_components_for_file (file)) {
- open_location (view, uri, parameters->choice);
+ open_location (view, uri, parameters->mode, parameters->flags);
} else {
nautilus_launch_show_file
(file, fm_directory_view_get_containing_window (view));
@@ -5389,7 +5335,8 @@ cancel_activate_callback (gpointer callback_data)
static void
fm_directory_view_activate_file (FMDirectoryView *view,
NautilusFile *file,
- WindowChoice choice)
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags)
{
ActivateParameters *parameters;
NautilusFileAttributes attributes;
@@ -5412,7 +5359,8 @@ fm_directory_view_activate_file (FMDirectoryView *view,
parameters = g_new (ActivateParameters, 1);
parameters->view = view;
parameters->file = file;
- parameters->choice = choice;
+ parameters->mode = mode;
+ parameters->flags = flags;
parameters->callback = activate_activation_uri_ready_callback;
file_name = nautilus_file_get_display_name (file);
@@ -5443,7 +5391,9 @@ fm_directory_view_activate_file (FMDirectoryView *view,
**/
void
fm_directory_view_activate_files (FMDirectoryView *view,
- GList *files)
+ GList *files,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags)
{
GList *node;
int file_count;
@@ -5458,15 +5408,21 @@ fm_directory_view_activate_files (FMDirectoryView *view,
* but it proved mysterious in practice.
*/
file_count = g_list_length (files);
- use_new_window = file_count > 1 || use_new_window_auto_value;
+ use_new_window = file_count > 1;
+
+ if (use_new_window && mode == Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE) {
+#if !NEW_UI_COMPLETE
+ /* Match the current window type */
+ mode = Nautilus_ViewFrame_OPEN_IN_SPATIAL;
+#endif
+ }
if (!use_new_window || fm_directory_view_confirm_multiple_windows (view, file_count)) {
for (node = files; node != NULL; node = node->next) {
- fm_directory_view_activate_file
- (view, node->data,
- file_count == 1
- ? RESPECT_PREFERENCE
- : PREFER_EXISTING_WINDOW);
+ /* The ui should ask for navigation or object windows
+ * depending on what the current one is */
+ fm_directory_view_activate_file
+ (view, node->data, mode, flags);
}
}
}
diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h
index b9388dd9c..2fa6afaef 100644
--- a/src/file-manager/fm-directory-view.h
+++ b/src/file-manager/fm-directory-view.h
@@ -343,7 +343,9 @@ void fm_directory_view_end_loading (FMDirect
* FMDirectoryView and its subclasses
*/
void fm_directory_view_activate_files (FMDirectoryView *view,
- GList *files);
+ GList *files,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags);
void fm_directory_view_start_batching_selection_changes (FMDirectoryView *view);
void fm_directory_view_stop_batching_selection_changes (FMDirectoryView *view);
gboolean fm_directory_view_confirm_multiple_windows (FMDirectoryView *view,
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 1f53f05da..debeedfdc 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -1702,7 +1702,23 @@ icon_container_activate_callback (NautilusIconContainer *container,
g_assert (FM_IS_ICON_VIEW (icon_view));
g_assert (container == get_icon_container (icon_view));
- fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view), file_list);
+ fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view),
+ file_list,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0);
+}
+
+static void
+icon_container_activate_alternate_callback (NautilusIconContainer *container,
+ GList *file_list,
+ FMIconView *icon_view)
+{
+ g_assert (FM_IS_ICON_VIEW (icon_view));
+ g_assert (container == get_icon_container (icon_view));
+
+ fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view),
+ file_list,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND);
}
static void
@@ -2444,6 +2460,8 @@ create_icon_container (FMIconView *icon_view)
g_signal_connect_object (icon_container, "activate",
G_CALLBACK (icon_container_activate_callback), icon_view, 0);
+ g_signal_connect_object (icon_container, "activate_alternate",
+ G_CALLBACK (icon_container_activate_alternate_callback), icon_view, 0);
g_signal_connect_object (icon_container, "band_select_started",
G_CALLBACK (band_select_started_callback), icon_view, 0);
g_signal_connect_object (icon_container, "band_select_ended",
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index 09cd4232c..778b1c76f 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -153,7 +153,23 @@ activate_selected_items (FMListView *view)
file_list = fm_list_view_get_selection (FM_DIRECTORY_VIEW (view));
fm_directory_view_activate_files (FM_DIRECTORY_VIEW (view),
- file_list);
+ file_list,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ 0);
+ nautilus_file_list_free (file_list);
+
+}
+
+static void
+activate_selected_items_alternate (FMListView *view)
+{
+ GList *file_list;
+
+ file_list = fm_list_view_get_selection (FM_DIRECTORY_VIEW (view));
+ fm_directory_view_activate_files (FM_DIRECTORY_VIEW (view),
+ file_list,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND);
nautilus_file_list_free (file_list);
}
@@ -185,10 +201,13 @@ fm_list_view_did_not_drag (FMListView *view,
gtk_tree_selection_select_path (selection, path);
}
- if ((event->button == 1)
- && (click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE)
+ if ((click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE)
&& !button_event_modifies_selection(event)) {
- activate_selected_items (view);
+ if (event->button == 1) {
+ activate_selected_items (view);
+ } else if (event->button == 2) {
+ activate_selected_items_alternate (view);
+ }
}
gtk_tree_path_free (path);
}
@@ -421,7 +440,7 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba
allow_drag = FALSE;
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
&path, NULL, NULL, NULL)) {
- if (event->button == 1 &&
+ if ((event->button == 1 || event->button == 2) &&
event->type == GDK_BUTTON_PRESS) {
if (view->details->double_click_path[1]) {
gtk_tree_path_free (view->details->double_click_path[1]);
@@ -430,13 +449,15 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba
view->details->double_click_path[0] = gtk_tree_path_copy (path);
}
- if (event->type == GDK_2BUTTON_PRESS &&
- (event->button == 1 || event->button == 3)) {
+ if (event->type == GDK_2BUTTON_PRESS) {
if (view->details->double_click_path[1] &&
gtk_tree_path_compare (view->details->double_click_path[0], view->details->double_click_path[1]) == 0
&& !button_event_modifies_selection (event)) {
- activate_selected_items (view);
-
+ if ((event->button == 1 || event->button == 3)) {
+ activate_selected_items (view);
+ } else if (event->button == 2) {
+ activate_selected_items_alternate (view);
+ }
}
}
diff --git a/src/file-manager/fm-search-list-view.c b/src/file-manager/fm-search-list-view.c
index a1cc40266..682daa757 100644
--- a/src/file-manager/fm-search-list-view.c
+++ b/src/file-manager/fm-search-list-view.c
@@ -800,9 +800,12 @@ reveal_selected_items_callback (BonoboUIComponent *component, gpointer user_data
parent_uri = nautilus_file_get_parent_uri (file);
if (parent_uri != NULL) {
file_as_list = g_list_prepend (NULL, nautilus_file_get_uri (file));
- nautilus_view_open_location_force_new_window
+ /* FIXME: match the current window type */
+ nautilus_view_open_location
(fm_directory_view_get_nautilus_view (directory_view),
parent_uri,
+ Nautilus_ViewFrame_OPEN_IN_SPATIAL,
+ 0,
file_as_list);
eel_g_list_free_deep (file_as_list);
}
diff --git a/src/file-manager/nautilus-desktop-icon-view-ui.xml b/src/file-manager/nautilus-desktop-icon-view-ui.xml
index 664e76d5d..ec442840b 100644
--- a/src/file-manager/nautilus-desktop-icon-view-ui.xml
+++ b/src/file-manager/nautilus-desktop-icon-view-ui.xml
@@ -26,7 +26,6 @@
<cmd name="New Launcher Desktop"
_label="Create L_auncher"
_tip="Create a new launcher"/>
- <cmd name="OpenAlternate" hidden="1"/>
<cmd name="Reset Background"
_label="Use _Default Background"
_tip="Use the default desktop background"/>
diff --git a/src/file-manager/nautilus-directory-view-ui.xml b/src/file-manager/nautilus-directory-view-ui.xml
index ab2c9cfda..72b3a04f4 100644
--- a/src/file-manager/nautilus-directory-view-ui.xml
+++ b/src/file-manager/nautilus-directory-view-ui.xml
@@ -28,8 +28,8 @@
_label="_Open"
_tip="Open the selected item in this window"/>
<cmd name="OpenAlternate"
- _label="Open _in New Window"
- _tip="Open each selected item in a new window"/>
+ _label="Navigation Window"
+ _tip="Open each selected item in a navigation window"/>
<cmd name="Open Scripts Folder"
_label="_Open Scripts Folder"
_tip="Show the folder containing the scripts that appear in this menu"/>
@@ -94,12 +94,13 @@
accel="*Control*o"
pixtype="stock" pixname="gtk-open"
verb="Open"/>
- <menuitem name="OpenAlternate"
- accel="*Control**Shift*o"
- verb="OpenAlternate"/>
<submenu name="Open With"
_label="Open Wit_h"
_tip="Choose a program with which to open the selected item">
+ <menuitem name="OpenAlternate"
+ accel="*Control**Shift*o"
+ verb="OpenAlternate"/>
+ <separator/>
<placeholder name="Applications Placeholder" delimit="none"/>
<menuitem name="OtherApplication"
verb="OtherApplication"/>
@@ -219,12 +220,13 @@
<menuitem name="Open"
pixtype="stock" pixname="gtk-open"
verb="Open"/>
- <menuitem name="OpenAlternate"
- verb="OpenAlternate"/>
<submenu name="Open With"
_label="Open Wit_h"
tearoff="0"
_tip="Choose a program with which to open the selected item">
+ <menuitem name="OpenAlternate"
+ verb="OpenAlternate"/>
+ <separator/>
<placeholder name="Applications Placeholder" delimit="none"/>
<menuitem name="OtherApplication" verb="OtherApplication"/>
<separator/>
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 723aba5ac..77fa71b61 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -39,8 +39,11 @@
#include "nautilus-desktop-window.h"
#include "nautilus-first-time-druid.h"
#include "nautilus-main.h"
+#include "nautilus-spatial-window.h"
+#include "nautilus-navigation-window.h"
#include "nautilus-shell-interface.h"
#include "nautilus-shell.h"
+#include "nautilus-window-private.h"
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h>
#include <eel/eel-gtk-macros.h>
@@ -88,6 +91,9 @@ static GList *nautilus_application_desktop_windows;
/* Keeps track of all the nautilus windows. */
static GList *nautilus_application_window_list;
+/* Keeps track of all the object windows */
+static GList *nautilus_application_spatial_window_list;
+
static gboolean need_to_show_first_time_druid (void);
static void desktop_changed_callback (gpointer user_data);
static void desktop_location_changed_callback (gpointer user_data);
@@ -140,6 +146,12 @@ nautilus_application_get_window_list (void)
return nautilus_application_window_list;
}
+GList *
+nautilus_application_get_spatial_window_list (void)
+{
+ return nautilus_application_spatial_window_list;
+}
+
static void
nautilus_application_instance_init (NautilusApplication *application)
{
@@ -755,134 +767,153 @@ nautilus_application_close_desktop (void)
}
void
-nautilus_application_close_all_windows (void)
+nautilus_application_close_all_navigation_windows (void)
{
- while (nautilus_application_window_list != NULL) {
- nautilus_window_close (NAUTILUS_WINDOW (nautilus_application_window_list->data));
+ GList *list_copy;
+ GList *l;
+
+ list_copy = g_list_copy (nautilus_application_window_list);
+ for (l = list_copy; l != NULL; l = l->next) {
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (l->data);
+
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ nautilus_window_close (window);
+ }
}
+ g_list_free (list_copy);
}
-static void
-nautilus_application_destroyed_window (GtkObject *object, NautilusApplication *application)
+static NautilusSpatialWindow *
+nautilus_application_get_existing_spatial_window (const char *location)
{
- nautilus_application_window_list = g_list_remove (nautilus_application_window_list, object);
+ GList *l;
+
+ for (l = nautilus_application_get_spatial_window_list ();
+ l != NULL; l = l->next) {
+ char *window_location;
+
+ window_location = nautilus_window_get_location (NAUTILUS_WINDOW (l->data));
+ if (!strcmp (location, window_location)) {
+ g_free (window_location);
+ return NAUTILUS_SPATIAL_WINDOW (l->data);
+ }
+ g_free (window_location);
+ }
+ return NULL;
}
-static gboolean
-nautilus_window_delete_event_callback (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
+static NautilusSpatialWindow *
+find_parent_spatial_window (NautilusSpatialWindow *window)
{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
- nautilus_window_close (window);
-
- return TRUE;
-}
+ NautilusFile *file;
+ NautilusFile *parent_file;
+ char *location;
+ char *desktop_directory;
-static gboolean
-save_window_geometry_timeout (gpointer callback_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- nautilus_window_save_geometry (window);
+ location = nautilus_window_get_location (NAUTILUS_WINDOW (window));
+ file = nautilus_file_get (location);
+ g_free (location);
- window->save_geometry_timeout_id = 0;
- return FALSE;
-}
-
-static gboolean
-nautilus_window_configure_event_callback (GtkWidget *widget,
- GdkEventConfigure *event,
- gpointer callback_data)
-{
- NautilusWindow *window;
- char *geometry_string;
+ if (!file) {
+ return NULL;
+ }
- window = NAUTILUS_WINDOW (widget);
+ desktop_directory = nautilus_get_desktop_directory_uri ();
- /* Only save the geometry if the user hasn't resized the window
- * for half a second. Otherwise delay the callback another half second.
- */
- if (window->save_geometry_timeout_id != 0) {
- g_source_remove (window->save_geometry_timeout_id);
- }
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (window)) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) {
+ parent_file = nautilus_file_get_parent (file);
+ nautilus_file_unref (file);
+ while (parent_file) {
+ NautilusSpatialWindow *parent_window;
- geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
-
- /* If the last geometry is NULL the window must have just
- * been shown. No need to save geometry to disk since it
- * must be the same.
- */
- if (window->last_geometry == NULL) {
- window->last_geometry = geometry_string;
- return FALSE;
+ location = nautilus_file_get_uri (parent_file);
+
+ /* Stop at the desktop directory, as this is the
+ * conceptual root of the spatial windows */
+ if (!strcmp (location, desktop_directory)) {
+ g_free (location);
+ g_free (desktop_directory);
+ nautilus_file_unref (parent_file);
+ return NULL;
}
-
- /* Don't save geometry if it's the same as before. */
- if (!strcmp (window->last_geometry, geometry_string)) {
- g_free (geometry_string);
- return FALSE;
+
+ parent_window = nautilus_application_get_existing_spatial_window (location);
+ g_free (location);
+
+ if (parent_window) {
+ nautilus_file_unref (parent_file);
+ return parent_window;
}
+ file = parent_file;
+ parent_file = nautilus_file_get_parent (file);
+ nautilus_file_unref (file);
+ }
+ g_free (desktop_directory);
+
+ return NULL;
+}
+
+void
+nautilus_application_close_with_parent_windows (NautilusSpatialWindow *window)
+{
+ NautilusSpatialWindow *parent_window;
- g_free (window->last_geometry);
- window->last_geometry = geometry_string;
+ g_return_if_fail (NAUTILUS_IS_SPATIAL_WINDOW (window));
- window->save_geometry_timeout_id =
- g_timeout_add (500, save_window_geometry_timeout, window);
+ parent_window = find_parent_spatial_window (window);
+ nautilus_window_close (NAUTILUS_WINDOW (window));
+ window = parent_window;
+
+ while (parent_window) {
+ parent_window = find_parent_spatial_window (window);
+ nautilus_window_close (NAUTILUS_WINDOW (window));
+ window = parent_window;
}
+}
- return FALSE;
+static void
+nautilus_application_destroyed_window (GtkObject *object, NautilusApplication *application)
+{
+ nautilus_application_window_list = g_list_remove (nautilus_application_window_list, object);
}
static gboolean
-nautilus_window_unrealize_event_callback (GtkWidget *widget,
- GdkEvent *event,
- gpointer callback_data)
+nautilus_window_delete_event_callback (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
{
NautilusWindow *window;
-
+
window = NAUTILUS_WINDOW (widget);
+ nautilus_window_close (window);
- if (window->save_geometry_timeout_id != 0) {
- g_source_remove (window->save_geometry_timeout_id);
- window->save_geometry_timeout_id = 0;
- nautilus_window_save_geometry (window);
- }
+ return TRUE;
+}
- return FALSE;
-}
-NautilusWindow *
-nautilus_application_create_window (NautilusApplication *application,
- GdkScreen *screen)
+static NautilusWindow *
+create_window (NautilusApplication *application,
+ GType window_type,
+ GdkScreen *screen)
{
NautilusWindow *window;
-
+
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
- window = NAUTILUS_WINDOW (gtk_widget_new (nautilus_window_get_type (),
+ window = NAUTILUS_WINDOW (gtk_widget_new (window_type,
"app", application,
"app_id", "nautilus",
"screen", screen,
NULL));
- g_signal_connect (window, "delete_event",
- G_CALLBACK (nautilus_window_delete_event_callback), NULL);
+ g_signal_connect_data (window, "delete_event",
+ G_CALLBACK (nautilus_window_delete_event_callback), NULL, NULL,
+ G_CONNECT_AFTER);
g_signal_connect_object (window, "destroy",
G_CALLBACK (nautilus_application_destroyed_window), application, 0);
- g_signal_connect (window, "configure_event",
- G_CALLBACK (nautilus_window_configure_event_callback), NULL);
-
- g_signal_connect (window, "unrealize",
- G_CALLBACK (nautilus_window_unrealize_event_callback), NULL);
-
nautilus_application_window_list = g_list_prepend (nautilus_application_window_list, window);
/* Do not yet show the window. It will be shown later on if it can
@@ -893,6 +924,65 @@ nautilus_application_create_window (NautilusApplication *application,
return window;
}
+static void
+spatial_window_destroyed_callback (void *user_data, GObject *window)
+{
+ nautilus_application_spatial_window_list = g_list_remove (nautilus_application_spatial_window_list, window);
+
+}
+
+NautilusWindow *
+nautilus_application_present_spatial_window (NautilusApplication *application,
+ const char *location,
+ GdkScreen *screen)
+{
+ NautilusWindow *window;
+ GList *l;
+
+ g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
+
+ for (l = nautilus_application_get_spatial_window_list ();
+ l != NULL; l = l->next) {
+ NautilusWindow *existing_window;
+ char *existing_location;
+
+ existing_window = NAUTILUS_WINDOW (l->data);
+ existing_location = existing_window->details->pending_location;
+
+ if (existing_location == NULL) {
+ existing_location = existing_window->details->location;
+ }
+
+ if (eel_uris_match (existing_location, location)) {
+ gtk_window_present (GTK_WINDOW (existing_window));
+ g_object_ref (existing_window);
+ return existing_window;
+ }
+ }
+
+ window = create_window (application, NAUTILUS_TYPE_SPATIAL_WINDOW, screen);
+ nautilus_application_spatial_window_list = g_list_prepend (nautilus_application_spatial_window_list, window);
+ g_object_weak_ref (G_OBJECT (window),
+ spatial_window_destroyed_callback, NULL);
+
+ nautilus_window_go_to (window, location);
+
+ return window;
+}
+
+NautilusWindow *
+nautilus_application_create_navigation_window (NautilusApplication *application,
+ GdkScreen *screen)
+{
+ NautilusWindow *window;
+
+ g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
+
+ window = create_window (application, NAUTILUS_TYPE_NAVIGATION_WINDOW, screen);
+
+ return window;
+}
+
/* callback for changing the directory the desktop points to */
static void
desktop_location_changed_callback (gpointer user_data)
@@ -977,23 +1067,6 @@ window_can_be_closed (NautilusWindow *window)
return FALSE;
}
-static gboolean
-is_last_closable_window (NautilusWindow *window)
-{
- GList *node, *window_list;
-
- window_list = nautilus_application_get_window_list ();
-
- for (node = window_list; node != NULL; node = node->next) {
- if (window != NAUTILUS_WINDOW (node->data) && window_can_be_closed (NAUTILUS_WINDOW (node->data))) {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-
/* Called whenever a volume is unmounted. Check and see if there are any windows open
* displaying contents on the volume. If there are, close them.
* It would also be cool to save open window and position info.
@@ -1029,12 +1102,7 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volum
/* Handle the windows in the close list. */
for (node = close_list; node != NULL; node = node->next) {
window = NAUTILUS_WINDOW (node->data);
- if (is_last_closable_window (window)) {
- /* Don't close the last or only window. Try to redirect to the default home directory. */
- nautilus_window_go_home (window);
- } else {
- nautilus_window_close (window);
- }
+ nautilus_window_close (window);
}
g_list_free (close_list);
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index f21415188..503e3bf63 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -44,6 +44,11 @@
typedef struct NautilusWindow NautilusWindow;
#endif
+#ifndef NAUTILUS_SPATIAL_WINDOW_DEFINED
+#define NAUTILUS_SPATIAL_WINDOW_DEFINED
+typedef struct _NautilusSpatialWindow NautilusSpatialWindow;
+#endif
+
typedef struct {
BonoboGenericFactory parent;
NautilusUndoManager *undo_manager;
@@ -63,10 +68,16 @@ void nautilus_application_startup (NautilusApplication
gboolean do_first_time_druid_check,
const char *default_geometry,
const char *urls[]);
-GList * nautilus_application_get_window_list (void);
-NautilusWindow * nautilus_application_create_window (NautilusApplication *application,
- GdkScreen *screen);
-void nautilus_application_close_all_windows (void);
+GList * nautilus_application_get_window_list (void);
+GList * nautilus_application_get_spatial_window_list (void);
+
+NautilusWindow * nautilus_application_present_spatial_window (NautilusApplication *application,
+ const char *location,
+ GdkScreen *screen);
+NautilusWindow * nautilus_application_create_navigation_window (NautilusApplication *application,
+ GdkScreen *screen);
+void nautilus_application_close_all_navigation_windows (void);
+void nautilus_application_close_with_parent_windows (NautilusSpatialWindow *window);
void nautilus_application_open_desktop (NautilusApplication *application);
void nautilus_application_close_desktop (void);
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index e981e54b9..6561c1fe5 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -24,14 +24,20 @@
#include <config.h>
#include "nautilus-desktop-window.h"
+#include "nautilus-window-private.h"
#include <X11/Xatom.h>
#include <gdk/gdkx.h>
#include <gtk/gtklayout.h>
+#include <eel/eel-gtk-macros.h>
#include <eel/eel-vfs-extensions.h>
#include <libgnome/gnome-macros.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
+#include <libnautilus-private/nautilus-bonobo-extensions.h>
+
+#define STATUS_BAR_PATH "/status"
+#define MENU_BAR_PATH "/menu"
struct NautilusDesktopWindowDetails {
int dummy;
@@ -40,7 +46,7 @@ struct NautilusDesktopWindowDetails {
static void set_wmspec_desktop_hint (GdkWindow *window);
GNOME_CLASS_BOILERPLATE (NautilusDesktopWindow, nautilus_desktop_window,
- NautilusWindow, NAUTILUS_TYPE_WINDOW)
+ NautilusSpatialWindow, NAUTILUS_TYPE_SPATIAL_WINDOW)
static void
nautilus_desktop_window_instance_init (NautilusDesktopWindow *window)
@@ -68,7 +74,7 @@ nautilus_desktop_window_update_directory (NautilusDesktopWindow *window)
{
g_assert (NAUTILUS_IS_DESKTOP_WINDOW (window));
- window->affect_desktop_on_next_location_change = TRUE;
+ NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE;
nautilus_window_go_to (NAUTILUS_WINDOW (window), EEL_DESKTOP_URI);
}
@@ -344,6 +350,23 @@ real_add_current_location_to_history_list (NautilusWindow *window)
*/
}
+static char *
+real_get_title (NautilusWindow *window)
+{
+ return g_strdup (_("Desktop"));
+}
+
+static void
+real_merge_menus (NautilusWindow *window)
+{
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, merge_menus, (window));
+
+ nautilus_bonobo_set_hidden (window->details->shell_ui,
+ STATUS_BAR_PATH, TRUE);
+ nautilus_bonobo_set_hidden (window->details->shell_ui,
+ MENU_BAR_PATH, TRUE);
+}
+
static void
nautilus_desktop_window_class_init (NautilusDesktopWindowClass *class)
{
@@ -356,4 +379,8 @@ nautilus_desktop_window_class_init (NautilusDesktopWindowClass *class)
NAUTILUS_WINDOW_CLASS (class)->add_current_location_to_history_list
= real_add_current_location_to_history_list;
+ NAUTILUS_WINDOW_CLASS (class)->merge_menus
+ = real_merge_menus;
+ NAUTILUS_WINDOW_CLASS (class)->get_title
+ = real_get_title;
}
diff --git a/src/nautilus-desktop-window.h b/src/nautilus-desktop-window.h
index c36615470..826ae4533 100644
--- a/src/nautilus-desktop-window.h
+++ b/src/nautilus-desktop-window.h
@@ -30,6 +30,7 @@
#include "nautilus-window.h"
#include "nautilus-application.h"
+#include "nautilus-spatial-window.h"
#define NAUTILUS_TYPE_DESKTOP_WINDOW (nautilus_desktop_window_get_type())
#define NAUTILUS_DESKTOP_WINDOW(object) (GTK_CHECK_CAST ((object), NAUTILUS_TYPE_DESKTOP_WINDOW, NautilusDesktopWindow))
@@ -40,13 +41,13 @@
typedef struct NautilusDesktopWindowDetails NautilusDesktopWindowDetails;
typedef struct {
- NautilusWindow parent_spot;
+ NautilusSpatialWindow parent_spot;
NautilusDesktopWindowDetails *details;
gboolean affect_desktop_on_next_location_change;
} NautilusDesktopWindow;
typedef struct {
- NautilusWindowClass parent_spot;
+ NautilusSpatialWindowClass parent_spot;
} NautilusDesktopWindowClass;
GType nautilus_desktop_window_get_type (void);
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index c77c437b6..2ccba328a 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -325,9 +325,6 @@ nautilus_file_management_properties_dialog_setup (GladeXML *xml_dialog, GtkWindo
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET,
NAUTILUS_PREFERENCES_ENABLE_DELETE);
eel_preferences_glade_connect_bool (xml_dialog,
- NAUTILUS_FILE_MANAGEMENT_PROPERTIES_OPEN_NEW_WINDOW_WIDGET,
- NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW);
- eel_preferences_glade_connect_bool (xml_dialog,
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
eel_preferences_glade_connect_bool_slave (xml_dialog,
diff --git a/src/nautilus-file-management-properties.glade b/src/nautilus-file-management-properties.glade
index 765b0e97b..411834bad 100644
--- a/src/nautilus-file-management-properties.glade
+++ b/src/nautilus-file-management-properties.glade
@@ -997,24 +997,6 @@
<property name="fill">False</property>
</packing>
</child>
-
- <child>
- <widget class="GtkCheckButton" id="new_window_checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">_Open activated item in a new window</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="padding">2</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
</widget>
<packing>
<property name="padding">0</property>
diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c
index 709e128d1..8efbd45c5 100644
--- a/src/nautilus-location-bar.c
+++ b/src/nautilus-location-bar.c
@@ -106,10 +106,10 @@ EEL_CLASS_BOILERPLATE (NautilusLocationBar,
nautilus_location_bar,
NAUTILUS_TYPE_NAVIGATION_BAR)
-static NautilusWindow *
+static NautilusNavigationWindow *
nautilus_location_bar_get_window (GtkWidget *bar)
{
- return NAUTILUS_WINDOW (gtk_widget_get_ancestor (bar, NAUTILUS_TYPE_WINDOW));
+ return NAUTILUS_NAVIGATION_WINDOW (gtk_widget_get_ancestor (bar, NAUTILUS_TYPE_WINDOW));
}
static void
@@ -126,7 +126,7 @@ drag_data_received_callback (GtkWidget *widget,
NautilusApplication *application;
int name_count;
NautilusWindow *new_window;
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
GdkScreen *screen;
gboolean new_windows_for_extras;
char *prompt;
@@ -177,11 +177,11 @@ drag_data_received_callback (GtkWidget *widget,
nautilus_navigation_bar_location_changed (NAUTILUS_NAVIGATION_BAR (widget));
if (new_windows_for_extras) {
- application = window->application;
+ application = NAUTILUS_WINDOW (window)->application;
screen = gtk_window_get_screen (GTK_WINDOW (window));
for (node = names->next; node != NULL; node = node->next) {
- new_window = nautilus_application_create_window (application, screen);
+ new_window = nautilus_application_create_navigation_window (application, screen);
nautilus_window_go_to (new_window, node->data);
}
}
@@ -760,7 +760,7 @@ nautilus_location_bar_init (NautilusLocationBar *bar)
}
GtkWidget *
-nautilus_location_bar_new (NautilusWindow *window)
+nautilus_location_bar_new (NautilusNavigationWindow *window)
{
GtkWidget *bar;
NautilusLocationBar *location_bar;
@@ -771,7 +771,7 @@ nautilus_location_bar_new (NautilusWindow *window)
/* Clipboard */
nautilus_clipboard_set_up_editable
(GTK_EDITABLE (location_bar->details->entry),
- nautilus_window_get_ui_container (window),
+ nautilus_window_get_ui_container (NAUTILUS_WINDOW (window)),
TRUE);
return bar;
diff --git a/src/nautilus-location-bar.h b/src/nautilus-location-bar.h
index aee4899ed..3d6b5a006 100644
--- a/src/nautilus-location-bar.h
+++ b/src/nautilus-location-bar.h
@@ -31,7 +31,7 @@
#define NAUTILUS_LOCATION_BAR_H
#include "nautilus-navigation-bar.h"
-#include "nautilus-window.h"
+#include "nautilus-navigation-window.h"
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkentry.h>
@@ -56,6 +56,6 @@ typedef struct {
} NautilusLocationBarClass;
GType nautilus_location_bar_get_type (void);
-GtkWidget* nautilus_location_bar_new (NautilusWindow *window);
+GtkWidget* nautilus_location_bar_new (NautilusNavigationWindow *window);
#endif /* NAUTILUS_LOCATION_BAR_H */
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 454ac0842..4d8055887 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -77,196 +77,32 @@
* don't want other code relying on their existence.
*/
-#define COMMAND_PATH_TOGGLE_FIND_MODE "/commands/Find"
-#define COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE "/commands/Toggle Find Mode"
-
#define MENU_PATH_SHOW_HIDE_SIDEBAR "/menu/View/Show Hide Placeholder/Show Hide Sidebar"
-#define MENU_PATH_SHOW_HIDE_TOOLBAR "/menu/View/Show Hide Placeholder/Show Hide Toolbar"
#define MENU_PATH_SHOW_HIDE_LOCATION_BAR "/menu/View/Show Hide Placeholder/Show Hide Location Bar"
-#define MENU_PATH_SHOW_HIDE_STATUS_BAR "/menu/View/Show Hide Placeholder/Show Hide Statusbar"
#define MENU_PATH_HISTORY_PLACEHOLDER "/menu/Go/History Placeholder"
-
#define MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER "/menu/Bookmarks/Built-in Bookmarks Placeholder"
#define MENU_PATH_BOOKMARKS_PLACEHOLDER "/menu/Bookmarks/Bookmarks Placeholder"
-#define COMMAND_PATH_CLOSE_WINDOW "/commands/Close"
#define COMMAND_SHOW_HIDE_SIDEBAR "/commands/Show Hide Sidebar"
-#define COMMAND_SHOW_HIDE_TOOLBAR "/commands/Show Hide Toolbar"
#define COMMAND_SHOW_HIDE_LOCATION_BAR "/commands/Show Hide Location Bar"
#define COMMAND_SHOW_HIDE_STATUS_BAR "/commands/Show Hide Statusbar"
-#define COMMAND_GO_BURN_CD "/commands/Go to Burn CD"
#define ID_SHOW_HIDE_SIDEBAR "Show Hide Sidebar"
-#define ID_SHOW_HIDE_TOOLBAR "Show Hide Toolbar"
#define ID_SHOW_HIDE_LOCATION_BAR "Show Hide Location Bar"
-#define ID_SHOW_HIDE_STATUS_BAR "Show Hide Statusbar"
-
-#define START_HERE_URI "start-here:"
-#define BURN_CD_URI "burn:"
#define RESPONSE_FORGET 1000
static GtkWindow *bookmarks_window = NULL;
+static NautilusBookmarkList *bookmarks = NULL;
-static void append_bookmark_to_menu (NautilusWindow *window,
- NautilusBookmark *bookmark,
- const char *parent_path,
- guint index_in_parent,
- gboolean is_in_bookmarks_menu);
-static void append_dynamic_bookmarks (NautilusWindow *window);
+static void append_dynamic_bookmarks (NautilusNavigationWindow *window);
static NautilusBookmarkList *get_bookmark_list (void);
-static void refresh_go_menu (NautilusWindow *window);
-static void refresh_bookmarks_menu (NautilusWindow *window);
-static void schedule_refresh_go_menu (NautilusWindow *window);
-static void schedule_refresh_bookmarks_menu (NautilusWindow *window);
-static void edit_bookmarks (NautilusWindow *window);
-static void add_bookmark_for_current_location (NautilusWindow *window);
-
-/* Struct that stores all the info necessary to activate a bookmark. */
-typedef struct {
- NautilusBookmark *bookmark;
- NautilusWindow *window;
- gboolean prompt_for_removal;
- guint changed_handler_id;
-} BookmarkHolder;
-
-static BookmarkHolder *
-bookmark_holder_new (NautilusBookmark *bookmark,
- NautilusWindow *window,
- gboolean is_bookmarks_menu)
-{
- BookmarkHolder *new_bookmark_holder;
-
- new_bookmark_holder = g_new (BookmarkHolder, 1);
- new_bookmark_holder->window = window;
- new_bookmark_holder->bookmark = bookmark;
- /* Ref the bookmark because it might be unreffed away while
- * we're holding onto it (not an issue for window).
- */
- g_object_ref (bookmark);
- new_bookmark_holder->prompt_for_removal = is_bookmarks_menu;
-
- new_bookmark_holder->changed_handler_id =
- g_signal_connect_object (bookmark, "appearance_changed",
- is_bookmarks_menu
- ? G_CALLBACK (schedule_refresh_bookmarks_menu)
- : G_CALLBACK (schedule_refresh_go_menu),
- window, G_CONNECT_SWAPPED);
-
- return new_bookmark_holder;
-}
-
-static void
-bookmark_holder_free (BookmarkHolder *bookmark_holder)
-{
- g_signal_handler_disconnect (bookmark_holder->bookmark,
- bookmark_holder->changed_handler_id);
- g_object_unref (bookmark_holder->bookmark);
- g_free (bookmark_holder);
-}
-
-/* Private menu definitions; others are in <libnautilus/nautilus-bonobo-ui.h>.
- * These are not part of the published set, either because they are
- * development-only or because we expect to change them and
- * don't want other code relying on their existence.
- */
-
-
-static void
-bookmark_holder_free_cover (gpointer callback_data, GClosure *closure)
-{
- bookmark_holder_free (callback_data);
-}
-
-static void
-file_menu_new_window_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- NautilusWindow *current_window;
- NautilusWindow *new_window;
-
- current_window = NAUTILUS_WINDOW (user_data);
- new_window = nautilus_application_create_window (
- current_window->application,
- gtk_window_get_screen (GTK_WINDOW (current_window)));
- nautilus_window_go_home (new_window);
-}
-
-static void
-file_menu_close_window_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_close (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-file_menu_close_all_windows_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_application_close_all_windows ();
-}
-
-static void
-file_menu_burn_cd_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- GError *error;
- char *argv[] = { "nautilus-cd-burner", NULL};
- char *text;
-
- error = NULL;
- if (!g_spawn_async (NULL,
- argv, NULL,
- G_SPAWN_SEARCH_PATH,
- NULL, NULL,
- NULL,
- &error)) {
- text = g_strdup_printf (_("Unable to launch the cd burner application:\n%s"), error->message);
- eel_show_error_dialog (text,
- _("Can't launch cd burner"),
- GTK_WINDOW (user_data));
- g_free (text);
- g_error_free (error);
- }
-
-}
-
-static gboolean
-have_burn_uri (void)
-{
- static gboolean initialized = FALSE;
- static gboolean res;
- GnomeVFSURI *uri;
-
- if (!initialized) {
- uri = gnome_vfs_uri_new ("burn:///");
- res = uri != NULL;
- if (uri != NULL) {
- gnome_vfs_uri_unref (uri);
- }
- initialized = TRUE;
- }
- return res;
-}
-
-static void
-nautilus_window_show_location_bar_temporarily (NautilusWindow *window,
- gboolean in_search_mode)
-{
- if (!nautilus_window_location_bar_showing (window)) {
- nautilus_window_show_location_bar (window, FALSE);
- window->details->temporary_navigation_bar = TRUE;
- }
- nautilus_window_set_search_mode
- (window, in_search_mode);
- nautilus_switchable_navigation_bar_activate
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar));
-}
+static void refresh_bookmarks_menu (NautilusNavigationWindow *window);
+static void schedule_refresh_bookmarks_menu (NautilusNavigationWindow *window);
+static void edit_bookmarks (NautilusNavigationWindow *window);
+static void add_bookmark_for_current_location (NautilusNavigationWindow *window);
+static void schedule_refresh_go_menu (NautilusWindow *window);
#ifdef HAVE_MEDUSA
static void
@@ -301,35 +137,11 @@ toolbar_toggle_find_mode_callback (BonoboUIComponent *component,
#endif
static void
-go_menu_location_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (!window->details->updating_bonobo_state) {
- nautilus_window_show_location_bar_temporarily
- (window, FALSE);
- }
-}
-
-static void
-stop_button_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_stop_loading (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-edit_menu_undo_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
+file_menu_close_all_windows_callback (BonoboUIComponent *component,
+ gpointer user_data,
+ const char *verb)
{
- nautilus_undo_manager_undo
- (NAUTILUS_WINDOW (user_data)->application->undo_manager);
+ nautilus_application_close_all_navigation_windows ();
}
static void
@@ -337,7 +149,7 @@ go_menu_back_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
- nautilus_window_go_back (NAUTILUS_WINDOW (user_data));
+ nautilus_navigation_window_go_back (NAUTILUS_NAVIGATION_WINDOW (user_data));
}
static void
@@ -345,50 +157,7 @@ go_menu_forward_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
- nautilus_window_go_forward (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-go_menu_up_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_up (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-go_menu_home_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_home (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-go_menu_start_here_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- START_HERE_URI);
-}
-
-static void
-go_menu_go_to_trash_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- EEL_TRASH_URI);
-}
-
-static void
-go_menu_go_to_burn_cd_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- BURN_CD_URI);
+ nautilus_navigation_window_go_forward (NAUTILUS_NAVIGATION_WINDOW (user_data));
}
static void
@@ -446,46 +215,15 @@ go_menu_forget_history_callback (BonoboUIComponent *component,
}
static void
-view_menu_reload_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_reload (NAUTILUS_WINDOW (user_data));
-}
-
-static void
view_menu_show_hide_sidebar_state_changed_callback (BonoboUIComponent *component,
const char *path,
Bonobo_UIComponent_EventType type,
const char *state,
gpointer user_data)
{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (strcmp (state, "") == 0) {
- /* State goes blank when component is removed; ignore this. */
- return;
- }
-
- if (!strcmp (state, "1")) {
- nautilus_window_show_sidebar (window);
- } else {
- nautilus_window_hide_sidebar (window);
- }
-}
-
-static void
-view_menu_show_hide_toolbar_state_changed_callback (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (user_data);
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
if (strcmp (state, "") == 0) {
/* State goes blank when component is removed; ignore this. */
@@ -493,9 +231,9 @@ view_menu_show_hide_toolbar_state_changed_callback (BonoboUIComponent *component
}
if (!strcmp (state, "1")) {
- nautilus_window_show_toolbar (window);
+ nautilus_navigation_window_show_sidebar (window);
} else {
- nautilus_window_hide_toolbar (window);
+ nautilus_navigation_window_hide_sidebar (window);
}
}
@@ -506,9 +244,9 @@ view_menu_show_hide_location_bar_state_changed_callback (BonoboUIComponent *comp
const char *state,
gpointer user_data)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (user_data);
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
if (strcmp (state, "") == 0) {
/* State goes blank when component is removed; ignore this. */
@@ -516,92 +254,32 @@ view_menu_show_hide_location_bar_state_changed_callback (BonoboUIComponent *comp
}
if (!strcmp (state, "1")) {
- nautilus_window_show_location_bar (window, TRUE);
+ nautilus_navigation_window_show_location_bar (window, TRUE);
} else {
- nautilus_window_hide_location_bar (window, TRUE);
- }
-}
-
-static void
-view_menu_show_hide_statusbar_state_changed_callback (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (strcmp (state, "") == 0) {
- /* State goes blank when component is removed; ignore this. */
- return;
- }
-
- if (!strcmp (state, "1")) {
- nautilus_window_show_status_bar (window);
- } else {
- nautilus_window_hide_status_bar (window);
+ nautilus_navigation_window_hide_location_bar (window, TRUE);
}
}
void
-nautilus_window_update_show_hide_menu_items (NautilusWindow *window)
+nautilus_navigation_window_update_show_hide_menu_items (NautilusNavigationWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
+ bonobo_ui_component_freeze (NAUTILUS_WINDOW (window)->details->shell_ui, NULL);
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
+ nautilus_bonobo_set_toggle_state (NAUTILUS_WINDOW (window)->details->shell_ui,
COMMAND_SHOW_HIDE_SIDEBAR,
- nautilus_window_sidebar_showing (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- COMMAND_SHOW_HIDE_TOOLBAR,
- nautilus_window_toolbar_showing (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
+ nautilus_navigation_window_sidebar_showing (window));
+ nautilus_bonobo_set_toggle_state (NAUTILUS_WINDOW (window)->details->shell_ui,
COMMAND_SHOW_HIDE_LOCATION_BAR,
- nautilus_window_location_bar_showing (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- COMMAND_SHOW_HIDE_STATUS_BAR,
- nautilus_window_status_bar_showing (window));
-
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+ nautilus_navigation_window_location_bar_showing (window));
- nautilus_window_ui_thaw (window);
-}
-
-static void
-view_menu_zoom_in_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_zoom_in (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-view_menu_zoom_out_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_zoom_out (NAUTILUS_WINDOW (user_data));
-}
+ bonobo_ui_component_thaw (NAUTILUS_WINDOW (window)->details->shell_ui,
+ NULL);
-static void
-view_menu_zoom_normal_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_zoom_to_level (NAUTILUS_WINDOW (user_data), 1.0);
-}
-
-static void
-view_menu_view_as_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_show_view_as_dialog (NAUTILUS_WINDOW (user_data));
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
static void
@@ -609,7 +287,7 @@ bookmarks_menu_add_bookmark_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
- add_bookmark_for_current_location (NAUTILUS_WINDOW (user_data));
+ add_bookmark_for_current_location (NAUTILUS_NAVIGATION_WINDOW (user_data));
}
static void
@@ -617,294 +295,7 @@ bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
- edit_bookmarks (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-preferences_respond_callback (GtkDialog *dialog,
- gint response_id)
-{
- if (response_id == GTK_RESPONSE_CLOSE) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- }
-}
-
-static void
-preferences_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- GtkWindow *window;
-
- window = GTK_WINDOW (user_data);
-
- nautilus_file_management_properties_dialog_show (G_CALLBACK (preferences_respond_callback), window);
-}
-
-static void
-backgrounds_and_emblems_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- GtkWindow *window;
-
- window = GTK_WINDOW (user_data);
-
- nautilus_property_browser_show (gtk_window_get_screen (window));
-}
-
-static void
-help_menu_about_nautilus_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- static GtkWidget *about = NULL;
- const char *authors[] = {
- "Alexander Larsson",
- "Ali Abdin",
- "Anders Carlsson",
- "Andy Hertzfeld",
- "Arlo Rose",
- "Darin Adler",
- "David Camp",
- "Eli Goldberg",
- "Elliot Lee",
- "Eskil Heyn Olsen",
- "Ettore Perazzoli",
- "Gene Z. Ragan",
- "George Lebl",
- "Ian McKellar",
- "J Shane Culpepper",
- "James Willcox",
- "Jan Arne Petersen",
- "John Harper",
- "John Sullivan",
- "Josh Barrow",
- "Maciej Stachowiak",
- "Mark McLoughlin",
- "Mathieu Lacage",
- "Mike Engber",
- "Mike Fleming",
- "Pavel Cisler",
- "Ramiro Estrugo",
- "Raph Levien",
- "Rebecca Schulman",
- "Robey Pointer",
- "Robin * Slomkowski",
- "Seth Nickell",
- "Susan Kare",
- NULL
- };
- const char *copyright;
- const char *translator_credits;
- const char *locale;
-
- if (about == NULL) {
- /* We could probably just put a translation in en_US
- * instead of doing this mess, but I got this working
- * and I don't feel like fiddling with it any more.
- */
- locale = setlocale (LC_MESSAGES, NULL);
- if (locale == NULL
- || strcmp (locale, "C") == 0
- || strcmp (locale, "POSIX") == 0
- || strcmp (locale, "en_US") == 0) {
- /* The copyright character here is in UTF-8 */
- copyright = "Copyright \xC2\xA9 1999-2001 Eazel, Inc.";
- } else {
- /* Localize to deal with issues in the copyright
- * symbol characters -- do not translate the company
- * name, please.
- */
- copyright = _("Copyright (C) 1999-2001 Eazel, Inc.");
- }
-
- /* Translators should localize the following string
- * which will be displayed at the bottom of the about
- * box to give credit to the translator(s).
- */
- translator_credits = (strcmp (_("Translator Credits"), "Translator Credits") == 0) ?
- NULL : _("Translator Credits");
-
- about = gnome_about_new (_("Nautilus"),
- VERSION,
- copyright,
- _("Nautilus is a graphical shell "
- "for GNOME that makes it "
- "easy to manage your files "
- "and the rest of your system."),
- authors,
- NULL,
- translator_credits,
- NULL);
- gtk_window_set_transient_for (GTK_WINDOW (about), GTK_WINDOW (user_data));
-
- eel_add_weak_pointer (&about);
- }
-
- gtk_window_present (GTK_WINDOW (about));
-}
-
-static void
-help_menu_nautilus_manual_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- NautilusWindow *window;
- GError *error;
- GtkWidget *dialog;
-
- error = NULL;
- window = NAUTILUS_WINDOW (user_data);
-
- egg_help_display_desktop_on_screen (
- NULL, "user-guide", "wgosnautilus.xml", "gosnautilus-21",
- gtk_window_get_screen (GTK_WINDOW (window)), &error);
-
- if (error) {
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("There was an error displaying help: \n%s"),
- error->message);
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
-
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_widget_show (dialog);
- g_error_free (error);
- }
-}
-
-static void
-remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callback_data)
-{
- const char *uri;
-
- g_assert (GTK_IS_DIALOG (dialog));
- g_assert (callback_data != NULL);
-
- if (response == GTK_RESPONSE_YES) {
- uri = callback_data;
- nautilus_bookmark_list_delete_items_with_uri (get_bookmark_list (), uri);
- }
-
- gtk_object_destroy (GTK_OBJECT (dialog));
-}
-
-static void
-show_bogus_bookmark_window (BookmarkHolder *holder)
-{
- GtkDialog *dialog;
- char *uri;
- char *uri_for_display;
- char *prompt;
-
- uri = nautilus_bookmark_get_uri (holder->bookmark);
- uri_for_display = eel_format_uri_for_display (uri);
-
- if (holder->prompt_for_removal) {
- prompt = g_strdup_printf (_("The location \"%s\" does not exist. Do you "
- "want to remove any bookmarks with this "
- "location from your list?"), uri_for_display);
- dialog = eel_show_yes_no_dialog (prompt,
- _("Bookmark for Nonexistent Location"),
- _("Remove"), GTK_STOCK_CANCEL,
- GTK_WINDOW (holder->window));
-
- eel_gtk_signal_connect_free_data
- (GTK_OBJECT (dialog),
- "response",
- G_CALLBACK (remove_bookmarks_for_uri_if_yes),
- g_strdup (uri));
-
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_NO);
- } else {
- prompt = g_strdup_printf (_("The location \"%s\" no longer exists."), uri_for_display);
- dialog = eel_show_info_dialog (prompt, _("Go to Nonexistent Location"), GTK_WINDOW (holder->window));
- }
-
- g_free (uri);
- g_free (uri_for_display);
- g_free (prompt);
-}
-
-static void
-activate_bookmark_in_menu_item (BonoboUIComponent *component, gpointer user_data, const char *path)
-{
- BookmarkHolder *holder;
- char *uri;
-
- holder = (BookmarkHolder *)user_data;
-
- if (nautilus_bookmark_uri_known_not_to_exist (holder->bookmark)) {
- show_bogus_bookmark_window (holder);
- } else {
- uri = nautilus_bookmark_get_uri (holder->bookmark);
- nautilus_window_go_to (holder->window, uri);
- g_free (uri);
- }
-}
-
-static void
-append_bookmark_to_menu (NautilusWindow *window,
- NautilusBookmark *bookmark,
- const char *parent_path,
- guint index_in_parent,
- gboolean is_bookmarks_menu)
-{
- BookmarkHolder *bookmark_holder;
- char *raw_name, *display_name, *truncated_name, *verb_name;
- char *ui_path;
- GdkPixbuf *pixbuf;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
-
- nautilus_window_ui_freeze (window);
-
- bookmark_holder = bookmark_holder_new (bookmark, window, is_bookmarks_menu);
-
- /* We double the underscores here to escape them so Bonobo will know they are
- * not keyboard accelerator character prefixes. If we ever find we need to
- * escape more than just the underscores, we'll add a menu helper function
- * instead of a string utility. (Like maybe escaping control characters.)
- */
- raw_name = nautilus_bookmark_get_name (bookmark);
- truncated_name = eel_truncate_text_for_menu_item (raw_name);
- display_name = eel_str_double_underscores (truncated_name);
- g_free (raw_name);
- g_free (truncated_name);
-
- /* Create menu item with pixbuf */
- pixbuf = nautilus_bookmark_get_pixbuf (bookmark, NAUTILUS_ICON_SIZE_FOR_MENUS, FALSE);
- nautilus_bonobo_add_numbered_menu_item
- (window->details->shell_ui,
- parent_path,
- index_in_parent,
- display_name,
- pixbuf);
- g_object_unref (pixbuf);
- g_free (display_name);
-
- /* Add the status tip */
- ui_path = nautilus_bonobo_get_numbered_menu_item_path
- (window->details->shell_ui, parent_path, index_in_parent);
- nautilus_bonobo_set_tip (window->details->shell_ui, ui_path, _("Go to the location specified by this bookmark"));
- g_free (ui_path);
-
- /* Add verb to new bookmark menu item */
- verb_name = nautilus_bonobo_get_numbered_menu_item_command
- (window->details->shell_ui, parent_path, index_in_parent);
- bonobo_ui_component_add_verb_full (window->details->shell_ui, verb_name,
- g_cclosure_new (G_CALLBACK (activate_bookmark_in_menu_item),
- bookmark_holder,
- bookmark_holder_free_cover));
- g_free (verb_name);
-
- nautilus_window_ui_thaw (window);
+ edit_bookmarks (NAUTILUS_NAVIGATION_WINDOW (user_data));
}
#ifdef WEB_NAVIGATION_ENABLED
@@ -974,17 +365,85 @@ get_static_bookmarks_file_path (void)
#endif
static void
-append_separator (NautilusWindow *window, const char *path)
+append_separator (NautilusNavigationWindow *window, const char *path)
{
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- nautilus_bonobo_add_menu_separator (window->details->shell_ui, path);
+ nautilus_bonobo_add_menu_separator
+ (NAUTILUS_WINDOW (window)->details->shell_ui, path);
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
static void
-create_menu_item_from_node (NautilusWindow *window,
+free_bookmark_list (void)
+{
+ g_object_unref (bookmarks);
+}
+
+static NautilusBookmarkList *
+get_bookmark_list (void)
+{
+ if (bookmarks == NULL) {
+ bookmarks = nautilus_bookmark_list_new ();
+ eel_debug_call_at_shutdown (free_bookmark_list);
+ }
+
+ return bookmarks;
+}
+
+
+static void
+remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callback_data)
+{
+ const char *uri;
+
+ g_assert (GTK_IS_DIALOG (dialog));
+ g_assert (callback_data != NULL);
+
+ if (response == GTK_RESPONSE_YES) {
+ uri = callback_data;
+ nautilus_bookmark_list_delete_items_with_uri (get_bookmark_list (), uri);
+ }
+
+ gtk_object_destroy (GTK_OBJECT (dialog));
+}
+
+static void
+show_bogus_bookmark_window (NautilusWindow *window,
+ NautilusBookmark *bookmark)
+{
+ GtkDialog *dialog;
+ char *uri;
+ char *uri_for_display;
+ char *prompt;
+
+ uri = nautilus_bookmark_get_uri (bookmark);
+ uri_for_display = eel_format_uri_for_display (uri);
+
+ prompt = g_strdup_printf (_("The location \"%s\" does not exist. Do you "
+ "want to remove any bookmarks with this "
+ "location from your list?"), uri_for_display);
+ dialog = eel_show_yes_no_dialog (prompt,
+ _("Bookmark for Nonexistent Location"),
+ _("Remove"), GTK_STOCK_CANCEL,
+ GTK_WINDOW (window));
+
+ eel_gtk_signal_connect_free_data
+ (GTK_OBJECT (dialog),
+ "response",
+ G_CALLBACK (remove_bookmarks_for_uri_if_yes),
+ g_strdup (uri));
+
+ gtk_dialog_set_default_response (dialog, GTK_RESPONSE_NO);
+
+ g_free (uri);
+ g_free (uri_for_display);
+ g_free (prompt);
+}
+
+static void
+create_menu_item_from_node (NautilusNavigationWindow *window,
xmlNodePtr node,
const char *menu_path,
int *index)
@@ -994,23 +453,30 @@ create_menu_item_from_node (NautilusWindow *window,
int sub_index;
char *sub_menu_path, *escaped_name;
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
if (node->type != XML_ELEMENT_NODE) {
return;
}
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
if (strcmp (node->name, "bookmark") == 0) {
bookmark = nautilus_bookmark_new_from_node (node);
- append_bookmark_to_menu (window, bookmark, menu_path, *index, TRUE);
+ nautilus_menus_append_bookmark_to_menu
+ (NAUTILUS_WINDOW (window),
+ NAUTILUS_WINDOW (window)->details->shell_ui,
+ bookmark,
+ menu_path,
+ *index,
+ G_CALLBACK (schedule_refresh_bookmarks_menu),
+ show_bogus_bookmark_window);
g_object_unref (bookmark);
} else if (strcmp (node->name, "separator") == 0) {
append_separator (window, menu_path);
} else if (strcmp (node->name, "folder") == 0) {
xml_folder_name = eel_xml_get_property_translated (node, "name");
- nautilus_bonobo_add_submenu (window->details->shell_ui, menu_path, xml_folder_name, NULL);
+ nautilus_bonobo_add_submenu (NAUTILUS_WINDOW (window)->details->shell_ui, menu_path, xml_folder_name, NULL);
/* Construct path and make sure it is escaped properly */
escaped_name = gnome_vfs_escape_string (xml_folder_name);
@@ -1030,7 +496,7 @@ create_menu_item_from_node (NautilusWindow *window,
(*index)++;
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
#ifdef WEB_NAVIGATION_ENABLED
@@ -1063,25 +529,6 @@ append_static_bookmarks (NautilusWindow *window, const char *menu_path)
}
#endif
-static NautilusBookmarkList *bookmarks = NULL;
-
-static void
-free_bookmark_list (void)
-{
- g_object_unref (bookmarks);
-}
-
-static NautilusBookmarkList *
-get_bookmark_list (void)
-{
- if (bookmarks == NULL) {
- bookmarks = nautilus_bookmark_list_new ();
- eel_debug_call_at_shutdown (free_bookmark_list);
- }
-
- return bookmarks;
-}
-
static GtkWindow *
get_or_create_bookmarks_window (GObject *undo_manager_source)
{
@@ -1112,15 +559,16 @@ nautilus_bookmarks_exiting (void)
* Does nothing if there's already a bookmark for the displayed location.
*/
static void
-add_bookmark_for_current_location (NautilusWindow *window)
+add_bookmark_for_current_location (NautilusNavigationWindow *window)
{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+ g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window));
- nautilus_bookmark_list_append (get_bookmark_list (), window->current_location_bookmark);
+ nautilus_bookmark_list_append (get_bookmark_list (),
+ NAUTILUS_WINDOW (window)->current_location_bookmark);
}
static void
-edit_bookmarks (NautilusWindow *window)
+edit_bookmarks (NautilusNavigationWindow *window)
{
GtkWindow *dialog;
@@ -1134,21 +582,22 @@ edit_bookmarks (NautilusWindow *window)
void
nautilus_window_bookmarks_preference_changed_callback (gpointer user_data)
{
- refresh_bookmarks_menu (NAUTILUS_WINDOW (user_data));
+ refresh_bookmarks_menu (NAUTILUS_NAVIGATION_WINDOW (user_data));
}
static void
-refresh_bookmarks_menu (NautilusWindow *window)
+refresh_bookmarks_menu (NautilusNavigationWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
/* Unregister any pending call to this function. */
- nautilus_window_remove_bookmarks_menu_callback (window);
+ nautilus_navigation_window_remove_bookmarks_menu_callback (window);
g_object_ref (G_OBJECT (window));
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
+ bonobo_ui_component_freeze
+ (NAUTILUS_WINDOW (window)->details->shell_ui, NULL);
- nautilus_window_remove_bookmarks_menu_items (window);
+ nautilus_navigation_window_remove_bookmarks_menu_items (window);
#ifdef WEB_NAVIGATION_ENABLED
if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS)) {
@@ -1158,20 +607,20 @@ refresh_bookmarks_menu (NautilusWindow *window)
append_dynamic_bookmarks (window);
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+ bonobo_ui_component_thaw (NAUTILUS_WINDOW (window)->details->shell_ui, NULL);
g_object_unref (G_OBJECT (window));
}
/**
- * nautilus_window_initialize_bookmarks_menu
+ * nautilus_navigation_window_initialize_bookmarks_menu
*
* Fill in bookmarks menu with stored bookmarks, and wire up signals
* so we'll be notified when bookmark list changes.
*/
static void
-nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
+nautilus_navigation_window_initialize_bookmarks_menu (NautilusNavigationWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
/* Construct the initial set of bookmarks. */
refresh_bookmarks_menu (window);
@@ -1195,13 +644,96 @@ nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
window, G_CONNECT_SWAPPED);
}
+void
+nautilus_window_remove_go_menu_callback (NautilusWindow *window)
+{
+ if (window->details->refresh_go_menu_idle_id != 0) {
+ g_source_remove (window->details->refresh_go_menu_idle_id);
+ window->details->refresh_go_menu_idle_id = 0;
+ }
+}
+
+void
+nautilus_window_remove_go_menu_items (NautilusWindow *window)
+{
+ nautilus_window_ui_freeze (window);
+
+ nautilus_bonobo_remove_menu_items_and_commands
+ (window->details->shell_ui,
+ MENU_PATH_HISTORY_PLACEHOLDER);
+
+ nautilus_window_ui_thaw (window);
+}
+
+/**
+ * refresh_go_menu:
+ *
+ * Refresh list of bookmarks at end of Go menu to match centralized history list.
+ * @window: The NautilusWindow whose Go menu will be refreshed.
+ **/
+static void
+refresh_go_menu (NautilusWindow *window)
+{
+ GList *node;
+ int index;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ /* Unregister any pending call to this function. */
+ nautilus_window_remove_go_menu_callback (window);
+
+ bonobo_ui_component_freeze (window->details->shell_ui, NULL);
+
+ /* Remove old set of history items. */
+ nautilus_window_remove_go_menu_items (window);
+
+ /* Add in a new set of history items. */
+ for (node = nautilus_get_history_list (), index = 0;
+ node != NULL && index < 10;
+ node = node->next, index++) {
+ nautilus_menus_append_bookmark_to_menu
+ (window,
+ window->details->shell_ui,
+ NAUTILUS_BOOKMARK (node->data),
+ MENU_PATH_HISTORY_PLACEHOLDER,
+ index,
+ G_CALLBACK (schedule_refresh_go_menu),
+ show_bogus_bookmark_window);
+ }
+
+ bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+}
+
+static gboolean
+refresh_go_menu_idle_callback (gpointer data)
+{
+ g_assert (NAUTILUS_IS_WINDOW (data));
+
+ refresh_go_menu (NAUTILUS_WINDOW (data));
+
+ /* Don't call this again (unless rescheduled) */
+ return FALSE;
+}
+
+static void
+schedule_refresh_go_menu (NautilusWindow *window)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ if (window->details->refresh_go_menu_idle_id == 0) {
+ window->details->refresh_go_menu_idle_id
+ = g_idle_add (refresh_go_menu_idle_callback,
+ window);
+ }
+}
+
/**
- * nautilus_window_initialize_go_menu
+ * nautilus_navigation_window_initialize_go_menu
*
* Wire up signals so we'll be notified when history list changes.
*/
static void
-nautilus_window_initialize_go_menu (NautilusWindow *window)
+nautilus_navigation_window_initialize_go_menu (NautilusNavigationWindow *window)
{
/* Recreate bookmarks part of menu if history list changes
* or if icon theme changes.
@@ -1219,58 +751,34 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
* @window: A recently-created NautilusWindow.
*/
void
-nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
+nautilus_navigation_window_initialize_menus_part_1 (NautilusNavigationWindow *navigation_window)
{
+ NautilusWindow *window;
BonoboUIVerb verbs [] = {
- BONOBO_UI_VERB ("New Window", file_menu_new_window_callback),
- BONOBO_UI_VERB ("Close", file_menu_close_window_callback),
- BONOBO_UI_VERB ("Burn CD", file_menu_burn_cd_callback),
BONOBO_UI_VERB ("Close All Windows", file_menu_close_all_windows_callback),
#ifdef HAVE_MEDUSA
BONOBO_UI_VERB ("Find", file_menu_find_callback),
BONOBO_UI_VERB ("Toggle Find Mode", toolbar_toggle_find_mode_callback),
#endif
- BONOBO_UI_VERB ("Undo", edit_menu_undo_callback),
- BONOBO_UI_VERB ("Backgrounds and Emblems", backgrounds_and_emblems_callback),
BONOBO_UI_VERB ("Back", go_menu_back_callback),
BONOBO_UI_VERB ("Forward", go_menu_forward_callback),
- BONOBO_UI_VERB ("Up", go_menu_up_callback),
- BONOBO_UI_VERB ("Home", go_menu_home_callback),
- BONOBO_UI_VERB ("Start Here", go_menu_start_here_callback),
- BONOBO_UI_VERB ("Go to Trash", go_menu_go_to_trash_callback),
- BONOBO_UI_VERB ("Go to Burn CD", go_menu_go_to_burn_cd_callback),
- BONOBO_UI_VERB ("Go to Location", go_menu_location_callback),
BONOBO_UI_VERB ("Clear History", go_menu_forget_history_callback),
- BONOBO_UI_VERB ("Reload", view_menu_reload_callback),
- BONOBO_UI_VERB ("Zoom In", view_menu_zoom_in_callback),
- BONOBO_UI_VERB ("Zoom Out", view_menu_zoom_out_callback),
- BONOBO_UI_VERB ("Zoom Normal", view_menu_zoom_normal_callback),
- BONOBO_UI_VERB ("View as", view_menu_view_as_callback),
BONOBO_UI_VERB ("Add Bookmark", bookmarks_menu_add_bookmark_callback),
BONOBO_UI_VERB ("Edit Bookmarks", bookmarks_menu_edit_bookmarks_callback),
-#ifdef ENABLE_PROFILER
- BONOBO_UI_VERB ("Start Profiling", nautilus_profiler_bonobo_ui_start_callback),
- BONOBO_UI_VERB ("Stop Profiling", nautilus_profiler_bonobo_ui_stop_callback),
- BONOBO_UI_VERB ("Reset Profiling", nautilus_profiler_bonobo_ui_reset_callback),
- BONOBO_UI_VERB ("Report Profiling", nautilus_profiler_bonobo_ui_report_callback),
-#endif
-
- BONOBO_UI_VERB ("About Nautilus", help_menu_about_nautilus_callback),
- BONOBO_UI_VERB ("Nautilus Manual", help_menu_nautilus_manual_callback),
- BONOBO_UI_VERB ("Preferences", preferences_callback),
- BONOBO_UI_VERB ("Stop", stop_button_callback),
-
BONOBO_UI_VERB_END
};
+ window = NAUTILUS_WINDOW (navigation_window);
+
nautilus_window_ui_freeze (window);
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
- nautilus_window_update_show_hide_menu_items (window);
+ nautilus_navigation_window_update_show_hide_menu_items (navigation_window);
- bonobo_ui_component_add_verb_list_with_data (window->details->shell_ui, verbs, window);
+ bonobo_ui_component_add_verb_list_with_data (window->details->shell_ui,
+ verbs, window);
bonobo_ui_component_add_listener
(window->details->shell_ui,
@@ -1279,69 +787,28 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
window);
bonobo_ui_component_add_listener
(window->details->shell_ui,
- ID_SHOW_HIDE_TOOLBAR,
- view_menu_show_hide_toolbar_state_changed_callback,
- window);
- bonobo_ui_component_add_listener
- (window->details->shell_ui,
ID_SHOW_HIDE_LOCATION_BAR,
view_menu_show_hide_location_bar_state_changed_callback,
window);
- bonobo_ui_component_add_listener
- (window->details->shell_ui,
- ID_SHOW_HIDE_STATUS_BAR,
- view_menu_show_hide_statusbar_state_changed_callback,
- window);
-
- /* Register to catch Bonobo UI events so we can notice View As changes */
- g_signal_connect_object (window->details->shell_ui, "ui_event",
- G_CALLBACK (nautilus_window_handle_ui_event_callback), window, 0);
bonobo_ui_component_thaw (window->details->shell_ui, NULL);
-
- if (!have_burn_uri ()) {
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- COMMAND_GO_BURN_CD,
- TRUE);
- }
-
-#ifndef ENABLE_PROFILER
- nautilus_bonobo_set_hidden (window->details->shell_ui, NAUTILUS_MENU_PATH_PROFILER, TRUE);
-#endif
-#ifndef HAVE_MEDUSA
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE,
- TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE,
- TRUE);
- /* Also set these items insensitive so that keyboard shortcuts do not trigger
- warnings */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE,
- FALSE);
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE,
- FALSE);
-
-#endif
nautilus_window_ui_thaw (window);
}
void
-nautilus_window_initialize_menus_part_2 (NautilusWindow *window)
+nautilus_navigation_window_initialize_menus_part_2 (NautilusNavigationWindow *window)
{
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- nautilus_window_initialize_bookmarks_menu (window);
- nautilus_window_initialize_go_menu (window);
+ nautilus_navigation_window_initialize_go_menu (window);
+ nautilus_navigation_window_initialize_bookmarks_menu (window);
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
void
-nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window)
+nautilus_navigation_window_remove_bookmarks_menu_callback (NautilusNavigationWindow *window)
{
if (window->details->refresh_bookmarks_menu_idle_id != 0) {
g_source_remove (window->details->refresh_bookmarks_menu_idle_id);
@@ -1350,78 +817,60 @@ nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window)
}
void
-nautilus_window_remove_go_menu_callback (NautilusWindow *window)
-{
- if (window->details->refresh_go_menu_idle_id != 0) {
- g_source_remove (window->details->refresh_go_menu_idle_id);
- window->details->refresh_go_menu_idle_id = 0;
- }
-}
-
-void
-nautilus_window_remove_bookmarks_menu_items (NautilusWindow *window)
+nautilus_navigation_window_remove_bookmarks_menu_items (NautilusNavigationWindow *window)
{
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui,
- MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER);
+ (NAUTILUS_WINDOW (window)->details->shell_ui,
+ MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER);
nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui,
- MENU_PATH_BOOKMARKS_PLACEHOLDER);
+ (NAUTILUS_WINDOW (window)->details->shell_ui,
+ MENU_PATH_BOOKMARKS_PLACEHOLDER);
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_remove_go_menu_items (NautilusWindow *window)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui,
- MENU_PATH_HISTORY_PLACEHOLDER);
-
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
static void
-append_dynamic_bookmarks (NautilusWindow *window)
+append_dynamic_bookmarks (NautilusNavigationWindow *window)
{
NautilusBookmarkList *bookmarks;
guint bookmark_count;
guint index;
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
bookmarks = get_bookmark_list ();
/* append new set of bookmarks */
bookmark_count = nautilus_bookmark_list_length (bookmarks);
for (index = 0; index < bookmark_count; ++index) {
- append_bookmark_to_menu (window,
- nautilus_bookmark_list_item_at (bookmarks, index),
- MENU_PATH_BOOKMARKS_PLACEHOLDER,
- index,
- TRUE);
+ nautilus_menus_append_bookmark_to_menu
+ (NAUTILUS_WINDOW (window),
+ NAUTILUS_WINDOW (window)->details->shell_ui,
+ nautilus_bookmark_list_item_at (bookmarks, index),
+ MENU_PATH_BOOKMARKS_PLACEHOLDER,
+ index,
+ G_CALLBACK (schedule_refresh_bookmarks_menu),
+ show_bogus_bookmark_window);
}
}
static gboolean
refresh_bookmarks_menu_idle_callback (gpointer data)
{
- g_assert (NAUTILUS_IS_WINDOW (data));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (data));
- refresh_bookmarks_menu (NAUTILUS_WINDOW (data));
+ refresh_bookmarks_menu (NAUTILUS_NAVIGATION_WINDOW (data));
/* Don't call this again (unless rescheduled) */
return FALSE;
}
static void
-schedule_refresh_bookmarks_menu (NautilusWindow *window)
+schedule_refresh_bookmarks_menu (NautilusNavigationWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
if (window->details->refresh_bookmarks_menu_idle_id == 0) {
window->details->refresh_bookmarks_menu_idle_id
@@ -1429,62 +878,3 @@ schedule_refresh_bookmarks_menu (NautilusWindow *window)
window);
}
}
-
-/**
- * refresh_go_menu:
- *
- * Refresh list of bookmarks at end of Go menu to match centralized history list.
- * @window: The NautilusWindow whose Go menu will be refreshed.
- **/
-static void
-refresh_go_menu (NautilusWindow *window)
-{
- GList *node;
- int index;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- /* Unregister any pending call to this function. */
- nautilus_window_remove_go_menu_callback (window);
-
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
-
- /* Remove old set of history items. */
- nautilus_window_remove_go_menu_items (window);
-
- /* Add in a new set of history items. */
- for (node = nautilus_get_history_list (), index = 0;
- node != NULL && index < 10;
- node = node->next, index++) {
- append_bookmark_to_menu (window,
- NAUTILUS_BOOKMARK (node->data),
- MENU_PATH_HISTORY_PLACEHOLDER,
- index,
- FALSE);
- }
-
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
-}
-
-static gboolean
-refresh_go_menu_idle_callback (gpointer data)
-{
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- refresh_go_menu (NAUTILUS_WINDOW (data));
-
- /* Don't call this again (unless rescheduled) */
- return FALSE;
-}
-
-static void
-schedule_refresh_go_menu (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->details->refresh_go_menu_idle_id == 0) {
- window->details->refresh_go_menu_idle_id
- = g_idle_add (refresh_go_menu_idle_callback,
- window);
- }
-}
diff --git a/src/nautilus-navigation-window-ui.xml b/src/nautilus-navigation-window-ui.xml
new file mode 100644
index 000000000..31b88b536
--- /dev/null
+++ b/src/nautilus-navigation-window-ui.xml
@@ -0,0 +1,163 @@
+<Root>
+
+<!-- A description of each placeholder's purpose is in libnautilus/nautilus-bonobo-ui.h -->
+
+<commands>
+ <!-- We define commands here for (at least) all the items
+ for which we share tip or sensitivity state between more
+ than one item (usually 1 menuitem and 1 toolitem.
+ -->
+
+ <cmd name="Back" accel="*Alt*Left"
+ _tip="Go to the previous visited location"/>
+ <cmd name="Forward" accel="*Alt*Right"
+ _tip="Go to the next visited location"/>
+ <cmd name="Find"
+ _tip="Search this computer for files"/>
+ <cmd name="Toggle Find Mode"
+ _label="Find"
+ _tip="Search this computer for files"/>
+</commands>
+
+<menu>
+ <submenu name="File">
+ <placeholder name="Close Items Placeholder">
+ <menuitem name="Close All Windows"
+ _label="Close _All Windows"
+ _tip="Close all Navigation windows"
+ accel="*Control**Shift*w"
+ verb="Close All Windows"/>
+ </placeholder>
+ </submenu>
+ <submenu name="View" _label="_View">
+ <placeholder name="Show Hide Placeholder" delimit="top">
+ <menuitem name="Show Hide Sidebar"
+ type="toggle"
+ _label="_Side Pane"
+ _tip="Change the visibility of this window's sidebar"
+ accel="F9"
+ id="Show Hide Sidebar"/>
+ <menuitem name="Show Hide Location Bar"
+ type="toggle"
+ _label="Location _Bar"
+ _tip="Change the visibility of this window's location bar"
+ id="Show Hide Location Bar"/>
+ <menuitem name="Show Hide Statusbar"
+ type="toggle"
+ _label="St_atusbar"
+ _tip="Change the visibility of this window's statusbar"
+ id="Show Hide Statusbar"/>
+ </placeholder>
+ </submenu>
+
+ <submenu name="Go" _label="_Go">
+ <placeholder name="Navigation Items">
+ <menuitem name="Up"
+ _label="_Up"
+ accel="*Alt*Up"
+ pixtype="stock" pixname="gtk-go-up"
+ verb="Up"/>
+ <menuitem name="Back"
+ _label="_Back"
+ pixtype="stock" pixname="gtk-go-back"
+ verb="Back"/>
+ <menuitem name="Forward"
+ _label="_Forward"
+ pixtype="stock" pixname="gtk-go-forward"
+ verb="Forward"/>
+ </placeholder>
+ <separator/>
+ <menuitem name="Home"
+ _label="_Home"
+ accel="*Alt*Home"
+ pixtype="stock" pixname="gtk-home"
+ verb="Home"/>
+ <menuitem name="Go to Trash"
+ _label="_Trash"
+ _tip="Go to the trash folder"
+ verb="Go to Trash"/>
+ <menuitem name="Go to Location"
+ _label="_Location..."
+ accel="*Control*l"
+ verb="Go to Location"/>
+
+ <separator/>
+
+ <menuitem name="Clear History"
+ _label="_Clear History"
+ _tip="Clear contents of Go menu and Back/Forward lists"
+ verb="Clear History"/>
+
+ <placeholder name="History Placeholder" delimit="top"/>
+ </submenu>
+
+ <submenu name="Bookmarks" _label="_Bookmarks">
+ <menuitem name="Add Bookmark"
+ _label="_Add Bookmark"
+ _tip="Add a bookmark for the current location to this menu"
+ accel="*Control*d"
+ pixtype="stock" pixname="gtk-add"
+ verb="Add Bookmark"/>
+ <menuitem name="Edit Bookmarks"
+ _label="_Edit Bookmarks"
+ _tip="Display a window that allows editing the bookmarks in this menu"
+ accel="*Control*b"
+ verb="Edit Bookmarks"/>
+
+ <placeholder name="Built-in Bookmarks Placeholder" delimit="top"/>
+ <placeholder name="Bookmarks Placeholder" delimit="top"/>
+ </submenu>
+</menu>
+
+<dockitem name="Location Bar" behavior="exclusive,never vertical">
+ <control name="Wrapper" behavior="expandable"/>
+</dockitem>
+
+<dockitem name="Toolbar" behavior="exclusive">
+
+ <toolitem name="Back"
+ _label="Back"
+ priority="1"
+ pixtype="stock" pixname="gtk-go-back"
+ verb="Back"/>
+ <control name="BackMenu"/>
+ <toolitem name="Forward"
+ _label="Forward"
+ pixtype="stock" pixname="gtk-go-forward"
+ verb="Forward"/>
+ <control name="ForwardMenu"/>
+ <toolitem name="Up"
+ _label="Up"
+ pixtype="stock" pixname="gtk-go-up"
+ verb="Up"/>
+ <toolitem name="Stop" _label="Stop"
+ pixtype="stock" pixname="gtk-stop"
+ verb="Stop"/>
+ <toolitem name="Reload"
+ _label="Reload"
+ pixtype="stock" pixname="gtk-refresh"
+ verb="Reload"/>
+ <separator/>
+
+ <toolitem name="Home"
+ _label="Home"
+ priority="1"
+ pixtype="stock" pixname="gtk-home"
+ verb="Home"/>
+ <toolitem name="Toggle Find Mode"
+ priority="1"
+ type="toggle"
+ pixtype="stock" pixname="Search"
+ verb="Toggle Find Mode"/>
+ <toolitem name="Burn CD"
+ _label="Write to CD"
+ priority="1"
+ pixtype="stock" pixname="gtk-cdrom"
+ verb="Burn CD"/>
+
+
+ <placeholder name="Extra Buttons Placeholder" delimit="top"/>
+
+ <control name="ThrobberWrapper" behavior="pack-end"/>
+</dockitem>
+</Root>
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 300f43ecb..2fbab90d3 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -5,6 +5,7 @@
*
* Copyright (C) 1999, 2000 Red Hat, Inc.
* Copyright (C) 1999, 2000, 2001 Eazel, Inc.
+ * Copyright (C) 2003 Ximian, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -41,12 +42,14 @@
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-property-bag-client.h>
#include <bonobo/bonobo-ui-util.h>
+#include <eel/eel-accessibility.h>
#include <eel/eel-debug.h>
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-generous-bin.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
+#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkx.h>
@@ -75,6 +78,7 @@
#include <libnautilus-private/nautilus-mime-actions.h>
#include <libnautilus-private/nautilus-program-choosing.h>
#include <libnautilus-private/nautilus-sidebar-functions.h>
+#include <libnautilus-private/nautilus-theme.h>
#include <libnautilus/nautilus-bonobo-ui.h>
#include <libnautilus/nautilus-clipboard.h>
#include <libnautilus/nautilus-undo.h>
@@ -87,26 +91,21 @@
*/
#include "nautilus-desktop-window.h"
-#define MAX_HISTORY_ITEMS 50
-
/* FIXME bugzilla.gnome.org 41245: hardwired sizes */
#define SIDE_PANE_MINIMUM_WIDTH 1
#define SIDE_PANE_MINIMUM_HEIGHT 400
+#define MAX_TITLE_LENGTH 180
+
/* dock items */
#define LOCATION_BAR_PATH "/Location Bar"
#define TOOLBAR_PATH "/Toolbar"
-#define STATUS_BAR_PATH "/status"
#define MENU_BAR_PATH "/menu"
-#define COMMAND_PREFIX "/commands/"
#define NAUTILUS_COMMAND_TOGGLE_FIND_MODE "/commands/Toggle Find Mode"
-#define NAUTILUS_COMMAND_VIEW_AS "/commands/View as"
-#define NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER "/menu/View/View Choices/Extra Viewer"
-#define NAUTILUS_MENU_PATH_BEFORE_SHORT_LIST_SEPARATOR "/menu/View/View Choices/Before Short List"
-#define NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER "/menu/View/View Choices/Short List"
-#define NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR "/menu/View/View Choices/After Short List"
+#define COMMAND_PATH_TOGGLE_FIND_MODE "/commands/Find"
+#define COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE "/commands/Toggle Find Mode"
enum {
ARG_0,
@@ -114,428 +113,89 @@ enum {
ARG_APP
};
-static GList *history_list;
static int side_pane_width_auto_value = SIDE_PANE_MINIMUM_WIDTH;
-static void add_sidebar_panels (NautilusWindow *window);
-static void cancel_view_as_callback (NautilusWindow *window);
+static void add_sidebar_panels (NautilusNavigationWindow *window);
+static void load_view_as_menu (NautilusWindow *window);
+static void side_panel_view_loaded_callback (NautilusViewFrame *view,
+ gpointer user_data);
+static void side_panel_view_failed_callback (NautilusViewFrame *view,
+ gpointer user_data);
-GNOME_CLASS_BOILERPLATE (NautilusWindow, nautilus_window,
- BonoboWindow, BONOBO_TYPE_WINDOW)
+GNOME_CLASS_BOILERPLATE (NautilusNavigationWindow, nautilus_navigation_window,
+ NautilusWindow, NAUTILUS_TYPE_WINDOW)
static void
-set_up_default_icon_list (void)
+nautilus_navigation_window_instance_init (NautilusNavigationWindow *window)
{
- GList *icon_list;
- guint i;
- GdkPixbuf *pixbuf;
- char *path;
- const char *icon_filenames[] = { "nautilus-mini-logo.png", "nautilus-launch-icon.png" };
-
- icon_list = NULL;
- for (i = 0; i < G_N_ELEMENTS (icon_filenames); i++) {
- path = nautilus_pixmap_file (icon_filenames[i]);
-
- if (path == NULL) {
- continue;
- }
-
- pixbuf = gdk_pixbuf_new_from_file (path, NULL);
- g_free (path);
-
- if (pixbuf != NULL) {
- icon_list = g_list_prepend (icon_list, pixbuf);
- }
- }
-
- gtk_window_set_default_icon_list (icon_list);
-
- eel_g_list_free_deep_custom (icon_list, (GFunc) g_object_unref, NULL);
-}
-
-static void
-icons_changed_callback (GObject *factory, NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_update_icon (window);
-}
-
-static void
-nautilus_window_instance_init (NautilusWindow *window)
-{
- window->details = g_new0 (NautilusWindowDetails, 1);
-
- /* CORBA and Bonobo setup, which must be done before the location bar setup */
- window->details->ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
- bonobo_object_ref (window->details->ui_container);
+ window->details = g_new0 (NautilusNavigationWindowDetails, 1);
window->details->tooltips = gtk_tooltips_new ();
g_object_ref (G_OBJECT (window->details->tooltips));
gtk_object_sink (GTK_OBJECT (window->details->tooltips));
-
- /* Set last geometry to NULL */
- window->last_geometry = NULL;
-
- /* Set initial window title */
- gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
-
- window->details->shell_ui = bonobo_ui_component_new ("Nautilus Shell");
- bonobo_ui_component_set_container
- (window->details->shell_ui,
- nautilus_window_get_ui_container (window),
- NULL);
-
- /* Register IconFactory callback to update the window border icon
- * when the icon-theme is changed.
- */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (icons_changed_callback), window,
- 0);
-
- /* Create a separate component so when we remove the status
- * we don't loose the status bar
- */
- window->details->status_ui = bonobo_ui_component_new ("Status Component");
- bonobo_ui_component_set_container
- (window->details->status_ui,
- nautilus_window_get_ui_container (window),
- NULL);
-
- gtk_quit_add_destroy (1, GTK_OBJECT (window));
-
- /* Keep the main event loop alive as long as the window exists */
- nautilus_main_event_loop_register (GTK_OBJECT (window));
-}
-
-static gint
-ui_idle_handler (gpointer data)
-{
- NautilusWindow *window;
- gboolean old_updating_bonobo_state;
-
- window = data;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_object_ref (data);
-
- g_assert (window->details->ui_change_depth == 0);
-
- /* Simulate an extra freeze/thaw so that calling window_ui_freeze
- * and thaw from within the idle handler doesn't try to remove it
- * (the already running idle handler)
- */
- window->details->ui_change_depth++;
- old_updating_bonobo_state = window->details->updating_bonobo_state;
-
- if (window->details->ui_pending_initialize_menus_part_2) {
- nautilus_window_initialize_menus_part_2 (window);
- window->details->ui_pending_initialize_menus_part_2 = FALSE;
- }
-
- if (window->details->ui_is_frozen) {
- window->details->updating_bonobo_state = TRUE;
- bonobo_ui_engine_thaw (bonobo_ui_container_get_engine (window->details->ui_container));
- window->details->ui_is_frozen = FALSE;
- window->details->updating_bonobo_state = old_updating_bonobo_state;
- }
-
- window->details->ui_change_depth--;
-
- window->details->ui_idle_id = 0;
-
- g_object_unref (data);
-
- return FALSE;
-}
-
-static inline void
-ui_install_idle_handler (NautilusWindow *window)
-{
- if (window->details->ui_idle_id == 0) {
- window->details->ui_idle_id = g_idle_add_full (G_PRIORITY_LOW, ui_idle_handler, window, NULL);
- }
-}
-
-static inline void
-ui_remove_idle_handler (NautilusWindow *window)
-{
- if (window->details->ui_idle_id != 0) {
- g_source_remove (window->details->ui_idle_id);
- window->details->ui_idle_id = 0;
- }
-}
-
-/* Register that BonoboUI changes are going to be made to WINDOW. The UI
- * won't actually be synchronised until some arbitrary date in the future.
- */
-void
-nautilus_window_ui_freeze (NautilusWindow *window)
-{
- g_object_ref (window);
-
- if (window->details->ui_change_depth == 0) {
- ui_remove_idle_handler (window);
- }
-
- if (!window->details->ui_is_frozen) {
- bonobo_ui_engine_freeze (bonobo_ui_container_get_engine (window->details->ui_container));
- window->details->ui_is_frozen = TRUE;
- }
-
- window->details->ui_change_depth++;
-}
-
-/* Register that the BonoboUI changes for WINDOW have finished. There _must_
- * be one and only one call to this function for every call to
- * starting_ui_change ()
- */
-void
-nautilus_window_ui_thaw (NautilusWindow *window)
-{
- window->details->ui_change_depth--;
-
- g_assert (window->details->ui_change_depth >= 0);
-
- if (window->details->ui_change_depth == 0
- && (window->details->ui_is_frozen
- || window->details->ui_pending_initialize_menus_part_2)) {
- ui_install_idle_handler (window);
- }
-
- g_object_unref (window);
-}
-
-/* Unconditionally synchronize the BonoboUI of WINDOW. */
-static void
-nautilus_window_ui_update (NautilusWindow *window)
-{
- BonoboUIEngine *engine;
- gboolean old_updating_bonobo_state;
-
- engine = bonobo_ui_container_get_engine (window->details->ui_container);
- old_updating_bonobo_state = window->details->updating_bonobo_state;
-
- window->details->updating_bonobo_state = TRUE;
- if (window->details->ui_is_frozen) {
- bonobo_ui_engine_thaw (engine);
- if (window->details->ui_change_depth == 0) {
- window->details->ui_is_frozen = FALSE;
- if (!window->details->ui_pending_initialize_menus_part_2) {
- ui_remove_idle_handler (window);
- }
- } else {
- bonobo_ui_engine_freeze (engine);
- }
- } else {
- bonobo_ui_engine_update (engine);
- }
- window->details->updating_bonobo_state = old_updating_bonobo_state;
-}
-
-static gboolean
-nautilus_window_clear_status (gpointer callback_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- bonobo_ui_component_set_status (window->details->status_ui, NULL, NULL);
-
- return FALSE;
-}
-
-void
-nautilus_window_set_status (NautilusWindow *window, const char *text)
-{
- if (text != NULL && text[0] != '\0') {
- bonobo_ui_component_set_status (window->details->status_ui, text, NULL);
- } else {
- nautilus_window_clear_status (window);
- }
-}
-
-void
-nautilus_window_go_to (NautilusWindow *window, const char *uri)
-{
- nautilus_window_open_location (window, uri);
-}
-
-char *
-nautilus_window_get_location (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
-
- return g_strdup (window->details->location);
+
+ window->details->content_paned = nautilus_horizontal_splitter_new ();
+ gtk_widget_show (window->details->content_paned);
+ bonobo_window_set_contents (BONOBO_WINDOW (window), window->details->content_paned);
}
static void
go_to_callback (GtkWidget *widget,
const char *uri,
- NautilusWindow *window)
+ NautilusNavigationWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
- nautilus_window_go_to (window, uri);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), uri);
}
static void
navigation_bar_location_changed_callback (GtkWidget *widget,
const char *uri,
- NautilusWindow *window)
+ NautilusNavigationWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
if (window->details->temporary_navigation_bar) {
- if (nautilus_window_location_bar_showing (window)) {
- nautilus_window_hide_location_bar (window, FALSE);
+ if (nautilus_navigation_window_location_bar_showing (window)) {
+ nautilus_navigation_window_hide_location_bar (window, FALSE);
}
window->details->temporary_navigation_bar = FALSE;
}
- nautilus_window_go_to (window, uri);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), uri);
}
static void
navigation_bar_mode_changed_callback (GtkWidget *widget,
NautilusSwitchableNavigationBarMode mode,
- NautilusWindow *window)
+ NautilusNavigationWindow *window)
{
- window->details->updating_bonobo_state = TRUE;
+ NAUTILUS_WINDOW (window)->details->updating_bonobo_state = TRUE;
g_assert (mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION
|| mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
+ nautilus_bonobo_set_toggle_state (NAUTILUS_WINDOW (window)->details->shell_ui,
NAUTILUS_COMMAND_TOGGLE_FIND_MODE,
mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
- window->details->updating_bonobo_state = FALSE;
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_zoom_in (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_in (window->content_view);
- }
-}
-
-void
-nautilus_window_zoom_to_level (NautilusWindow *window, float level)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_set_zoom_level (window->content_view, level);
- }
-}
+ NAUTILUS_WINDOW (window)->details->updating_bonobo_state = FALSE;
-void
-nautilus_window_zoom_out (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_out (window->content_view);
- }
-}
-
-void
-nautilus_window_zoom_to_fit (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_to_fit (window->content_view);
- }
-}
-
-/* Code should never force the window taller than this size.
- * (The user can still stretch the window taller if desired).
- */
-static guint
-get_max_forced_height (GdkScreen *screen)
-{
- return (gdk_screen_get_height (screen) * 90) / 100;
-}
-
-/* Code should never force the window wider than this size.
- * (The user can still stretch the window wider if desired).
- */
-static guint
-get_max_forced_width (GdkScreen *screen)
-{
- return (gdk_screen_get_width (screen) * 90) / 100;
-}
-
-static void
-set_initial_window_geometry (NautilusWindow *window)
-{
- GdkScreen *screen;
- guint max_width_for_screen, max_height_for_screen;
-
- screen = gtk_window_get_screen (GTK_WINDOW (window));
-
- /* Don't let GTK determine the minimum size
- * automatically. It will insist that the window be
- * really wide based on some misguided notion about
- * the content view area. Also, it might start the
- * window wider (or taller) than the screen, which
- * is evil. So we choose semi-arbitrary initial and
- * minimum widths instead of letting GTK decide.
- */
- /* FIXME - the above comment suggests that the size request
- * of the content view area is wrong, probably because of
- * another stupid set_usize someplace. If someone gets the
- * content view area's size request right then we can
- * probably remove this broken set_size_request() here.
- * - hp@redhat.com
- */
-
- max_width_for_screen = get_max_forced_width (screen);
- max_height_for_screen = get_max_forced_height (screen);
-
- gtk_widget_set_size_request (GTK_WIDGET (window),
- MIN (NAUTILUS_WINDOW_MIN_WIDTH,
- max_width_for_screen),
- MIN (NAUTILUS_WINDOW_MIN_HEIGHT,
- max_height_for_screen));
-
- gtk_window_set_default_size (GTK_WINDOW (window),
- MIN (NAUTILUS_WINDOW_DEFAULT_WIDTH,
- max_width_for_screen),
- MIN (NAUTILUS_WINDOW_DEFAULT_HEIGHT,
- max_height_for_screen));
-}
-
-/* Add a dummy menu with a "View as ..." item when we first create the
- * view_as_option_menu -- without this the menu draws empty and shrunk,
- * once we populate it it grows and forces the toolbar and all the other
- * views to re-layout.
- */
-static void
-set_dummy_initial_view_as_menu (NautilusWindow *window)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
-
- new_menu = gtk_menu_new ();
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
static void
side_pane_close_requested_callback (GtkWidget *widget,
gpointer user_data)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (user_data);
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
- nautilus_window_hide_sidebar (window);
+ nautilus_navigation_window_hide_sidebar (window);
}
static void
@@ -543,9 +203,9 @@ side_pane_size_allocate_callback (GtkWidget *widget,
GtkAllocation *allocation,
gpointer user_data)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (user_data);
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
if (allocation->width != window->details->side_pane_width) {
window->details->side_pane_width = allocation->width;
@@ -558,7 +218,7 @@ side_pane_size_allocate_callback (GtkWidget *widget,
}
static void
-setup_side_pane_width (NautilusWindow *window)
+setup_side_pane_width (NautilusNavigationWindow *window)
{
static gboolean setup_auto_value= TRUE;
@@ -576,7 +236,7 @@ setup_side_pane_width (NautilusWindow *window)
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
- gtk_paned_set_position (GTK_PANED (window->content_hbox),
+ gtk_paned_set_position (GTK_PANED (window->details->content_paned),
side_pane_width_auto_value);
}
@@ -608,7 +268,7 @@ side_panel_set_open (GtkWidget *view,
}
static void
-set_current_side_panel (NautilusWindow *window,
+set_current_side_panel (NautilusNavigationWindow *window,
GtkWidget *panel)
{
if (window->details->current_side_panel) {
@@ -625,7 +285,7 @@ set_current_side_panel (NautilusWindow *window,
static void
side_pane_switch_page_callback (NautilusSidePane *side_pane,
GtkWidget *panel,
- NautilusWindow *window)
+ NautilusNavigationWindow *window)
{
const char *view_iid;
@@ -646,11 +306,11 @@ side_pane_switch_page_callback (NautilusSidePane *side_pane,
}
static void
-nautilus_window_set_up_sidebar (NautilusWindow *window)
+nautilus_navigation_window_set_up_sidebar (NautilusNavigationWindow *window)
{
window->sidebar = nautilus_side_pane_new ();
- gtk_paned_pack1 (GTK_PANED (window->content_hbox),
+ gtk_paned_pack1 (GTK_PANED (window->details->content_paned),
GTK_WIDGET (window->sidebar),
FALSE, TRUE);
@@ -662,11 +322,11 @@ nautilus_window_set_up_sidebar (NautilusWindow *window)
window->information_panel = nautilus_information_panel_new ();
- if (window->details->location != NULL &&
- window->details->title != NULL) {
+ if (NAUTILUS_WINDOW (window)->details->location != NULL &&
+ NAUTILUS_WINDOW (window)->details->title != NULL) {
nautilus_information_panel_set_uri (window->information_panel,
- window->details->location,
- window->details->title);
+ NAUTILUS_WINDOW (window)->details->location,
+ NAUTILUS_WINDOW (window)->details->title);
}
g_signal_connect_object (window->information_panel, "location_changed",
@@ -695,222 +355,24 @@ nautilus_window_set_up_sidebar (NautilusWindow *window)
}
static void
-nautilus_window_tear_down_sidebar (NautilusWindow *window)
+nautilus_navigation_window_tear_down_sidebar (NautilusNavigationWindow *window)
{
g_signal_handlers_disconnect_by_func (window->sidebar,
side_pane_switch_page_callback,
window);
-
- nautilus_window_set_sidebar_panels (window, NULL);
+
+ nautilus_navigation_window_set_sidebar_panels (window, NULL);
gtk_widget_destroy (GTK_WIDGET (window->sidebar));
window->sidebar = NULL;
window->information_panel = NULL;
}
static void
-nautilus_window_constructed (NautilusWindow *window)
-{
- GtkWidget *location_bar_box;
- GtkWidget *view_as_menu_vbox;
- BonoboControl *location_bar_wrapper;
-
- nautilus_window_ui_freeze (window);
-
- /* Load the user interface from the XML file. */
- bonobo_ui_util_set_ui (window->details->shell_ui,
- DATADIR,
- "nautilus-shell-ui.xml",
- "nautilus", NULL);
-
- /* set up location bar */
- location_bar_box = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (location_bar_box), GNOME_PAD_SMALL);
-
- window->navigation_bar = nautilus_switchable_navigation_bar_new (window);
- gtk_widget_show (GTK_WIDGET (window->navigation_bar));
-
- g_signal_connect_object (window->navigation_bar, "location_changed",
- G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
- g_signal_connect_object (window->navigation_bar, "mode_changed",
- G_CALLBACK (navigation_bar_mode_changed_callback), window, 0);
-
- gtk_box_pack_start (GTK_BOX (location_bar_box), window->navigation_bar,
- TRUE, TRUE, GNOME_PAD_SMALL);
-
- /* Option menu for content view types; it's empty here, filled in when a uri is set.
- * Pack it into vbox so it doesn't grow vertically when location bar does.
- */
- view_as_menu_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_widget_show (view_as_menu_vbox);
- gtk_box_pack_end (GTK_BOX (location_bar_box), view_as_menu_vbox, FALSE, FALSE, 0);
-
- window->view_as_option_menu = gtk_option_menu_new ();
- gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), window->view_as_option_menu, TRUE, FALSE, 0);
- gtk_widget_show (window->view_as_option_menu);
- /* Make sure there is something in the option menu to prevent it from
- * growing later.
- */
- set_dummy_initial_view_as_menu (window);
-
- /* Allocate the zoom control and place on the right next to the menu.
- * It gets shown later, if the view-frame contains something zoomable.
- */
- window->zoom_control = nautilus_zoom_control_new ();
- g_signal_connect_object (window->zoom_control, "zoom_in",
- G_CALLBACK (nautilus_window_zoom_in),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_out",
- G_CALLBACK (nautilus_window_zoom_out),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_level",
- G_CALLBACK (nautilus_window_zoom_to_level),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_fit",
- G_CALLBACK (nautilus_window_zoom_to_fit),
- window, G_CONNECT_SWAPPED);
- gtk_box_pack_end (GTK_BOX (location_bar_box), window->zoom_control, FALSE, FALSE, 0);
-
- gtk_widget_show (location_bar_box);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- window->content_hbox = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
- } else {
- set_initial_window_geometry (window);
-
- window->content_hbox = nautilus_horizontal_splitter_new ();
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_set_up_sidebar (window);
- }
- }
-
- gtk_widget_show (window->content_hbox);
- bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
-
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- LOCATION_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- TOOLBAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- STATUS_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- MENU_BAR_PATH, TRUE);
- }
-
- /* Wrap the location bar in a control and set it up. */
- location_bar_wrapper = bonobo_control_new (location_bar_box);
- bonobo_ui_component_object_set (window->details->shell_ui,
- "/Location Bar/Wrapper",
- BONOBO_OBJREF (location_bar_wrapper),
- NULL);
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
- bonobo_object_unref (location_bar_wrapper);
-
- /* initalize the menus and toolbars */
- nautilus_window_initialize_menus_part_1 (window);
- nautilus_window_initialize_toolbars (window);
-
- /* We'll do the second part later (bookmarks and go menus) */
- window->details->ui_pending_initialize_menus_part_2 = TRUE;
-
- /* 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);
-
- nautilus_window_allow_burn_cd (window, FALSE);
-
- /* Set up undo manager */
- nautilus_undo_manager_attach (window->application->undo_manager, G_OBJECT (window));
-
- /* Register that things may be dragged from this window */
- nautilus_drag_window_register (GTK_WINDOW (window));
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-nautilus_window_set_property (GObject *object,
- guint arg_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- char *old_name;
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
-
- switch (arg_id) {
- case ARG_APP_ID:
- if (g_value_get_string (value) == NULL) {
- return;
- }
- old_name = bonobo_window_get_name (BONOBO_WINDOW (window));
- bonobo_window_set_name (BONOBO_WINDOW (window), g_value_get_string (value));
- /* This hack of using the time when the name first
- * goes non-NULL to be window-constructed time is
- * completely lame. But it works, so for now we leave
- * it alone.
- */
- if (old_name == NULL) {
- nautilus_window_constructed (window);
- }
- g_free (old_name);
- break;
- case ARG_APP:
- window->application = NAUTILUS_APPLICATION (g_value_get_object (value));
- break;
- }
-}
-
-static void
-nautilus_window_get_property (GObject *object,
- guint arg_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (arg_id) {
- case ARG_APP_ID:
- g_value_set_string_take_ownership (
- value,
- bonobo_window_get_name (BONOBO_WINDOW (object)));
- break;
- case ARG_APP:
- g_value_set_object (value, NAUTILUS_WINDOW (object)->application);
- break;
- }
-}
-
-static void
-free_stored_viewers (NautilusWindow *window)
+nautilus_navigation_window_unrealize (GtkWidget *widget)
{
- eel_g_list_free_deep_custom (window->details->short_list_viewers,
- (GFunc) nautilus_view_identifier_free,
- NULL);
- window->details->short_list_viewers = NULL;
- nautilus_view_identifier_free (window->details->extra_viewer);
- window->details->extra_viewer = NULL;
-}
-
-static void
-nautilus_window_unrealize (GtkWidget *widget)
-{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (widget);
+ window = NAUTILUS_NAVIGATION_WINDOW (widget);
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
@@ -921,13 +383,11 @@ nautilus_window_unrealize (GtkWidget *widget)
}
static void
-nautilus_window_destroy (GtkObject *object)
+nautilus_navigation_window_destroy (GtkObject *object)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (object);
-
- nautilus_window_manage_views_destroy (window);
+ window = NAUTILUS_NAVIGATION_WINDOW (object);
window->sidebar = NULL;
eel_g_object_list_free (window->sidebar_panels);
@@ -935,13 +395,9 @@ nautilus_window_destroy (GtkObject *object)
window->view_as_option_menu = NULL;
window->navigation_bar = NULL;
- window->content_hbox = NULL;
window->zoom_control = NULL;
- if (window->content_view) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
+ window->details->content_paned = NULL;
if (window->details->tooltips) {
g_object_unref (G_OBJECT (window->details->tooltips));
@@ -952,139 +408,156 @@ nautilus_window_destroy (GtkObject *object)
}
static void
-nautilus_window_finalize (GObject *object)
+nautilus_navigation_window_finalize (GObject *object)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (object);
+ window = NAUTILUS_NAVIGATION_WINDOW (object);
- nautilus_window_manage_views_finalize (window);
+ nautilus_navigation_window_remove_bookmarks_menu_callback (window);
+ nautilus_navigation_window_clear_back_list (window);
+ nautilus_navigation_window_clear_forward_list (window);
- nautilus_window_set_viewed_file (window, NULL);
- nautilus_window_remove_bookmarks_menu_callback (window);
- nautilus_window_remove_go_menu_callback (window);
+ g_free (window->details);
- if (window->details->ui_idle_id != 0) {
- g_source_remove (window->details->ui_idle_id);
- }
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
- if (window->details->shell_ui != NULL) {
- bonobo_ui_component_unset_container (window->details->shell_ui, NULL);
- bonobo_object_unref (window->details->shell_ui);
- window->details->shell_ui = NULL;
- }
+/*
+ * Main API
+ */
- if (window->details->status_ui != NULL) {
- bonobo_ui_component_unset_container (window->details->status_ui, NULL);
- bonobo_object_unref (window->details->status_ui);
- window->details->status_ui = NULL;
- }
+void
+nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window,
+ NautilusViewFrame *sidebar_panel)
+{
+ char *label;
+ const char *view_iid;
+ char *default_iid;
- nautilus_file_unref (window->details->viewed_file);
+ g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+ g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
+ g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar));
+ g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL);
- free_stored_viewers (window);
+ label = nautilus_view_frame_get_label (sidebar_panel);
+
+ nautilus_side_pane_add_panel (window->sidebar,
+ GTK_WIDGET (sidebar_panel),
+ label);
+ g_free (label);
- g_free (window->details->location);
- eel_g_list_free_deep (window->details->selection);
- eel_g_list_free_deep (window->details->pending_selection);
+ g_object_ref (sidebar_panel);
+ window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel);
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
+ view_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
+ default_iid = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW);
- if (window->current_location_bookmark != NULL) {
- g_object_unref (window->current_location_bookmark);
- }
- if (window->last_location_bookmark != NULL) {
- g_object_unref (window->last_location_bookmark);
- }
+ if (view_iid && default_iid && !strcmp (view_iid, default_iid)) {
+ nautilus_side_pane_show_panel (window->sidebar,
+ GTK_WIDGET (sidebar_panel));
+ }
- bonobo_object_unref (window->details->ui_container);
+ g_free (default_iid);
+}
- if (window->details->location_change_at_idle_id != 0) {
- g_source_remove (window->details->location_change_at_idle_id);
- }
+void
+nautilus_navigation_window_remove_sidebar_panel (NautilusNavigationWindow *window, NautilusViewFrame *sidebar_panel)
+{
+ g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+ g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
- g_free (window->details->title);
-
- g_free (window->details);
+ if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL) {
+ return;
+ }
- g_free (window->last_geometry);
+ nautilus_side_pane_remove_panel (window->sidebar,
+ GTK_WIDGET (sidebar_panel));
+ window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel);
+ g_object_unref (sidebar_panel);
+}
- G_OBJECT_CLASS (parent_class)->finalize (object);
+void
+nautilus_navigation_window_go_back (NautilusNavigationWindow *window)
+{
+ nautilus_navigation_window_back_or_forward (window, TRUE, 0);
}
void
-nautilus_window_save_geometry (NautilusWindow *window)
+nautilus_navigation_window_go_forward (NautilusNavigationWindow *window)
{
- char *geometry_string;
+ nautilus_navigation_window_back_or_forward (window, FALSE, 0);
+}
- g_assert (NAUTILUS_IS_WINDOW (window));
+void
+nautilus_navigation_window_set_search_mode (NautilusNavigationWindow *window,
+ gboolean search_mode)
+{
+ nautilus_switchable_navigation_bar_set_mode
+ (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar),
+ search_mode
+ ? NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH
+ : NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION);
+}
- if (GTK_WIDGET(window)->window &&
- !(gdk_window_get_state (GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
- geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
-
- nautilus_file_set_metadata (window->details->viewed_file,
- NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
- NULL,
- geometry_string);
-
- g_free (geometry_string);
- }
+gboolean
+nautilus_navigation_window_get_search_mode (NautilusNavigationWindow *window)
+{
+ return nautilus_switchable_navigation_bar_get_mode
+ (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar))
+ == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH;
}
void
-nautilus_window_close (NautilusWindow *window)
+nautilus_navigation_window_go_home (NautilusNavigationWindow *window)
{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+ char *home_uri;
+
+ nautilus_navigation_window_set_search_mode (window, FALSE);
- gtk_widget_destroy (GTK_WIDGET (window));
+#ifdef WEB_NAVIGATION_ENABLED
+ home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
+#else
+ home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+#endif
+
+ g_assert (home_uri != NULL);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), home_uri);
+ g_free (home_uri);
}
-static void
-nautilus_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GdkScreen *screen;
- guint max_width;
- guint max_height;
-
- g_assert (NAUTILUS_IS_WINDOW (widget));
- g_assert (requisition != NULL);
-
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
-
- screen = gtk_window_get_screen (GTK_WINDOW (widget));
-
- /* Limit the requisition to be within 90% of the available screen
- * real state.
- *
- * This way the user will have a fighting chance of getting
- * control of their window back if for whatever reason one of the
- * window's descendants decide they want to be 4000 pixels wide.
- *
- * Note that the user can still make the window really huge by hand.
- *
- * Bugs in components or other widgets that cause such huge geometries
- * to be requested, should still be fixed. This code is here only to
- * prevent the extremely frustrating consequence of such bugs.
+void
+nautilus_navigation_window_allow_back (NautilusNavigationWindow *window, gboolean allow)
+{
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
+
+ nautilus_bonobo_set_sensitive (NAUTILUS_WINDOW (window)->details->shell_ui,
+ NAUTILUS_COMMAND_BACK, allow);
+ /* Have to handle non-standard Back button explicitly (it's
+ * non-standard to support right-click menu).
*/
- max_width = get_max_forced_width (screen);
- max_height = get_max_forced_height (screen);
+ gtk_widget_set_sensitive
+ (GTK_WIDGET (window->details->back_button_item), allow);
- if (requisition->width > (int) max_width) {
- requisition->width = max_width;
- }
-
- if (requisition->height > (int) max_height) {
- requisition->height = max_height;
- }
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
+void
+nautilus_navigation_window_allow_forward (NautilusNavigationWindow *window, gboolean allow)
+{
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
-/*
- * Main API
- */
+ nautilus_bonobo_set_sensitive (NAUTILUS_WINDOW (window)->details->shell_ui,
+ NAUTILUS_COMMAND_FORWARD, allow);
+
+ /* Have to handle non-standard Forward button explicitly (it's
+ * non-standard to support right-click menu).
+ */
+ gtk_widget_set_sensitive
+ (GTK_WIDGET (window->details->forward_button_item), allow);
+
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
+}
static void
activate_nth_short_list_item (NautilusWindow *window, guint index)
@@ -1106,40 +579,6 @@ activate_extra_viewer (NautilusWindow *window)
}
static void
-handle_view_as_item_from_bonobo_menu (NautilusWindow *window, const char *id)
-{
- char *container_path;
-
- container_path = nautilus_bonobo_get_numbered_menu_item_container_path_from_command (id);
-
- if (eel_strcmp (container_path, NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER) == 0) {
- activate_nth_short_list_item
- (window,
- nautilus_bonobo_get_numbered_menu_item_index_from_command (id));
- } else if (eel_strcmp (container_path, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER) == 0) {
- g_return_if_fail
- (nautilus_bonobo_get_numbered_menu_item_index_from_command (id) == 0);
- activate_extra_viewer (window);
- }
-
- g_free (container_path);
-}
-
-void
-nautilus_window_handle_ui_event_callback (BonoboUIComponent *ui,
- const char *id,
- Bonobo_UIComponent_EventType type,
- const char *state,
- NautilusWindow *window)
-{
- if (!window->details->updating_bonobo_state
- && type == Bonobo_UIComponent_STATE_CHANGED
- && strcmp (state, "1") == 0) {
- handle_view_as_item_from_bonobo_menu (window, id);
- }
-}
-
-static void
view_as_menu_switch_views_callback (GtkWidget *widget, gpointer data)
{
NautilusWindow *window;
@@ -1194,222 +633,6 @@ new_gtk_separator (void)
}
static void
-add_view_as_bonobo_menu_item (NautilusWindow *window,
- const char *placeholder_path,
- NautilusViewIdentifier *identifier,
- int index)
-{
- char *tip;
- char *item_path;
-
- nautilus_bonobo_add_numbered_radio_menu_item
- (window->details->shell_ui,
- placeholder_path,
- index,
- identifier->view_as_label_with_mnemonic,
- "viewers group");
-
- tip = g_strdup_printf (_("Display this location with \"%s\""),
- identifier->viewer_label);
- item_path = nautilus_bonobo_get_numbered_menu_item_path
- (window->details->shell_ui,
- placeholder_path,
- index);
- nautilus_bonobo_set_tip (window->details->shell_ui, item_path, tip);
- g_free (item_path);
- g_free (tip);
-}
-
-static void
-remove_first_child (GtkContainer *container)
-{
- gtk_container_remove (container,
- eel_gtk_container_get_first_child (container));
-}
-
-/* Make a special first item in the "View as" option menu that represents
- * the current content view. This should only be called if the current
- * content view isn't already in the "View as" option menu.
- */
-static void
-update_extra_viewer_in_view_as_menus (NautilusWindow *window,
- const NautilusViewIdentifier *id)
-{
- GtkWidget *menu;
- GtkWidget *new_menu_item;
- gboolean had_extra_viewer;
-
- had_extra_viewer = window->details->extra_viewer != NULL;
-
- if (id == NULL) {
- if (!had_extra_viewer) {
- return;
- }
- } else {
- if (had_extra_viewer
- && nautilus_view_identifier_compare (window->details->extra_viewer, id) == 0) {
- return;
- }
- }
- nautilus_view_identifier_free (window->details->extra_viewer);
- window->details->extra_viewer = nautilus_view_identifier_copy (id);
-
- /* Update the View As option menu */
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove menu before changing contents so it is resized properly
- * when reattached later in this function.
- */
- g_object_ref (menu);
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove old menu item, and either remove or add separator. */
- if (had_extra_viewer) {
- remove_first_child (GTK_CONTAINER (menu));
- if (id == NULL) {
- remove_first_child (GTK_CONTAINER (menu));
- }
- } else {
- if (id != NULL) {
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_gtk_separator ());
- }
- }
-
- /* Add new menu item. */
- if (id != NULL) {
- new_menu_item = create_view_as_menu_item (window, window->details->extra_viewer, 0);
- g_object_set_data (G_OBJECT (new_menu_item), "extra viewer", GINT_TO_POINTER (TRUE));
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_menu_item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu), menu);
- g_object_unref (menu);
-
- /* Also update the Bonobo View menu item */
- if (id == NULL) {
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER);
- } else {
- add_view_as_bonobo_menu_item (window,
- NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER,
- window->details->extra_viewer,
- 0);
- }
-}
-
-static void
-remove_extra_viewer_in_view_as_menus (NautilusWindow *window)
-{
- update_extra_viewer_in_view_as_menus (window, NULL);
-}
-
-static void
-replace_extra_viewer_in_view_as_menus (NautilusWindow *window)
-{
- NautilusViewIdentifier *id;
-
- id = nautilus_window_get_content_view_id (window);
- update_extra_viewer_in_view_as_menus (window, id);
- nautilus_view_identifier_free (id);
-}
-
-/**
- * nautilus_window_synch_view_as_menus:
- *
- * Set the visible item of the "View as" option menu and
- * the marked "View as" item in the View menu to
- * match the current content view.
- *
- * @window: The NautilusWindow whose "View as" option menu should be synched.
- */
-void
-nautilus_window_synch_view_as_menus (NautilusWindow *window)
-{
- int index;
- char *verb_name, *command_path;
- GList *node;
- const char *numbered_menu_item_container_path;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- if (window->content_view == NULL) {
- return;
- }
-
- for (node = window->details->short_list_viewers, index = 0;
- node != NULL;
- node = node->next, ++index) {
- if (nautilus_window_content_view_matches_iid (window, ((NautilusViewIdentifier *)node->data)->iid)) {
- break;
- }
- }
- if (node == NULL) {
- replace_extra_viewer_in_view_as_menus (window);
- index = 0;
- numbered_menu_item_container_path = NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER;
- } else {
- remove_extra_viewer_in_view_as_menus (window);
- numbered_menu_item_container_path = NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER;
- }
-
- g_assert (numbered_menu_item_container_path != NULL);
-
- /* Make option menu show the right item */
- gtk_option_menu_set_history (GTK_OPTION_MENU (window->view_as_option_menu), index);
-
- /* Make View menu in menu bar mark the right item */
- verb_name = nautilus_bonobo_get_numbered_menu_item_command
- (window->details->shell_ui,
- numbered_menu_item_container_path, index);
- command_path = g_strconcat (COMMAND_PREFIX, verb_name, NULL);
- nautilus_bonobo_set_toggle_state (window->details->shell_ui, command_path, TRUE);
- g_free (command_path);
- g_free (verb_name);
-}
-
-static void
-chose_component_callback (NautilusViewIdentifier *identifier, gpointer callback_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
- if (identifier != NULL) {
- nautilus_window_set_content_view (window, identifier);
- }
-
- /* FIXME bugzilla.gnome.org 41334: There should be some global
- * way to signal that the file type associations have changed,
- * so that the places that display these lists can react. For
- * now, hardwire this case, which is the most obvious one by
- * far.
- */
- nautilus_window_load_view_as_menus (window);
-}
-
-static void
-cancel_chose_component_callback (NautilusWindow *window)
-{
- if (window->details->viewed_file != NULL) {
- nautilus_cancel_choose_component_for_file (window->details->viewed_file,
- chose_component_callback,
- window);
- }
-}
-
-void
-nautilus_window_show_view_as_dialog (NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- /* Call back when the user chose the component. */
- cancel_chose_component_callback (window);
- nautilus_choose_component_for_file (window->details->viewed_file,
- GTK_WINDOW (window),
- chose_component_callback,
- window);
-}
-
-static void
view_as_menu_choose_view_callback (GtkWidget *widget, gpointer data)
{
NautilusWindow *window;
@@ -1427,53 +650,19 @@ view_as_menu_choose_view_callback (GtkWidget *widget, gpointer data)
* the user never sees the option menu set to "View as
* Other...".
*/
- nautilus_window_synch_view_as_menus (window);
+ load_view_as_menu (window);
nautilus_window_show_view_as_dialog (window);
}
static void
-refresh_stored_viewers (NautilusWindow *window)
+load_view_as_menu (NautilusWindow *window)
{
- GList *components, *node, *viewers;
- NautilusViewIdentifier *identifier;
-
- components = nautilus_mime_get_short_list_components_for_file (window->details->viewed_file);
- viewers = NULL;
- for (node = components; node != NULL; node = node->next) {
- identifier = nautilus_view_identifier_new_from_content_view (node->data);
- viewers = g_list_prepend (viewers, identifier);
- }
- gnome_vfs_mime_component_list_free (components);
-
- free_stored_viewers (window);
- window->details->short_list_viewers = g_list_reverse (viewers);
-}
-
-static void
-load_view_as_menus_callback (NautilusFile *file,
- gpointer callback_data)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
- GList *node;
- NautilusWindow *window;
+ GtkWidget *new_menu;
+ GtkWidget *menu_item;
+ GList *node;
int index;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- g_assert (GTK_IS_OPTION_MENU (window->view_as_option_menu));
-
- /* Clear out the menu items created last time. For the option menu, we need do
- * nothing since we replace the entire menu. For the View menu, we have
- * to do this explicitly.
- */
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER);
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER);
-
- refresh_stored_viewers (window);
+ int selected_index = -1;
new_menu = gtk_menu_new ();
@@ -1487,20 +676,27 @@ load_view_as_menus_callback (NautilusFile *file,
menu_item = create_view_as_menu_item (window, node->data, index);
gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
- /* Menu item in View menu. */
- add_view_as_bonobo_menu_item (window,
- NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER,
- node->data,
- index);
+ if (nautilus_window_content_view_matches_iid (NAUTILUS_WINDOW (window), ((NautilusViewIdentifier *)node->data)->iid)) {
+ selected_index = index;
+ }
}
+ if (selected_index == -1) {
+ NautilusViewIdentifier *id;
+ /* We're using an extra viewer, add a menu item for it */
+
+ id = nautilus_window_get_content_view_id (window);
+ menu_item = create_view_as_menu_item (window, id, index);
+ nautilus_view_identifier_free (id);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
+ selected_index = index;
+ }
+
/* Add/Show separator before "View as..." if there are any other viewers in menu. */
if (window->details->short_list_viewers != NULL) {
gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), new_gtk_separator ());
}
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR,
- window->details->short_list_viewers == NULL);
/* Add "View as..." extra bonus choice. */
menu_item = gtk_menu_item_new_with_label (_("View as..."));
@@ -1512,483 +708,578 @@ load_view_as_menus_callback (NautilusFile *file,
/* We create and attach a new menu here because adding/removing
* items from existing menu screws up the size of the option menu.
*/
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (NAUTILUS_NAVIGATION_WINDOW (window)->view_as_option_menu),
new_menu);
- nautilus_window_synch_view_as_menus (window);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (NAUTILUS_NAVIGATION_WINDOW (window)->view_as_option_menu), selected_index);
}
static void
-cancel_view_as_callback (NautilusWindow *window)
+real_load_view_as_menu (NautilusWindow *window)
{
- nautilus_file_cancel_call_when_ready (window->details->viewed_file,
- load_view_as_menus_callback,
- window);
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
+ load_view_as_menu, (window));
+
+ load_view_as_menu (window);
}
-void
-nautilus_window_load_view_as_menus (NautilusWindow *window)
+static void
+real_set_title (NautilusWindow *window, const char *title)
{
- NautilusFileAttributes attributes;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+ char *full_title;
+ char *window_title;
+
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
+ set_title, (window, title));
+ full_title = g_strdup_printf (_("File Browser: %s"), title);
- attributes = nautilus_mime_actions_get_full_file_attributes ();
+ window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH);
+ gtk_window_set_title (GTK_WINDOW (window), window_title);
+ g_free (window_title);
+ g_free (full_title);
- cancel_view_as_callback (window);
- nautilus_file_call_when_ready (window->details->viewed_file,
- attributes,
- load_view_as_menus_callback,
- window);
+ if (NAUTILUS_NAVIGATION_WINDOW (window)->information_panel) {
+ nautilus_information_panel_set_title
+ (NAUTILUS_NAVIGATION_WINDOW (window)->information_panel, title);
+ }
}
-void
-nautilus_window_add_sidebar_panel (NautilusWindow *window,
- NautilusViewFrame *sidebar_panel)
+static void
+real_merge_menus (NautilusWindow *nautilus_window)
{
- char *label;
- const char *view_iid;
- char *default_iid;
+ NautilusNavigationWindow *window;
+ GtkWidget *location_bar_box;
+ GtkWidget *view_as_menu_vbox;
+ BonoboControl *location_bar_wrapper;
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
- g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar));
- g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL);
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
+ merge_menus, (nautilus_window));
- label = nautilus_view_frame_get_label (sidebar_panel);
+ window = NAUTILUS_NAVIGATION_WINDOW (nautilus_window);
- nautilus_side_pane_add_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel),
- label);
- g_free (label);
+ bonobo_ui_util_set_ui (NAUTILUS_WINDOW (window)->details->shell_ui,
+ DATADIR,
+ "nautilus-navigation-window-ui.xml",
+ "nautilus", NULL);
- g_object_ref (sidebar_panel);
- window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel);
+ bonobo_ui_component_freeze
+ (NAUTILUS_WINDOW (window)->details->shell_ui, NULL);
- view_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
- default_iid = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW);
+ nautilus_navigation_window_initialize_menus_part_1 (window);
+ nautilus_navigation_window_initialize_toolbars (window);
- if (view_iid && default_iid && !strcmp (view_iid, default_iid)) {
- nautilus_side_pane_show_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- }
+ /* Set initial sensitivity of some buttons & menu items
+ * now that they're all created.
+ */
+ nautilus_navigation_window_allow_back (window, FALSE);
+ nautilus_navigation_window_allow_forward (window, FALSE);
- g_free (default_iid);
-}
+ /* set up location bar */
+ location_bar_box = gtk_hbox_new (FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (location_bar_box), GNOME_PAD_SMALL);
+
+ window->navigation_bar = nautilus_switchable_navigation_bar_new (window);
+ gtk_widget_show (GTK_WIDGET (window->navigation_bar));
-void
-nautilus_window_remove_sidebar_panel (NautilusWindow *window, NautilusViewFrame *sidebar_panel)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
+ g_signal_connect_object (window->navigation_bar, "location_changed",
+ G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
+ g_signal_connect_object (window->navigation_bar, "mode_changed",
+ G_CALLBACK (navigation_bar_mode_changed_callback), window, 0);
- if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL) {
- return;
- }
+ gtk_box_pack_start (GTK_BOX (location_bar_box), window->navigation_bar,
+ TRUE, TRUE, GNOME_PAD_SMALL);
+
+ /* Option menu for content view types; it's empty here, filled in when a uri is set.
+ * Pack it into vbox so it doesn't grow vertically when location bar does.
+ */
+ view_as_menu_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_widget_show (view_as_menu_vbox);
+ gtk_box_pack_end (GTK_BOX (location_bar_box), view_as_menu_vbox, FALSE, FALSE, 0);
- nautilus_side_pane_remove_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel);
- g_object_unref (sidebar_panel);
-}
+ window->view_as_option_menu = gtk_option_menu_new ();
+ gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), window->view_as_option_menu, TRUE, FALSE, 0);
+ gtk_widget_show (window->view_as_option_menu);
-void
-nautilus_window_go_back (NautilusWindow *window)
-{
- nautilus_window_back_or_forward (window, TRUE, 0);
+ /* Allocate the zoom control and place on the right next to the menu.
+ * It gets shown later, if the view-frame contains something zoomable.
+ */
+ window->zoom_control = nautilus_zoom_control_new ();
+ g_signal_connect_object (window->zoom_control, "zoom_in",
+ G_CALLBACK (nautilus_window_zoom_in),
+ window, G_CONNECT_SWAPPED);
+ g_signal_connect_object (window->zoom_control, "zoom_out",
+ G_CALLBACK (nautilus_window_zoom_out),
+ window, G_CONNECT_SWAPPED);
+ g_signal_connect_object (window->zoom_control, "zoom_to_level",
+ G_CALLBACK (nautilus_window_zoom_to_level),
+ window, G_CONNECT_SWAPPED);
+ g_signal_connect_object (window->zoom_control, "zoom_to_fit",
+ G_CALLBACK (nautilus_window_zoom_to_fit),
+ window, G_CONNECT_SWAPPED);
+ gtk_box_pack_end (GTK_BOX (location_bar_box), window->zoom_control, FALSE, FALSE, 0);
+
+ gtk_widget_show (location_bar_box);
+
+ /* Wrap the location bar in a control and set it up. */
+ location_bar_wrapper = bonobo_control_new (location_bar_box);
+ bonobo_ui_component_object_set (NAUTILUS_WINDOW (window)->details->shell_ui,
+ "/Location Bar/Wrapper",
+ BONOBO_OBJREF (location_bar_wrapper),
+ NULL);
+
+ bonobo_object_unref (location_bar_wrapper);
+
+
+#ifndef HAVE_MEDUSA
+ /* Hide medusa menu items if medusa is not installed */
+ nautilus_bonobo_set_hidden (NAUTILUS_WINDOW (window)->details->shell_ui,
+ COMMAND_PATH_TOGGLE_FIND_MODE,
+ TRUE);
+ nautilus_bonobo_set_hidden (NAUTILUS_WINDOW (window)->details->shell_ui,
+ COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE,
+ TRUE);
+ /* Also set these items insensitive so that keyboard shortcuts do not trigger
+ warnings */
+ nautilus_bonobo_set_sensitive (NAUTILUS_WINDOW (window)->details->shell_ui,
+ COMMAND_PATH_TOGGLE_FIND_MODE,
+ FALSE);
+ nautilus_bonobo_set_sensitive (NAUTILUS_WINDOW (window)->details->shell_ui,
+ COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE,
+ FALSE);
+#endif
+
+ bonobo_ui_component_thaw (NAUTILUS_WINDOW (window)->details->shell_ui,
+ NULL);
}
-void
-nautilus_window_go_forward (NautilusWindow *window)
+static void
+zoom_level_changed_callback (NautilusViewFrame *view,
+ NautilusNavigationWindow *window)
{
- nautilus_window_back_or_forward (window, FALSE, 0);
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ /* This is called each time the component successfully completed
+ * a zooming operation.
+ */
+ nautilus_zoom_control_set_zoom_level (NAUTILUS_ZOOM_CONTROL (window->zoom_control),
+ nautilus_view_frame_get_zoom_level (view));
}
-void
-nautilus_window_go_up (NautilusWindow *window)
+static void
+zoom_parameters_changed_callback (NautilusViewFrame *view,
+ NautilusNavigationWindow *window)
{
- GnomeVFSURI *current_uri;
- GnomeVFSURI *parent_uri;
- GList *selection;
- char *parent_uri_string;
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
- if (window->details->location == NULL) {
- return;
- }
-
- current_uri = gnome_vfs_uri_new (window->details->location);
- parent_uri = gnome_vfs_uri_get_parent (current_uri);
- gnome_vfs_uri_unref (current_uri);
+ /* This callback is invoked via the "zoom_parameters_changed"
+ * signal of the BonoboZoomableFrame.
+ *
+ * You can rely upon this callback being called in the following
+ * situations:
+ *
+ * - a zoomable component has been set in the NautilusViewFrame;
+ * in this case nautilus_view_frame_set_to_component() emits the
+ * "zoom_parameters_changed" signal after creating the
+ * BonoboZoomableFrame and binding it to the Bonobo::Zoomable.
+ *
+ * This means that we can use the following call to
+ * nautilus_zoom_control_set_parameters() to display the zoom
+ * control when a new zoomable component has been loaded.
+ *
+ * - a new file has been loaded by the zoomable component; this is
+ * not 100% guaranteed since it's up to the component to emit this
+ * signal, but I consider it "good behaviour" of a component to
+ * emit this signal after loading a new file.
+ */
- if (parent_uri == NULL) {
- g_warning ("Can't go Up from here. The UI should have prevented us from getting this far.");
- return;
- }
-
- parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (parent_uri);
+ nautilus_zoom_control_set_parameters
+ (NAUTILUS_ZOOM_CONTROL (window->zoom_control),
+ nautilus_view_frame_get_min_zoom_level (view),
+ nautilus_view_frame_get_max_zoom_level (view),
+ nautilus_view_frame_get_has_min_zoom_level (view),
+ nautilus_view_frame_get_has_max_zoom_level (view),
+ nautilus_view_frame_get_preferred_zoom_levels (view));
- selection = g_list_prepend (NULL, g_strdup (window->details->location));
-
- nautilus_window_open_location_with_selection (window, parent_uri_string, selection);
-
- g_free (parent_uri_string);
- eel_g_list_free_deep (selection);
+ /* "zoom_parameters_changed" always implies "zoom_level_changed",
+ * but you won't get both signals, so we need to pass it down.
+ */
+ zoom_level_changed_callback (view, window);
}
-void
-nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode)
+static void
+connect_view (NautilusNavigationWindow *window, NautilusViewFrame *view)
{
- nautilus_switchable_navigation_bar_set_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar),
- search_mode
- ? NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH
- : NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION);
-
-
+ g_signal_connect (view, "zoom_parameters_changed",
+ G_CALLBACK (zoom_parameters_changed_callback),
+ window);
+ g_signal_connect (view, "zoom_level_changed",
+ G_CALLBACK (zoom_level_changed_callback),
+ window);
}
-gboolean
-nautilus_window_get_search_mode (NautilusWindow *window)
+static void
+disconnect_view (NautilusNavigationWindow *window, NautilusViewFrame *view)
{
- return nautilus_switchable_navigation_bar_get_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar))
- == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH;
+ if (!view) {
+ return;
+ }
+
+ g_signal_handlers_disconnect_by_func
+ (G_OBJECT (view),
+ G_CALLBACK (zoom_parameters_changed_callback),
+ window);
+ g_signal_handlers_disconnect_by_func
+ (view,
+ G_CALLBACK (zoom_level_changed_callback),
+ window);
}
-void
-nautilus_window_go_home (NautilusWindow *window)
+static void
+real_set_content_view_widget (NautilusWindow *nautilus_window,
+ NautilusViewFrame *new_view)
{
- char *home_uri;
+ NautilusNavigationWindow *window;
+
+ window = NAUTILUS_NAVIGATION_WINDOW (nautilus_window);
+
+ disconnect_view (window, nautilus_window->content_view);
- nautilus_window_set_search_mode (window, FALSE);
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
+ set_content_view_widget,
+ (nautilus_window, new_view));
-#ifdef WEB_NAVIGATION_ENABLED
- home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
-#else
- home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-#endif
-
- g_assert (home_uri != NULL);
- nautilus_window_go_to (window, home_uri);
- g_free (home_uri);
-}
+ connect_view (window, new_view);
-void
-nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
+ nautilus_horizontal_splitter_pack2 (
+ NAUTILUS_HORIZONTAL_SPLITTER (window->details->content_paned),
+ GTK_WIDGET (new_view));
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_BACK, allow);
- /* Have to handle non-standard Back button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->back_button_item), allow);
+ if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) {
+ gtk_widget_show (window->zoom_control);
+ } else {
+ gtk_widget_hide (window->zoom_control);
+ }
- nautilus_window_ui_thaw (window);
+ /* Update displayed view in menu. Only do this if we're not switching
+ * locations though, because if we are switching locations we'll
+ * install a whole new set of views in the menu later (the current
+ * views in the menu are for the old location).
+ */
+ if (nautilus_window->details->pending_location == NULL) {
+ load_view_as_menu (nautilus_window);
+ }
}
-void
-nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
+static void
+real_set_throbber_active (NautilusWindow *window, gboolean active)
{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_FORWARD, allow);
- /* Have to handle non-standard Forward button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->forward_button_item), allow);
-
- nautilus_window_ui_thaw (window);
+ nautilus_navigation_window_set_throbber_active
+ (NAUTILUS_NAVIGATION_WINDOW (window), active);
}
-void
-nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
+static void
+nautilus_navigation_window_show_location_bar_temporarily (NautilusNavigationWindow *window,
+ gboolean in_search_mode)
{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_UP, allow);
-
- nautilus_window_ui_thaw (window);
+ if (!nautilus_navigation_window_location_bar_showing (window)) {
+ nautilus_navigation_window_show_location_bar (window, FALSE);
+ window->details->temporary_navigation_bar = TRUE;
+ }
+ nautilus_navigation_window_set_search_mode
+ (window, in_search_mode);
+ nautilus_switchable_navigation_bar_activate
+ (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar));
}
-void
-nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
+static void
+real_prompt_for_location (NautilusWindow *window)
{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_RELOAD, allow);
-
- nautilus_window_ui_thaw (window);
+ if (!window->details->updating_bonobo_state) {
+ nautilus_navigation_window_show_location_bar_temporarily (NAUTILUS_NAVIGATION_WINDOW (window), FALSE);
+ }
}
void
-nautilus_window_allow_burn_cd (NautilusWindow *window, gboolean allow)
+nautilus_navigation_window_clear_forward_list (NautilusNavigationWindow *window)
{
- nautilus_window_ui_freeze (window);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_COMMAND_BURN_CD, !allow);
- nautilus_window_ui_thaw (window);
+ eel_g_object_list_free (window->forward_list);
+ window->forward_list = NULL;
}
void
-nautilus_send_history_list_changed (void)
+nautilus_navigation_window_clear_back_list (NautilusNavigationWindow *window)
{
- g_signal_emit_by_name (nautilus_signaller_get_current (),
- "history_list_changed");
+ eel_g_object_list_free (window->back_list);
+ window->back_list = NULL;
}
-static void
-free_history_list (void)
+static int
+compare_view_identifier_with_iid (gconstpointer passed_view_identifier,
+ gconstpointer passed_iid)
{
- eel_g_object_list_free (history_list);
- history_list = NULL;
+ return strcmp (((NautilusViewIdentifier *) passed_view_identifier)->iid,
+ (char *) passed_iid);
}
-/* Remove the this URI from the history list.
- * Do not sent out a change notice.
- * We pass in a bookmark for convenience.
- */
static void
-remove_from_history_list (NautilusBookmark *bookmark)
+disconnect_and_destroy_sidebar_panel (NautilusNavigationWindow *window,
+ NautilusViewFrame *view)
{
- GList *node;
+ g_object_ref (view);
- /* Compare only the uris here. Comparing the names also is not
- * necessary and can cause problems due to the asynchronous
- * nature of when the title of the window is set.
- */
- node = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
-
- /* Remove any older entry for this same item. There can be at most 1. */
- if (node != NULL) {
- history_list = g_list_remove_link (history_list, node);
- g_object_unref (node->data);
- g_list_free_1 (node);
- }
+ g_signal_handlers_disconnect_by_func
+ (view,
+ G_CALLBACK (side_panel_view_failed_callback),
+ window);
+ g_signal_handlers_disconnect_by_func
+ (view,
+ G_CALLBACK (side_panel_view_loaded_callback),
+ window);
+
+ nautilus_window_disconnect_extra_view (NAUTILUS_WINDOW (window), view);
+ nautilus_navigation_window_remove_sidebar_panel (window, view);
+ gtk_object_destroy (GTK_OBJECT (view));
+ g_object_unref (view);
}
static void
-add_to_history_list (NautilusBookmark *bookmark)
+set_side_panel_image (NautilusWindow *window,
+ NautilusViewFrame *side_panel,
+ const char *image_name)
{
- /* Note that the history is shared amongst all windows so
- * this is not a NautilusWindow function. Perhaps it belongs
- * in its own file.
- */
- int i;
- GList *l, *next;
- static gboolean free_history_list_is_set_up;
-
- g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
+ GdkPixbuf *pixbuf;
+ char *image_path;
- if (!free_history_list_is_set_up) {
- eel_debug_call_at_shutdown (free_history_list);
- free_history_list_is_set_up = TRUE;
- }
-
-/* g_warning ("Add to history list '%s' '%s'",
- nautilus_bookmark_get_name (bookmark),
- nautilus_bookmark_get_uri (bookmark)); */
-
- if (!history_list ||
- nautilus_bookmark_compare_uris (history_list->data, bookmark)) {
- g_object_ref (bookmark);
- remove_from_history_list (bookmark);
- history_list = g_list_prepend (history_list, bookmark);
-
- for (i = 0, l = history_list; l; l = next) {
- next = l->next;
-
- if (i++ >= MAX_HISTORY_ITEMS) {
- g_object_unref (l->data);
- history_list = g_list_delete_link (history_list, l);
- }
- }
+ pixbuf = NULL;
+
+ if (image_name && image_name[0]) {
+ image_path = nautilus_theme_get_image_path (image_name);
+ if (image_path) {
+ pixbuf = gdk_pixbuf_new_from_file (image_path, NULL);
+ g_free (image_path);
+ }
+ }
- nautilus_send_history_list_changed ();
- }
+ nautilus_side_pane_set_panel_image (NAUTILUS_NAVIGATION_WINDOW (window)->sidebar,
+ GTK_WIDGET (side_panel),
+ pixbuf);
+
+ if (pixbuf) {
+ g_object_unref (pixbuf);
+ }
}
-void
-nautilus_remove_from_history_list_no_notify (const char *uri)
+static void
+side_panel_image_changed_callback (BonoboListener *listener,
+ const char *event_name,
+ const CORBA_any *arg,
+ CORBA_Environment *ev,
+ gpointer callback_data)
{
- NautilusBookmark *bookmark;
+ NautilusViewFrame *side_panel;
+ NautilusWindow *window;
- bookmark = nautilus_bookmark_new (uri, "");
- remove_from_history_list (bookmark);
- g_object_unref (bookmark);
+ side_panel = NAUTILUS_VIEW_FRAME (callback_data);
+ window = NAUTILUS_WINDOW (g_object_get_data (G_OBJECT (side_panel),
+ "nautilus-window"));
+
+ set_side_panel_image (window, side_panel, BONOBO_ARG_GET_STRING (arg));
}
static void
-real_add_current_location_to_history_list (NautilusWindow *window)
+report_side_panel_failure_to_user (NautilusWindow *window, NautilusViewFrame *view_frame)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ char *message;
+ char *label;
- add_to_history_list (window->current_location_bookmark);
-}
+ label = nautilus_window_get_view_frame_label (view_frame);
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
-}
+ if (label == NULL) {
+ message = g_strdup
+ (_("One of the side panels encountered an error and can't continue. "
+ "Unfortunately I couldn't tell which one."));
+ } else {
+ message = g_strdup_printf
+ (_("The %s side panel encountered an error and can't continue. "
+ "If this keeps happening, you might want to turn this panel off."),
+ label);
+ }
-void
-nautilus_window_clear_forward_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->forward_list);
- window->forward_list = NULL;
-}
+ eel_show_error_dialog (message, _("Side Panel Failed"), GTK_WINDOW (window));
-void
-nautilus_window_clear_back_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->back_list);
- window->back_list = NULL;
+ g_free (label);
+ g_free (message);
}
-void
-nautilus_forget_history (void)
+static void
+side_panel_view_failed_callback (NautilusViewFrame *view,
+ gpointer user_data)
{
- GList *window_node;
NautilusWindow *window;
+ const char *current_iid;
+
+ g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged.");
- /* Clear out each window's back & forward lists. Also, remove
- * each window's current location bookmark from history list
- * so it doesn't get clobbered.
- */
- for (window_node = nautilus_application_get_window_list ();
- window_node != NULL;
- window_node = window_node->next) {
-
- window = NAUTILUS_WINDOW (window_node->data);
-
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
- nautilus_window_allow_back (window, FALSE);
- nautilus_window_allow_forward (window, FALSE);
-
- history_list = g_list_remove (history_list, window->current_location_bookmark);
- }
-
- /* Clobber history list. */
- free_history_list ();
-
- /* Re-add each window's current location to history list. */
- for (window_node = nautilus_application_get_window_list ();
- window_node != NULL;
- window_node = window_node->next) {
+ window = NAUTILUS_WINDOW (user_data);
- window = NAUTILUS_WINDOW (window_node->data);
- nautilus_window_add_current_location_to_history_list (window);
- }
+ report_side_panel_failure_to_user (window, view);
+ current_iid = nautilus_view_frame_get_view_iid (view);
+ disconnect_and_destroy_sidebar_panel (NAUTILUS_NAVIGATION_WINDOW (window), view);
}
-GList *
-nautilus_get_history_list (void)
+static void
+connect_side_panel (NautilusWindow *window,
+ NautilusViewFrame *side_panel)
{
- return history_list;
+ Bonobo_Control control;
+ Bonobo_PropertyBag property_bag;
+ CORBA_Environment ev;
+ char *image_name;
+
+ g_object_set_data (G_OBJECT (side_panel),
+ "nautilus-window",
+ window);
+
+ control = nautilus_view_frame_get_control (side_panel);
+
+ g_signal_connect_object (side_panel,
+ "failed",
+ G_CALLBACK (side_panel_view_failed_callback),
+ window, 0);
+
+ if (control != CORBA_OBJECT_NIL) {
+ CORBA_exception_init (&ev);
+ property_bag = Bonobo_Control_getProperties (control, &ev);
+ if (property_bag != CORBA_OBJECT_NIL) {
+ bonobo_event_source_client_add_listener
+ (property_bag,
+ side_panel_image_changed_callback,
+ "Bonobo/Property:change:tab_image",
+ NULL,
+ side_panel);
+
+ /* Set the initial tab image */
+ image_name = bonobo_property_bag_client_get_value_string
+ (property_bag,
+ "tab_image",
+ NULL);
+ set_side_panel_image (window, side_panel, image_name);
+ g_free (image_name);
+
+ bonobo_object_release_unref (property_bag, NULL);
+ }
+ CORBA_exception_free (&ev);
+ }
}
-void
-nautilus_window_display_error (NautilusWindow *window, const char *error_msg)
+static void
+side_panel_view_loaded_callback (NautilusViewFrame *view,
+ gpointer user_data)
{
- GtkWidget *dialog;
+ NautilusWindow *window;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, error_msg, NULL);
- gtk_widget_show (dialog);
+ window = NAUTILUS_WINDOW (user_data);
+
+ connect_side_panel (window, view);
}
void
-nautilus_window_set_content_view_widget (NautilusWindow *window,
- NautilusViewFrame *new_view)
+nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window,
+ GList *passed_identifier_list)
{
+ GList *identifier_list;
+ GList *node, *next, *found_node;
+ NautilusViewFrame *sidebar_panel;
+ NautilusViewIdentifier *identifier;
+ const char *current_iid;
+
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view));
-
- if (new_view == window->content_view) {
- return;
- }
+
+ /* Make a copy of the list so we can remove items from it. */
+ identifier_list = g_list_copy (passed_identifier_list);
- if (window->content_view != NULL) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
+ /* Remove panels from the window that don't appear in the list. */
+ for (node = window->sidebar_panels; node != NULL; node = next) {
+ next = node->next;
- if (new_view != NULL) {
- gtk_widget_show (GTK_WIDGET (new_view));
-
- /* When creating the desktop window the UI needs to
- * be in sync. Otherwise I get failed assertions in
- * bonobo while trying to reference something called
- * `/commands/Unmount Volume Conditional'
- */
- nautilus_window_ui_update (window);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (!GTK_IS_PANED (window->content_hbox)) {
- gtk_container_add (GTK_CONTAINER (window->content_hbox),
- GTK_WIDGET (new_view));
+ sidebar_panel = NAUTILUS_VIEW_FRAME (node->data);
+
+ found_node = g_list_find_custom (identifier_list,
+ (char *) nautilus_view_frame_get_view_iid (sidebar_panel),
+ compare_view_identifier_with_iid);
+ if (found_node == NULL) {
+ current_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
+ disconnect_and_destroy_sidebar_panel (window, sidebar_panel);
} else {
- nautilus_horizontal_splitter_pack2 (
- NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
- GTK_WIDGET (new_view));
+ identifier = (NautilusViewIdentifier *) found_node->data;
+
+ /* Right panel, make sure it has the right name. */
+ /* FIXME: Is this set_label necessary? Shouldn't it already
+ * have the right label here?
+ */
+ nautilus_view_frame_set_label (sidebar_panel, identifier->name);
+
+ /* Since this was found, there's no need to add it in the loop below. */
+ identifier_list = g_list_remove_link (identifier_list, found_node);
+ g_list_free_1 (found_node);
}
- }
+ }
- /* Display or hide zoom control */
- if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) {
- gtk_widget_show (window->zoom_control);
- } else {
- gtk_widget_hide (window->zoom_control);
+ /* Add panels to the window that were in the list, but not the window. */
+ for (node = identifier_list; node != NULL; node = node->next) {
+ g_assert (node->data != NULL);
+
+ identifier = (NautilusViewIdentifier *) node->data;
+
+ /* Create and load the panel. */
+ sidebar_panel = nautilus_view_frame_new (NAUTILUS_WINDOW (window)->details->ui_container,
+ NAUTILUS_WINDOW (window)->application->undo_manager);
+
+ eel_accessibility_set_name (sidebar_panel, _("Side Pane"));
+ eel_accessibility_set_description
+ (sidebar_panel, _("Contains a side pane view"));
+
+
+ nautilus_view_frame_set_label (sidebar_panel, identifier->name);
+ nautilus_window_connect_extra_view (NAUTILUS_WINDOW (window),
+ sidebar_panel,
+ identifier);
+ g_signal_connect_object (sidebar_panel,
+ "view_loaded",
+ G_CALLBACK (side_panel_view_loaded_callback),
+ G_OBJECT (window), 0);
+
+ nautilus_view_frame_load_view (sidebar_panel, identifier->iid);
+
+ connect_side_panel (NAUTILUS_WINDOW (window), sidebar_panel);
+
+ nautilus_navigation_window_add_sidebar_panel (window, sidebar_panel);
+ gtk_object_sink (GTK_OBJECT (sidebar_panel));
}
- window->content_view = new_view;
+ g_list_free (identifier_list);
}
/**
* add_sidebar_panels:
- * @window: A NautilusWindow
+ * @window: A NautilusNavigationWindow
*
* Adds all sidebars available
*
*/
static void
-add_sidebar_panels (NautilusWindow *window)
+add_sidebar_panels (NautilusNavigationWindow *window)
{
GList *identifier_list;
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
if (window->sidebar == NULL) {
return;
}
identifier_list = nautilus_sidebar_get_all_sidebar_panel_view_identifiers ();
- nautilus_window_set_sidebar_panels (window, identifier_list);
+ nautilus_navigation_window_set_sidebar_panels (window, identifier_list);
nautilus_view_identifier_list_free (identifier_list);
set_current_side_panel
@@ -1997,44 +1288,40 @@ add_sidebar_panels (NautilusWindow *window)
}
static void
-show_dock_item (NautilusWindow *window, const char *dock_item_path)
+show_dock_item (NautilusNavigationWindow *window, const char *dock_item_path)
{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- return;
- }
-
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- nautilus_bonobo_set_hidden (window->details->shell_ui,
+ nautilus_bonobo_set_hidden (NAUTILUS_WINDOW (window)->details->shell_ui,
dock_item_path,
FALSE);
- nautilus_window_update_show_hide_menu_items (window);
+ nautilus_navigation_window_update_show_hide_menu_items (window);
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
static void
-hide_dock_item (NautilusWindow *window, const char *dock_item_path)
+hide_dock_item (NautilusNavigationWindow *window, const char *dock_item_path)
{
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- nautilus_bonobo_set_hidden (window->details->shell_ui,
+ nautilus_bonobo_set_hidden (NAUTILUS_WINDOW (window)->details->shell_ui,
dock_item_path,
TRUE);
- nautilus_window_update_show_hide_menu_items (window);
+ nautilus_navigation_window_update_show_hide_menu_items (window);
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
static gboolean
-dock_item_showing (NautilusWindow *window, const char *dock_item_path)
+dock_item_showing (NautilusNavigationWindow *window, const char *dock_item_path)
{
- return !nautilus_bonobo_get_hidden (window->details->shell_ui,
+ return !nautilus_bonobo_get_hidden (NAUTILUS_WINDOW (window)->details->shell_ui,
dock_item_path);
}
void
-nautilus_window_hide_location_bar (NautilusWindow *window, gboolean save_preference)
+nautilus_navigation_window_hide_location_bar (NautilusNavigationWindow *window, gboolean save_preference)
{
window->details->temporary_navigation_bar = FALSE;
hide_dock_item (window, LOCATION_BAR_PATH);
@@ -2045,7 +1332,7 @@ nautilus_window_hide_location_bar (NautilusWindow *window, gboolean save_prefere
}
void
-nautilus_window_show_location_bar (NautilusWindow *window, gboolean save_preference)
+nautilus_navigation_window_show_location_bar (NautilusNavigationWindow *window, gboolean save_preference)
{
show_dock_item (window, LOCATION_BAR_PATH);
if (save_preference &&
@@ -2055,103 +1342,57 @@ nautilus_window_show_location_bar (NautilusWindow *window, gboolean save_prefere
}
gboolean
-nautilus_window_location_bar_showing (NautilusWindow *window)
+nautilus_navigation_window_location_bar_showing (NautilusNavigationWindow *window)
{
return dock_item_showing (window, LOCATION_BAR_PATH);
}
-void
-nautilus_window_hide_toolbar (NautilusWindow *window)
-{
- hide_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_toolbar (NautilusWindow *window)
-{
- nautilus_window_activate_throbber (window);
- show_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, TRUE);
- }
-}
-
gboolean
-nautilus_window_toolbar_showing (NautilusWindow *window)
+nautilus_navigation_window_toolbar_showing (NautilusNavigationWindow *window)
{
return dock_item_showing (window, TOOLBAR_PATH);
}
void
-nautilus_window_hide_sidebar (NautilusWindow *window)
+nautilus_navigation_window_hide_sidebar (NautilusNavigationWindow *window)
{
if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar == NULL) {
return;
}
- nautilus_window_tear_down_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
+ nautilus_navigation_window_tear_down_sidebar (window);
+ nautilus_navigation_window_update_show_hide_menu_items (window);
+
if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, FALSE);
}
}
void
-nautilus_window_show_sidebar (NautilusWindow *window)
+nautilus_navigation_window_show_sidebar (NautilusNavigationWindow *window)
{
if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar != NULL) {
return;
}
- nautilus_window_set_up_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
+ nautilus_navigation_window_set_up_sidebar (window);
+ nautilus_navigation_window_update_show_hide_menu_items (window);
if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE);
}
}
gboolean
-nautilus_window_sidebar_showing (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), FALSE);
-
- return (window->sidebar != NULL) && GTK_IS_PANED (window->content_hbox)
- && nautilus_horizontal_splitter_is_hidden (NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox));
-}
-
-void
-nautilus_window_hide_status_bar (NautilusWindow *window)
-{
- hide_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_status_bar (NautilusWindow *window)
+nautilus_navigation_window_sidebar_showing (NautilusNavigationWindow *window)
{
- show_dock_item (window, STATUS_BAR_PATH);
+ g_return_val_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window), FALSE);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_status_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, STATUS_BAR_PATH);
+ return (window->sidebar != NULL)
+ && nautilus_horizontal_splitter_is_hidden (NAUTILUS_HORIZONTAL_SPLITTER (window->details->content_paned));
}
/**
- * nautilus_window_get_base_page_index:
+ * nautilus_navigation_window_get_base_page_index:
* @window: Window to get index from
*
* Returns the index of the base page in the history list.
@@ -2160,7 +1401,7 @@ nautilus_window_status_bar_showing (NautilusWindow *window)
* navigate from.
*/
gint
-nautilus_window_get_base_page_index (NautilusWindow *window)
+nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window)
{
gint forward_count;
@@ -2178,120 +1419,48 @@ nautilus_window_get_base_page_index (NautilusWindow *window)
}
/**
- * nautilus_window_show:
+ * nautilus_navigation_window_show:
* @widget: GtkWidget
*
* Call parent and then show/hide window items
* base on user prefs.
*/
static void
-nautilus_window_show (GtkWidget *widget)
+nautilus_navigation_window_show (GtkWidget *widget)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
- window = NAUTILUS_WINDOW (widget);
+ window = NAUTILUS_NAVIGATION_WINDOW (widget);
- GTK_WIDGET_CLASS (parent_class)->show (widget);
-
/* Initially show or hide views based on preferences; once the window is displayed
* these can be controlled on a per-window basis from View menu items.
*/
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- nautilus_window_show_toolbar (window);
- } else {
- nautilus_window_hide_toolbar (window);
- }
-
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- nautilus_window_show_location_bar (window, FALSE);
+ nautilus_navigation_window_show_location_bar (window, FALSE);
} else {
- nautilus_window_hide_location_bar (window, FALSE);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- nautilus_window_show_status_bar (window);
- } else {
- nautilus_window_hide_status_bar (window);
+ nautilus_navigation_window_hide_location_bar (window, FALSE);
}
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_show_sidebar (window);
+ nautilus_navigation_window_show_sidebar (window);
} else {
- nautilus_window_hide_sidebar (window);
- }
-
- nautilus_window_ui_update (window);
-}
-
-Bonobo_UIContainer
-nautilus_window_get_ui_container (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), CORBA_OBJECT_NIL);
-
- return BONOBO_OBJREF (window->details->ui_container);
-}
-
-void
-nautilus_window_set_viewed_file (NautilusWindow *window,
- NautilusFile *file)
-{
- NautilusFileAttributes attributes;
-
- if (window->details->viewed_file == file) {
- return;
- }
-
- nautilus_file_ref (file);
-
- cancel_view_as_callback (window);
- cancel_chose_component_callback (window);
-
- if (window->details->viewed_file != NULL) {
- nautilus_file_monitor_remove (window->details->viewed_file,
- window);
+ nautilus_navigation_window_hide_sidebar (window);
}
- if (file != NULL) {
- attributes = NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
- nautilus_file_monitor_add (file, window, attributes);
- }
-
- nautilus_file_unref (window->details->viewed_file);
- window->details->viewed_file = file;
+ GTK_WIDGET_CLASS (parent_class)->show (widget);
}
static void
-nautilus_window_class_init (NautilusWindowClass *class)
-{
- G_OBJECT_CLASS (class)->finalize = nautilus_window_finalize;
- G_OBJECT_CLASS (class)->get_property = nautilus_window_get_property;
- G_OBJECT_CLASS (class)->set_property = nautilus_window_set_property;
- GTK_OBJECT_CLASS (class)->destroy = nautilus_window_destroy;
- GTK_WIDGET_CLASS (class)->show = nautilus_window_show;
- GTK_WIDGET_CLASS (class)->unrealize = nautilus_window_unrealize;
- GTK_WIDGET_CLASS (class)->size_request = nautilus_window_size_request;
- class->add_current_location_to_history_list = real_add_current_location_to_history_list;
-
- g_object_class_install_property (G_OBJECT_CLASS (class),
- ARG_APP_ID,
- g_param_spec_string ("app_id",
- _("Application ID"),
- _("The application ID of the window."),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (G_OBJECT_CLASS (class),
- ARG_APP,
- g_param_spec_object ("app",
- _("Application"),
- _("The NautilusApplication associated with this window."),
- NAUTILUS_TYPE_APPLICATION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /* Set default for all windows. This probably should be done
- * in main or NautilusApplication rather than here in case
- * some other window is created before the first
- * NautilusWindow. Also, do we really want this icon for
- * dialogs?
- */
- set_up_default_icon_list ();
+nautilus_navigation_window_class_init (NautilusNavigationWindowClass *class)
+{
+ G_OBJECT_CLASS (class)->finalize = nautilus_navigation_window_finalize;
+ GTK_OBJECT_CLASS (class)->destroy = nautilus_navigation_window_destroy;
+ GTK_WIDGET_CLASS (class)->show = nautilus_navigation_window_show;
+ GTK_WIDGET_CLASS (class)->unrealize = nautilus_navigation_window_unrealize;
+ NAUTILUS_WINDOW_CLASS (class)->merge_menus = real_merge_menus;
+ NAUTILUS_WINDOW_CLASS (class)->load_view_as_menu = real_load_view_as_menu;
+ NAUTILUS_WINDOW_CLASS (class)->set_content_view_widget = real_set_content_view_widget;
+ NAUTILUS_WINDOW_CLASS (class)->set_throbber_active = real_set_throbber_active;
+ NAUTILUS_WINDOW_CLASS (class)->prompt_for_location = real_prompt_for_location;
+ NAUTILUS_WINDOW_CLASS (class)->set_title = real_set_title;
}
diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h
index a14157094..5888ac28f 100644
--- a/src/nautilus-navigation-window.h
+++ b/src/nautilus-navigation-window.h
@@ -5,6 +5,7 @@
*
* Copyright (C) 1999, 2000 Red Hat, Inc.
* Copyright (C) 1999, 2000, 2001 Eazel, Inc.
+ * Copyright (C) 2003 Ximian, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -24,10 +25,10 @@
* Darin Adler <darin@bentspoon.com>
*
*/
-/* nautilus-window.h: Interface of the main window object */
+/* nautilus-navigation-window.h: Interface of the navigation window object */
-#ifndef NAUTILUS_WINDOW_H
-#define NAUTILUS_WINDOW_H
+#ifndef NAUTILUS_NAVIGATION_WINDOW_H
+#define NAUTILUS_NAVIGATION_WINDOW_H
#include <bonobo/bonobo-window.h>
#include <eel/eel-glib-extensions.h>
@@ -38,129 +39,80 @@
#include "nautilus-application.h"
#include "nautilus-information-panel.h"
#include "nautilus-side-pane.h"
+#include "nautilus-window.h"
-#define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type())
-#define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow))
-#define NAUTILUS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_WINDOW, NautilusWindowClass))
-#define NAUTILUS_IS_WINDOW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_WINDOW))
-#define NAUTILUS_IS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_WINDOW))
+#define NAUTILUS_TYPE_NAVIGATION_WINDOW (nautilus_navigation_window_get_type())
+#define NAUTILUS_NAVIGATION_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_NAVIGATION_WINDOW, NautilusNavigationWindow))
+#define NAUTILUS_NAVIGATION_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_NAVIGATION_WINDOW, NautilusNavigationWindowClass))
+#define NAUTILUS_IS_NAVIGATION_WINDOW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_NAVIGATION_WINDOW))
+#define NAUTILUS_IS_NAVIGATION_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_NAVIGATION_WINDOW))
-#ifndef NAUTILUS_WINDOW_DEFINED
-#define NAUTILUS_WINDOW_DEFINED
-typedef struct NautilusWindow NautilusWindow;
-#endif
-
-typedef struct {
- BonoboWindowClass parent_spot;
-
- /* Function pointers for overriding, without corresponding signals */
-
- /* add_current_location_to_history_list is a function pointer that
- * subclasses may override if they wish to add something other than
- * NautilusWindow's idea of the "current location" to the history
- * list, or nothing at all.
- */
- void (* add_current_location_to_history_list) (NautilusWindow *window);
-} NautilusWindowClass;
-
-typedef enum {
- NAUTILUS_WINDOW_NOT_SHOWN,
- NAUTILUS_WINDOW_POSITION_SET,
- NAUTILUS_WINDOW_SHOULD_SHOW
-} NautilusWindowShowState;
-
-typedef struct NautilusWindowDetails NautilusWindowDetails;
+typedef struct _NautilusNavigationWindow NautilusNavigationWindow;
+typedef struct _NautilusNavigationWindowClass NautilusNavigationWindowClass;
+typedef struct _NautilusNavigationWindowDetails NautilusNavigationWindowDetails;
-struct NautilusWindow {
- BonoboWindow parent_object;
+struct _NautilusNavigationWindow {
+ NautilusWindow parent_object;
- NautilusWindowDetails *details;
+ NautilusNavigationWindowDetails *details;
/** UI stuff **/
NautilusSidePane *sidebar;
NautilusInformationPanel *information_panel;
- GtkWidget *content_hbox;
GtkWidget *view_as_option_menu;
GtkWidget *navigation_bar;
- char *last_geometry;
-
- guint save_geometry_timeout_id;
-
- /** CORBA-related elements **/
- NautilusApplication *application;
-
- /** State information **/
-
- /* Information about current location/selection */
-
/* Back/Forward chain, and history list.
* The data in these lists are NautilusBookmark pointers.
*/
GList *back_list, *forward_list;
- NautilusBookmark *current_location_bookmark;
- NautilusBookmark *last_location_bookmark;
-
/* Current views stuff */
- NautilusViewFrame *content_view;
GList *sidebar_panels;
/* Widgets to keep track of (for state changes, etc) */
GtkWidget *zoom_control;
-
- /* Pending changes */
- NautilusViewFrame *new_content_view;
+};
- /* Window showed state (for saved_window_positions) */
- NautilusWindowShowState show_state;
+
+struct _NautilusNavigationWindowClass {
+ NautilusWindowClass parent_spot;
};
-GType nautilus_window_get_type (void);
-void nautilus_window_ui_freeze (NautilusWindow *window);
-void nautilus_window_ui_thaw (NautilusWindow *window);
-void nautilus_window_close (NautilusWindow *window);
-char * nautilus_window_get_location (NautilusWindow *window);
-void nautilus_window_go_to (NautilusWindow *window,
- const char *location);
-gboolean nautilus_window_get_search_mode (NautilusWindow *window);
-void nautilus_window_set_search_mode (NautilusWindow *window,
+GType nautilus_navigation_window_get_type (void);
+gboolean nautilus_navigation_window_get_search_mode (NautilusNavigationWindow *window);
+void nautilus_navigation_window_set_search_mode (NautilusNavigationWindow *window,
gboolean search_mode);
-void nautilus_window_go_home (NautilusWindow *window);
-void nautilus_window_display_error (NautilusWindow *window,
- const char *error_msg);
-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,
+void nautilus_navigation_window_go_home (NautilusNavigationWindow *window);
+void nautilus_navigation_window_allow_back (NautilusNavigationWindow *window,
gboolean allow);
-void nautilus_window_allow_reload (NautilusWindow *window,
+void nautilus_navigation_window_allow_forward (NautilusNavigationWindow *window,
gboolean allow);
-void nautilus_window_allow_stop (NautilusWindow *window,
- gboolean allow);
-void nautilus_window_allow_burn_cd (NautilusWindow *window,
- gboolean allow);
-void nautilus_window_clear_back_list (NautilusWindow *window);
-void nautilus_window_clear_forward_list (NautilusWindow *window);
+void nautilus_navigation_window_clear_back_list (NautilusNavigationWindow *window);
+void nautilus_navigation_window_clear_forward_list (NautilusNavigationWindow *window);
+
void nautilus_forget_history (void);
void nautilus_bookmarks_exiting (void);
-void nautilus_window_reload (NautilusWindow *window);
-gint nautilus_window_get_base_page_index (NautilusWindow *window);
-void nautilus_window_hide_location_bar (NautilusWindow *window,
+
+gint nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window);
+
+void nautilus_navigation_window_hide_location_bar (NautilusNavigationWindow *window,
gboolean save_preference);
-void nautilus_window_show_location_bar (NautilusWindow *window,
+void nautilus_navigation_window_show_location_bar (NautilusNavigationWindow *window,
gboolean save_preference);
-gboolean nautilus_window_location_bar_showing (NautilusWindow *window);
-void nautilus_window_hide_toolbar (NautilusWindow *window);
-void nautilus_window_show_toolbar (NautilusWindow *window);
-gboolean nautilus_window_toolbar_showing (NautilusWindow *window);
-void nautilus_window_hide_sidebar (NautilusWindow *window);
-void nautilus_window_show_sidebar (NautilusWindow *window);
-gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
-void nautilus_window_hide_status_bar (NautilusWindow *window);
-void nautilus_window_show_status_bar (NautilusWindow *window);
-gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
-void nautilus_window_save_geometry (NautilusWindow *window);
+gboolean nautilus_navigation_window_location_bar_showing (NautilusNavigationWindow *window);
+
+void nautilus_navigation_window_hide_toolbar (NautilusNavigationWindow *window);
+void nautilus_navigation_window_show_toolbar (NautilusNavigationWindow *window);
+gboolean nautilus_navigation_window_toolbar_showing (NautilusNavigationWindow *window);
+
+void nautilus_navigation_window_hide_sidebar (NautilusNavigationWindow *window);
+void nautilus_navigation_window_show_sidebar (NautilusNavigationWindow *window);
+gboolean nautilus_navigation_window_sidebar_showing (NautilusNavigationWindow *window);
+
+void nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window,
+ NautilusViewFrame *sidebar_panel);
+void nautilus_navigation_window_remove_sidebar_panel (NautilusNavigationWindow *window,
+ NautilusViewFrame *sidebar_panel);
#endif
diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c
deleted file mode 100644
index 300f43ecb..000000000
--- a/src/nautilus-object-window.c
+++ /dev/null
@@ -1,2297 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Nautilus
- *
- * Copyright (C) 1999, 2000 Red Hat, Inc.
- * Copyright (C) 1999, 2000, 2001 Eazel, Inc.
- *
- * Nautilus is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * Nautilus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Authors: Elliot Lee <sopwith@redhat.com>
- * John Sullivan <sullivan@eazel.com>
- *
- */
-
-/* nautilus-window.c: Implementation of the main window object */
-
-#include <config.h>
-#include "nautilus-window-private.h"
-
-#include "nautilus-application.h"
-#include "nautilus-bookmarks-window.h"
-#include "nautilus-information-panel.h"
-#include "nautilus-main.h"
-#include "nautilus-signaller.h"
-#include "nautilus-switchable-navigation-bar.h"
-#include "nautilus-window-manage-views.h"
-#include "nautilus-zoom-control.h"
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-property-bag-client.h>
-#include <bonobo/bonobo-ui-util.h>
-#include <eel/eel-debug.h>
-#include <eel/eel-gdk-extensions.h>
-#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-generous-bin.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-string.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gdk/gdkx.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmenubar.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkoptionmenu.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-messagebox.h>
-#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomeui/gnome-window-icon.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libnautilus-private/nautilus-bonobo-extensions.h>
-#include <libnautilus-private/nautilus-drag-window.h>
-#include <libnautilus-private/nautilus-file-utilities.h>
-#include <libnautilus-private/nautilus-file-attributes.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-horizontal-splitter.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-#include <libnautilus-private/nautilus-metadata.h>
-#include <libnautilus-private/nautilus-mime-actions.h>
-#include <libnautilus-private/nautilus-program-choosing.h>
-#include <libnautilus-private/nautilus-sidebar-functions.h>
-#include <libnautilus/nautilus-bonobo-ui.h>
-#include <libnautilus/nautilus-clipboard.h>
-#include <libnautilus/nautilus-undo.h>
-#include <math.h>
-#include <sys/time.h>
-
-/* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
-#include "nautilus-desktop-window.h"
-
-#define MAX_HISTORY_ITEMS 50
-
-/* FIXME bugzilla.gnome.org 41245: hardwired sizes */
-#define SIDE_PANE_MINIMUM_WIDTH 1
-#define SIDE_PANE_MINIMUM_HEIGHT 400
-
-/* dock items */
-#define LOCATION_BAR_PATH "/Location Bar"
-#define TOOLBAR_PATH "/Toolbar"
-#define STATUS_BAR_PATH "/status"
-#define MENU_BAR_PATH "/menu"
-
-#define COMMAND_PREFIX "/commands/"
-#define NAUTILUS_COMMAND_TOGGLE_FIND_MODE "/commands/Toggle Find Mode"
-#define NAUTILUS_COMMAND_VIEW_AS "/commands/View as"
-
-#define NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER "/menu/View/View Choices/Extra Viewer"
-#define NAUTILUS_MENU_PATH_BEFORE_SHORT_LIST_SEPARATOR "/menu/View/View Choices/Before Short List"
-#define NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER "/menu/View/View Choices/Short List"
-#define NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR "/menu/View/View Choices/After Short List"
-
-enum {
- ARG_0,
- ARG_APP_ID,
- ARG_APP
-};
-
-static GList *history_list;
-static int side_pane_width_auto_value = SIDE_PANE_MINIMUM_WIDTH;
-
-static void add_sidebar_panels (NautilusWindow *window);
-static void cancel_view_as_callback (NautilusWindow *window);
-
-GNOME_CLASS_BOILERPLATE (NautilusWindow, nautilus_window,
- BonoboWindow, BONOBO_TYPE_WINDOW)
-
-static void
-set_up_default_icon_list (void)
-{
- GList *icon_list;
- guint i;
- GdkPixbuf *pixbuf;
- char *path;
- const char *icon_filenames[] = { "nautilus-mini-logo.png", "nautilus-launch-icon.png" };
-
- icon_list = NULL;
- for (i = 0; i < G_N_ELEMENTS (icon_filenames); i++) {
- path = nautilus_pixmap_file (icon_filenames[i]);
-
- if (path == NULL) {
- continue;
- }
-
- pixbuf = gdk_pixbuf_new_from_file (path, NULL);
- g_free (path);
-
- if (pixbuf != NULL) {
- icon_list = g_list_prepend (icon_list, pixbuf);
- }
- }
-
- gtk_window_set_default_icon_list (icon_list);
-
- eel_g_list_free_deep_custom (icon_list, (GFunc) g_object_unref, NULL);
-}
-
-static void
-icons_changed_callback (GObject *factory, NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_update_icon (window);
-}
-
-static void
-nautilus_window_instance_init (NautilusWindow *window)
-{
- window->details = g_new0 (NautilusWindowDetails, 1);
-
- /* CORBA and Bonobo setup, which must be done before the location bar setup */
- window->details->ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
- bonobo_object_ref (window->details->ui_container);
-
- window->details->tooltips = gtk_tooltips_new ();
- g_object_ref (G_OBJECT (window->details->tooltips));
- gtk_object_sink (GTK_OBJECT (window->details->tooltips));
-
- /* Set last geometry to NULL */
- window->last_geometry = NULL;
-
- /* Set initial window title */
- gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
-
- window->details->shell_ui = bonobo_ui_component_new ("Nautilus Shell");
- bonobo_ui_component_set_container
- (window->details->shell_ui,
- nautilus_window_get_ui_container (window),
- NULL);
-
- /* Register IconFactory callback to update the window border icon
- * when the icon-theme is changed.
- */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (icons_changed_callback), window,
- 0);
-
- /* Create a separate component so when we remove the status
- * we don't loose the status bar
- */
- window->details->status_ui = bonobo_ui_component_new ("Status Component");
- bonobo_ui_component_set_container
- (window->details->status_ui,
- nautilus_window_get_ui_container (window),
- NULL);
-
- gtk_quit_add_destroy (1, GTK_OBJECT (window));
-
- /* Keep the main event loop alive as long as the window exists */
- nautilus_main_event_loop_register (GTK_OBJECT (window));
-}
-
-static gint
-ui_idle_handler (gpointer data)
-{
- NautilusWindow *window;
- gboolean old_updating_bonobo_state;
-
- window = data;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_object_ref (data);
-
- g_assert (window->details->ui_change_depth == 0);
-
- /* Simulate an extra freeze/thaw so that calling window_ui_freeze
- * and thaw from within the idle handler doesn't try to remove it
- * (the already running idle handler)
- */
- window->details->ui_change_depth++;
- old_updating_bonobo_state = window->details->updating_bonobo_state;
-
- if (window->details->ui_pending_initialize_menus_part_2) {
- nautilus_window_initialize_menus_part_2 (window);
- window->details->ui_pending_initialize_menus_part_2 = FALSE;
- }
-
- if (window->details->ui_is_frozen) {
- window->details->updating_bonobo_state = TRUE;
- bonobo_ui_engine_thaw (bonobo_ui_container_get_engine (window->details->ui_container));
- window->details->ui_is_frozen = FALSE;
- window->details->updating_bonobo_state = old_updating_bonobo_state;
- }
-
- window->details->ui_change_depth--;
-
- window->details->ui_idle_id = 0;
-
- g_object_unref (data);
-
- return FALSE;
-}
-
-static inline void
-ui_install_idle_handler (NautilusWindow *window)
-{
- if (window->details->ui_idle_id == 0) {
- window->details->ui_idle_id = g_idle_add_full (G_PRIORITY_LOW, ui_idle_handler, window, NULL);
- }
-}
-
-static inline void
-ui_remove_idle_handler (NautilusWindow *window)
-{
- if (window->details->ui_idle_id != 0) {
- g_source_remove (window->details->ui_idle_id);
- window->details->ui_idle_id = 0;
- }
-}
-
-/* Register that BonoboUI changes are going to be made to WINDOW. The UI
- * won't actually be synchronised until some arbitrary date in the future.
- */
-void
-nautilus_window_ui_freeze (NautilusWindow *window)
-{
- g_object_ref (window);
-
- if (window->details->ui_change_depth == 0) {
- ui_remove_idle_handler (window);
- }
-
- if (!window->details->ui_is_frozen) {
- bonobo_ui_engine_freeze (bonobo_ui_container_get_engine (window->details->ui_container));
- window->details->ui_is_frozen = TRUE;
- }
-
- window->details->ui_change_depth++;
-}
-
-/* Register that the BonoboUI changes for WINDOW have finished. There _must_
- * be one and only one call to this function for every call to
- * starting_ui_change ()
- */
-void
-nautilus_window_ui_thaw (NautilusWindow *window)
-{
- window->details->ui_change_depth--;
-
- g_assert (window->details->ui_change_depth >= 0);
-
- if (window->details->ui_change_depth == 0
- && (window->details->ui_is_frozen
- || window->details->ui_pending_initialize_menus_part_2)) {
- ui_install_idle_handler (window);
- }
-
- g_object_unref (window);
-}
-
-/* Unconditionally synchronize the BonoboUI of WINDOW. */
-static void
-nautilus_window_ui_update (NautilusWindow *window)
-{
- BonoboUIEngine *engine;
- gboolean old_updating_bonobo_state;
-
- engine = bonobo_ui_container_get_engine (window->details->ui_container);
- old_updating_bonobo_state = window->details->updating_bonobo_state;
-
- window->details->updating_bonobo_state = TRUE;
- if (window->details->ui_is_frozen) {
- bonobo_ui_engine_thaw (engine);
- if (window->details->ui_change_depth == 0) {
- window->details->ui_is_frozen = FALSE;
- if (!window->details->ui_pending_initialize_menus_part_2) {
- ui_remove_idle_handler (window);
- }
- } else {
- bonobo_ui_engine_freeze (engine);
- }
- } else {
- bonobo_ui_engine_update (engine);
- }
- window->details->updating_bonobo_state = old_updating_bonobo_state;
-}
-
-static gboolean
-nautilus_window_clear_status (gpointer callback_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- bonobo_ui_component_set_status (window->details->status_ui, NULL, NULL);
-
- return FALSE;
-}
-
-void
-nautilus_window_set_status (NautilusWindow *window, const char *text)
-{
- if (text != NULL && text[0] != '\0') {
- bonobo_ui_component_set_status (window->details->status_ui, text, NULL);
- } else {
- nautilus_window_clear_status (window);
- }
-}
-
-void
-nautilus_window_go_to (NautilusWindow *window, const char *uri)
-{
- nautilus_window_open_location (window, uri);
-}
-
-char *
-nautilus_window_get_location (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
-
- return g_strdup (window->details->location);
-}
-
-static void
-go_to_callback (GtkWidget *widget,
- const char *uri,
- NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_go_to (window, uri);
-}
-
-static void
-navigation_bar_location_changed_callback (GtkWidget *widget,
- const char *uri,
- NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->details->temporary_navigation_bar) {
- if (nautilus_window_location_bar_showing (window)) {
- nautilus_window_hide_location_bar (window, FALSE);
- }
- window->details->temporary_navigation_bar = FALSE;
- }
-
- nautilus_window_go_to (window, uri);
-}
-
-static void
-navigation_bar_mode_changed_callback (GtkWidget *widget,
- NautilusSwitchableNavigationBarMode mode,
- NautilusWindow *window)
-{
- window->details->updating_bonobo_state = TRUE;
-
- g_assert (mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION
- || mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
-
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- NAUTILUS_COMMAND_TOGGLE_FIND_MODE,
- mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
-
- window->details->updating_bonobo_state = FALSE;
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_zoom_in (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_in (window->content_view);
- }
-}
-
-void
-nautilus_window_zoom_to_level (NautilusWindow *window, float level)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_set_zoom_level (window->content_view, level);
- }
-}
-
-void
-nautilus_window_zoom_out (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_out (window->content_view);
- }
-}
-
-void
-nautilus_window_zoom_to_fit (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_to_fit (window->content_view);
- }
-}
-
-/* Code should never force the window taller than this size.
- * (The user can still stretch the window taller if desired).
- */
-static guint
-get_max_forced_height (GdkScreen *screen)
-{
- return (gdk_screen_get_height (screen) * 90) / 100;
-}
-
-/* Code should never force the window wider than this size.
- * (The user can still stretch the window wider if desired).
- */
-static guint
-get_max_forced_width (GdkScreen *screen)
-{
- return (gdk_screen_get_width (screen) * 90) / 100;
-}
-
-static void
-set_initial_window_geometry (NautilusWindow *window)
-{
- GdkScreen *screen;
- guint max_width_for_screen, max_height_for_screen;
-
- screen = gtk_window_get_screen (GTK_WINDOW (window));
-
- /* Don't let GTK determine the minimum size
- * automatically. It will insist that the window be
- * really wide based on some misguided notion about
- * the content view area. Also, it might start the
- * window wider (or taller) than the screen, which
- * is evil. So we choose semi-arbitrary initial and
- * minimum widths instead of letting GTK decide.
- */
- /* FIXME - the above comment suggests that the size request
- * of the content view area is wrong, probably because of
- * another stupid set_usize someplace. If someone gets the
- * content view area's size request right then we can
- * probably remove this broken set_size_request() here.
- * - hp@redhat.com
- */
-
- max_width_for_screen = get_max_forced_width (screen);
- max_height_for_screen = get_max_forced_height (screen);
-
- gtk_widget_set_size_request (GTK_WIDGET (window),
- MIN (NAUTILUS_WINDOW_MIN_WIDTH,
- max_width_for_screen),
- MIN (NAUTILUS_WINDOW_MIN_HEIGHT,
- max_height_for_screen));
-
- gtk_window_set_default_size (GTK_WINDOW (window),
- MIN (NAUTILUS_WINDOW_DEFAULT_WIDTH,
- max_width_for_screen),
- MIN (NAUTILUS_WINDOW_DEFAULT_HEIGHT,
- max_height_for_screen));
-}
-
-/* Add a dummy menu with a "View as ..." item when we first create the
- * view_as_option_menu -- without this the menu draws empty and shrunk,
- * once we populate it it grows and forces the toolbar and all the other
- * views to re-layout.
- */
-static void
-set_dummy_initial_view_as_menu (NautilusWindow *window)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
-
- new_menu = gtk_menu_new ();
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
-}
-
-static void
-side_pane_close_requested_callback (GtkWidget *widget,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- nautilus_window_hide_sidebar (window);
-}
-
-static void
-side_pane_size_allocate_callback (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (allocation->width != window->details->side_pane_width) {
- window->details->side_pane_width = allocation->width;
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH)) {
- eel_preferences_set_integer
- (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
- allocation->width);
- }
- }
-}
-
-static void
-setup_side_pane_width (NautilusWindow *window)
-{
- static gboolean setup_auto_value= TRUE;
-
- g_return_if_fail (window->sidebar != NULL);
-
- if (setup_auto_value) {
- setup_auto_value = FALSE;
- eel_preferences_add_auto_integer
- (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
- &side_pane_width_auto_value);
- }
-
- window->details->side_pane_width = side_pane_width_auto_value;
-
- /* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
- /* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
-
- gtk_paned_set_position (GTK_PANED (window->content_hbox),
- side_pane_width_auto_value);
-}
-
-static void
-side_panel_set_open (GtkWidget *view,
- gboolean open)
-{
- CORBA_Environment ev;
- Bonobo_PropertyBag property_bag;
- Bonobo_Control control;
-
- if (!view || !NAUTILUS_IS_VIEW_FRAME (view)) {
- return;
- }
-
- control = nautilus_view_frame_get_control (NAUTILUS_VIEW_FRAME (view));
-
- if (control != CORBA_OBJECT_NIL) {
- CORBA_exception_init (&ev);
- property_bag = Bonobo_Control_getProperties (control, &ev);
- if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
- /* For some reason this was implemented as 'close'
- * before, but open seems more natural */
- bonobo_property_bag_client_set_value_gboolean
- (property_bag, "close", !open, &ev);
- bonobo_object_release_unref (property_bag, NULL);
- }
- }
-}
-
-static void
-set_current_side_panel (NautilusWindow *window,
- GtkWidget *panel)
-{
- if (window->details->current_side_panel) {
- side_panel_set_open (window->details->current_side_panel,
- FALSE);
- eel_remove_weak_pointer (&window->details->current_side_panel);
- }
-
- side_panel_set_open (panel, TRUE);
- window->details->current_side_panel = panel;
- eel_add_weak_pointer (&window->details->current_side_panel);
-}
-
-static void
-side_pane_switch_page_callback (NautilusSidePane *side_pane,
- GtkWidget *panel,
- NautilusWindow *window)
-{
- const char *view_iid;
-
- set_current_side_panel (window, panel);
-
- if (NAUTILUS_IS_VIEW_FRAME (panel)) {
- view_iid = nautilus_view_frame_get_view_iid (NAUTILUS_VIEW_FRAME (panel));
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) {
- eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW,
- view_iid);
- }
-
- } else {
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) {
- eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW, "");
- }
- }
-}
-
-static void
-nautilus_window_set_up_sidebar (NautilusWindow *window)
-{
- window->sidebar = nautilus_side_pane_new ();
-
- gtk_paned_pack1 (GTK_PANED (window->content_hbox),
- GTK_WIDGET (window->sidebar),
- FALSE, TRUE);
-
- setup_side_pane_width (window);
- g_signal_connect (window->sidebar,
- "size_allocate",
- G_CALLBACK (side_pane_size_allocate_callback),
- window);
-
- window->information_panel = nautilus_information_panel_new ();
-
- if (window->details->location != NULL &&
- window->details->title != NULL) {
- nautilus_information_panel_set_uri (window->information_panel,
- window->details->location,
- window->details->title);
- }
-
- g_signal_connect_object (window->information_panel, "location_changed",
- G_CALLBACK (go_to_callback), window, 0);
-
- /* Set up the sidebar panels. */
- nautilus_side_pane_add_panel (NAUTILUS_SIDE_PANE (window->sidebar),
- GTK_WIDGET (window->information_panel),
- _("Information"));
-
- add_sidebar_panels (window);
-
- g_signal_connect (window->sidebar,
- "close_requested",
- G_CALLBACK (side_pane_close_requested_callback),
- window);
-
- g_signal_connect (window->sidebar,
- "switch_page",
- G_CALLBACK (side_pane_switch_page_callback),
- window);
-
- gtk_widget_show (GTK_WIDGET (window->information_panel));
-
- gtk_widget_show (GTK_WIDGET (window->sidebar));
-}
-
-static void
-nautilus_window_tear_down_sidebar (NautilusWindow *window)
-{
- g_signal_handlers_disconnect_by_func (window->sidebar,
- side_pane_switch_page_callback,
- window);
-
- nautilus_window_set_sidebar_panels (window, NULL);
- gtk_widget_destroy (GTK_WIDGET (window->sidebar));
- window->sidebar = NULL;
- window->information_panel = NULL;
-}
-
-static void
-nautilus_window_constructed (NautilusWindow *window)
-{
- GtkWidget *location_bar_box;
- GtkWidget *view_as_menu_vbox;
- BonoboControl *location_bar_wrapper;
-
- nautilus_window_ui_freeze (window);
-
- /* Load the user interface from the XML file. */
- bonobo_ui_util_set_ui (window->details->shell_ui,
- DATADIR,
- "nautilus-shell-ui.xml",
- "nautilus", NULL);
-
- /* set up location bar */
- location_bar_box = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (location_bar_box), GNOME_PAD_SMALL);
-
- window->navigation_bar = nautilus_switchable_navigation_bar_new (window);
- gtk_widget_show (GTK_WIDGET (window->navigation_bar));
-
- g_signal_connect_object (window->navigation_bar, "location_changed",
- G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
- g_signal_connect_object (window->navigation_bar, "mode_changed",
- G_CALLBACK (navigation_bar_mode_changed_callback), window, 0);
-
- gtk_box_pack_start (GTK_BOX (location_bar_box), window->navigation_bar,
- TRUE, TRUE, GNOME_PAD_SMALL);
-
- /* Option menu for content view types; it's empty here, filled in when a uri is set.
- * Pack it into vbox so it doesn't grow vertically when location bar does.
- */
- view_as_menu_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_widget_show (view_as_menu_vbox);
- gtk_box_pack_end (GTK_BOX (location_bar_box), view_as_menu_vbox, FALSE, FALSE, 0);
-
- window->view_as_option_menu = gtk_option_menu_new ();
- gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), window->view_as_option_menu, TRUE, FALSE, 0);
- gtk_widget_show (window->view_as_option_menu);
- /* Make sure there is something in the option menu to prevent it from
- * growing later.
- */
- set_dummy_initial_view_as_menu (window);
-
- /* Allocate the zoom control and place on the right next to the menu.
- * It gets shown later, if the view-frame contains something zoomable.
- */
- window->zoom_control = nautilus_zoom_control_new ();
- g_signal_connect_object (window->zoom_control, "zoom_in",
- G_CALLBACK (nautilus_window_zoom_in),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_out",
- G_CALLBACK (nautilus_window_zoom_out),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_level",
- G_CALLBACK (nautilus_window_zoom_to_level),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_fit",
- G_CALLBACK (nautilus_window_zoom_to_fit),
- window, G_CONNECT_SWAPPED);
- gtk_box_pack_end (GTK_BOX (location_bar_box), window->zoom_control, FALSE, FALSE, 0);
-
- gtk_widget_show (location_bar_box);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- window->content_hbox = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
- } else {
- set_initial_window_geometry (window);
-
- window->content_hbox = nautilus_horizontal_splitter_new ();
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_set_up_sidebar (window);
- }
- }
-
- gtk_widget_show (window->content_hbox);
- bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
-
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- LOCATION_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- TOOLBAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- STATUS_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- MENU_BAR_PATH, TRUE);
- }
-
- /* Wrap the location bar in a control and set it up. */
- location_bar_wrapper = bonobo_control_new (location_bar_box);
- bonobo_ui_component_object_set (window->details->shell_ui,
- "/Location Bar/Wrapper",
- BONOBO_OBJREF (location_bar_wrapper),
- NULL);
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
- bonobo_object_unref (location_bar_wrapper);
-
- /* initalize the menus and toolbars */
- nautilus_window_initialize_menus_part_1 (window);
- nautilus_window_initialize_toolbars (window);
-
- /* We'll do the second part later (bookmarks and go menus) */
- window->details->ui_pending_initialize_menus_part_2 = TRUE;
-
- /* 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);
-
- nautilus_window_allow_burn_cd (window, FALSE);
-
- /* Set up undo manager */
- nautilus_undo_manager_attach (window->application->undo_manager, G_OBJECT (window));
-
- /* Register that things may be dragged from this window */
- nautilus_drag_window_register (GTK_WINDOW (window));
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-nautilus_window_set_property (GObject *object,
- guint arg_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- char *old_name;
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
-
- switch (arg_id) {
- case ARG_APP_ID:
- if (g_value_get_string (value) == NULL) {
- return;
- }
- old_name = bonobo_window_get_name (BONOBO_WINDOW (window));
- bonobo_window_set_name (BONOBO_WINDOW (window), g_value_get_string (value));
- /* This hack of using the time when the name first
- * goes non-NULL to be window-constructed time is
- * completely lame. But it works, so for now we leave
- * it alone.
- */
- if (old_name == NULL) {
- nautilus_window_constructed (window);
- }
- g_free (old_name);
- break;
- case ARG_APP:
- window->application = NAUTILUS_APPLICATION (g_value_get_object (value));
- break;
- }
-}
-
-static void
-nautilus_window_get_property (GObject *object,
- guint arg_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (arg_id) {
- case ARG_APP_ID:
- g_value_set_string_take_ownership (
- value,
- bonobo_window_get_name (BONOBO_WINDOW (object)));
- break;
- case ARG_APP:
- g_value_set_object (value, NAUTILUS_WINDOW (object)->application);
- break;
- }
-}
-
-static void
-free_stored_viewers (NautilusWindow *window)
-{
- eel_g_list_free_deep_custom (window->details->short_list_viewers,
- (GFunc) nautilus_view_identifier_free,
- NULL);
- window->details->short_list_viewers = NULL;
- nautilus_view_identifier_free (window->details->extra_viewer);
- window->details->extra_viewer = NULL;
-}
-
-static void
-nautilus_window_unrealize (GtkWidget *widget)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
-
- if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
- window->details->throbber_property_bag = CORBA_OBJECT_NIL;
- }
-
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
-}
-
-static void
-nautilus_window_destroy (GtkObject *object)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
-
- nautilus_window_manage_views_destroy (window);
-
- window->sidebar = NULL;
- eel_g_object_list_free (window->sidebar_panels);
- window->sidebar_panels = NULL;
-
- window->view_as_option_menu = NULL;
- window->navigation_bar = NULL;
- window->content_hbox = NULL;
- window->zoom_control = NULL;
-
- if (window->content_view) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
-
- if (window->details->tooltips) {
- g_object_unref (G_OBJECT (window->details->tooltips));
- window->details->tooltips = NULL;
- }
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-nautilus_window_finalize (GObject *object)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
-
- nautilus_window_manage_views_finalize (window);
-
- nautilus_window_set_viewed_file (window, NULL);
- nautilus_window_remove_bookmarks_menu_callback (window);
- nautilus_window_remove_go_menu_callback (window);
-
- if (window->details->ui_idle_id != 0) {
- g_source_remove (window->details->ui_idle_id);
- }
-
- if (window->details->shell_ui != NULL) {
- bonobo_ui_component_unset_container (window->details->shell_ui, NULL);
- bonobo_object_unref (window->details->shell_ui);
- window->details->shell_ui = NULL;
- }
-
- if (window->details->status_ui != NULL) {
- bonobo_ui_component_unset_container (window->details->status_ui, NULL);
- bonobo_object_unref (window->details->status_ui);
- window->details->status_ui = NULL;
- }
-
- nautilus_file_unref (window->details->viewed_file);
-
- free_stored_viewers (window);
-
- g_free (window->details->location);
- eel_g_list_free_deep (window->details->selection);
- eel_g_list_free_deep (window->details->pending_selection);
-
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
- if (window->current_location_bookmark != NULL) {
- g_object_unref (window->current_location_bookmark);
- }
- if (window->last_location_bookmark != NULL) {
- g_object_unref (window->last_location_bookmark);
- }
-
- bonobo_object_unref (window->details->ui_container);
-
- if (window->details->location_change_at_idle_id != 0) {
- g_source_remove (window->details->location_change_at_idle_id);
- }
-
- g_free (window->details->title);
-
- g_free (window->details);
-
- g_free (window->last_geometry);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-void
-nautilus_window_save_geometry (NautilusWindow *window)
-{
- char *geometry_string;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (GTK_WIDGET(window)->window &&
- !(gdk_window_get_state (GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
- geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
-
- nautilus_file_set_metadata (window->details->viewed_file,
- NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
- NULL,
- geometry_string);
-
- g_free (geometry_string);
- }
-}
-
-void
-nautilus_window_close (NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- gtk_widget_destroy (GTK_WIDGET (window));
-}
-
-static void
-nautilus_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GdkScreen *screen;
- guint max_width;
- guint max_height;
-
- g_assert (NAUTILUS_IS_WINDOW (widget));
- g_assert (requisition != NULL);
-
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
-
- screen = gtk_window_get_screen (GTK_WINDOW (widget));
-
- /* Limit the requisition to be within 90% of the available screen
- * real state.
- *
- * This way the user will have a fighting chance of getting
- * control of their window back if for whatever reason one of the
- * window's descendants decide they want to be 4000 pixels wide.
- *
- * Note that the user can still make the window really huge by hand.
- *
- * Bugs in components or other widgets that cause such huge geometries
- * to be requested, should still be fixed. This code is here only to
- * prevent the extremely frustrating consequence of such bugs.
- */
- max_width = get_max_forced_width (screen);
- max_height = get_max_forced_height (screen);
-
- if (requisition->width > (int) max_width) {
- requisition->width = max_width;
- }
-
- if (requisition->height > (int) max_height) {
- requisition->height = max_height;
- }
-}
-
-
-/*
- * Main API
- */
-
-static void
-activate_nth_short_list_item (NautilusWindow *window, guint index)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_assert (index < g_list_length (window->details->short_list_viewers));
-
- nautilus_window_set_content_view (window,
- g_list_nth_data (window->details->short_list_viewers, index));
-}
-
-static void
-activate_extra_viewer (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_assert (window->details->extra_viewer != NULL);
-
- nautilus_window_set_content_view (window, window->details->extra_viewer);
-}
-
-static void
-handle_view_as_item_from_bonobo_menu (NautilusWindow *window, const char *id)
-{
- char *container_path;
-
- container_path = nautilus_bonobo_get_numbered_menu_item_container_path_from_command (id);
-
- if (eel_strcmp (container_path, NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER) == 0) {
- activate_nth_short_list_item
- (window,
- nautilus_bonobo_get_numbered_menu_item_index_from_command (id));
- } else if (eel_strcmp (container_path, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER) == 0) {
- g_return_if_fail
- (nautilus_bonobo_get_numbered_menu_item_index_from_command (id) == 0);
- activate_extra_viewer (window);
- }
-
- g_free (container_path);
-}
-
-void
-nautilus_window_handle_ui_event_callback (BonoboUIComponent *ui,
- const char *id,
- Bonobo_UIComponent_EventType type,
- const char *state,
- NautilusWindow *window)
-{
- if (!window->details->updating_bonobo_state
- && type == Bonobo_UIComponent_STATE_CHANGED
- && strcmp (state, "1") == 0) {
- handle_view_as_item_from_bonobo_menu (window, id);
- }
-}
-
-static void
-view_as_menu_switch_views_callback (GtkWidget *widget, gpointer data)
-{
- NautilusWindow *window;
- int viewer_index;
-
- g_assert (GTK_IS_MENU_ITEM (widget));
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- window = NAUTILUS_WINDOW (data);
-
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "extra viewer")) == TRUE) {
- activate_extra_viewer (window);
- } else {
- viewer_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "viewer index"));
- activate_nth_short_list_item (window, viewer_index);
- }
-}
-
-static GtkWidget *
-create_view_as_menu_item (NautilusWindow *window,
- NautilusViewIdentifier *identifier,
- guint index)
-{
- GtkWidget *menu_item;
- char *menu_label;
-
- menu_label = g_strdup (_(identifier->view_as_label));
- menu_item = gtk_menu_item_new_with_mnemonic (menu_label);
- g_free (menu_label);
-
- g_signal_connect_object (menu_item, "activate",
- G_CALLBACK (view_as_menu_switch_views_callback),
- window, 0);
-
- g_object_set_data (G_OBJECT (menu_item), "viewer index", GINT_TO_POINTER (index));
-
- gtk_widget_show (menu_item);
-
- return menu_item;
-}
-
-static GtkWidget *
-new_gtk_separator (void)
-{
- GtkWidget *result;
-
- result = gtk_menu_item_new ();
- gtk_widget_show (result);
- gtk_widget_set_sensitive (result, FALSE);
-
- return result;
-}
-
-static void
-add_view_as_bonobo_menu_item (NautilusWindow *window,
- const char *placeholder_path,
- NautilusViewIdentifier *identifier,
- int index)
-{
- char *tip;
- char *item_path;
-
- nautilus_bonobo_add_numbered_radio_menu_item
- (window->details->shell_ui,
- placeholder_path,
- index,
- identifier->view_as_label_with_mnemonic,
- "viewers group");
-
- tip = g_strdup_printf (_("Display this location with \"%s\""),
- identifier->viewer_label);
- item_path = nautilus_bonobo_get_numbered_menu_item_path
- (window->details->shell_ui,
- placeholder_path,
- index);
- nautilus_bonobo_set_tip (window->details->shell_ui, item_path, tip);
- g_free (item_path);
- g_free (tip);
-}
-
-static void
-remove_first_child (GtkContainer *container)
-{
- gtk_container_remove (container,
- eel_gtk_container_get_first_child (container));
-}
-
-/* Make a special first item in the "View as" option menu that represents
- * the current content view. This should only be called if the current
- * content view isn't already in the "View as" option menu.
- */
-static void
-update_extra_viewer_in_view_as_menus (NautilusWindow *window,
- const NautilusViewIdentifier *id)
-{
- GtkWidget *menu;
- GtkWidget *new_menu_item;
- gboolean had_extra_viewer;
-
- had_extra_viewer = window->details->extra_viewer != NULL;
-
- if (id == NULL) {
- if (!had_extra_viewer) {
- return;
- }
- } else {
- if (had_extra_viewer
- && nautilus_view_identifier_compare (window->details->extra_viewer, id) == 0) {
- return;
- }
- }
- nautilus_view_identifier_free (window->details->extra_viewer);
- window->details->extra_viewer = nautilus_view_identifier_copy (id);
-
- /* Update the View As option menu */
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove menu before changing contents so it is resized properly
- * when reattached later in this function.
- */
- g_object_ref (menu);
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove old menu item, and either remove or add separator. */
- if (had_extra_viewer) {
- remove_first_child (GTK_CONTAINER (menu));
- if (id == NULL) {
- remove_first_child (GTK_CONTAINER (menu));
- }
- } else {
- if (id != NULL) {
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_gtk_separator ());
- }
- }
-
- /* Add new menu item. */
- if (id != NULL) {
- new_menu_item = create_view_as_menu_item (window, window->details->extra_viewer, 0);
- g_object_set_data (G_OBJECT (new_menu_item), "extra viewer", GINT_TO_POINTER (TRUE));
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_menu_item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu), menu);
- g_object_unref (menu);
-
- /* Also update the Bonobo View menu item */
- if (id == NULL) {
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER);
- } else {
- add_view_as_bonobo_menu_item (window,
- NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER,
- window->details->extra_viewer,
- 0);
- }
-}
-
-static void
-remove_extra_viewer_in_view_as_menus (NautilusWindow *window)
-{
- update_extra_viewer_in_view_as_menus (window, NULL);
-}
-
-static void
-replace_extra_viewer_in_view_as_menus (NautilusWindow *window)
-{
- NautilusViewIdentifier *id;
-
- id = nautilus_window_get_content_view_id (window);
- update_extra_viewer_in_view_as_menus (window, id);
- nautilus_view_identifier_free (id);
-}
-
-/**
- * nautilus_window_synch_view_as_menus:
- *
- * Set the visible item of the "View as" option menu and
- * the marked "View as" item in the View menu to
- * match the current content view.
- *
- * @window: The NautilusWindow whose "View as" option menu should be synched.
- */
-void
-nautilus_window_synch_view_as_menus (NautilusWindow *window)
-{
- int index;
- char *verb_name, *command_path;
- GList *node;
- const char *numbered_menu_item_container_path;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- if (window->content_view == NULL) {
- return;
- }
-
- for (node = window->details->short_list_viewers, index = 0;
- node != NULL;
- node = node->next, ++index) {
- if (nautilus_window_content_view_matches_iid (window, ((NautilusViewIdentifier *)node->data)->iid)) {
- break;
- }
- }
- if (node == NULL) {
- replace_extra_viewer_in_view_as_menus (window);
- index = 0;
- numbered_menu_item_container_path = NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER;
- } else {
- remove_extra_viewer_in_view_as_menus (window);
- numbered_menu_item_container_path = NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER;
- }
-
- g_assert (numbered_menu_item_container_path != NULL);
-
- /* Make option menu show the right item */
- gtk_option_menu_set_history (GTK_OPTION_MENU (window->view_as_option_menu), index);
-
- /* Make View menu in menu bar mark the right item */
- verb_name = nautilus_bonobo_get_numbered_menu_item_command
- (window->details->shell_ui,
- numbered_menu_item_container_path, index);
- command_path = g_strconcat (COMMAND_PREFIX, verb_name, NULL);
- nautilus_bonobo_set_toggle_state (window->details->shell_ui, command_path, TRUE);
- g_free (command_path);
- g_free (verb_name);
-}
-
-static void
-chose_component_callback (NautilusViewIdentifier *identifier, gpointer callback_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
- if (identifier != NULL) {
- nautilus_window_set_content_view (window, identifier);
- }
-
- /* FIXME bugzilla.gnome.org 41334: There should be some global
- * way to signal that the file type associations have changed,
- * so that the places that display these lists can react. For
- * now, hardwire this case, which is the most obvious one by
- * far.
- */
- nautilus_window_load_view_as_menus (window);
-}
-
-static void
-cancel_chose_component_callback (NautilusWindow *window)
-{
- if (window->details->viewed_file != NULL) {
- nautilus_cancel_choose_component_for_file (window->details->viewed_file,
- chose_component_callback,
- window);
- }
-}
-
-void
-nautilus_window_show_view_as_dialog (NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- /* Call back when the user chose the component. */
- cancel_chose_component_callback (window);
- nautilus_choose_component_for_file (window->details->viewed_file,
- GTK_WINDOW (window),
- chose_component_callback,
- window);
-}
-
-static void
-view_as_menu_choose_view_callback (GtkWidget *widget, gpointer data)
-{
- NautilusWindow *window;
-
- g_assert (GTK_IS_MENU_ITEM (widget));
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- window = NAUTILUS_WINDOW (data);
-
- /* Set the option menu back to its previous setting (Don't
- * leave it on this dialog-producing "View as..."
- * setting). If the menu choice causes a content view change,
- * this will be updated again later, in
- * nautilus_window_load_view_as_menus. Do this right away so
- * the user never sees the option menu set to "View as
- * Other...".
- */
- nautilus_window_synch_view_as_menus (window);
-
- nautilus_window_show_view_as_dialog (window);
-}
-
-static void
-refresh_stored_viewers (NautilusWindow *window)
-{
- GList *components, *node, *viewers;
- NautilusViewIdentifier *identifier;
-
- components = nautilus_mime_get_short_list_components_for_file (window->details->viewed_file);
- viewers = NULL;
- for (node = components; node != NULL; node = node->next) {
- identifier = nautilus_view_identifier_new_from_content_view (node->data);
- viewers = g_list_prepend (viewers, identifier);
- }
- gnome_vfs_mime_component_list_free (components);
-
- free_stored_viewers (window);
- window->details->short_list_viewers = g_list_reverse (viewers);
-}
-
-static void
-load_view_as_menus_callback (NautilusFile *file,
- gpointer callback_data)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
- GList *node;
- NautilusWindow *window;
- int index;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- g_assert (GTK_IS_OPTION_MENU (window->view_as_option_menu));
-
- /* Clear out the menu items created last time. For the option menu, we need do
- * nothing since we replace the entire menu. For the View menu, we have
- * to do this explicitly.
- */
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER);
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER);
-
- refresh_stored_viewers (window);
-
- new_menu = gtk_menu_new ();
-
- /* Add a menu item for each view in the preferred list for this location. */
- for (node = window->details->short_list_viewers, index = 0;
- node != NULL;
- node = node->next, ++index) {
- /* Menu item in option menu. This doesn't use Bonobo, for various
- * historical and technical reasons.
- */
- menu_item = create_view_as_menu_item (window, node->data, index);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- /* Menu item in View menu. */
- add_view_as_bonobo_menu_item (window,
- NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER,
- node->data,
- index);
- }
-
- /* Add/Show separator before "View as..." if there are any other viewers in menu. */
- if (window->details->short_list_viewers != NULL) {
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), new_gtk_separator ());
- }
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR,
- window->details->short_list_viewers == NULL);
-
- /* Add "View as..." extra bonus choice. */
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- g_signal_connect_object (menu_item, "activate",
- G_CALLBACK (view_as_menu_choose_view_callback), window, 0);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- /* We create and attach a new menu here because adding/removing
- * items from existing menu screws up the size of the option menu.
- */
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
-
- nautilus_window_synch_view_as_menus (window);
-}
-
-static void
-cancel_view_as_callback (NautilusWindow *window)
-{
- nautilus_file_cancel_call_when_ready (window->details->viewed_file,
- load_view_as_menus_callback,
- window);
-}
-
-void
-nautilus_window_load_view_as_menus (NautilusWindow *window)
-{
- NautilusFileAttributes attributes;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- attributes = nautilus_mime_actions_get_full_file_attributes ();
-
- cancel_view_as_callback (window);
- nautilus_file_call_when_ready (window->details->viewed_file,
- attributes,
- load_view_as_menus_callback,
- window);
-}
-
-void
-nautilus_window_add_sidebar_panel (NautilusWindow *window,
- NautilusViewFrame *sidebar_panel)
-{
- char *label;
- const char *view_iid;
- char *default_iid;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
- g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar));
- g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL);
-
- label = nautilus_view_frame_get_label (sidebar_panel);
-
- nautilus_side_pane_add_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel),
- label);
- g_free (label);
-
- g_object_ref (sidebar_panel);
- window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel);
-
- view_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
- default_iid = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW);
-
- if (view_iid && default_iid && !strcmp (view_iid, default_iid)) {
- nautilus_side_pane_show_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- }
-
- g_free (default_iid);
-}
-
-void
-nautilus_window_remove_sidebar_panel (NautilusWindow *window, NautilusViewFrame *sidebar_panel)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
-
- if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL) {
- return;
- }
-
- nautilus_side_pane_remove_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel);
- g_object_unref (sidebar_panel);
-}
-
-void
-nautilus_window_go_back (NautilusWindow *window)
-{
- nautilus_window_back_or_forward (window, TRUE, 0);
-}
-
-void
-nautilus_window_go_forward (NautilusWindow *window)
-{
- nautilus_window_back_or_forward (window, FALSE, 0);
-}
-
-void
-nautilus_window_go_up (NautilusWindow *window)
-{
- GnomeVFSURI *current_uri;
- GnomeVFSURI *parent_uri;
- GList *selection;
- char *parent_uri_string;
-
- if (window->details->location == NULL) {
- return;
- }
-
- current_uri = gnome_vfs_uri_new (window->details->location);
- parent_uri = gnome_vfs_uri_get_parent (current_uri);
- gnome_vfs_uri_unref (current_uri);
-
- if (parent_uri == NULL) {
- g_warning ("Can't go Up from here. The UI should have prevented us from getting this far.");
- return;
- }
-
- parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (parent_uri);
-
- selection = g_list_prepend (NULL, g_strdup (window->details->location));
-
- nautilus_window_open_location_with_selection (window, parent_uri_string, selection);
-
- g_free (parent_uri_string);
- eel_g_list_free_deep (selection);
-}
-
-void
-nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode)
-{
- nautilus_switchable_navigation_bar_set_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar),
- search_mode
- ? NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH
- : NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION);
-
-
-}
-
-gboolean
-nautilus_window_get_search_mode (NautilusWindow *window)
-{
- return nautilus_switchable_navigation_bar_get_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar))
- == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH;
-}
-
-void
-nautilus_window_go_home (NautilusWindow *window)
-{
- char *home_uri;
-
- nautilus_window_set_search_mode (window, FALSE);
-
-#ifdef WEB_NAVIGATION_ENABLED
- home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
-#else
- home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-#endif
-
- g_assert (home_uri != NULL);
- nautilus_window_go_to (window, home_uri);
- g_free (home_uri);
-}
-
-void
-nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_BACK, allow);
- /* Have to handle non-standard Back button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->back_button_item), allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_FORWARD, allow);
- /* Have to handle non-standard Forward button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->forward_button_item), allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_UP, allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_RELOAD, allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_burn_cd (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_COMMAND_BURN_CD, !allow);
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_send_history_list_changed (void)
-{
- g_signal_emit_by_name (nautilus_signaller_get_current (),
- "history_list_changed");
-}
-
-static void
-free_history_list (void)
-{
- eel_g_object_list_free (history_list);
- history_list = NULL;
-}
-
-/* Remove the this URI from the history list.
- * Do not sent out a change notice.
- * We pass in a bookmark for convenience.
- */
-static void
-remove_from_history_list (NautilusBookmark *bookmark)
-{
- GList *node;
-
- /* Compare only the uris here. Comparing the names also is not
- * necessary and can cause problems due to the asynchronous
- * nature of when the title of the window is set.
- */
- node = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
-
- /* Remove any older entry for this same item. There can be at most 1. */
- if (node != NULL) {
- history_list = g_list_remove_link (history_list, node);
- g_object_unref (node->data);
- g_list_free_1 (node);
- }
-}
-
-static void
-add_to_history_list (NautilusBookmark *bookmark)
-{
- /* Note that the history is shared amongst all windows so
- * this is not a NautilusWindow function. Perhaps it belongs
- * in its own file.
- */
- int i;
- GList *l, *next;
- static gboolean free_history_list_is_set_up;
-
- g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
-
- if (!free_history_list_is_set_up) {
- eel_debug_call_at_shutdown (free_history_list);
- free_history_list_is_set_up = TRUE;
- }
-
-/* g_warning ("Add to history list '%s' '%s'",
- nautilus_bookmark_get_name (bookmark),
- nautilus_bookmark_get_uri (bookmark)); */
-
- if (!history_list ||
- nautilus_bookmark_compare_uris (history_list->data, bookmark)) {
- g_object_ref (bookmark);
- remove_from_history_list (bookmark);
- history_list = g_list_prepend (history_list, bookmark);
-
- for (i = 0, l = history_list; l; l = next) {
- next = l->next;
-
- if (i++ >= MAX_HISTORY_ITEMS) {
- g_object_unref (l->data);
- history_list = g_list_delete_link (history_list, l);
- }
- }
-
- nautilus_send_history_list_changed ();
- }
-}
-
-void
-nautilus_remove_from_history_list_no_notify (const char *uri)
-{
- NautilusBookmark *bookmark;
-
- bookmark = nautilus_bookmark_new (uri, "");
- remove_from_history_list (bookmark);
- g_object_unref (bookmark);
-}
-
-static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- add_to_history_list (window->current_location_bookmark);
-}
-
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
-}
-
-void
-nautilus_window_clear_forward_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->forward_list);
- window->forward_list = NULL;
-}
-
-void
-nautilus_window_clear_back_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->back_list);
- window->back_list = NULL;
-}
-
-void
-nautilus_forget_history (void)
-{
- GList *window_node;
- NautilusWindow *window;
-
- /* Clear out each window's back & forward lists. Also, remove
- * each window's current location bookmark from history list
- * so it doesn't get clobbered.
- */
- for (window_node = nautilus_application_get_window_list ();
- window_node != NULL;
- window_node = window_node->next) {
-
- window = NAUTILUS_WINDOW (window_node->data);
-
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
- nautilus_window_allow_back (window, FALSE);
- nautilus_window_allow_forward (window, FALSE);
-
- history_list = g_list_remove (history_list, window->current_location_bookmark);
- }
-
- /* Clobber history list. */
- free_history_list ();
-
- /* Re-add each window's current location to history list. */
- for (window_node = nautilus_application_get_window_list ();
- window_node != NULL;
- window_node = window_node->next) {
-
- window = NAUTILUS_WINDOW (window_node->data);
- nautilus_window_add_current_location_to_history_list (window);
- }
-}
-
-GList *
-nautilus_get_history_list (void)
-{
- return history_list;
-}
-
-void
-nautilus_window_display_error (NautilusWindow *window, const char *error_msg)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, error_msg, NULL);
- gtk_widget_show (dialog);
-}
-
-void
-nautilus_window_set_content_view_widget (NautilusWindow *window,
- NautilusViewFrame *new_view)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view));
-
- if (new_view == window->content_view) {
- return;
- }
-
- if (window->content_view != NULL) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
-
- if (new_view != NULL) {
- gtk_widget_show (GTK_WIDGET (new_view));
-
- /* When creating the desktop window the UI needs to
- * be in sync. Otherwise I get failed assertions in
- * bonobo while trying to reference something called
- * `/commands/Unmount Volume Conditional'
- */
- nautilus_window_ui_update (window);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (!GTK_IS_PANED (window->content_hbox)) {
- gtk_container_add (GTK_CONTAINER (window->content_hbox),
- GTK_WIDGET (new_view));
- } else {
- nautilus_horizontal_splitter_pack2 (
- NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
- GTK_WIDGET (new_view));
- }
- }
-
- /* Display or hide zoom control */
- if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) {
- gtk_widget_show (window->zoom_control);
- } else {
- gtk_widget_hide (window->zoom_control);
- }
-
- window->content_view = new_view;
-}
-
-/**
- * add_sidebar_panels:
- * @window: A NautilusWindow
- *
- * Adds all sidebars available
- *
- */
-static void
-add_sidebar_panels (NautilusWindow *window)
-{
- GList *identifier_list;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->sidebar == NULL) {
- return;
- }
-
- identifier_list = nautilus_sidebar_get_all_sidebar_panel_view_identifiers ();
- nautilus_window_set_sidebar_panels (window, identifier_list);
- nautilus_view_identifier_list_free (identifier_list);
-
- set_current_side_panel
- (window,
- nautilus_side_pane_get_current_panel (window->sidebar));
-}
-
-static void
-show_dock_item (NautilusWindow *window, const char *dock_item_path)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- return;
- }
-
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- dock_item_path,
- FALSE);
- nautilus_window_update_show_hide_menu_items (window);
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-hide_dock_item (NautilusWindow *window, const char *dock_item_path)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- dock_item_path,
- TRUE);
- nautilus_window_update_show_hide_menu_items (window);
-
- nautilus_window_ui_thaw (window);
-}
-
-static gboolean
-dock_item_showing (NautilusWindow *window, const char *dock_item_path)
-{
- return !nautilus_bonobo_get_hidden (window->details->shell_ui,
- dock_item_path);
-}
-
-void
-nautilus_window_hide_location_bar (NautilusWindow *window, gboolean save_preference)
-{
- window->details->temporary_navigation_bar = FALSE;
- hide_dock_item (window, LOCATION_BAR_PATH);
- if (save_preference &&
- eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_location_bar (NautilusWindow *window, gboolean save_preference)
-{
- show_dock_item (window, LOCATION_BAR_PATH);
- if (save_preference &&
- eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_location_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, LOCATION_BAR_PATH);
-}
-
-void
-nautilus_window_hide_toolbar (NautilusWindow *window)
-{
- hide_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_toolbar (NautilusWindow *window)
-{
- nautilus_window_activate_throbber (window);
- show_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_toolbar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, TOOLBAR_PATH);
-}
-
-void
-nautilus_window_hide_sidebar (NautilusWindow *window)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar == NULL) {
- return;
- }
-
- nautilus_window_tear_down_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_sidebar (NautilusWindow *window)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar != NULL) {
- return;
- }
-
- nautilus_window_set_up_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_sidebar_showing (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), FALSE);
-
- return (window->sidebar != NULL) && GTK_IS_PANED (window->content_hbox)
- && nautilus_horizontal_splitter_is_hidden (NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox));
-}
-
-void
-nautilus_window_hide_status_bar (NautilusWindow *window)
-{
- hide_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_status_bar (NautilusWindow *window)
-{
- show_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_status_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, STATUS_BAR_PATH);
-}
-
-/**
- * nautilus_window_get_base_page_index:
- * @window: Window to get index from
- *
- * Returns the index of the base page in the history list.
- * Base page is not the currently displayed page, but the page
- * that acts as the base from which the back and forward commands
- * navigate from.
- */
-gint
-nautilus_window_get_base_page_index (NautilusWindow *window)
-{
- gint forward_count;
-
- forward_count = g_list_length (window->forward_list);
-
- /* If forward is empty, the base it at the top of the list */
- if (forward_count == 0) {
- return 0;
- }
-
- /* The forward count indicate the relative postion of the base page
- * in the history list
- */
- return forward_count;
-}
-
-/**
- * nautilus_window_show:
- * @widget: GtkWidget
- *
- * Call parent and then show/hide window items
- * base on user prefs.
- */
-static void
-nautilus_window_show (GtkWidget *widget)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
-
- GTK_WIDGET_CLASS (parent_class)->show (widget);
-
- /* Initially show or hide views based on preferences; once the window is displayed
- * these can be controlled on a per-window basis from View menu items.
- */
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- nautilus_window_show_toolbar (window);
- } else {
- nautilus_window_hide_toolbar (window);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- nautilus_window_show_location_bar (window, FALSE);
- } else {
- nautilus_window_hide_location_bar (window, FALSE);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- nautilus_window_show_status_bar (window);
- } else {
- nautilus_window_hide_status_bar (window);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_show_sidebar (window);
- } else {
- nautilus_window_hide_sidebar (window);
- }
-
- nautilus_window_ui_update (window);
-}
-
-Bonobo_UIContainer
-nautilus_window_get_ui_container (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), CORBA_OBJECT_NIL);
-
- return BONOBO_OBJREF (window->details->ui_container);
-}
-
-void
-nautilus_window_set_viewed_file (NautilusWindow *window,
- NautilusFile *file)
-{
- NautilusFileAttributes attributes;
-
- if (window->details->viewed_file == file) {
- return;
- }
-
- nautilus_file_ref (file);
-
- cancel_view_as_callback (window);
- cancel_chose_component_callback (window);
-
- if (window->details->viewed_file != NULL) {
- nautilus_file_monitor_remove (window->details->viewed_file,
- window);
- }
-
- if (file != NULL) {
- attributes = NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
- nautilus_file_monitor_add (file, window, attributes);
- }
-
- nautilus_file_unref (window->details->viewed_file);
- window->details->viewed_file = file;
-}
-
-static void
-nautilus_window_class_init (NautilusWindowClass *class)
-{
- G_OBJECT_CLASS (class)->finalize = nautilus_window_finalize;
- G_OBJECT_CLASS (class)->get_property = nautilus_window_get_property;
- G_OBJECT_CLASS (class)->set_property = nautilus_window_set_property;
- GTK_OBJECT_CLASS (class)->destroy = nautilus_window_destroy;
- GTK_WIDGET_CLASS (class)->show = nautilus_window_show;
- GTK_WIDGET_CLASS (class)->unrealize = nautilus_window_unrealize;
- GTK_WIDGET_CLASS (class)->size_request = nautilus_window_size_request;
- class->add_current_location_to_history_list = real_add_current_location_to_history_list;
-
- g_object_class_install_property (G_OBJECT_CLASS (class),
- ARG_APP_ID,
- g_param_spec_string ("app_id",
- _("Application ID"),
- _("The application ID of the window."),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (G_OBJECT_CLASS (class),
- ARG_APP,
- g_param_spec_object ("app",
- _("Application"),
- _("The NautilusApplication associated with this window."),
- NAUTILUS_TYPE_APPLICATION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /* Set default for all windows. This probably should be done
- * in main or NautilusApplication rather than here in case
- * some other window is created before the first
- * NautilusWindow. Also, do we really want this icon for
- * dialogs?
- */
- set_up_default_icon_list ();
-}
diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h
deleted file mode 100644
index a14157094..000000000
--- a/src/nautilus-object-window.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
-/*
- * Nautilus
- *
- * Copyright (C) 1999, 2000 Red Hat, Inc.
- * Copyright (C) 1999, 2000, 2001 Eazel, Inc.
- *
- * Nautilus is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Nautilus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Authors: Elliot Lee <sopwith@redhat.com>
- * Darin Adler <darin@bentspoon.com>
- *
- */
-/* nautilus-window.h: Interface of the main window object */
-
-#ifndef NAUTILUS_WINDOW_H
-#define NAUTILUS_WINDOW_H
-
-#include <bonobo/bonobo-window.h>
-#include <eel/eel-glib-extensions.h>
-#include <libnautilus-private/nautilus-bookmark.h>
-#include <libnautilus-private/nautilus-view-identifier.h>
-#include "nautilus-applicable-views.h"
-#include "nautilus-view-frame.h"
-#include "nautilus-application.h"
-#include "nautilus-information-panel.h"
-#include "nautilus-side-pane.h"
-
-#define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type())
-#define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow))
-#define NAUTILUS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_WINDOW, NautilusWindowClass))
-#define NAUTILUS_IS_WINDOW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_WINDOW))
-#define NAUTILUS_IS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_WINDOW))
-
-#ifndef NAUTILUS_WINDOW_DEFINED
-#define NAUTILUS_WINDOW_DEFINED
-typedef struct NautilusWindow NautilusWindow;
-#endif
-
-typedef struct {
- BonoboWindowClass parent_spot;
-
- /* Function pointers for overriding, without corresponding signals */
-
- /* add_current_location_to_history_list is a function pointer that
- * subclasses may override if they wish to add something other than
- * NautilusWindow's idea of the "current location" to the history
- * list, or nothing at all.
- */
- void (* add_current_location_to_history_list) (NautilusWindow *window);
-} NautilusWindowClass;
-
-typedef enum {
- NAUTILUS_WINDOW_NOT_SHOWN,
- NAUTILUS_WINDOW_POSITION_SET,
- NAUTILUS_WINDOW_SHOULD_SHOW
-} NautilusWindowShowState;
-
-typedef struct NautilusWindowDetails NautilusWindowDetails;
-
-struct NautilusWindow {
- BonoboWindow parent_object;
-
- NautilusWindowDetails *details;
-
- /** UI stuff **/
- NautilusSidePane *sidebar;
- NautilusInformationPanel *information_panel;
- GtkWidget *content_hbox;
- GtkWidget *view_as_option_menu;
- GtkWidget *navigation_bar;
-
- char *last_geometry;
-
- guint save_geometry_timeout_id;
-
- /** CORBA-related elements **/
- NautilusApplication *application;
-
- /** State information **/
-
- /* Information about current location/selection */
-
- /* Back/Forward chain, and history list.
- * The data in these lists are NautilusBookmark pointers.
- */
- GList *back_list, *forward_list;
-
- NautilusBookmark *current_location_bookmark;
- NautilusBookmark *last_location_bookmark;
-
- /* Current views stuff */
- NautilusViewFrame *content_view;
- GList *sidebar_panels;
-
- /* Widgets to keep track of (for state changes, etc) */
- GtkWidget *zoom_control;
-
- /* Pending changes */
- NautilusViewFrame *new_content_view;
-
- /* Window showed state (for saved_window_positions) */
- NautilusWindowShowState show_state;
-};
-
-GType nautilus_window_get_type (void);
-void nautilus_window_ui_freeze (NautilusWindow *window);
-void nautilus_window_ui_thaw (NautilusWindow *window);
-void nautilus_window_close (NautilusWindow *window);
-char * nautilus_window_get_location (NautilusWindow *window);
-void nautilus_window_go_to (NautilusWindow *window,
- const char *location);
-gboolean nautilus_window_get_search_mode (NautilusWindow *window);
-void nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode);
-void nautilus_window_go_home (NautilusWindow *window);
-void nautilus_window_display_error (NautilusWindow *window,
- const char *error_msg);
-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);
-void nautilus_window_allow_burn_cd (NautilusWindow *window,
- gboolean allow);
-void nautilus_window_clear_back_list (NautilusWindow *window);
-void nautilus_window_clear_forward_list (NautilusWindow *window);
-void nautilus_forget_history (void);
-void nautilus_bookmarks_exiting (void);
-void nautilus_window_reload (NautilusWindow *window);
-gint nautilus_window_get_base_page_index (NautilusWindow *window);
-void nautilus_window_hide_location_bar (NautilusWindow *window,
- gboolean save_preference);
-void nautilus_window_show_location_bar (NautilusWindow *window,
- gboolean save_preference);
-gboolean nautilus_window_location_bar_showing (NautilusWindow *window);
-void nautilus_window_hide_toolbar (NautilusWindow *window);
-void nautilus_window_show_toolbar (NautilusWindow *window);
-gboolean nautilus_window_toolbar_showing (NautilusWindow *window);
-void nautilus_window_hide_sidebar (NautilusWindow *window);
-void nautilus_window_show_sidebar (NautilusWindow *window);
-gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
-void nautilus_window_hide_status_bar (NautilusWindow *window);
-void nautilus_window_show_status_bar (NautilusWindow *window);
-gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
-void nautilus_window_save_geometry (NautilusWindow *window);
-
-#endif
diff --git a/src/nautilus-shell-ui.xml b/src/nautilus-shell-ui.xml
index dd8247b27..0d8b67c9a 100644
--- a/src/nautilus-shell-ui.xml
+++ b/src/nautilus-shell-ui.xml
@@ -6,12 +6,7 @@
<!-- We define commands here for (at least) all the items
for which we share tip or sensitivity state between more
than one item (usually 1 menuitem and 1 toolitem.
- -->
-
- <cmd name="Back" accel="*Alt*Left"
- _tip="Go to the previous visited location"/>
- <cmd name="Forward" accel="*Alt*Right"
- _tip="Go to the next visited location"/>
+ -->
<cmd name="Up"
_tip="Go up one level"/>
<cmd name="Find"
@@ -19,9 +14,6 @@
<cmd name="Toggle Find Mode"
_label="Find"
_tip="Search this computer for files"/>
- <cmd name="New Window"
- _label="Open New _Window"
- _tip="Open another Nautilus window for the displayed location"/>
<cmd name="Home"
_tip="Go to the home location"/>
<cmd name="Stop"
@@ -59,15 +51,10 @@
<submenu name="File" _label="_File">
<placeholder name="New Items Placeholder" delimit="none">
- <menuitem name="New Window"
- accel="*Control*n"
- verb="New Window"/>
</placeholder>
- <placeholder name="Open Placeholder" delimit="top"/>
- <menuitem name="Find"
- _label="_Find"
- verb="Find"/>
+ <placeholder name="Open Placeholder" delimit="top"/>
+ <placeholder name="Location Placeholder" delimit="top"/>
<placeholder name="General Status Placeholder" delimit="top"/>
<placeholder name="File Items Placeholder" delimit="top"/>
@@ -79,11 +66,8 @@
<separator/>
- <menuitem name="Close All Windows"
- _label="Close _All Windows"
- _tip="Close all Nautilus windows"
- accel="*Control**Shift*w"
- verb="Close All Windows"/>
+ <placeholder name="Close Items Placeholder"/>
+
<menuitem name="Close"
_label="_Close Window"
_tip="Close this window"
@@ -166,28 +150,8 @@
verb="Reload"/>
<placeholder name="Show Hide Placeholder" delimit="top">
- <menuitem name="Show Hide Sidebar"
- type="toggle"
- _label="_Side Pane"
- _tip="Change the visibility of this window's sidebar"
- accel="F9"
- id="Show Hide Sidebar"/>
- <menuitem name="Show Hide Toolbar"
- type="toggle"
- _label="_Toolbar"
- _tip="Change the visibility of this window's toolbar"
- id="Show Hide Toolbar"/>
- <menuitem name="Show Hide Location Bar"
- type="toggle"
- _label="Location _Bar"
- _tip="Change the visibility of this window's location bar"
- id="Show Hide Location Bar"/>
- <menuitem name="Show Hide Statusbar"
- type="toggle"
- _label="St_atusbar"
- _tip="Change the visibility of this window's statusbar"
- id="Show Hide Statusbar"/>
</placeholder>
+
<placeholder name="View Preferences Placeholder" delimit = "top"/>
<placeholder name="View Items Placeholder" delimit="top"/>
@@ -212,70 +176,6 @@
<menuitem name="View as" _label="_View as..." verb="View as"/>
</placeholder>
</submenu>
-
- <submenu name="Go" _label="_Go">
- <menuitem name="Back"
- _label="_Back"
- pixtype="stock" pixname="gtk-go-back"
- verb="Back"/>
- <menuitem name="Forward"
- _label="_Forward"
- pixtype="stock" pixname="gtk-go-forward"
- verb="Forward"/>
- <menuitem name="Up"
- _label="_Up"
- accel="*Alt*Up"
- pixtype="stock" pixname="gtk-go-up"
- verb="Up"/>
-
- <separator/>
-
- <menuitem name="Home"
- _label="_Home"
- accel="*Alt*Home"
- pixtype="stock" pixname="gtk-home"
- verb="Home"/>
- <menuitem name="Start Here"
- _label="_Start Here"
- _tip="Go to the Start Here folder"
- verb="Start Here"/>
- <menuitem name="Go to Trash"
- _label="_Trash"
- _tip="Go to the trash folder"
- verb="Go to Trash"/>
- <menuitem name="Go to Burn CD"
- verb="Go to Burn CD"/>
- <menuitem name="Go to Location"
- _label="_Location..."
- accel="*Control*l"
- verb="Go to Location"/>
-
- <separator/>
-
- <menuitem name="Clear History"
- _label="_Clear History"
- _tip="Clear contents of Go menu and Back/Forward lists"
- verb="Clear History"/>
-
- <placeholder name="History Placeholder" delimit="top"/>
- </submenu>
-
- <submenu name="Bookmarks" _label="_Bookmarks">
- <menuitem name="Add Bookmark"
- _label="_Add Bookmark"
- _tip="Add a bookmark for the current location to this menu"
- accel="*Control*d"
- pixtype="stock" pixname="gtk-add"
- verb="Add Bookmark"/>
- <menuitem name="Edit Bookmarks"
- _label="_Edit Bookmarks"
- _tip="Display a window that allows editing the bookmarks in this menu"
- accel="*Control*b"
- verb="Edit Bookmarks"/>
-
- <placeholder name="Built-in Bookmarks Placeholder" delimit="top"/>
- <placeholder name="Bookmarks Placeholder" delimit="top"/>
- </submenu>
<placeholder/>
@@ -313,58 +213,6 @@
</submenu>
</menu>
-<dockitem name="Location Bar" behavior="exclusive,never vertical">
- <control name="Wrapper" behavior="expandable"/>
-</dockitem>
-
-<dockitem name="Toolbar" behavior="exclusive">
-
- <toolitem name="Back"
- _label="Back"
- priority="1"
- pixtype="stock" pixname="gtk-go-back"
- verb="Back"/>
- <control name="BackMenu"/>
- <toolitem name="Forward"
- _label="Forward"
- pixtype="stock" pixname="gtk-go-forward"
- verb="Forward"/>
- <control name="ForwardMenu"/>
- <toolitem name="Up"
- _label="Up"
- pixtype="stock" pixname="gtk-go-up"
- verb="Up"/>
- <toolitem name="Stop" _label="Stop"
- pixtype="stock" pixname="gtk-stop"
- verb="Stop"/>
- <toolitem name="Reload"
- _label="Reload"
- pixtype="stock" pixname="gtk-refresh"
- verb="Reload"/>
- <separator/>
-
- <toolitem name="Home"
- _label="Home"
- priority="1"
- pixtype="stock" pixname="gtk-home"
- verb="Home"/>
- <toolitem name="Toggle Find Mode"
- priority="1"
- type="toggle"
- pixtype="stock" pixname="Search"
- verb="Toggle Find Mode"/>
- <toolitem name="Burn CD"
- _label="Write to CD"
- priority="1"
- pixtype="stock" pixname="gtk-cdrom"
- verb="Burn CD"/>
-
-
- <placeholder name="Extra Buttons Placeholder" delimit="top"/>
-
- <control name="ThrobberWrapper" behavior="pack-end"/>
-</dockitem>
-
<status>
<!-- the name "main" is required by Bonobo -->
<item name="main"/>
@@ -374,8 +222,6 @@
<popup name="background" tearoff="0">
<placeholder name="Before Zoom Items" delimit="none">
<placeholder name="New Window Items" delimit="none">
- <menuitem name="New Window"
- verb="New Window"/>
</placeholder>
<placeholder name="New Object Items" delimit="none">
</placeholder>
diff --git a/src/nautilus-shell.c b/src/nautilus-shell.c
index 10e62a9e5..3c4c0299e 100644
--- a/src/nautilus-shell.c
+++ b/src/nautilus-shell.c
@@ -130,8 +130,10 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry)
const char *existing_location;
gboolean prefer_existing_window;
- prefer_existing_window = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW);
-
+#if NEW_UI_COMPLETE
+ /* FIXME: This needs more thought */
+#endif
+ prefer_existing_window = TRUE;
/* If the user's preference is always_open_in_new_window
* we raise an existing window for the location if it already exists.
@@ -156,9 +158,20 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry)
}
/* Otherwise, open a new window. */
- window = nautilus_application_create_window (shell->details->application,
- gdk_screen_get_default ());
-
+ if (uri) {
+ window = nautilus_application_present_spatial_window (shell->details->application,
+ uri,
+ gdk_screen_get_default ());
+ } else {
+ window = nautilus_application_create_navigation_window (shell->details->application,
+ gdk_screen_get_default ());
+ if (uri == NULL) {
+ nautilus_window_go_home (window);
+ } else {
+ nautilus_window_go_to (window, uri);
+ }
+ }
+
if (geometry != NULL) {
eel_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window),
geometry,
@@ -166,12 +179,6 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry)
APPLICATION_WINDOW_MIN_HEIGHT,
FALSE);
}
-
- if (uri == NULL) {
- nautilus_window_go_home (window);
- } else {
- nautilus_window_go_to (window, uri);
- }
}
static void
@@ -348,11 +355,16 @@ restore_one_window_callback (const char *attributes,
screen = gdk_screen_get_default ();
}
- window = nautilus_application_create_window (shell->details->application, screen);
-
+#if NEW_UI_COMPLETE
+/* don't always create object windows here */
+#endif
if (eel_strlen (location) > 0) {
- nautilus_window_go_to (window, location);
+ window = nautilus_application_present_spatial_window (shell->details->application,
+ location,
+ screen);
} else {
+ window = nautilus_application_create_navigation_window (shell->details->application,
+ screen);
nautilus_window_go_home (window);
}
diff --git a/src/nautilus-spatial-window-ui.xml b/src/nautilus-spatial-window-ui.xml
new file mode 100644
index 000000000..66859e782
--- /dev/null
+++ b/src/nautilus-spatial-window-ui.xml
@@ -0,0 +1,47 @@
+<Root>
+
+<!-- A description of each placeholder's purpose is in libnautilus/nautilus-bonobo-ui.h -->
+
+<commands>
+</commands>
+
+<menu>
+ <submenu name="File">
+ <placeholder name="Location Placeholder">
+ <menuitem name="Up"
+ _label="Open _Pa_rent"
+ _tip="Open the parent folder"
+ accel="*Alt*Up"
+ verb="Up"/>
+ <menuitem name="Go to Location"
+ _label="Open _Location..."
+ accel="*Control*l"
+ verb="Go to Location"/>
+ </placeholder>
+ <placeholder name="Close Items Placeholder">
+ <menuitem name="Close With Parents"
+ _label="Close _All Parents"
+ _tip="Close all Navigation windows"
+ accel="*Control**Shift*w"
+ verb="Close With Parents"/>
+ </placeholder>
+ </submenu>
+
+ <submenu name="Places" _label="_Places">
+ <menuitem name="Home"
+ _label="_Home"
+ accel="*Alt*Home"
+ pixtype="stock" pixname="gtk-home"
+ verb="Home"/>
+ <menuitem name="Go to Trash"
+ _label="_Trash"
+ _tip="Go to the trash folder"
+ verb="Go to Trash"/>
+ <menuitem name="Go to Burn CD"
+ _label="CD _Creator"
+ _tip="Go to the CD Creator"
+ verb="Go to Burn CD"/>
+ </submenu>
+</menu>
+
+</Root>
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 300f43ecb..7adb80ac1 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -28,9 +28,11 @@
/* nautilus-window.c: Implementation of the main window object */
#include <config.h>
+#include "nautilus-spatial-window.h"
#include "nautilus-window-private.h"
#include "nautilus-application.h"
+#include "nautilus-desktop-window.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-information-panel.h"
#include "nautilus-main.h"
@@ -81,940 +83,118 @@
#include <math.h>
#include <sys/time.h>
-/* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
-#include "nautilus-desktop-window.h"
-
-#define MAX_HISTORY_ITEMS 50
-
-/* FIXME bugzilla.gnome.org 41245: hardwired sizes */
-#define SIDE_PANE_MINIMUM_WIDTH 1
-#define SIDE_PANE_MINIMUM_HEIGHT 400
-
-/* dock items */
-#define LOCATION_BAR_PATH "/Location Bar"
-#define TOOLBAR_PATH "/Toolbar"
-#define STATUS_BAR_PATH "/status"
-#define MENU_BAR_PATH "/menu"
-
-#define COMMAND_PREFIX "/commands/"
-#define NAUTILUS_COMMAND_TOGGLE_FIND_MODE "/commands/Toggle Find Mode"
-#define NAUTILUS_COMMAND_VIEW_AS "/commands/View as"
+#define MAX_TITLE_LENGTH 180
-#define NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER "/menu/View/View Choices/Extra Viewer"
-#define NAUTILUS_MENU_PATH_BEFORE_SHORT_LIST_SEPARATOR "/menu/View/View Choices/Before Short List"
-#define NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER "/menu/View/View Choices/Short List"
-#define NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR "/menu/View/View Choices/After Short List"
-
-enum {
- ARG_0,
- ARG_APP_ID,
- ARG_APP
+struct _NautilusSpatialWindowDetails {
+ char *last_geometry;
+ guint save_geometry_timeout_id;
+
+ GtkWidget *content_box;
};
-static GList *history_list;
-static int side_pane_width_auto_value = SIDE_PANE_MINIMUM_WIDTH;
-
-static void add_sidebar_panels (NautilusWindow *window);
-static void cancel_view_as_callback (NautilusWindow *window);
-
-GNOME_CLASS_BOILERPLATE (NautilusWindow, nautilus_window,
- BonoboWindow, BONOBO_TYPE_WINDOW)
-
-static void
-set_up_default_icon_list (void)
-{
- GList *icon_list;
- guint i;
- GdkPixbuf *pixbuf;
- char *path;
- const char *icon_filenames[] = { "nautilus-mini-logo.png", "nautilus-launch-icon.png" };
-
- icon_list = NULL;
- for (i = 0; i < G_N_ELEMENTS (icon_filenames); i++) {
- path = nautilus_pixmap_file (icon_filenames[i]);
-
- if (path == NULL) {
- continue;
- }
-
- pixbuf = gdk_pixbuf_new_from_file (path, NULL);
- g_free (path);
-
- if (pixbuf != NULL) {
- icon_list = g_list_prepend (icon_list, pixbuf);
- }
- }
-
- gtk_window_set_default_icon_list (icon_list);
-
- eel_g_list_free_deep_custom (icon_list, (GFunc) g_object_unref, NULL);
-}
-
-static void
-icons_changed_callback (GObject *factory, NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_update_icon (window);
-}
-
-static void
-nautilus_window_instance_init (NautilusWindow *window)
-{
- window->details = g_new0 (NautilusWindowDetails, 1);
-
- /* CORBA and Bonobo setup, which must be done before the location bar setup */
- window->details->ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
- bonobo_object_ref (window->details->ui_container);
-
- window->details->tooltips = gtk_tooltips_new ();
- g_object_ref (G_OBJECT (window->details->tooltips));
- gtk_object_sink (GTK_OBJECT (window->details->tooltips));
-
- /* Set last geometry to NULL */
- window->last_geometry = NULL;
-
- /* Set initial window title */
- gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
-
- window->details->shell_ui = bonobo_ui_component_new ("Nautilus Shell");
- bonobo_ui_component_set_container
- (window->details->shell_ui,
- nautilus_window_get_ui_container (window),
- NULL);
-
- /* Register IconFactory callback to update the window border icon
- * when the icon-theme is changed.
- */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (icons_changed_callback), window,
- 0);
-
- /* Create a separate component so when we remove the status
- * we don't loose the status bar
- */
- window->details->status_ui = bonobo_ui_component_new ("Status Component");
- bonobo_ui_component_set_container
- (window->details->status_ui,
- nautilus_window_get_ui_container (window),
- NULL);
-
- gtk_quit_add_destroy (1, GTK_OBJECT (window));
-
- /* Keep the main event loop alive as long as the window exists */
- nautilus_main_event_loop_register (GTK_OBJECT (window));
-}
-
-static gint
-ui_idle_handler (gpointer data)
-{
- NautilusWindow *window;
- gboolean old_updating_bonobo_state;
-
- window = data;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_object_ref (data);
-
- g_assert (window->details->ui_change_depth == 0);
-
- /* Simulate an extra freeze/thaw so that calling window_ui_freeze
- * and thaw from within the idle handler doesn't try to remove it
- * (the already running idle handler)
- */
- window->details->ui_change_depth++;
- old_updating_bonobo_state = window->details->updating_bonobo_state;
-
- if (window->details->ui_pending_initialize_menus_part_2) {
- nautilus_window_initialize_menus_part_2 (window);
- window->details->ui_pending_initialize_menus_part_2 = FALSE;
- }
-
- if (window->details->ui_is_frozen) {
- window->details->updating_bonobo_state = TRUE;
- bonobo_ui_engine_thaw (bonobo_ui_container_get_engine (window->details->ui_container));
- window->details->ui_is_frozen = FALSE;
- window->details->updating_bonobo_state = old_updating_bonobo_state;
- }
-
- window->details->ui_change_depth--;
-
- window->details->ui_idle_id = 0;
-
- g_object_unref (data);
-
- return FALSE;
-}
-
-static inline void
-ui_install_idle_handler (NautilusWindow *window)
-{
- if (window->details->ui_idle_id == 0) {
- window->details->ui_idle_id = g_idle_add_full (G_PRIORITY_LOW, ui_idle_handler, window, NULL);
- }
-}
-
-static inline void
-ui_remove_idle_handler (NautilusWindow *window)
-{
- if (window->details->ui_idle_id != 0) {
- g_source_remove (window->details->ui_idle_id);
- window->details->ui_idle_id = 0;
- }
-}
-
-/* Register that BonoboUI changes are going to be made to WINDOW. The UI
- * won't actually be synchronised until some arbitrary date in the future.
- */
-void
-nautilus_window_ui_freeze (NautilusWindow *window)
-{
- g_object_ref (window);
-
- if (window->details->ui_change_depth == 0) {
- ui_remove_idle_handler (window);
- }
-
- if (!window->details->ui_is_frozen) {
- bonobo_ui_engine_freeze (bonobo_ui_container_get_engine (window->details->ui_container));
- window->details->ui_is_frozen = TRUE;
- }
-
- window->details->ui_change_depth++;
-}
-
-/* Register that the BonoboUI changes for WINDOW have finished. There _must_
- * be one and only one call to this function for every call to
- * starting_ui_change ()
- */
-void
-nautilus_window_ui_thaw (NautilusWindow *window)
-{
- window->details->ui_change_depth--;
-
- g_assert (window->details->ui_change_depth >= 0);
-
- if (window->details->ui_change_depth == 0
- && (window->details->ui_is_frozen
- || window->details->ui_pending_initialize_menus_part_2)) {
- ui_install_idle_handler (window);
- }
-
- g_object_unref (window);
-}
-
-/* Unconditionally synchronize the BonoboUI of WINDOW. */
-static void
-nautilus_window_ui_update (NautilusWindow *window)
-{
- BonoboUIEngine *engine;
- gboolean old_updating_bonobo_state;
-
- engine = bonobo_ui_container_get_engine (window->details->ui_container);
- old_updating_bonobo_state = window->details->updating_bonobo_state;
-
- window->details->updating_bonobo_state = TRUE;
- if (window->details->ui_is_frozen) {
- bonobo_ui_engine_thaw (engine);
- if (window->details->ui_change_depth == 0) {
- window->details->ui_is_frozen = FALSE;
- if (!window->details->ui_pending_initialize_menus_part_2) {
- ui_remove_idle_handler (window);
- }
- } else {
- bonobo_ui_engine_freeze (engine);
- }
- } else {
- bonobo_ui_engine_update (engine);
- }
- window->details->updating_bonobo_state = old_updating_bonobo_state;
-}
+GNOME_CLASS_BOILERPLATE (NautilusSpatialWindow, nautilus_spatial_window,
+ NautilusWindow, NAUTILUS_TYPE_WINDOW)
static gboolean
-nautilus_window_clear_status (gpointer callback_data)
+save_window_geometry_timeout (gpointer callback_data)
{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- bonobo_ui_component_set_status (window->details->status_ui, NULL, NULL);
-
- return FALSE;
-}
-
-void
-nautilus_window_set_status (NautilusWindow *window, const char *text)
-{
- if (text != NULL && text[0] != '\0') {
- bonobo_ui_component_set_status (window->details->status_ui, text, NULL);
- } else {
- nautilus_window_clear_status (window);
- }
-}
-
-void
-nautilus_window_go_to (NautilusWindow *window, const char *uri)
-{
- nautilus_window_open_location (window, uri);
-}
-
-char *
-nautilus_window_get_location (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
-
- return g_strdup (window->details->location);
-}
-
-static void
-go_to_callback (GtkWidget *widget,
- const char *uri,
- NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_go_to (window, uri);
-}
-
-static void
-navigation_bar_location_changed_callback (GtkWidget *widget,
- const char *uri,
- NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->details->temporary_navigation_bar) {
- if (nautilus_window_location_bar_showing (window)) {
- nautilus_window_hide_location_bar (window, FALSE);
- }
- window->details->temporary_navigation_bar = FALSE;
- }
-
- nautilus_window_go_to (window, uri);
-}
-
-static void
-navigation_bar_mode_changed_callback (GtkWidget *widget,
- NautilusSwitchableNavigationBarMode mode,
- NautilusWindow *window)
-{
- window->details->updating_bonobo_state = TRUE;
-
- g_assert (mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION
- || mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
-
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- NAUTILUS_COMMAND_TOGGLE_FIND_MODE,
- mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
+ NautilusSpatialWindow *window;
- window->details->updating_bonobo_state = FALSE;
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_zoom_in (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_in (window->content_view);
- }
-}
-
-void
-nautilus_window_zoom_to_level (NautilusWindow *window, float level)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_set_zoom_level (window->content_view, level);
- }
-}
-
-void
-nautilus_window_zoom_out (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_out (window->content_view);
- }
-}
-
-void
-nautilus_window_zoom_to_fit (NautilusWindow *window)
-{
- if (window->content_view != NULL) {
- nautilus_view_frame_zoom_to_fit (window->content_view);
- }
-}
-
-/* Code should never force the window taller than this size.
- * (The user can still stretch the window taller if desired).
- */
-static guint
-get_max_forced_height (GdkScreen *screen)
-{
- return (gdk_screen_get_height (screen) * 90) / 100;
-}
-
-/* Code should never force the window wider than this size.
- * (The user can still stretch the window wider if desired).
- */
-static guint
-get_max_forced_width (GdkScreen *screen)
-{
- return (gdk_screen_get_width (screen) * 90) / 100;
-}
-
-static void
-set_initial_window_geometry (NautilusWindow *window)
-{
- GdkScreen *screen;
- guint max_width_for_screen, max_height_for_screen;
-
- screen = gtk_window_get_screen (GTK_WINDOW (window));
+ window = NAUTILUS_SPATIAL_WINDOW (callback_data);
- /* Don't let GTK determine the minimum size
- * automatically. It will insist that the window be
- * really wide based on some misguided notion about
- * the content view area. Also, it might start the
- * window wider (or taller) than the screen, which
- * is evil. So we choose semi-arbitrary initial and
- * minimum widths instead of letting GTK decide.
- */
- /* FIXME - the above comment suggests that the size request
- * of the content view area is wrong, probably because of
- * another stupid set_usize someplace. If someone gets the
- * content view area's size request right then we can
- * probably remove this broken set_size_request() here.
- * - hp@redhat.com
- */
-
- max_width_for_screen = get_max_forced_width (screen);
- max_height_for_screen = get_max_forced_height (screen);
+ nautilus_spatial_window_save_geometry (window);
- gtk_widget_set_size_request (GTK_WIDGET (window),
- MIN (NAUTILUS_WINDOW_MIN_WIDTH,
- max_width_for_screen),
- MIN (NAUTILUS_WINDOW_MIN_HEIGHT,
- max_height_for_screen));
+ window->details->save_geometry_timeout_id = 0;
- gtk_window_set_default_size (GTK_WINDOW (window),
- MIN (NAUTILUS_WINDOW_DEFAULT_WIDTH,
- max_width_for_screen),
- MIN (NAUTILUS_WINDOW_DEFAULT_HEIGHT,
- max_height_for_screen));
-}
-
-/* Add a dummy menu with a "View as ..." item when we first create the
- * view_as_option_menu -- without this the menu draws empty and shrunk,
- * once we populate it it grows and forces the toolbar and all the other
- * views to re-layout.
- */
-static void
-set_dummy_initial_view_as_menu (NautilusWindow *window)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
-
- new_menu = gtk_menu_new ();
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
-}
-
-static void
-side_pane_close_requested_callback (GtkWidget *widget,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- nautilus_window_hide_sidebar (window);
-}
-
-static void
-side_pane_size_allocate_callback (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (allocation->width != window->details->side_pane_width) {
- window->details->side_pane_width = allocation->width;
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH)) {
- eel_preferences_set_integer
- (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
- allocation->width);
- }
- }
+ return FALSE;
}
-static void
-setup_side_pane_width (NautilusWindow *window)
+static gboolean
+nautilus_spatial_window_configure_event (GtkWidget *widget,
+ GdkEventConfigure *event)
{
- static gboolean setup_auto_value= TRUE;
-
- g_return_if_fail (window->sidebar != NULL);
+ NautilusSpatialWindow *window;
+ char *geometry_string;
- if (setup_auto_value) {
- setup_auto_value = FALSE;
- eel_preferences_add_auto_integer
- (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
- &side_pane_width_auto_value);
- }
-
- window->details->side_pane_width = side_pane_width_auto_value;
+ window = NAUTILUS_SPATIAL_WINDOW (widget);
- /* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
- /* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
+ GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
- gtk_paned_set_position (GTK_PANED (window->content_hbox),
- side_pane_width_auto_value);
-}
-
-static void
-side_panel_set_open (GtkWidget *view,
- gboolean open)
-{
- CORBA_Environment ev;
- Bonobo_PropertyBag property_bag;
- Bonobo_Control control;
-
- if (!view || !NAUTILUS_IS_VIEW_FRAME (view)) {
- return;
+ /* Only save the geometry if the user hasn't resized the window
+ * for half a second. Otherwise delay the callback another half second.
+ */
+ if (window->details->save_geometry_timeout_id != 0) {
+ g_source_remove (window->details->save_geometry_timeout_id);
}
-
- control = nautilus_view_frame_get_control (NAUTILUS_VIEW_FRAME (view));
+ if (GTK_WIDGET_VISIBLE (GTK_WIDGET (window)) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) {
+ geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
- if (control != CORBA_OBJECT_NIL) {
- CORBA_exception_init (&ev);
- property_bag = Bonobo_Control_getProperties (control, &ev);
- if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
- /* For some reason this was implemented as 'close'
- * before, but open seems more natural */
- bonobo_property_bag_client_set_value_gboolean
- (property_bag, "close", !open, &ev);
- bonobo_object_release_unref (property_bag, NULL);
- }
- }
-}
-
-static void
-set_current_side_panel (NautilusWindow *window,
- GtkWidget *panel)
-{
- if (window->details->current_side_panel) {
- side_panel_set_open (window->details->current_side_panel,
- FALSE);
- eel_remove_weak_pointer (&window->details->current_side_panel);
- }
-
- side_panel_set_open (panel, TRUE);
- window->details->current_side_panel = panel;
- eel_add_weak_pointer (&window->details->current_side_panel);
-}
-
-static void
-side_pane_switch_page_callback (NautilusSidePane *side_pane,
- GtkWidget *panel,
- NautilusWindow *window)
-{
- const char *view_iid;
-
- set_current_side_panel (window, panel);
-
- if (NAUTILUS_IS_VIEW_FRAME (panel)) {
- view_iid = nautilus_view_frame_get_view_iid (NAUTILUS_VIEW_FRAME (panel));
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) {
- eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW,
- view_iid);
- }
-
- } else {
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) {
- eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW, "");
+ /* If the last geometry is NULL the window must have just
+ * been shown. No need to save geometry to disk since it
+ * must be the same.
+ */
+ if (window->details->last_geometry == NULL) {
+ window->details->last_geometry = geometry_string;
+ return FALSE;
}
- }
-}
-
-static void
-nautilus_window_set_up_sidebar (NautilusWindow *window)
-{
- window->sidebar = nautilus_side_pane_new ();
-
- gtk_paned_pack1 (GTK_PANED (window->content_hbox),
- GTK_WIDGET (window->sidebar),
- FALSE, TRUE);
-
- setup_side_pane_width (window);
- g_signal_connect (window->sidebar,
- "size_allocate",
- G_CALLBACK (side_pane_size_allocate_callback),
- window);
-
- window->information_panel = nautilus_information_panel_new ();
- if (window->details->location != NULL &&
- window->details->title != NULL) {
- nautilus_information_panel_set_uri (window->information_panel,
- window->details->location,
- window->details->title);
- }
-
- g_signal_connect_object (window->information_panel, "location_changed",
- G_CALLBACK (go_to_callback), window, 0);
-
- /* Set up the sidebar panels. */
- nautilus_side_pane_add_panel (NAUTILUS_SIDE_PANE (window->sidebar),
- GTK_WIDGET (window->information_panel),
- _("Information"));
-
- add_sidebar_panels (window);
-
- g_signal_connect (window->sidebar,
- "close_requested",
- G_CALLBACK (side_pane_close_requested_callback),
- window);
-
- g_signal_connect (window->sidebar,
- "switch_page",
- G_CALLBACK (side_pane_switch_page_callback),
- window);
-
- gtk_widget_show (GTK_WIDGET (window->information_panel));
-
- gtk_widget_show (GTK_WIDGET (window->sidebar));
-}
-
-static void
-nautilus_window_tear_down_sidebar (NautilusWindow *window)
-{
- g_signal_handlers_disconnect_by_func (window->sidebar,
- side_pane_switch_page_callback,
- window);
-
- nautilus_window_set_sidebar_panels (window, NULL);
- gtk_widget_destroy (GTK_WIDGET (window->sidebar));
- window->sidebar = NULL;
- window->information_panel = NULL;
-}
-
-static void
-nautilus_window_constructed (NautilusWindow *window)
-{
- GtkWidget *location_bar_box;
- GtkWidget *view_as_menu_vbox;
- BonoboControl *location_bar_wrapper;
-
- nautilus_window_ui_freeze (window);
-
- /* Load the user interface from the XML file. */
- bonobo_ui_util_set_ui (window->details->shell_ui,
- DATADIR,
- "nautilus-shell-ui.xml",
- "nautilus", NULL);
-
- /* set up location bar */
- location_bar_box = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (location_bar_box), GNOME_PAD_SMALL);
-
- window->navigation_bar = nautilus_switchable_navigation_bar_new (window);
- gtk_widget_show (GTK_WIDGET (window->navigation_bar));
-
- g_signal_connect_object (window->navigation_bar, "location_changed",
- G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
- g_signal_connect_object (window->navigation_bar, "mode_changed",
- G_CALLBACK (navigation_bar_mode_changed_callback), window, 0);
-
- gtk_box_pack_start (GTK_BOX (location_bar_box), window->navigation_bar,
- TRUE, TRUE, GNOME_PAD_SMALL);
-
- /* Option menu for content view types; it's empty here, filled in when a uri is set.
- * Pack it into vbox so it doesn't grow vertically when location bar does.
- */
- view_as_menu_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_widget_show (view_as_menu_vbox);
- gtk_box_pack_end (GTK_BOX (location_bar_box), view_as_menu_vbox, FALSE, FALSE, 0);
-
- window->view_as_option_menu = gtk_option_menu_new ();
- gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), window->view_as_option_menu, TRUE, FALSE, 0);
- gtk_widget_show (window->view_as_option_menu);
- /* Make sure there is something in the option menu to prevent it from
- * growing later.
- */
- set_dummy_initial_view_as_menu (window);
-
- /* Allocate the zoom control and place on the right next to the menu.
- * It gets shown later, if the view-frame contains something zoomable.
- */
- window->zoom_control = nautilus_zoom_control_new ();
- g_signal_connect_object (window->zoom_control, "zoom_in",
- G_CALLBACK (nautilus_window_zoom_in),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_out",
- G_CALLBACK (nautilus_window_zoom_out),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_level",
- G_CALLBACK (nautilus_window_zoom_to_level),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_fit",
- G_CALLBACK (nautilus_window_zoom_to_fit),
- window, G_CONNECT_SWAPPED);
- gtk_box_pack_end (GTK_BOX (location_bar_box), window->zoom_control, FALSE, FALSE, 0);
-
- gtk_widget_show (location_bar_box);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- window->content_hbox = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
- } else {
- set_initial_window_geometry (window);
-
- window->content_hbox = nautilus_horizontal_splitter_new ();
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_set_up_sidebar (window);
+ /* Don't save geometry if it's the same as before. */
+ if (!strcmp (window->details->last_geometry,
+ geometry_string)) {
+ g_free (geometry_string);
+ return FALSE;
}
- }
- gtk_widget_show (window->content_hbox);
- bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
-
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
+ g_free (window->details->last_geometry);
+ window->details->last_geometry = geometry_string;
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- LOCATION_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- TOOLBAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- STATUS_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- MENU_BAR_PATH, TRUE);
+ window->details->save_geometry_timeout_id =
+ g_timeout_add (500, save_window_geometry_timeout, window);
}
-
- /* Wrap the location bar in a control and set it up. */
- location_bar_wrapper = bonobo_control_new (location_bar_box);
- bonobo_ui_component_object_set (window->details->shell_ui,
- "/Location Bar/Wrapper",
- BONOBO_OBJREF (location_bar_wrapper),
- NULL);
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
- bonobo_object_unref (location_bar_wrapper);
-
- /* initalize the menus and toolbars */
- nautilus_window_initialize_menus_part_1 (window);
- nautilus_window_initialize_toolbars (window);
-
- /* We'll do the second part later (bookmarks and go menus) */
- window->details->ui_pending_initialize_menus_part_2 = TRUE;
-
- /* 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);
-
- nautilus_window_allow_burn_cd (window, FALSE);
- /* Set up undo manager */
- nautilus_undo_manager_attach (window->application->undo_manager, G_OBJECT (window));
-
- /* Register that things may be dragged from this window */
- nautilus_drag_window_register (GTK_WINDOW (window));
-
- nautilus_window_ui_thaw (window);
+ return FALSE;
}
static void
-nautilus_window_set_property (GObject *object,
- guint arg_id,
- const GValue *value,
- GParamSpec *pspec)
+nautilus_spatial_window_unrealize (GtkWidget *widget)
{
- char *old_name;
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
+ NautilusSpatialWindow *window;
- switch (arg_id) {
- case ARG_APP_ID:
- if (g_value_get_string (value) == NULL) {
- return;
- }
- old_name = bonobo_window_get_name (BONOBO_WINDOW (window));
- bonobo_window_set_name (BONOBO_WINDOW (window), g_value_get_string (value));
- /* This hack of using the time when the name first
- * goes non-NULL to be window-constructed time is
- * completely lame. But it works, so for now we leave
- * it alone.
- */
- if (old_name == NULL) {
- nautilus_window_constructed (window);
- }
- g_free (old_name);
- break;
- case ARG_APP:
- window->application = NAUTILUS_APPLICATION (g_value_get_object (value));
- break;
- }
-}
-
-static void
-nautilus_window_get_property (GObject *object,
- guint arg_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (arg_id) {
- case ARG_APP_ID:
- g_value_set_string_take_ownership (
- value,
- bonobo_window_get_name (BONOBO_WINDOW (object)));
- break;
- case ARG_APP:
- g_value_set_object (value, NAUTILUS_WINDOW (object)->application);
- break;
- }
-}
-
-static void
-free_stored_viewers (NautilusWindow *window)
-{
- eel_g_list_free_deep_custom (window->details->short_list_viewers,
- (GFunc) nautilus_view_identifier_free,
- NULL);
- window->details->short_list_viewers = NULL;
- nautilus_view_identifier_free (window->details->extra_viewer);
- window->details->extra_viewer = NULL;
-}
+ window = NAUTILUS_SPATIAL_WINDOW (widget);
-static void
-nautilus_window_unrealize (GtkWidget *widget)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
- if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
- window->details->throbber_property_bag = CORBA_OBJECT_NIL;
+ if (window->details->save_geometry_timeout_id != 0) {
+ g_source_remove (window->details->save_geometry_timeout_id);
+ window->details->save_geometry_timeout_id = 0;
+ nautilus_spatial_window_save_geometry (window);
}
-
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
-nautilus_window_destroy (GtkObject *object)
+nautilus_spatial_window_destroy (GtkObject *object)
{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
-
- nautilus_window_manage_views_destroy (window);
+ NautilusSpatialWindow *window;
- window->sidebar = NULL;
- eel_g_object_list_free (window->sidebar_panels);
- window->sidebar_panels = NULL;
+ window = NAUTILUS_SPATIAL_WINDOW (object);
- window->view_as_option_menu = NULL;
- window->navigation_bar = NULL;
- window->content_hbox = NULL;
- window->zoom_control = NULL;
-
- if (window->content_view) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
-
- if (window->details->tooltips) {
- g_object_unref (G_OBJECT (window->details->tooltips));
- window->details->tooltips = NULL;
- }
+ window->details->content_box = NULL;
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
-nautilus_window_finalize (GObject *object)
+nautilus_spatial_window_finalize (GObject *object)
{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (object);
-
- nautilus_window_manage_views_finalize (window);
-
- nautilus_window_set_viewed_file (window, NULL);
- nautilus_window_remove_bookmarks_menu_callback (window);
- nautilus_window_remove_go_menu_callback (window);
-
- if (window->details->ui_idle_id != 0) {
- g_source_remove (window->details->ui_idle_id);
- }
-
- if (window->details->shell_ui != NULL) {
- bonobo_ui_component_unset_container (window->details->shell_ui, NULL);
- bonobo_object_unref (window->details->shell_ui);
- window->details->shell_ui = NULL;
- }
-
- if (window->details->status_ui != NULL) {
- bonobo_ui_component_unset_container (window->details->status_ui, NULL);
- bonobo_object_unref (window->details->status_ui);
- window->details->status_ui = NULL;
- }
-
- nautilus_file_unref (window->details->viewed_file);
-
- free_stored_viewers (window);
-
- g_free (window->details->location);
- eel_g_list_free_deep (window->details->selection);
- eel_g_list_free_deep (window->details->pending_selection);
-
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
- if (window->current_location_bookmark != NULL) {
- g_object_unref (window->current_location_bookmark);
- }
- if (window->last_location_bookmark != NULL) {
- g_object_unref (window->last_location_bookmark);
- }
-
- bonobo_object_unref (window->details->ui_container);
-
- if (window->details->location_change_at_idle_id != 0) {
- g_source_remove (window->details->location_change_at_idle_id);
- }
-
- g_free (window->details->title);
-
- g_free (window->details);
+ NautilusSpatialWindow *window;
- g_free (window->last_geometry);
+ window = NAUTILUS_SPATIAL_WINDOW (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
-nautilus_window_save_geometry (NautilusWindow *window)
+nautilus_spatial_window_save_geometry (NautilusSpatialWindow *window)
{
char *geometry_string;
@@ -1024,7 +204,7 @@ nautilus_window_save_geometry (NautilusWindow *window)
!(gdk_window_get_state (GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
- nautilus_file_set_metadata (window->details->viewed_file,
+ nautilus_file_set_metadata (NAUTILUS_WINDOW (window)->details->viewed_file,
NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
NULL,
geometry_string);
@@ -1034,1264 +214,123 @@ nautilus_window_save_geometry (NautilusWindow *window)
}
void
-nautilus_window_close (NautilusWindow *window)
+nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window)
{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+ NautilusWindow *parent;
+ char *scroll_string;
- gtk_widget_destroy (GTK_WIDGET (window));
+ parent = NAUTILUS_WINDOW(window);
+ scroll_string = nautilus_view_frame_get_first_visible_file (parent->content_view);
+ nautilus_file_set_metadata (parent->details->viewed_file,
+ NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION,
+ NULL,
+ scroll_string);
+ g_free (scroll_string);
}
static void
-nautilus_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GdkScreen *screen;
- guint max_width;
- guint max_height;
-
- g_assert (NAUTILUS_IS_WINDOW (widget));
- g_assert (requisition != NULL);
-
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
-
- screen = gtk_window_get_screen (GTK_WINDOW (widget));
-
- /* Limit the requisition to be within 90% of the available screen
- * real state.
- *
- * This way the user will have a fighting chance of getting
- * control of their window back if for whatever reason one of the
- * window's descendants decide they want to be 4000 pixels wide.
- *
- * Note that the user can still make the window really huge by hand.
- *
- * Bugs in components or other widgets that cause such huge geometries
- * to be requested, should still be fixed. This code is here only to
- * prevent the extremely frustrating consequence of such bugs.
- */
- max_width = get_max_forced_width (screen);
- max_height = get_max_forced_height (screen);
-
- if (requisition->width > (int) max_width) {
- requisition->width = max_width;
- }
-
- if (requisition->height > (int) max_height) {
- requisition->height = max_height;
- }
-}
-
-
-/*
- * Main API
- */
-
-static void
-activate_nth_short_list_item (NautilusWindow *window, guint index)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_assert (index < g_list_length (window->details->short_list_viewers));
-
- nautilus_window_set_content_view (window,
- g_list_nth_data (window->details->short_list_viewers, index));
-}
-
-static void
-activate_extra_viewer (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_assert (window->details->extra_viewer != NULL);
-
- nautilus_window_set_content_view (window, window->details->extra_viewer);
-}
-
-static void
-handle_view_as_item_from_bonobo_menu (NautilusWindow *window, const char *id)
-{
- char *container_path;
-
- container_path = nautilus_bonobo_get_numbered_menu_item_container_path_from_command (id);
-
- if (eel_strcmp (container_path, NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER) == 0) {
- activate_nth_short_list_item
- (window,
- nautilus_bonobo_get_numbered_menu_item_index_from_command (id));
- } else if (eel_strcmp (container_path, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER) == 0) {
- g_return_if_fail
- (nautilus_bonobo_get_numbered_menu_item_index_from_command (id) == 0);
- activate_extra_viewer (window);
- }
-
- g_free (container_path);
-}
-
-void
-nautilus_window_handle_ui_event_callback (BonoboUIComponent *ui,
- const char *id,
- Bonobo_UIComponent_EventType type,
- const char *state,
- NautilusWindow *window)
-{
- if (!window->details->updating_bonobo_state
- && type == Bonobo_UIComponent_STATE_CHANGED
- && strcmp (state, "1") == 0) {
- handle_view_as_item_from_bonobo_menu (window, id);
- }
-}
-
-static void
-view_as_menu_switch_views_callback (GtkWidget *widget, gpointer data)
-{
- NautilusWindow *window;
- int viewer_index;
-
- g_assert (GTK_IS_MENU_ITEM (widget));
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- window = NAUTILUS_WINDOW (data);
-
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "extra viewer")) == TRUE) {
- activate_extra_viewer (window);
- } else {
- viewer_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "viewer index"));
- activate_nth_short_list_item (window, viewer_index);
- }
-}
-
-static GtkWidget *
-create_view_as_menu_item (NautilusWindow *window,
- NautilusViewIdentifier *identifier,
- guint index)
-{
- GtkWidget *menu_item;
- char *menu_label;
-
- menu_label = g_strdup (_(identifier->view_as_label));
- menu_item = gtk_menu_item_new_with_mnemonic (menu_label);
- g_free (menu_label);
-
- g_signal_connect_object (menu_item, "activate",
- G_CALLBACK (view_as_menu_switch_views_callback),
- window, 0);
-
- g_object_set_data (G_OBJECT (menu_item), "viewer index", GINT_TO_POINTER (index));
-
- gtk_widget_show (menu_item);
-
- return menu_item;
-}
-
-static GtkWidget *
-new_gtk_separator (void)
-{
- GtkWidget *result;
-
- result = gtk_menu_item_new ();
- gtk_widget_show (result);
- gtk_widget_set_sensitive (result, FALSE);
-
- return result;
-}
-
-static void
-add_view_as_bonobo_menu_item (NautilusWindow *window,
- const char *placeholder_path,
- NautilusViewIdentifier *identifier,
- int index)
-{
- char *tip;
- char *item_path;
-
- nautilus_bonobo_add_numbered_radio_menu_item
- (window->details->shell_ui,
- placeholder_path,
- index,
- identifier->view_as_label_with_mnemonic,
- "viewers group");
-
- tip = g_strdup_printf (_("Display this location with \"%s\""),
- identifier->viewer_label);
- item_path = nautilus_bonobo_get_numbered_menu_item_path
- (window->details->shell_ui,
- placeholder_path,
- index);
- nautilus_bonobo_set_tip (window->details->shell_ui, item_path, tip);
- g_free (item_path);
- g_free (tip);
-}
-
-static void
-remove_first_child (GtkContainer *container)
-{
- gtk_container_remove (container,
- eel_gtk_container_get_first_child (container));
-}
-
-/* Make a special first item in the "View as" option menu that represents
- * the current content view. This should only be called if the current
- * content view isn't already in the "View as" option menu.
- */
-static void
-update_extra_viewer_in_view_as_menus (NautilusWindow *window,
- const NautilusViewIdentifier *id)
-{
- GtkWidget *menu;
- GtkWidget *new_menu_item;
- gboolean had_extra_viewer;
-
- had_extra_viewer = window->details->extra_viewer != NULL;
-
- if (id == NULL) {
- if (!had_extra_viewer) {
- return;
- }
- } else {
- if (had_extra_viewer
- && nautilus_view_identifier_compare (window->details->extra_viewer, id) == 0) {
- return;
- }
- }
- nautilus_view_identifier_free (window->details->extra_viewer);
- window->details->extra_viewer = nautilus_view_identifier_copy (id);
-
- /* Update the View As option menu */
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove menu before changing contents so it is resized properly
- * when reattached later in this function.
- */
- g_object_ref (menu);
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove old menu item, and either remove or add separator. */
- if (had_extra_viewer) {
- remove_first_child (GTK_CONTAINER (menu));
- if (id == NULL) {
- remove_first_child (GTK_CONTAINER (menu));
- }
- } else {
- if (id != NULL) {
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_gtk_separator ());
- }
- }
-
- /* Add new menu item. */
- if (id != NULL) {
- new_menu_item = create_view_as_menu_item (window, window->details->extra_viewer, 0);
- g_object_set_data (G_OBJECT (new_menu_item), "extra viewer", GINT_TO_POINTER (TRUE));
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_menu_item);
- }
+nautilus_spatial_window_show (GtkWidget *widget)
+{
+ NautilusSpatialWindow *window;
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu), menu);
- g_object_unref (menu);
+ window = NAUTILUS_SPATIAL_WINDOW (widget);
- /* Also update the Bonobo View menu item */
- if (id == NULL) {
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER);
- } else {
- add_view_as_bonobo_menu_item (window,
- NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER,
- window->details->extra_viewer,
- 0);
- }
+ GTK_WIDGET_CLASS (parent_class)->show (widget);
}
static void
-remove_extra_viewer_in_view_as_menus (NautilusWindow *window)
+file_menu_close_with_parent_windows_callback (BonoboUIComponent *component,
+ gpointer user_data,
+ const char *verb)
{
- update_extra_viewer_in_view_as_menus (window, NULL);
+ nautilus_application_close_with_parent_windows (NAUTILUS_SPATIAL_WINDOW (user_data));
}
static void
-replace_extra_viewer_in_view_as_menus (NautilusWindow *window)
+real_set_title (NautilusWindow *window, const char *title)
{
- NautilusViewIdentifier *id;
- id = nautilus_window_get_content_view_id (window);
- update_extra_viewer_in_view_as_menus (window, id);
- nautilus_view_identifier_free (id);
-}
-
-/**
- * nautilus_window_synch_view_as_menus:
- *
- * Set the visible item of the "View as" option menu and
- * the marked "View as" item in the View menu to
- * match the current content view.
- *
- * @window: The NautilusWindow whose "View as" option menu should be synched.
- */
-void
-nautilus_window_synch_view_as_menus (NautilusWindow *window)
-{
- int index;
- char *verb_name, *command_path;
- GList *node;
- const char *numbered_menu_item_container_path;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- if (window->content_view == NULL) {
- return;
- }
-
- for (node = window->details->short_list_viewers, index = 0;
- node != NULL;
- node = node->next, ++index) {
- if (nautilus_window_content_view_matches_iid (window, ((NautilusViewIdentifier *)node->data)->iid)) {
- break;
- }
- }
- if (node == NULL) {
- replace_extra_viewer_in_view_as_menus (window);
- index = 0;
- numbered_menu_item_container_path = NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER;
+ if (title[0] == '\0') {
+ gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
} else {
- remove_extra_viewer_in_view_as_menus (window);
- numbered_menu_item_container_path = NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER;
- }
-
- g_assert (numbered_menu_item_container_path != NULL);
-
- /* Make option menu show the right item */
- gtk_option_menu_set_history (GTK_OPTION_MENU (window->view_as_option_menu), index);
-
- /* Make View menu in menu bar mark the right item */
- verb_name = nautilus_bonobo_get_numbered_menu_item_command
- (window->details->shell_ui,
- numbered_menu_item_container_path, index);
- command_path = g_strconcat (COMMAND_PREFIX, verb_name, NULL);
- nautilus_bonobo_set_toggle_state (window->details->shell_ui, command_path, TRUE);
- g_free (command_path);
- g_free (verb_name);
-}
-
-static void
-chose_component_callback (NautilusViewIdentifier *identifier, gpointer callback_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (callback_data);
- if (identifier != NULL) {
- nautilus_window_set_content_view (window, identifier);
- }
-
- /* FIXME bugzilla.gnome.org 41334: There should be some global
- * way to signal that the file type associations have changed,
- * so that the places that display these lists can react. For
- * now, hardwire this case, which is the most obvious one by
- * far.
- */
- nautilus_window_load_view_as_menus (window);
-}
-
-static void
-cancel_chose_component_callback (NautilusWindow *window)
-{
- if (window->details->viewed_file != NULL) {
- nautilus_cancel_choose_component_for_file (window->details->viewed_file,
- chose_component_callback,
- window);
- }
-}
-
-void
-nautilus_window_show_view_as_dialog (NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- /* Call back when the user chose the component. */
- cancel_chose_component_callback (window);
- nautilus_choose_component_for_file (window->details->viewed_file,
- GTK_WINDOW (window),
- chose_component_callback,
- window);
-}
-
-static void
-view_as_menu_choose_view_callback (GtkWidget *widget, gpointer data)
-{
- NautilusWindow *window;
-
- g_assert (GTK_IS_MENU_ITEM (widget));
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- window = NAUTILUS_WINDOW (data);
-
- /* Set the option menu back to its previous setting (Don't
- * leave it on this dialog-producing "View as..."
- * setting). If the menu choice causes a content view change,
- * this will be updated again later, in
- * nautilus_window_load_view_as_menus. Do this right away so
- * the user never sees the option menu set to "View as
- * Other...".
- */
- nautilus_window_synch_view_as_menus (window);
-
- nautilus_window_show_view_as_dialog (window);
-}
-
-static void
-refresh_stored_viewers (NautilusWindow *window)
-{
- GList *components, *node, *viewers;
- NautilusViewIdentifier *identifier;
-
- components = nautilus_mime_get_short_list_components_for_file (window->details->viewed_file);
- viewers = NULL;
- for (node = components; node != NULL; node = node->next) {
- identifier = nautilus_view_identifier_new_from_content_view (node->data);
- viewers = g_list_prepend (viewers, identifier);
- }
- gnome_vfs_mime_component_list_free (components);
-
- free_stored_viewers (window);
- window->details->short_list_viewers = g_list_reverse (viewers);
-}
-
-static void
-load_view_as_menus_callback (NautilusFile *file,
- gpointer callback_data)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
- GList *node;
- NautilusWindow *window;
- int index;
-
- window = NAUTILUS_WINDOW (callback_data);
-
- g_assert (GTK_IS_OPTION_MENU (window->view_as_option_menu));
-
- /* Clear out the menu items created last time. For the option menu, we need do
- * nothing since we replace the entire menu. For the View menu, we have
- * to do this explicitly.
- */
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER);
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui, NAUTILUS_MENU_PATH_EXTRA_VIEWER_PLACEHOLDER);
-
- refresh_stored_viewers (window);
-
- new_menu = gtk_menu_new ();
-
- /* Add a menu item for each view in the preferred list for this location. */
- for (node = window->details->short_list_viewers, index = 0;
- node != NULL;
- node = node->next, ++index) {
- /* Menu item in option menu. This doesn't use Bonobo, for various
- * historical and technical reasons.
- */
- menu_item = create_view_as_menu_item (window, node->data, index);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- /* Menu item in View menu. */
- add_view_as_bonobo_menu_item (window,
- NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER,
- node->data,
- index);
- }
-
- /* Add/Show separator before "View as..." if there are any other viewers in menu. */
- if (window->details->short_list_viewers != NULL) {
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), new_gtk_separator ());
- }
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR,
- window->details->short_list_viewers == NULL);
-
- /* Add "View as..." extra bonus choice. */
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- g_signal_connect_object (menu_item, "activate",
- G_CALLBACK (view_as_menu_choose_view_callback), window, 0);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- /* We create and attach a new menu here because adding/removing
- * items from existing menu screws up the size of the option menu.
- */
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
-
- nautilus_window_synch_view_as_menus (window);
-}
-
-static void
-cancel_view_as_callback (NautilusWindow *window)
-{
- nautilus_file_cancel_call_when_ready (window->details->viewed_file,
- load_view_as_menus_callback,
- window);
-}
-
-void
-nautilus_window_load_view_as_menus (NautilusWindow *window)
-{
- NautilusFileAttributes attributes;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- attributes = nautilus_mime_actions_get_full_file_attributes ();
+ char *window_title;
- cancel_view_as_callback (window);
- nautilus_file_call_when_ready (window->details->viewed_file,
- attributes,
- load_view_as_menus_callback,
- window);
-}
-
-void
-nautilus_window_add_sidebar_panel (NautilusWindow *window,
- NautilusViewFrame *sidebar_panel)
-{
- char *label;
- const char *view_iid;
- char *default_iid;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
- g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar));
- g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL);
-
- label = nautilus_view_frame_get_label (sidebar_panel);
-
- nautilus_side_pane_add_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel),
- label);
- g_free (label);
-
- g_object_ref (sidebar_panel);
- window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel);
-
- view_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
- default_iid = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW);
-
- if (view_iid && default_iid && !strcmp (view_iid, default_iid)) {
- nautilus_side_pane_show_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- }
-
- g_free (default_iid);
-}
-
-void
-nautilus_window_remove_sidebar_panel (NautilusWindow *window, NautilusViewFrame *sidebar_panel)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
-
- if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL) {
- return;
- }
-
- nautilus_side_pane_remove_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel);
- g_object_unref (sidebar_panel);
-}
-
-void
-nautilus_window_go_back (NautilusWindow *window)
-{
- nautilus_window_back_or_forward (window, TRUE, 0);
-}
-
-void
-nautilus_window_go_forward (NautilusWindow *window)
-{
- nautilus_window_back_or_forward (window, FALSE, 0);
-}
-
-void
-nautilus_window_go_up (NautilusWindow *window)
-{
- GnomeVFSURI *current_uri;
- GnomeVFSURI *parent_uri;
- GList *selection;
- char *parent_uri_string;
-
- if (window->details->location == NULL) {
- return;
+ window_title = eel_str_middle_truncate (title, MAX_TITLE_LENGTH);
+ gtk_window_set_title (GTK_WINDOW (window), window_title);
+ g_free (window_title);
}
-
- current_uri = gnome_vfs_uri_new (window->details->location);
- parent_uri = gnome_vfs_uri_get_parent (current_uri);
- gnome_vfs_uri_unref (current_uri);
-
- if (parent_uri == NULL) {
- g_warning ("Can't go Up from here. The UI should have prevented us from getting this far.");
- return;
- }
-
- parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (parent_uri);
-
- selection = g_list_prepend (NULL, g_strdup (window->details->location));
-
- nautilus_window_open_location_with_selection (window, parent_uri_string, selection);
-
- g_free (parent_uri_string);
- eel_g_list_free_deep (selection);
}
-void
-nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode)
-{
- nautilus_switchable_navigation_bar_set_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar),
- search_mode
- ? NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH
- : NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION);
-
-
-}
-
-gboolean
-nautilus_window_get_search_mode (NautilusWindow *window)
-{
- return nautilus_switchable_navigation_bar_get_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar))
- == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH;
-}
-
-void
-nautilus_window_go_home (NautilusWindow *window)
-{
- char *home_uri;
-
- nautilus_window_set_search_mode (window, FALSE);
-
-#ifdef WEB_NAVIGATION_ENABLED
- home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
-#else
- home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-#endif
-
- g_assert (home_uri != NULL);
- nautilus_window_go_to (window, home_uri);
- g_free (home_uri);
-}
-
-void
-nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_BACK, allow);
- /* Have to handle non-standard Back button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->back_button_item), allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_FORWARD, allow);
- /* Have to handle non-standard Forward button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->forward_button_item), allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_UP, allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_RELOAD, allow);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_allow_burn_cd (NautilusWindow *window, gboolean allow)
-{
- nautilus_window_ui_freeze (window);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_COMMAND_BURN_CD, !allow);
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_send_history_list_changed (void)
-{
- g_signal_emit_by_name (nautilus_signaller_get_current (),
- "history_list_changed");
-}
-
-static void
-free_history_list (void)
-{
- eel_g_object_list_free (history_list);
- history_list = NULL;
-}
-
-/* Remove the this URI from the history list.
- * Do not sent out a change notice.
- * We pass in a bookmark for convenience.
- */
static void
-remove_from_history_list (NautilusBookmark *bookmark)
+real_merge_menus (NautilusWindow *nautilus_window)
{
- GList *node;
-
- /* Compare only the uris here. Comparing the names also is not
- * necessary and can cause problems due to the asynchronous
- * nature of when the title of the window is set.
- */
- node = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
+ NautilusSpatialWindow *window;
+ BonoboUIVerb verbs [] = {
+ BONOBO_UI_VERB ("Close With Parents", file_menu_close_with_parent_windows_callback),
+ BONOBO_UI_VERB_END
+ };
- /* Remove any older entry for this same item. There can be at most 1. */
- if (node != NULL) {
- history_list = g_list_remove_link (history_list, node);
- g_object_unref (node->data);
- g_list_free_1 (node);
- }
-}
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
+ merge_menus, (nautilus_window));
-static void
-add_to_history_list (NautilusBookmark *bookmark)
-{
- /* Note that the history is shared amongst all windows so
- * this is not a NautilusWindow function. Perhaps it belongs
- * in its own file.
- */
- int i;
- GList *l, *next;
- static gboolean free_history_list_is_set_up;
-
- g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
-
- if (!free_history_list_is_set_up) {
- eel_debug_call_at_shutdown (free_history_list);
- free_history_list_is_set_up = TRUE;
- }
-
-/* g_warning ("Add to history list '%s' '%s'",
- nautilus_bookmark_get_name (bookmark),
- nautilus_bookmark_get_uri (bookmark)); */
-
- if (!history_list ||
- nautilus_bookmark_compare_uris (history_list->data, bookmark)) {
- g_object_ref (bookmark);
- remove_from_history_list (bookmark);
- history_list = g_list_prepend (history_list, bookmark);
-
- for (i = 0, l = history_list; l; l = next) {
- next = l->next;
-
- if (i++ >= MAX_HISTORY_ITEMS) {
- g_object_unref (l->data);
- history_list = g_list_delete_link (history_list, l);
- }
- }
-
- nautilus_send_history_list_changed ();
- }
-}
+ window = NAUTILUS_SPATIAL_WINDOW (nautilus_window);
-void
-nautilus_remove_from_history_list_no_notify (const char *uri)
-{
- NautilusBookmark *bookmark;
+ bonobo_ui_util_set_ui (NAUTILUS_WINDOW (window)->details->shell_ui,
+ DATADIR,
+ "nautilus-spatial-window-ui.xml",
+ "nautilus", NULL);
- bookmark = nautilus_bookmark_new (uri, "");
- remove_from_history_list (bookmark);
- g_object_unref (bookmark);
+ bonobo_ui_component_add_verb_list_with_data (nautilus_window->details->shell_ui,
+ verbs, window);
}
static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- add_to_history_list (window->current_location_bookmark);
-}
-
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
-}
-
-void
-nautilus_window_clear_forward_list (NautilusWindow *window)
+real_set_content_view_widget (NautilusWindow *window,
+ NautilusViewFrame *new_view)
{
- eel_g_object_list_free (window->forward_list);
- window->forward_list = NULL;
-}
-
-void
-nautilus_window_clear_back_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->back_list);
- window->back_list = NULL;
-}
-
-void
-nautilus_forget_history (void)
-{
- GList *window_node;
- NautilusWindow *window;
-
- /* Clear out each window's back & forward lists. Also, remove
- * each window's current location bookmark from history list
- * so it doesn't get clobbered.
- */
- for (window_node = nautilus_application_get_window_list ();
- window_node != NULL;
- window_node = window_node->next) {
-
- window = NAUTILUS_WINDOW (window_node->data);
-
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
- nautilus_window_allow_back (window, FALSE);
- nautilus_window_allow_forward (window, FALSE);
-
- history_list = g_list_remove (history_list, window->current_location_bookmark);
- }
-
- /* Clobber history list. */
- free_history_list ();
-
- /* Re-add each window's current location to history list. */
- for (window_node = nautilus_application_get_window_list ();
- window_node != NULL;
- window_node = window_node->next) {
-
- window = NAUTILUS_WINDOW (window_node->data);
- nautilus_window_add_current_location_to_history_list (window);
- }
-}
-
-GList *
-nautilus_get_history_list (void)
-{
- return history_list;
-}
-
-void
-nautilus_window_display_error (NautilusWindow *window, const char *error_msg)
-{
- GtkWidget *dialog;
+ EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, set_content_view_widget,
+ (window, new_view));
- dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, error_msg, NULL);
- gtk_widget_show (dialog);
-}
-
-void
-nautilus_window_set_content_view_widget (NautilusWindow *window,
- NautilusViewFrame *new_view)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view));
-
- if (new_view == window->content_view) {
- return;
- }
-
- if (window->content_view != NULL) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
-
- if (new_view != NULL) {
- gtk_widget_show (GTK_WIDGET (new_view));
-
- /* When creating the desktop window the UI needs to
- * be in sync. Otherwise I get failed assertions in
- * bonobo while trying to reference something called
- * `/commands/Unmount Volume Conditional'
- */
- nautilus_window_ui_update (window);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (!GTK_IS_PANED (window->content_hbox)) {
- gtk_container_add (GTK_CONTAINER (window->content_hbox),
- GTK_WIDGET (new_view));
- } else {
- nautilus_horizontal_splitter_pack2 (
- NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
- GTK_WIDGET (new_view));
- }
- }
-
- /* Display or hide zoom control */
- if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) {
- gtk_widget_show (window->zoom_control);
- } else {
- gtk_widget_hide (window->zoom_control);
- }
-
- window->content_view = new_view;
-}
-
-/**
- * add_sidebar_panels:
- * @window: A NautilusWindow
- *
- * Adds all sidebars available
- *
- */
-static void
-add_sidebar_panels (NautilusWindow *window)
-{
- GList *identifier_list;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->sidebar == NULL) {
- return;
- }
-
- identifier_list = nautilus_sidebar_get_all_sidebar_panel_view_identifiers ();
- nautilus_window_set_sidebar_panels (window, identifier_list);
- nautilus_view_identifier_list_free (identifier_list);
-
- set_current_side_panel
- (window,
- nautilus_side_pane_get_current_panel (window->sidebar));
-}
-
-static void
-show_dock_item (NautilusWindow *window, const char *dock_item_path)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- return;
- }
-
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- dock_item_path,
- FALSE);
- nautilus_window_update_show_hide_menu_items (window);
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-hide_dock_item (NautilusWindow *window, const char *dock_item_path)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- dock_item_path,
- TRUE);
- nautilus_window_update_show_hide_menu_items (window);
-
- nautilus_window_ui_thaw (window);
+ gtk_container_add (GTK_CONTAINER (NAUTILUS_SPATIAL_WINDOW (window)->details->content_box),
+ GTK_WIDGET (new_view));
}
static gboolean
-dock_item_showing (NautilusWindow *window, const char *dock_item_path)
+real_delete_event (GtkWidget *window, GdkEventAny *event)
{
- return !nautilus_bonobo_get_hidden (window->details->shell_ui,
- dock_item_path);
-}
-
-void
-nautilus_window_hide_location_bar (NautilusWindow *window, gboolean save_preference)
-{
- window->details->temporary_navigation_bar = FALSE;
- hide_dock_item (window, LOCATION_BAR_PATH);
- if (save_preference &&
- eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_location_bar (NautilusWindow *window, gboolean save_preference)
-{
- show_dock_item (window, LOCATION_BAR_PATH);
- if (save_preference &&
- eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_location_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, LOCATION_BAR_PATH);
-}
-
-void
-nautilus_window_hide_toolbar (NautilusWindow *window)
-{
- hide_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_toolbar (NautilusWindow *window)
-{
- nautilus_window_activate_throbber (window);
- show_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_toolbar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, TOOLBAR_PATH);
-}
-
-void
-nautilus_window_hide_sidebar (NautilusWindow *window)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar == NULL) {
- return;
- }
-
- nautilus_window_tear_down_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_sidebar (NautilusWindow *window)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar != NULL) {
- return;
- }
+ nautilus_spatial_window_save_scroll_position (NAUTILUS_SPATIAL_WINDOW (window));
- nautilus_window_set_up_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_sidebar_showing (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), FALSE);
-
- return (window->sidebar != NULL) && GTK_IS_PANED (window->content_hbox)
- && nautilus_horizontal_splitter_is_hidden (NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox));
-}
-
-void
-nautilus_window_hide_status_bar (NautilusWindow *window)
-{
- hide_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_status_bar (NautilusWindow *window)
-{
- show_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_status_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, STATUS_BAR_PATH);
-}
-
-/**
- * nautilus_window_get_base_page_index:
- * @window: Window to get index from
- *
- * Returns the index of the base page in the history list.
- * Base page is not the currently displayed page, but the page
- * that acts as the base from which the back and forward commands
- * navigate from.
- */
-gint
-nautilus_window_get_base_page_index (NautilusWindow *window)
-{
- gint forward_count;
-
- forward_count = g_list_length (window->forward_list);
-
- /* If forward is empty, the base it at the top of the list */
- if (forward_count == 0) {
- return 0;
- }
-
- /* The forward count indicate the relative postion of the base page
- * in the history list
- */
- return forward_count;
+ return FALSE;
}
-/**
- * nautilus_window_show:
- * @widget: GtkWidget
- *
- * Call parent and then show/hide window items
- * base on user prefs.
- */
static void
-nautilus_window_show (GtkWidget *widget)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
-
- GTK_WIDGET_CLASS (parent_class)->show (widget);
-
- /* Initially show or hide views based on preferences; once the window is displayed
- * these can be controlled on a per-window basis from View menu items.
- */
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- nautilus_window_show_toolbar (window);
- } else {
- nautilus_window_hide_toolbar (window);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- nautilus_window_show_location_bar (window, FALSE);
- } else {
- nautilus_window_hide_location_bar (window, FALSE);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- nautilus_window_show_status_bar (window);
- } else {
- nautilus_window_hide_status_bar (window);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_show_sidebar (window);
- } else {
- nautilus_window_hide_sidebar (window);
- }
-
- nautilus_window_ui_update (window);
-}
-
-Bonobo_UIContainer
-nautilus_window_get_ui_container (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), CORBA_OBJECT_NIL);
-
- return BONOBO_OBJREF (window->details->ui_container);
-}
-
-void
-nautilus_window_set_viewed_file (NautilusWindow *window,
- NautilusFile *file)
+nautilus_spatial_window_instance_init (NautilusSpatialWindow *window)
{
- NautilusFileAttributes attributes;
+ window->details = g_new0 (NautilusSpatialWindowDetails, 1);
+ window->affect_spatial_window_on_next_location_change = TRUE;
- if (window->details->viewed_file == file) {
- return;
- }
-
- nautilus_file_ref (file);
-
- cancel_view_as_callback (window);
- cancel_chose_component_callback (window);
-
- if (window->details->viewed_file != NULL) {
- nautilus_file_monitor_remove (window->details->viewed_file,
- window);
- }
-
- if (file != NULL) {
- attributes = NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
- nautilus_file_monitor_add (file, window, attributes);
- }
-
- nautilus_file_unref (window->details->viewed_file);
- window->details->viewed_file = file;
+ window->details->content_box =
+ gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
+ gtk_widget_show (window->details->content_box);
+ bonobo_window_set_contents (BONOBO_WINDOW (window),
+ window->details->content_box);
}
static void
-nautilus_window_class_init (NautilusWindowClass *class)
+nautilus_spatial_window_class_init (NautilusSpatialWindowClass *class)
{
- G_OBJECT_CLASS (class)->finalize = nautilus_window_finalize;
- G_OBJECT_CLASS (class)->get_property = nautilus_window_get_property;
- G_OBJECT_CLASS (class)->set_property = nautilus_window_set_property;
- GTK_OBJECT_CLASS (class)->destroy = nautilus_window_destroy;
- GTK_WIDGET_CLASS (class)->show = nautilus_window_show;
- GTK_WIDGET_CLASS (class)->unrealize = nautilus_window_unrealize;
- GTK_WIDGET_CLASS (class)->size_request = nautilus_window_size_request;
- class->add_current_location_to_history_list = real_add_current_location_to_history_list;
-
- g_object_class_install_property (G_OBJECT_CLASS (class),
- ARG_APP_ID,
- g_param_spec_string ("app_id",
- _("Application ID"),
- _("The application ID of the window."),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (G_OBJECT_CLASS (class),
- ARG_APP,
- g_param_spec_object ("app",
- _("Application"),
- _("The NautilusApplication associated with this window."),
- NAUTILUS_TYPE_APPLICATION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /* Set default for all windows. This probably should be done
- * in main or NautilusApplication rather than here in case
- * some other window is created before the first
- * NautilusWindow. Also, do we really want this icon for
- * dialogs?
- */
- set_up_default_icon_list ();
+ G_OBJECT_CLASS (class)->finalize = nautilus_spatial_window_finalize;
+ GTK_OBJECT_CLASS (class)->destroy = nautilus_spatial_window_destroy;
+ GTK_WIDGET_CLASS (class)->show = nautilus_spatial_window_show;
+ GTK_WIDGET_CLASS (class)->configure_event = nautilus_spatial_window_configure_event;
+ GTK_WIDGET_CLASS (class)->unrealize = nautilus_spatial_window_unrealize;
+
+ NAUTILUS_WINDOW_CLASS (class)->set_title =
+ real_set_title;
+ NAUTILUS_WINDOW_CLASS (class)->merge_menus =
+ real_merge_menus;
+ NAUTILUS_WINDOW_CLASS (class)->set_content_view_widget =
+ real_set_content_view_widget;
+ GTK_WIDGET_CLASS (class)->delete_event =
+ real_delete_event;
}
diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h
index a14157094..486ccbe61 100644
--- a/src/nautilus-spatial-window.h
+++ b/src/nautilus-spatial-window.h
@@ -5,6 +5,7 @@
*
* Copyright (C) 1999, 2000 Red Hat, Inc.
* Copyright (C) 1999, 2000, 2001 Eazel, Inc.
+ * Copyright (C) 2003 Ximian, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -20,147 +21,45 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * Authors: Elliot Lee <sopwith@redhat.com>
- * Darin Adler <darin@bentspoon.com>
- *
*/
/* nautilus-window.h: Interface of the main window object */
-#ifndef NAUTILUS_WINDOW_H
-#define NAUTILUS_WINDOW_H
+#ifndef NAUTILUS_SPATIAL_WINDOW_H
+#define NAUTILUS_SPATIAL_WINDOW_H
-#include <bonobo/bonobo-window.h>
-#include <eel/eel-glib-extensions.h>
-#include <libnautilus-private/nautilus-bookmark.h>
-#include <libnautilus-private/nautilus-view-identifier.h>
-#include "nautilus-applicable-views.h"
-#include "nautilus-view-frame.h"
-#include "nautilus-application.h"
-#include "nautilus-information-panel.h"
-#include "nautilus-side-pane.h"
+#include "nautilus-window.h"
+#include "nautilus-window-private.h"
-#define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type())
-#define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow))
-#define NAUTILUS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_WINDOW, NautilusWindowClass))
-#define NAUTILUS_IS_WINDOW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_WINDOW))
-#define NAUTILUS_IS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_WINDOW))
+#define NAUTILUS_TYPE_SPATIAL_WINDOW (nautilus_spatial_window_get_type())
+#define NAUTILUS_SPATIAL_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SPATIAL_WINDOW, NautilusSpatialWindow))
+#define NAUTILUS_SPATIAL_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SPATIAL_WINDOW, NautilusSpatialWindowClass))
+#define NAUTILUS_IS_SPATIAL_WINDOW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SPATIAL_WINDOW))
+#define NAUTILUS_IS_SPATIAL_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SPATIAL_WINDOW))
-#ifndef NAUTILUS_WINDOW_DEFINED
-#define NAUTILUS_WINDOW_DEFINED
-typedef struct NautilusWindow NautilusWindow;
+#ifndef NAUTILUS_SPATIAL_WINDOW_DEFINED
+#define NAUTILUS_SPATIAL_WINDOW_DEFINED
+typedef struct _NautilusSpatialWindow NautilusSpatialWindow;
#endif
+typedef struct _NautilusSpatialWindowClass NautilusSpatialWindowClass;
+typedef struct _NautilusSpatialWindowDetails NautilusSpatialWindowDetails;
-typedef struct {
- BonoboWindowClass parent_spot;
-
- /* Function pointers for overriding, without corresponding signals */
-
- /* add_current_location_to_history_list is a function pointer that
- * subclasses may override if they wish to add something other than
- * NautilusWindow's idea of the "current location" to the history
- * list, or nothing at all.
- */
- void (* add_current_location_to_history_list) (NautilusWindow *window);
-} NautilusWindowClass;
-
-typedef enum {
- NAUTILUS_WINDOW_NOT_SHOWN,
- NAUTILUS_WINDOW_POSITION_SET,
- NAUTILUS_WINDOW_SHOULD_SHOW
-} NautilusWindowShowState;
-
-typedef struct NautilusWindowDetails NautilusWindowDetails;
+struct _NautilusSpatialWindow {
+ NautilusWindow parent_object;
-struct NautilusWindow {
- BonoboWindow parent_object;
-
- NautilusWindowDetails *details;
-
- /** UI stuff **/
- NautilusSidePane *sidebar;
- NautilusInformationPanel *information_panel;
- GtkWidget *content_hbox;
- GtkWidget *view_as_option_menu;
- GtkWidget *navigation_bar;
-
- char *last_geometry;
-
- guint save_geometry_timeout_id;
-
- /** CORBA-related elements **/
- NautilusApplication *application;
-
- /** State information **/
+ gboolean affect_spatial_window_on_next_location_change;
- /* Information about current location/selection */
-
- /* Back/Forward chain, and history list.
- * The data in these lists are NautilusBookmark pointers.
- */
- GList *back_list, *forward_list;
-
- NautilusBookmark *current_location_bookmark;
- NautilusBookmark *last_location_bookmark;
-
- /* Current views stuff */
- NautilusViewFrame *content_view;
- GList *sidebar_panels;
-
- /* Widgets to keep track of (for state changes, etc) */
- GtkWidget *zoom_control;
-
- /* Pending changes */
- NautilusViewFrame *new_content_view;
+ NautilusSpatialWindowDetails *details;
+};
- /* Window showed state (for saved_window_positions) */
- NautilusWindowShowState show_state;
+struct _NautilusSpatialWindowClass {
+ NautilusWindowClass parent_spot;
};
-GType nautilus_window_get_type (void);
-void nautilus_window_ui_freeze (NautilusWindow *window);
-void nautilus_window_ui_thaw (NautilusWindow *window);
-void nautilus_window_close (NautilusWindow *window);
-char * nautilus_window_get_location (NautilusWindow *window);
-void nautilus_window_go_to (NautilusWindow *window,
- const char *location);
-gboolean nautilus_window_get_search_mode (NautilusWindow *window);
-void nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode);
-void nautilus_window_go_home (NautilusWindow *window);
-void nautilus_window_display_error (NautilusWindow *window,
- const char *error_msg);
-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);
-void nautilus_window_allow_burn_cd (NautilusWindow *window,
- gboolean allow);
-void nautilus_window_clear_back_list (NautilusWindow *window);
-void nautilus_window_clear_forward_list (NautilusWindow *window);
-void nautilus_forget_history (void);
-void nautilus_bookmarks_exiting (void);
-void nautilus_window_reload (NautilusWindow *window);
-gint nautilus_window_get_base_page_index (NautilusWindow *window);
-void nautilus_window_hide_location_bar (NautilusWindow *window,
- gboolean save_preference);
-void nautilus_window_show_location_bar (NautilusWindow *window,
- gboolean save_preference);
-gboolean nautilus_window_location_bar_showing (NautilusWindow *window);
-void nautilus_window_hide_toolbar (NautilusWindow *window);
-void nautilus_window_show_toolbar (NautilusWindow *window);
-gboolean nautilus_window_toolbar_showing (NautilusWindow *window);
-void nautilus_window_hide_sidebar (NautilusWindow *window);
-void nautilus_window_show_sidebar (NautilusWindow *window);
-gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
-void nautilus_window_hide_status_bar (NautilusWindow *window);
-void nautilus_window_show_status_bar (NautilusWindow *window);
-gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
-void nautilus_window_save_geometry (NautilusWindow *window);
+
+GType nautilus_spatial_window_get_type (void);
+GtkWidget *nautilus_spatial_window_get (const char *uri);
+void nautilus_spatial_window_save_geometry (NautilusSpatialWindow *window);
+void nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window);
+
#endif
diff --git a/src/nautilus-switchable-navigation-bar.c b/src/nautilus-switchable-navigation-bar.c
index fb64783d2..99fcb8ae6 100644
--- a/src/nautilus-switchable-navigation-bar.c
+++ b/src/nautilus-switchable-navigation-bar.c
@@ -48,7 +48,7 @@ struct NautilusSwitchableNavigationBarDetails {
NautilusLocationBar *location_bar;
NautilusSwitchableSearchBar *search_bar;
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
GtkWidget *hbox;
};
@@ -119,7 +119,7 @@ create_search_bar_if_non_existant (NautilusSwitchableNavigationBar *bar)
return;
}
- bar->details->search_bar = NAUTILUS_SWITCHABLE_SEARCH_BAR (nautilus_switchable_search_bar_new (bar->details->window));
+ bar->details->search_bar = NAUTILUS_SWITCHABLE_SEARCH_BAR (nautilus_switchable_search_bar_new (NAUTILUS_WINDOW (bar->details->window)));
g_signal_connect_object (bar->details->search_bar, "location_changed",
G_CALLBACK (nautilus_navigation_bar_location_changed), bar, G_CONNECT_SWAPPED);
@@ -129,7 +129,7 @@ create_search_bar_if_non_existant (NautilusSwitchableNavigationBar *bar)
GtkWidget *
-nautilus_switchable_navigation_bar_new (NautilusWindow *window)
+nautilus_switchable_navigation_bar_new (NautilusNavigationWindow *window)
{
GtkWidget *bar;
NautilusSwitchableNavigationBar *switchable_navigation_bar;
diff --git a/src/nautilus-switchable-navigation-bar.h b/src/nautilus-switchable-navigation-bar.h
index 93a92953a..51d875687 100644
--- a/src/nautilus-switchable-navigation-bar.h
+++ b/src/nautilus-switchable-navigation-bar.h
@@ -64,7 +64,7 @@ typedef struct {
} NautilusSwitchableNavigationBarClass;
GType nautilus_switchable_navigation_bar_get_type (void);
-GtkWidget* nautilus_switchable_navigation_bar_new (NautilusWindow *window);
+GtkWidget* nautilus_switchable_navigation_bar_new (NautilusNavigationWindow *window);
NautilusSwitchableNavigationBarMode nautilus_switchable_navigation_bar_get_mode (NautilusSwitchableNavigationBar *switchable_navigation_bar);
void nautilus_switchable_navigation_bar_set_mode (NautilusSwitchableNavigationBar *switchable_navigation_bar,
NautilusSwitchableNavigationBarMode mode);
diff --git a/src/nautilus-view-frame-corba.c b/src/nautilus-view-frame-corba.c
index 95e6da6db..6dbf6715d 100644
--- a/src/nautilus-view-frame-corba.c
+++ b/src/nautilus-view-frame-corba.c
@@ -53,6 +53,8 @@ typedef struct {
char *location;
GList *selection;
char *title;
+ Nautilus_ViewFrame_OpenMode mode;
+ Nautilus_ViewFrame_OpenFlags flags;
} LocationPlus;
static void
@@ -75,29 +77,17 @@ free_location_plus_callback (gpointer callback_data)
}
static void
-open_in_this_window (NautilusViewFrame *view,
- gpointer callback_data)
-{
- nautilus_view_frame_open_location_in_this_window (view, callback_data);
-}
-
-static void
-open_prefer_existing_window (NautilusViewFrame *view,
- gpointer callback_data)
-{
- nautilus_view_frame_open_location_prefer_existing_window (view, callback_data);
-}
-
-static void
-open_force_new_window (NautilusViewFrame *view,
- gpointer callback_data)
+open_location (NautilusViewFrame *view,
+ gpointer callback_data)
{
LocationPlus *location_plus;
location_plus = callback_data;
- nautilus_view_frame_open_location_force_new_window
+ nautilus_view_frame_open_location
(view,
location_plus->location,
+ location_plus->mode,
+ location_plus->flags,
location_plus->selection);
}
@@ -192,46 +182,25 @@ close_window (NautilusViewFrame *view,
{
nautilus_view_frame_close_window (view);
}
-
static void
-impl_Nautilus_ViewFrame_open_location_in_this_window (PortableServer_Servant servant,
- const CORBA_char *location,
- CORBA_Environment *ev)
-{
- nautilus_view_frame_queue_incoming_call
- (servant,
- open_in_this_window,
- g_strdup (location),
- g_free);
-}
-
-static void
-impl_Nautilus_ViewFrame_open_location_prefer_existing_window (PortableServer_Servant servant,
- const CORBA_char *location,
- CORBA_Environment *ev)
-{
- nautilus_view_frame_queue_incoming_call
- (servant,
- open_prefer_existing_window,
- g_strdup (location),
- g_free);
-}
-
-static void
-impl_Nautilus_ViewFrame_open_location_force_new_window (PortableServer_Servant servant,
- const CORBA_char *location,
- const Nautilus_URIList *selection,
- CORBA_Environment *ev)
+impl_Nautilus_ViewFrame_open_location (PortableServer_Servant servant,
+ const CORBA_char *location,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
+ const Nautilus_URIList *selection,
+ CORBA_Environment *ev)
{
LocationPlus *location_plus;
location_plus = g_new0 (LocationPlus, 1);
location_plus->location = g_strdup (location);
location_plus->selection = nautilus_g_list_from_uri_list (selection);
+ location_plus->mode = mode;
+ location_plus->flags = flags;
nautilus_view_frame_queue_incoming_call
(servant,
- open_force_new_window,
+ open_location,
location_plus,
free_location_plus_callback);
}
@@ -393,9 +362,7 @@ BONOBO_CLASS_BOILERPLATE_FULL (NautilusViewFrameCorbaPart, nautilus_view_frame_c
static void
nautilus_view_frame_corba_part_class_init (NautilusViewFrameCorbaPartClass *class)
{
- class->epv.open_location_in_this_window = impl_Nautilus_ViewFrame_open_location_in_this_window;
- class->epv.open_location_prefer_existing_window = impl_Nautilus_ViewFrame_open_location_prefer_existing_window;
- class->epv.open_location_force_new_window = impl_Nautilus_ViewFrame_open_location_force_new_window;
+ class->epv.open_location = impl_Nautilus_ViewFrame_open_location;
class->epv.report_location_change = impl_Nautilus_ViewFrame_report_location_change;
class->epv.report_redirect = impl_Nautilus_ViewFrame_report_redirect;
class->epv.report_selection_change = impl_Nautilus_ViewFrame_report_selection_change;
diff --git a/src/nautilus-view-frame-private.h b/src/nautilus-view-frame-private.h
index 449832c66..914602f56 100644
--- a/src/nautilus-view-frame-private.h
+++ b/src/nautilus-view-frame-private.h
@@ -43,13 +43,10 @@ void nautilus_view_frame_queue_incoming_call (Portable
BonoboObject *nautilus_view_frame_create_corba_part (NautilusViewFrame *widget);
NautilusViewFrame *nautilus_view_frame_from_servant (PortableServer_Servant servant);
-/* ViewFrame */
-void nautilus_view_frame_open_location_in_this_window (NautilusViewFrame *view,
- const char *location);
-void nautilus_view_frame_open_location_prefer_existing_window (NautilusViewFrame *view,
- const char *location);
-void nautilus_view_frame_open_location_force_new_window (NautilusViewFrame *view,
+void nautilus_view_frame_open_location (NautilusViewFrame *view,
const char *location,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
GList *selection);
void nautilus_view_frame_report_location_change (NautilusViewFrame *view,
const char *location,
diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c
index b2fa7e66e..722022d67 100644
--- a/src/nautilus-view-frame.c
+++ b/src/nautilus-view-frame.c
@@ -63,9 +63,7 @@ enum {
LOAD_COMPLETE,
LOAD_PROGRESS_CHANGED,
LOAD_UNDERWAY,
- OPEN_LOCATION_FORCE_NEW_WINDOW,
- OPEN_LOCATION_IN_THIS_WINDOW,
- OPEN_LOCATION_PREFER_EXISTING_WINDOW,
+ OPEN_LOCATION,
REPORT_LOCATION_CHANGE,
REPORT_REDIRECT,
TITLE_CHANGED,
@@ -112,6 +110,14 @@ struct NautilusViewFrameDetails {
guint failed_idle_id;
guint socket_gone_idle_id;
+
+ /* zoom data */
+ float zoom_level;
+ float min_zoom_level;
+ float max_zoom_level;
+ gboolean has_min_zoom_level;
+ gboolean has_max_zoom_level;
+ GList *zoom_levels;
};
static void nautilus_view_frame_init (NautilusViewFrame *view);
@@ -265,9 +271,23 @@ nautilus_view_frame_finalize (GObject *object)
static void
emit_zoom_parameters_changed (NautilusViewFrame *view)
-{
- if (view->details->zoomable_frame != NULL) {
+{
+ eel_g_list_free_deep (view->details->zoom_levels);
+
+ if (view->details->zoomable_frame) {
+ view->details->min_zoom_level = bonobo_zoomable_frame_get_min_zoom_level (view->details->zoomable_frame);
+ view->details->max_zoom_level = bonobo_zoomable_frame_get_max_zoom_level (view->details->zoomable_frame);
+ view->details->has_min_zoom_level = bonobo_zoomable_frame_has_min_zoom_level (view->details->zoomable_frame);
+ view->details->has_max_zoom_level = bonobo_zoomable_frame_has_max_zoom_level (view->details->zoomable_frame);
+ view->details->zoom_levels = bonobo_zoomable_frame_get_preferred_zoom_levels (view->details->zoomable_frame);
+
g_signal_emit (view, signals[ZOOM_PARAMETERS_CHANGED], 0);
+ } else {
+ view->details->min_zoom_level = 0.0;
+ view->details->max_zoom_level = 0.0;
+ view->details->has_min_zoom_level = FALSE;
+ view->details->has_max_zoom_level = FALSE;
+ view->details->zoom_levels = NULL;
}
}
@@ -349,7 +369,6 @@ view_frame_underway (NautilusViewFrame *view)
/* stimulus
- open_location call from component
- - open_location_in_new_window
- report_selection_change
- report_status
- set_title
@@ -449,6 +468,8 @@ static void
emit_zoom_parameters_changed_callback (gpointer data,
gpointer callback_data)
{
+
+
emit_zoom_parameters_changed (NAUTILUS_VIEW_FRAME (data));
}
@@ -469,7 +490,13 @@ static void
emit_zoom_level_changed_callback (gpointer data,
gpointer callback_data)
{
- g_signal_emit (data,
+ NautilusViewFrame *view;
+
+ view = NAUTILUS_VIEW_FRAME (data);
+
+ view->details->zoom_level = bonobo_zoomable_frame_get_zoom_level (view->details->zoomable_frame);
+
+ g_signal_emit (view,
signals[ZOOM_LEVEL_CHANGED], 0,
* (float *) callback_data);
}
@@ -959,7 +986,7 @@ nautilus_view_frame_get_zoom_level (NautilusViewFrame *view)
return 0.0;
}
- return bonobo_zoomable_frame_get_zoom_level (view->details->zoomable_frame);
+ return view->details->zoom_level;
}
void
@@ -984,7 +1011,7 @@ nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view)
return 0.0;
}
- return bonobo_zoomable_frame_get_min_zoom_level (view->details->zoomable_frame);
+ return view->details->min_zoom_level;
}
float
@@ -996,7 +1023,7 @@ nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view)
return 0.0;
}
- return bonobo_zoomable_frame_get_max_zoom_level (view->details->zoomable_frame);
+ return view->details->max_zoom_level;
}
gboolean
@@ -1008,7 +1035,7 @@ nautilus_view_frame_get_has_min_zoom_level (NautilusViewFrame *view)
return FALSE;
}
- return bonobo_zoomable_frame_has_min_zoom_level (view->details->zoomable_frame);
+ return view->details->has_min_zoom_level;
}
gboolean
@@ -1020,7 +1047,7 @@ nautilus_view_frame_get_has_max_zoom_level (NautilusViewFrame *view)
return FALSE;
}
- return bonobo_zoomable_frame_has_max_zoom_level (view->details->zoomable_frame);
+ return view->details->has_max_zoom_level;
}
gboolean
@@ -1035,6 +1062,24 @@ nautilus_view_frame_get_is_continuous (NautilusViewFrame *view)
return bonobo_zoomable_frame_is_continuous (view->details->zoomable_frame);
}
+gboolean
+nautilus_view_frame_get_can_zoom_in (NautilusViewFrame *view)
+{
+ return !view->details->has_max_zoom_level ||
+ (view->details->zoom_level
+ < view->details->max_zoom_level);
+
+}
+
+gboolean
+nautilus_view_frame_get_can_zoom_out (NautilusViewFrame *view)
+{
+ return !view->details->has_min_zoom_level ||
+ (view->details->zoom_level
+ > view->details->min_zoom_level);
+}
+
+
GList *
nautilus_view_frame_get_preferred_zoom_levels (NautilusViewFrame *view)
{
@@ -1101,6 +1146,7 @@ nautilus_view_frame_get_first_visible_file (NautilusViewFrame *view)
CORBA_free (uri);
CORBA_exception_free (&ev);
}
+
return ret;
}
@@ -1132,37 +1178,11 @@ nautilus_view_frame_get_view_iid (NautilusViewFrame *view)
}
void
-nautilus_view_frame_open_location_in_this_window (NautilusViewFrame *view,
- const char *location)
-{
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
-
- if (view->details->state == VIEW_FRAME_FAILED) {
- return;
- }
-
- view_frame_wait_is_over (view);
- g_signal_emit (view, signals[OPEN_LOCATION_IN_THIS_WINDOW], 0, location);
-}
-
-void
-nautilus_view_frame_open_location_prefer_existing_window (NautilusViewFrame *view,
- const char *location)
-{
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
-
- if (view->details->state == VIEW_FRAME_FAILED) {
- return;
- }
-
- view_frame_wait_is_over (view);
- g_signal_emit (view, signals[OPEN_LOCATION_PREFER_EXISTING_WINDOW], 0, location);
-}
-
-void
-nautilus_view_frame_open_location_force_new_window (NautilusViewFrame *view,
- const char *location,
- GList *selection)
+nautilus_view_frame_open_location (NautilusViewFrame *view,
+ const char *location,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
+ GList *selection)
{
g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
@@ -1172,8 +1192,8 @@ nautilus_view_frame_open_location_force_new_window (NautilusViewFrame *view,
view_frame_wait_is_over (view);
g_signal_emit (view,
- signals[OPEN_LOCATION_FORCE_NEW_WINDOW], 0,
- location, selection);
+ signals[OPEN_LOCATION], 0,
+ location, mode, flags, selection);
}
void
@@ -1537,33 +1557,15 @@ nautilus_view_frame_class_init (NautilusViewFrameClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- signals[OPEN_LOCATION_FORCE_NEW_WINDOW] = g_signal_new
- ("open_location_force_new_window",
+ signals[OPEN_LOCATION] = g_signal_new
+ ("open_location",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusViewFrameClass,
- open_location_force_new_window),
+ open_location),
NULL, NULL,
- eel_marshal_VOID__STRING_POINTER,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER);
- signals[OPEN_LOCATION_IN_THIS_WINDOW] = g_signal_new
- ("open_location_in_this_window",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusViewFrameClass,
- open_location_in_this_window),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
- signals[OPEN_LOCATION_PREFER_EXISTING_WINDOW] = g_signal_new
- ("open_location_prefer_existing_window",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusViewFrameClass,
- open_location_prefer_existing_window),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ eel_marshal_VOID__STRING_LONG_LONG_POINTER,
+ G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG, G_TYPE_POINTER);
signals[REPORT_LOCATION_CHANGE] = g_signal_new
("report_location_change",
G_TYPE_FROM_CLASS (class),
diff --git a/src/nautilus-view-frame.h b/src/nautilus-view-frame.h
index a24a6d3d7..fabb4a7f1 100644
--- a/src/nautilus-view-frame.h
+++ b/src/nautilus-view-frame.h
@@ -65,12 +65,10 @@ typedef struct {
void (* failed) (NautilusViewFrame *view);
/* These will only happen after load_underway (guaranteed). */
- void (* open_location_in_this_window) (NautilusViewFrame *view,
- const char *location);
- void (* open_location_prefer_existing_window) (NautilusViewFrame *view,
- const char *location);
- void (* open_location_force_new_window) (NautilusViewFrame *view,
+ void (* open_location) (NautilusViewFrame *view,
const char *location,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
GList *selection); /* list of char * */
void (* report_location_change) (NautilusViewFrame *view,
const char *location,
@@ -123,6 +121,9 @@ float nautilus_view_frame_get_max_zoom_level (NautilusViewFr
gboolean nautilus_view_frame_get_has_min_zoom_level (NautilusViewFrame *view);
gboolean nautilus_view_frame_get_has_max_zoom_level (NautilusViewFrame *view);
gboolean nautilus_view_frame_get_is_continuous (NautilusViewFrame *view);
+gboolean nautilus_view_frame_get_can_zoom_in (NautilusViewFrame *view);
+gboolean nautilus_view_frame_get_can_zoom_out (NautilusViewFrame *view);
+
GList * nautilus_view_frame_get_preferred_zoom_levels (NautilusViewFrame *view);
void nautilus_view_frame_zoom_in (NautilusViewFrame *view);
void nautilus_view_frame_zoom_out (NautilusViewFrame *view);
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 0be23283b..efe6dfe1c 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Nautilus
@@ -71,18 +71,6 @@
*/
#include "nautilus-desktop-window.h"
-/* This number controls a maximum character count for a Nautilus
- * window title. Without limiting the window title, most window
- * managers make the window wide enough to able to display the whole
- * title. When this happens, the Nautilus window in question becomes
- * unusable. This is a very common thing to happen, especially with
- * generated web content, such as bugzilla queries, which generate
- * very long urls. I found the number experimentally. To properly
- * compute it, we would need window manager support to access the
- * character metrics for the window title.
- */
-#define MAX_TITLE_LENGTH 180
-
/* This number controls a maximum character count for a URL that is
* displayed as part of a dialog. It's fairly arbitrary -- big enough
* to allow most "normal" URIs to display in full, but small enough to
@@ -90,19 +78,14 @@
*/
#define MAX_URI_IN_DIALOG_LENGTH 60
-typedef enum {
- THIS_WINDOW,
- EXISTING_WINDOW,
- NEW_WINDOW
-} OpenLocationWindow;
-
typedef struct {
gboolean is_sidebar_panel;
NautilusViewIdentifier *id;
} ViewFrameInfo;
static void connect_view (NautilusWindow *window,
- NautilusViewFrame *view);
+ NautilusViewFrame *view,
+ gboolean content_view);
static void disconnect_view (NautilusWindow *window,
NautilusViewFrame *view);
static void begin_location_change (NautilusWindow *window,
@@ -119,7 +102,9 @@ change_selection (NautilusWindow *window,
GList *selection,
NautilusViewFrame *requesting_view)
{
- GList *sorted, *node, *sidebar_panels;
+ GList *sorted;
+ GList *views;
+ GList *node;
NautilusViewFrame *view;
/* Sort list into canonical order and check if it's the same as
@@ -134,71 +119,20 @@ change_selection (NautilusWindow *window,
/* Store the new selection. */
eel_g_list_free_deep (window->details->selection);
window->details->selection = sorted;
-
- /* Tell all the view frames about it, except the one that changed it. */
- if (window->content_view != requesting_view) {
- nautilus_view_frame_selection_changed (window->content_view, sorted);
- }
-
- /* Copy the list before traversing it, because during a failure in
- * selection_changed, list could be modified and bad things would
- * happen
- */
- sidebar_panels = g_list_copy (window->sidebar_panels);
- for (node = sidebar_panels; node != NULL; node = node->next) {
- view = node->data;
+
+ /* Tell all the view frames about it, except the one that changed it.
+ * Copy the list before traversing it, because during a failure in
+ * selection_changed, list could be modified and bad things would
+ * happen
+ */
+ views = g_list_copy (window->views);
+ for (node = views; node != NULL; node = node->next) {
+ view = NAUTILUS_VIEW_FRAME (node->data);
if (view != requesting_view) {
nautilus_view_frame_selection_changed (view, sorted);
}
}
- g_list_free (sidebar_panels);
-}
-
-static char *
-compute_default_title (const char *text_uri)
-{
- NautilusFile *file;
- char *title;
-
- if (text_uri == NULL) {
- title = g_strdup ("");
- } else {
- file = nautilus_file_get (text_uri);
- title = nautilus_file_get_display_name (file);
- nautilus_file_unref (file);
- }
-
- return title;
-}
-
-/* compute_title:
- *
- * Get a newly allocated copy of the user-displayable title for the current
- * location. Note that the window title is related to this but might not
- * be exactly this.
- * @window: The NautilusWindow in question.
- *
- * Return value: A newly allocated string. Use g_free when done with it.
- */
-static char *
-compute_title (NautilusWindow *window)
-{
- char *title;
-
- title = NULL;
-
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- /* Special Desktop window title (displayed in the Ctrl-Alt-Tab window) */
- title = g_strdup(_("Desktop"));
- } else if (window->new_content_view != NULL) {
- title = nautilus_view_frame_get_title (window->new_content_view);
- } else if (window->content_view != NULL) {
- title = nautilus_view_frame_get_title (window->content_view);
- }
- if (title == NULL) {
- title = compute_default_title (window->details->location);
- }
- return title;
+ g_list_free (views);
}
/* update_title:
@@ -212,55 +146,21 @@ compute_title (NautilusWindow *window)
static void
update_title (NautilusWindow *window)
{
- char *title;
- char *window_title;
- GList *sidebar_panels;
+ GList *views;
GList *node;
- title = compute_title (window);
-
- /* Remember the title and check if it's the same as last time. */
- if (window->details->title != NULL
- && strcmp (title, window->details->title) == 0) {
- g_free (title);
- return;
- }
- g_free (window->details->title);
- window->details->title = g_strdup (title);
+ nautilus_window_update_title (window);
- if (title[0] == '\0') {
- gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
- } else {
- window_title = eel_str_middle_truncate (title, MAX_TITLE_LENGTH);
- gtk_window_set_title (GTK_WINDOW (window), window_title);
- g_free (window_title);
+ /* Copy the list before traversing it, because during a failure in
+ * title_change, list could be modified and bad things would happen
+ */
+ views = g_list_copy (window->views);
+ for (node = views; node != NULL; node = node->next) {
+ nautilus_view_frame_title_changed (node->data,
+ window->details->title);
}
- if (window->information_panel) {
- nautilus_information_panel_set_title
- (window->information_panel, title);
- }
- if (title [0] != '\0' && window->current_location_bookmark &&
- nautilus_bookmark_set_name (window->current_location_bookmark, title)) {
- /* Name of item in history list changed, tell listeners. */
- nautilus_send_history_list_changed ();
- }
-
- /* warn all views and sidebar panels of the potential title change */
- if (window->content_view != NULL) {
- nautilus_view_frame_title_changed (window->content_view, title);
- }
-
- /* Copy the list before traversing it, because during a failure in
- * title_change, list could be modified and bad things would happen
- */
- sidebar_panels = g_list_copy (window->sidebar_panels);
- for (node = sidebar_panels; node != NULL; node = node->next) {
- nautilus_view_frame_title_changed (node->data, title);
- }
- g_list_free (sidebar_panels);
-
- g_free (title);
+ g_list_free (views);
}
/* nautilus_window_update_icon:
@@ -329,7 +229,6 @@ set_displayed_location (NautilusWindow *window, const char *location)
window->current_location_bookmark = location == NULL ? NULL
: nautilus_bookmark_new (location, location);
}
-
update_title (window);
nautilus_window_update_icon (window);
}
@@ -358,30 +257,32 @@ check_last_bookmark_location_matches_window (NautilusWindow *window)
}
static void
-handle_go_back (NautilusWindow *window, const char *location)
+handle_go_back (NautilusNavigationWindow *window, const char *location)
{
guint i;
GList *link;
NautilusBookmark *bookmark;
+ g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+
/* Going back. Move items from the back list to the forward list. */
- g_assert (g_list_length (window->back_list) > window->details->location_change_distance);
+ g_assert (g_list_length (window->back_list) > NAUTILUS_WINDOW (window)->details->location_change_distance);
check_bookmark_location_matches (NAUTILUS_BOOKMARK (g_list_nth_data (window->back_list,
- window->details->location_change_distance)),
+ NAUTILUS_WINDOW (window)->details->location_change_distance)),
location);
- g_assert (window->details->location != NULL);
+ g_assert (NAUTILUS_WINDOW (window)->details->location != NULL);
/* Move current location to Forward list */
- check_last_bookmark_location_matches_window (window);
+ check_last_bookmark_location_matches_window (NAUTILUS_WINDOW (window));
/* Use the first bookmark in the history list rather than creating a new one. */
window->forward_list = g_list_prepend (window->forward_list,
- window->last_location_bookmark);
+ NAUTILUS_WINDOW (window)->last_location_bookmark);
g_object_ref (window->forward_list->data);
/* Move extra links from Back to Forward list */
- for (i = 0; i < window->details->location_change_distance; ++i) {
+ for (i = 0; i < NAUTILUS_WINDOW (window)->details->location_change_distance; ++i) {
bookmark = NAUTILUS_BOOKMARK (window->back_list->data);
window->back_list = g_list_remove (window->back_list, bookmark);
window->forward_list = g_list_prepend (window->forward_list, bookmark);
@@ -395,30 +296,32 @@ handle_go_back (NautilusWindow *window, const char *location)
}
static void
-handle_go_forward (NautilusWindow *window, const char *location)
+handle_go_forward (NautilusNavigationWindow *window, const char *location)
{
guint i;
GList *link;
NautilusBookmark *bookmark;
+ g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+
/* Going forward. Move items from the forward list to the back list. */
- g_assert (g_list_length (window->forward_list) > window->details->location_change_distance);
+ g_assert (g_list_length (window->forward_list) > NAUTILUS_WINDOW (window)->details->location_change_distance);
check_bookmark_location_matches (NAUTILUS_BOOKMARK (g_list_nth_data (window->forward_list,
- window->details->location_change_distance)),
+ NAUTILUS_WINDOW (window)->details->location_change_distance)),
location);
- g_assert (window->details->location != NULL);
+ g_assert (NAUTILUS_WINDOW (window)->details->location != NULL);
/* Move current location to Back list */
- check_last_bookmark_location_matches_window (window);
+ check_last_bookmark_location_matches_window (NAUTILUS_WINDOW (window));
/* Use the first bookmark in the history list rather than creating a new one. */
window->back_list = g_list_prepend (window->back_list,
- window->last_location_bookmark);
+ NAUTILUS_WINDOW (window)->last_location_bookmark);
g_object_ref (window->back_list->data);
/* Move extra links from Forward to Back list */
- for (i = 0; i < window->details->location_change_distance; ++i) {
+ for (i = 0; i < NAUTILUS_WINDOW (window)->details->location_change_distance; ++i) {
bookmark = NAUTILUS_BOOKMARK (window->forward_list->data);
window->forward_list = g_list_remove (window->forward_list, bookmark);
window->back_list = g_list_prepend (window->back_list, bookmark);
@@ -434,24 +337,27 @@ handle_go_forward (NautilusWindow *window, const char *location)
static void
handle_go_elsewhere (NautilusWindow *window, const char *location)
{
- /* Clobber the entire forward list, and move displayed location to back list */
- nautilus_window_clear_forward_list (window);
-
- if (window->details->location != NULL) {
- /* If we're returning to the same uri somehow, don't put this uri on back list.
- * This also avoids a problem where set_displayed_location
- * didn't update last_location_bookmark since the uri didn't change.
- */
- if (!eel_uris_match (window->details->location, location)) {
- /* Store bookmark for current location in back list, unless there is no current location */
- check_last_bookmark_location_matches_window (window);
-
- /* Use the first bookmark in the history list rather than creating a new one. */
- window->back_list = g_list_prepend (window->back_list,
- window->last_location_bookmark);
- g_object_ref (window->back_list->data);
- }
+#if !NEW_UI_COMPLETE
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ /* Clobber the entire forward list, and move displayed location to back list */
+ nautilus_navigation_window_clear_forward_list (NAUTILUS_NAVIGATION_WINDOW (window));
+
+ if (window->details->location != NULL) {
+ /* If we're returning to the same uri somehow, don't put this uri on back list.
+ * This also avoids a problem where set_displayed_location
+ * didn't update last_location_bookmark since the uri didn't change.
+ */
+ if (!eel_uris_match (window->details->location, location)) {
+ /* Store bookmark for current location in back list, unless there is no current location */
+ check_last_bookmark_location_matches_window (window);
+ /* Use the first bookmark in the history list rather than creating a new one. */
+ NAUTILUS_NAVIGATION_WINDOW (window)->back_list = g_list_prepend (NAUTILUS_NAVIGATION_WINDOW (window)->back_list,
+ window->last_location_bookmark);
+ g_object_ref (NAUTILUS_NAVIGATION_WINDOW (window)->back_list->data);
+ }
+ }
}
+#endif
}
static void
@@ -468,6 +374,7 @@ update_up_button (NautilusWindow *window)
gnome_vfs_uri_unref (new_uri);
}
}
+
nautilus_window_allow_up (window, allowed);
}
@@ -542,11 +449,14 @@ viewed_file_changed_callback (NautilusFile *file,
/* Check if we can go up. */
update_up_button (window);
-
- /* Change the location bar to match the current location. */
- nautilus_navigation_bar_set_location
- (NAUTILUS_NAVIGATION_BAR (window->navigation_bar),
- window->details->location);
+#if !NEW_UI_COMPLETE
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ /* Change the location bar to match the current location. */
+ nautilus_navigation_bar_set_location
+ (NAUTILUS_NAVIGATION_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->navigation_bar),
+ window->details->location);
+ }
+#endif
} else {
g_free (new_location);
@@ -586,11 +496,13 @@ update_history (NautilusWindow *window,
return;
case NAUTILUS_LOCATION_CHANGE_BACK:
nautilus_window_add_current_location_to_history_list (window);
- handle_go_back (window, new_location);
+ handle_go_back (NAUTILUS_NAVIGATION_WINDOW (window),
+ new_location);
return;
case NAUTILUS_LOCATION_CHANGE_FORWARD:
nautilus_window_add_current_location_to_history_list (window);
- handle_go_forward (window, new_location);
+ handle_go_forward (NAUTILUS_NAVIGATION_WINDOW (window),
+ new_location);
return;
case NAUTILUS_LOCATION_CHANGE_REDIRECT:
/* for the redirect case, the caller can do the updating */
@@ -629,31 +541,36 @@ update_for_new_location (NautilusWindow *window)
/* Check if we can go up. */
update_up_button (window);
-
+
/* Check if we can go up. */
update_burn_cd_items (window);
-
+
/* Set up the content view menu for this new location. */
nautilus_window_load_view_as_menus (window);
-
- /* Check if the back and forward buttons need enabling or disabling. */
- nautilus_window_allow_back (window, window->back_list != NULL);
- nautilus_window_allow_forward (window, window->forward_list != NULL);
-
- /* Change the location bar to match the current location. */
- nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (window->navigation_bar),
- window->details->location);
+
+#if !NEW_UI_COMPLETE
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ /* Check if the back and forward buttons need enabling or disabling. */
+ nautilus_navigation_window_allow_back (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->back_list != NULL);
+ nautilus_navigation_window_allow_forward (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->forward_list != NULL);
+
+ /* Change the location bar to match the current location. */
+ nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->navigation_bar),
+ window->details->location);
+ }
/* Notify the information panel of the location change. */
/* FIXME bugzilla.gnome.org 40211:
* Eventually, this will not be necessary when we restructure the
* sidebar itself to be a NautilusViewFrame.
*/
- if (window->information_panel) {
- nautilus_information_panel_set_uri (window->information_panel,
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)
+ && NAUTILUS_NAVIGATION_WINDOW (window)->information_panel) {
+ nautilus_information_panel_set_uri (NAUTILUS_NAVIGATION_WINDOW (window)->information_panel,
window->details->location,
window->details->title);
}
+#endif
}
static gboolean
@@ -693,14 +610,7 @@ location_has_really_changed (NautilusWindow *window)
g_object_unref (window->new_content_view);
window->new_content_view = NULL;
- /* Update displayed view in menu. Only do this if we're not switching
- * locations though, because if we are switching locations we'll
- * install a whole new set of views in the menu later (the current
- * views in the menu are for the old location).
- */
- if (window->details->pending_location == NULL) {
- nautilus_window_synch_view_as_menus (window);
- } else {
+ if (window->details->pending_location != NULL) {
/* Tell the window we are finished. */
update_for_new_location (window);
}
@@ -723,41 +633,85 @@ location_has_really_changed (NautilusWindow *window)
}
static void
+new_window_show_callback (GtkWidget *widget,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (user_data);
+
+ gtk_widget_destroy (GTK_WIDGET (window));
+
+ g_signal_handlers_disconnect_by_func (widget,
+ G_CALLBACK (new_window_show_callback),
+ user_data);
+}
+
+
+static void
open_location (NautilusWindow *window,
const char *location,
- gboolean force_new_window,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
GList *new_selection)
{
NautilusWindow *target_window;
- gboolean create_new_window;
+ gboolean do_load_location = TRUE;
- target_window = window;
- create_new_window = force_new_window;
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- /* We used to have behavior here that worked like this: when
- * loading a location on the desktop in "open within same window
- * mode", always use another window. Either use the topmost window,
- * or create a new window if the desktop is the topmost (and only).
- * However, this behavior was nearly universally disliked (see
- * bugzilla.gnome.org bug 48122).
- */
- if (!create_new_window && NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- if (!NAUTILUS_DESKTOP_WINDOW (window)->affect_desktop_on_next_location_change) {
- create_new_window = TRUE;
+ target_window = NULL;
+
+ switch (mode) {
+ case Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE :
+ if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
+ if (!NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change) {
+ target_window = nautilus_application_present_spatial_window (
+ window->application,
+ location,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ do_load_location = FALSE;
+ } else {
+ NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = FALSE;
+ target_window = window;
+ }
} else {
- NAUTILUS_DESKTOP_WINDOW (window)->affect_desktop_on_next_location_change = FALSE;
+ target_window = window;
+ }
+ break;
+ case Nautilus_ViewFrame_OPEN_IN_SPATIAL :
+ target_window = nautilus_application_present_spatial_window (
+ window->application,
+ location,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ break;
+ case Nautilus_ViewFrame_OPEN_IN_NAVIGATION :
+ target_window = nautilus_application_create_navigation_window
+ (window->application,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ break;
+ default :
+ g_warning ("Unknown open location mode");
+ return;
+ }
+
+ g_assert (target_window != NULL);
+
+ if ((flags & Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND) != 0) {
+ if (NAUTILUS_IS_SPATIAL_WINDOW (window) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) {
+ if (GTK_WIDGET_VISIBLE (target_window)) {
+ gtk_widget_destroy (GTK_WIDGET (window));
+ } else {
+ g_signal_connect_object (target_window,
+ "show",
+ G_CALLBACK (new_window_show_callback),
+ window,
+ G_CONNECT_AFTER);
+ }
}
}
- if (create_new_window) {
- target_window = nautilus_application_create_window (
- window->application,
- gtk_window_get_screen (GTK_WINDOW (window)));
- }
+ if (!do_load_location) {
+ return;
+ }
eel_g_list_free_deep (target_window->details->pending_selection);
target_window->details->pending_selection = eel_g_str_list_copy (new_selection);
@@ -774,7 +728,9 @@ void
nautilus_window_open_location (NautilusWindow *window,
const char *location)
{
- open_location (window, location, FALSE, NULL);
+ open_location (window, location,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ 0, NULL);
}
void
@@ -782,20 +738,20 @@ nautilus_window_open_location_with_selection (NautilusWindow *window,
const char *location,
GList *selection)
{
- open_location (window, location, FALSE, selection);
+ open_location (window, location,
+ Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
+ 0, selection);
}
static ViewFrameInfo *
-view_frame_info_new (gboolean is_sidebar_panel,
- const NautilusViewIdentifier *id)
+view_frame_info_new (const NautilusViewIdentifier *id)
{
ViewFrameInfo *new_info;
g_return_val_if_fail (id != NULL, NULL);
new_info = g_new (ViewFrameInfo, 1);
- new_info->is_sidebar_panel = is_sidebar_panel;
new_info->id = nautilus_view_identifier_copy (id);
return new_info;
@@ -812,27 +768,16 @@ view_frame_info_free (ViewFrameInfo *info)
static void
set_view_frame_info (NautilusViewFrame *view_frame,
- gboolean is_sidebar_panel,
const NautilusViewIdentifier *id)
{
g_object_set_data_full (G_OBJECT (view_frame),
"info",
- view_frame_info_new (is_sidebar_panel, id),
+ view_frame_info_new (id),
(GtkDestroyNotify) view_frame_info_free);
}
-static gboolean
-view_frame_is_sidebar_panel (NautilusViewFrame *view_frame)
-{
- ViewFrameInfo *info;
-
- info = (ViewFrameInfo *) g_object_get_data
- (G_OBJECT (view_frame), "info");
- return info->is_sidebar_panel;
-}
-
-static char *
-view_frame_get_label (NautilusViewFrame *view_frame)
+char *
+nautilus_window_get_view_frame_label (NautilusViewFrame *view_frame)
{
ViewFrameInfo *info;
@@ -841,6 +786,7 @@ view_frame_get_label (NautilusViewFrame *view_frame)
return g_strdup (info->id->name);
}
+
static NautilusViewIdentifier *
view_frame_get_id (NautilusViewFrame *view_frame)
{
@@ -858,7 +804,7 @@ report_content_view_failure_to_user_internal (NautilusWindow *window,
{
char *label;
- label = view_frame_get_label (view_frame);
+ label = nautilus_window_get_view_frame_label (view_frame);
message = g_strdup_printf (message, label);
eel_show_error_dialog (message, _("View Failed"), GTK_WINDOW (window));
g_free (label);
@@ -895,61 +841,50 @@ load_new_location_in_one_view (NautilusViewFrame *view,
}
static void
-load_new_location_in_sidebar_panels (NautilusWindow *window,
- const char *location,
- GList *selection,
- NautilusViewFrame *view_to_skip)
-{
- GList *l;
- GList *node;
- GList *sidebar_panels;
- NautilusViewFrame *view;
-
- /* Copy the list before traversing it, because during a failure in
- * load_new..., list could be modified and bad things would happen
- * also reference each object in case of re-enterency eg. window close.
- */
- sidebar_panels = NULL;
- for (l = window->sidebar_panels; l; l = l->next) {
- sidebar_panels = g_list_prepend (sidebar_panels,
- g_object_ref (l->data));
- }
-
- for (node = sidebar_panels; node != NULL; node = node->next) {
- view = node->data;
- if (view != view_to_skip
- && nautilus_view_frame_get_is_view_loaded (view)) {
- load_new_location_in_one_view (view, location, selection);
- }
- }
-
- for (l = sidebar_panels; l; l = l->next) {
- g_object_unref (l->data);
- }
-
- g_list_free (sidebar_panels);
-}
-
-static void
load_new_location_in_all_views (NautilusWindow *window,
const char *location,
GList *selection,
NautilusViewFrame *view_to_skip)
{
+ GList *views;
+ GList *l;
+ NautilusViewFrame *view;
+
g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (location != NULL);
set_displayed_location (window, location);
+
if (window->new_content_view != view_to_skip
&& window->new_content_view != NULL) {
load_new_location_in_one_view (window->new_content_view,
location,
selection);
}
- load_new_location_in_sidebar_panels (window,
- location,
- selection,
- view_to_skip);
+
+ /* Copy the list before traversing it, because during a failure in
+ * load_new..., list could be modified and bad things would happen
+ * also reference each object in case of re-enterency eg. window close.
+ */
+ views = NULL;
+ for (l = window->views; l; l = l->next) {
+ if (l->data != view_to_skip &&
+ l->data != window->content_view &&
+ l->data != window->new_content_view) {
+ views = g_list_prepend (views, g_object_ref (l->data));
+ }
+ }
+
+ for (l = views; l != NULL; l = l->next) {
+ view = l->data;
+ load_new_location_in_one_view (view, location, selection);
+ }
+
+ for (l = views; l; l = l->next) {
+ g_object_unref (l->data);
+ }
+
+ g_list_free (views);
}
static void
@@ -1045,8 +980,8 @@ load_content_view (NautilusWindow *window,
window->new_content_view = view;
g_object_ref (view);
gtk_object_sink (GTK_OBJECT (view));
- set_view_frame_info (view, FALSE, id);
- connect_view (window, view);
+ set_view_frame_info (view, id);
+ connect_view (window, view, TRUE);
nautilus_view_frame_load_view (view, iid);
}
@@ -1054,73 +989,30 @@ load_content_view (NautilusWindow *window,
}
static void
-report_sidebar_panel_failure_to_user (NautilusWindow *window, NautilusViewFrame *view_frame)
-{
- char *message;
- char *label;
-
- label = view_frame_get_label (view_frame);
-
- if (label == NULL) {
- message = g_strdup
- (_("One of the sidebar panels encountered an error and can't continue. "
- "Unfortunately I couldn't tell which one."));
- } else {
- message = g_strdup_printf
- (_("The %s sidebar panel encountered an error and can't continue. "
- "If this keeps happening, you might want to turn this panel off."),
- label);
- }
-
- eel_show_error_dialog (message, _("Sidebar Panel Failed"), GTK_WINDOW (window));
-
- g_free (label);
- g_free (message);
-}
-
-static void
-disconnect_and_destroy_sidebar_panel (NautilusWindow *window, NautilusViewFrame *view)
-{
- g_object_ref (view);
- disconnect_view (window, view);
- nautilus_window_remove_sidebar_panel (window, view);
- gtk_object_destroy (GTK_OBJECT (view));
- g_object_unref (view);
-}
-
-static void
handle_view_failure (NautilusWindow *window,
NautilusViewFrame *view)
{
- const char *current_iid;
-
g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged.");
- if (view_frame_is_sidebar_panel (view)) {
- report_sidebar_panel_failure_to_user (window, view);
- current_iid = nautilus_view_frame_get_view_iid (view);
- disconnect_and_destroy_sidebar_panel (window, view);
- } else {
- if (view == window->content_view) {
- nautilus_window_set_content_view_widget (window, NULL);
-
- /* FIXME bugzilla.gnome.org 45039: We need a
- * way to report the specific error that
- * happens in this case - adapter factory not
- * found, component failed to load, etc.
- */
- report_current_content_view_failure_to_user (window, view);
- } else {
- /* FIXME bugzilla.gnome.org 45039: We need a
- * way to report the specific error that
- * happens in this case - adapter factory not
- * found, component failed to load, etc.
- */
- report_nascent_content_view_failure_to_user (window, view);
- }
-
- cancel_location_change (window);
- }
+ if (view == window->content_view) {
+ nautilus_window_set_content_view_widget (window, NULL);
+
+ /* FIXME bugzilla.gnome.org 45039: We need a
+ * way to report the specific error that
+ * happens in this case - adapter factory not
+ * found, component failed to load, etc.
+ */
+ report_current_content_view_failure_to_user (window, view);
+ } else {
+ /* FIXME bugzilla.gnome.org 45039: We need a
+ * way to report the specific error that
+ * happens in this case - adapter factory not
+ * found, component failed to load, etc.
+ */
+ report_nascent_content_view_failure_to_user (window, view);
+ }
+
+ cancel_location_change (window);
}
static void
@@ -1219,10 +1111,12 @@ position_and_show_window_callback (NautilusFile *file,
{
NautilusWindow *window;
char *geometry_string;
+ char *scroll_string;
window = NAUTILUS_WINDOW (callback_data);
- if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
+#if !NEW_UI_COMPLETE
+ if (NAUTILUS_IS_SPATIAL_WINDOW (window) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) {
/* load the saved window geometry */
geometry_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL);
@@ -1239,8 +1133,16 @@ position_and_show_window_callback (NautilusFile *file,
pending_location_already_showing (window));
}
g_free (geometry_string);
- }
+ /* load the saved scroll position */
+ scroll_string = nautilus_file_get_metadata
+ (file, NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION,
+ NULL);
+ if (scroll_string != NULL) {
+ window->details->pending_scroll_to = scroll_string;
+ }
+ }
+#endif
/* If we finished constructing the window by now we need
* to show the window here.
*/
@@ -1251,7 +1153,7 @@ position_and_show_window_callback (NautilusFile *file,
/* This object was ref'd when starting the callback. */
nautilus_file_unref (file);
-}
+}
/* utility routine that returns true if there's one or fewer windows in the window list */
static gboolean
@@ -1576,18 +1478,15 @@ stop_loading_cover (gpointer data, gpointer callback_data)
void
nautilus_window_stop_loading (NautilusWindow *window)
{
- GList *sidebar_panels;
-
- stop_loading (window->content_view);
- stop_loading (window->new_content_view);
-
+ GList *views;
+
/* Copy the list before traversing it, because during a failure in
* stop_loading_cover, list could be modified and bad things would
* happen
*/
- sidebar_panels = g_list_copy (window->sidebar_panels);
- g_list_foreach (sidebar_panels, stop_loading_cover, NULL);
- g_list_free (sidebar_panels);
+ views = g_list_copy (window->views);
+ g_list_foreach (views, stop_loading_cover, NULL);
+ g_list_free (views);
cancel_location_change (window);
}
@@ -1624,80 +1523,20 @@ nautilus_window_set_content_view (NautilusWindow *window,
load_content_view (window, id);
}
-static int
-compare_view_identifier_with_iid (gconstpointer passed_view_identifier,
- gconstpointer passed_iid)
+void
+nautilus_window_connect_extra_view (NautilusWindow *window,
+ NautilusViewFrame *view_frame,
+ NautilusViewIdentifier *id)
{
- return strcmp (((NautilusViewIdentifier *) passed_view_identifier)->iid,
- (char *) passed_iid);
+ connect_view (window, view_frame, FALSE);
+ set_view_frame_info (view_frame, id);
}
void
-nautilus_window_set_sidebar_panels (NautilusWindow *window,
- GList *passed_identifier_list)
+nautilus_window_disconnect_extra_view (NautilusWindow *window,
+ NautilusViewFrame *view_frame)
{
- GList *identifier_list;
- GList *node, *next, *found_node;
- NautilusViewFrame *sidebar_panel;
- NautilusViewIdentifier *identifier;
- const char *current_iid;
-
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- /* Make a copy of the list so we can remove items from it. */
- identifier_list = g_list_copy (passed_identifier_list);
-
- /* Remove panels from the window that don't appear in the list. */
- for (node = window->sidebar_panels; node != NULL; node = next) {
- next = node->next;
-
- sidebar_panel = NAUTILUS_VIEW_FRAME (node->data);
-
- found_node = g_list_find_custom (identifier_list,
- (char *) nautilus_view_frame_get_view_iid (sidebar_panel),
- compare_view_identifier_with_iid);
- if (found_node == NULL) {
- current_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
- disconnect_and_destroy_sidebar_panel (window, sidebar_panel);
- } else {
- identifier = (NautilusViewIdentifier *) found_node->data;
-
- /* Right panel, make sure it has the right name. */
- /* FIXME: Is this set_label necessary? Shouldn't it already
- * have the right label here?
- */
- nautilus_view_frame_set_label (sidebar_panel, identifier->name);
-
- /* Since this was found, there's no need to add it in the loop below. */
- identifier_list = g_list_remove_link (identifier_list, found_node);
- g_list_free_1 (found_node);
- }
- }
-
- /* Add panels to the window that were in the list, but not the window. */
- for (node = identifier_list; node != NULL; node = node->next) {
- g_assert (node->data != NULL);
-
- identifier = (NautilusViewIdentifier *) node->data;
-
- /* Create and load the panel. */
- sidebar_panel = nautilus_view_frame_new (window->details->ui_container,
- window->application->undo_manager);
-
- eel_accessibility_set_name (sidebar_panel, _("Side Pane"));
- eel_accessibility_set_description
- (sidebar_panel, _("Contains a side pane view"));
-
-
- nautilus_view_frame_set_label (sidebar_panel, identifier->name);
- set_view_frame_info (sidebar_panel, TRUE, identifier);
- connect_view (window, sidebar_panel);
- nautilus_view_frame_load_view (sidebar_panel, identifier->iid);
- nautilus_window_add_sidebar_panel (window, sidebar_panel);
- gtk_object_sink (GTK_OBJECT (sidebar_panel));
- }
-
- g_list_free (identifier_list);
+ disconnect_view (window, view_frame);
}
static void
@@ -1712,21 +1551,19 @@ zoom_level_changed_callback (NautilusViewFrame *view,
nautilus_window_ui_freeze (window);
- nautilus_zoom_control_set_zoom_level (NAUTILUS_ZOOM_CONTROL (window->zoom_control),
- nautilus_view_frame_get_zoom_level (view));
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_ZOOM_IN,
- nautilus_zoom_control_can_zoom_in (NAUTILUS_ZOOM_CONTROL (window->zoom_control)));
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_ZOOM_OUT,
- nautilus_zoom_control_can_zoom_out (NAUTILUS_ZOOM_CONTROL (window->zoom_control)));
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_ZOOM_NORMAL,
- TRUE);
+ nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ NAUTILUS_COMMAND_ZOOM_IN,
+ nautilus_view_frame_get_can_zoom_in (view));
+ nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ NAUTILUS_COMMAND_ZOOM_OUT,
+ nautilus_view_frame_get_can_zoom_out (view));
+ nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ NAUTILUS_COMMAND_ZOOM_NORMAL,
+ TRUE);
+
/* FIXME bugzilla.gnome.org 43442: Desensitize "Zoom Normal"? */
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (window);
}
static void
@@ -1737,35 +1574,6 @@ zoom_parameters_changed_callback (NautilusViewFrame *view,
g_assert (NAUTILUS_IS_WINDOW (window));
- /* This callback is invoked via the "zoom_parameters_changed"
- * signal of the BonoboZoomableFrame.
- *
- * You can rely upon this callback being called in the following
- * situations:
- *
- * - a zoomable component has been set in the NautilusViewFrame;
- * in this case nautilus_view_frame_set_to_component() emits the
- * "zoom_parameters_changed" signal after creating the
- * BonoboZoomableFrame and binding it to the Bonobo::Zoomable.
- *
- * This means that we can use the following call to
- * nautilus_zoom_control_set_parameters() to display the zoom
- * control when a new zoomable component has been loaded.
- *
- * - a new file has been loaded by the zoomable component; this is
- * not 100% guaranteed since it's up to the component to emit this
- * signal, but I consider it "good behaviour" of a component to
- * emit this signal after loading a new file.
- */
-
- nautilus_zoom_control_set_parameters
- (NAUTILUS_ZOOM_CONTROL (window->zoom_control),
- nautilus_view_frame_get_min_zoom_level (view),
- nautilus_view_frame_get_max_zoom_level (view),
- nautilus_view_frame_get_has_min_zoom_level (view),
- nautilus_view_frame_get_has_max_zoom_level (view),
- nautilus_view_frame_get_preferred_zoom_levels (view));
-
/* The initial zoom level of a component is allowed to be 0.0 if
* there is no file loaded yet. In this case we need to set the
* commands insensitive but display the zoom control nevertheless
@@ -1798,7 +1606,6 @@ zoom_parameters_changed_callback (NautilusViewFrame *view,
zoom_level_changed_callback (view, window);
}
-
static Nautilus_History *
get_history_list_callback (NautilusViewFrame *view,
NautilusWindow *window)
@@ -1840,13 +1647,17 @@ static void
go_back_callback (NautilusViewFrame *view,
NautilusWindow *window)
{
+#if !NEW_UI_COMPLETE
g_assert (NAUTILUS_IS_WINDOW (window));
- if (window->back_list != NULL) {
- nautilus_window_go_back (window);
- } else {
- nautilus_window_go_home (window);
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ if (NAUTILUS_NAVIGATION_WINDOW (window)->back_list != NULL) {
+ nautilus_navigation_window_go_back (NAUTILUS_NAVIGATION_WINDOW (window));
+ } else {
+ nautilus_window_go_home (window);
+ }
}
+#endif
}
static void
@@ -1879,8 +1690,8 @@ change_status_callback (NautilusViewFrame *view,
}
static void
-failed_callback (NautilusViewFrame *view,
- NautilusWindow *window)
+content_view_failed_callback (NautilusViewFrame *view,
+ NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
@@ -1926,55 +1737,17 @@ load_complete_callback (NautilusViewFrame *view,
}
static void
-open_location_in_this_window_callback (NautilusViewFrame *view,
- const char *location,
- NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_open_location (window, location);
-}
-
-static void
-open_location_prefer_existing_window_callback (NautilusViewFrame *view,
- const char *location,
- NautilusWindow *window)
-{
- NautilusWindow *existing_window;
- GList *node;
- const char *existing_location;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- /* First, handle the case where there's already a window for
- * this location.
- */
- for (node = nautilus_application_get_window_list ();
- node != NULL; node = node->next) {
- existing_window = NAUTILUS_WINDOW (node->data);
- existing_location = existing_window->details->pending_location;
- if (existing_location == NULL) {
- existing_location = existing_window->details->location;
- }
- if (eel_uris_match (existing_location, location)) {
- gtk_window_present (GTK_WINDOW (existing_window));
- return;
- }
- }
-
- /* Otherwise, open a new window. */
- open_location (window, location, TRUE, NULL);
-}
-
-static void
-open_location_force_new_window_callback (NautilusViewFrame *view,
- const char *location,
- GList *selection,
- NautilusWindow *window)
+open_location_callback (NautilusViewFrame *view,
+ const char *location,
+ Nautilus_ViewFrame_OpenMode mode,
+ Nautilus_ViewFrame_OpenFlags flags,
+ GList *selection,
+ NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
- open_location (window, location, TRUE, selection);
+ /* Open in a new navigation window */
+ open_location (window, location, mode, flags, selection);
}
static void
@@ -2039,7 +1812,7 @@ report_redirect_callback (NautilusViewFrame *view,
nautilus_remove_from_history_list_no_notify (from_location);
nautilus_window_add_current_location_to_history_list (window);
-
+
window->details->location_change_type = NAUTILUS_LOCATION_CHANGE_REDIRECT;
window->details->pending_location = g_strdup (to_location);
update_for_new_location (window);
@@ -2056,90 +1829,6 @@ title_changed_callback (NautilusViewFrame *view,
}
static void
-set_side_panel_image (NautilusWindow *window,
- NautilusViewFrame *side_panel,
- const char *image_name)
-{
- GdkPixbuf *pixbuf;
- char *image_path;
-
- pixbuf = NULL;
-
- if (image_name && image_name[0]) {
- image_path = nautilus_theme_get_image_path (image_name);
- if (image_path) {
- pixbuf = gdk_pixbuf_new_from_file (image_path, NULL);
- g_free (image_path);
- }
- }
-
- nautilus_side_pane_set_panel_image (window->sidebar,
- GTK_WIDGET (side_panel),
- pixbuf);
-
- if (pixbuf) {
- g_object_unref (pixbuf);
- }
-}
-
-static void
-side_panel_image_changed_callback (BonoboListener *listener,
- const char *event_name,
- const CORBA_any *arg,
- CORBA_Environment *ev,
- gpointer callback_data)
-{
- NautilusViewFrame *side_panel;
- NautilusWindow *window;
-
- side_panel = NAUTILUS_VIEW_FRAME (callback_data);
- window = NAUTILUS_WINDOW (g_object_get_data (G_OBJECT (side_panel),
- "nautilus-window"));
-
- set_side_panel_image (window, side_panel, BONOBO_ARG_GET_STRING (arg));
-}
-
-static void
-connect_side_panel (NautilusWindow *window,
- NautilusViewFrame *side_panel)
-{
- Bonobo_Control control;
- Bonobo_PropertyBag property_bag;
- CORBA_Environment ev;
- char *image_name;
-
- g_object_set_data (G_OBJECT (side_panel),
- "nautilus-window",
- window);
-
- control = nautilus_view_frame_get_control (side_panel);
-
- if (control != CORBA_OBJECT_NIL) {
- CORBA_exception_init (&ev);
- property_bag = Bonobo_Control_getProperties (control, &ev);
- if (property_bag != CORBA_OBJECT_NIL) {
- bonobo_event_source_client_add_listener
- (property_bag,
- side_panel_image_changed_callback,
- "Bonobo/Property:change:tab_image",
- NULL,
- side_panel);
-
- /* Set the initial tab image */
- image_name = bonobo_property_bag_client_get_value_string
- (property_bag,
- "tab_image",
- NULL);
- set_side_panel_image (window, side_panel, image_name);
- g_free (image_name);
-
- bonobo_object_release_unref (property_bag, NULL);
- }
- CORBA_exception_free (&ev);
- }
-}
-
-static void
view_loaded_callback (NautilusViewFrame *view,
NautilusWindow *window)
{
@@ -2159,10 +1848,6 @@ view_loaded_callback (NautilusViewFrame *view,
}
}
- if (view_frame_is_sidebar_panel (view)) {
- connect_side_panel (window, view);
- }
-
if (window->details->title != NULL) {
nautilus_view_frame_title_changed (view, window->details->title);
}
@@ -2171,15 +1856,12 @@ view_loaded_callback (NautilusViewFrame *view,
#define FOR_EACH_NAUTILUS_WINDOW_SIGNAL(macro) \
macro (change_selection) \
macro (change_status) \
- macro (failed) \
macro (get_history_list) \
macro (go_back) \
macro (close_window) \
macro (load_complete) \
macro (load_underway) \
- macro (open_location_force_new_window) \
- macro (open_location_in_this_window) \
- macro (open_location_prefer_existing_window) \
+ macro (open_location) \
macro (report_location_change) \
macro (report_redirect) \
macro (title_changed) \
@@ -2188,8 +1870,20 @@ view_loaded_callback (NautilusViewFrame *view,
macro (zoom_parameters_changed)
static void
-connect_view (NautilusWindow *window, NautilusViewFrame *view)
-{
+connect_view (NautilusWindow *window,
+ NautilusViewFrame *view,
+ gboolean is_content_view)
+{
+ window->views = g_list_prepend (window->views, view);
+
+ if (is_content_view) {
+ g_signal_connect (view, "failed",
+ G_CALLBACK (content_view_failed_callback),
+ window);
+ g_object_set_data (G_OBJECT (view), "is_content_view",
+ GINT_TO_POINTER (1));
+ }
+
#define CONNECT(signal) g_signal_connect \
(view, #signal, \
G_CALLBACK (signal##_callback), window);
@@ -2208,6 +1902,14 @@ disconnect_view (NautilusWindow *window, NautilusViewFrame *view)
g_assert (NAUTILUS_IS_VIEW_FRAME (view));
+ window->views = g_list_remove (window->views, view);
+
+ if (g_object_get_data (G_OBJECT (view), "is_content_view")) {
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (content_view_failed_callback),
+ window);
+ }
+
#define DISCONNECT(signal) g_signal_handlers_disconnect_by_func \
(view, \
G_CALLBACK (signal##_callback), window);
@@ -2225,11 +1927,16 @@ disconnect_view_callback (gpointer list_item_data, gpointer callback_data)
void
nautilus_window_manage_views_destroy (NautilusWindow *window)
{
+ GList *views;
/* Disconnect view signals here so they don't trigger when
* views are destroyed.
*/
- g_list_foreach (window->sidebar_panels, disconnect_view_callback, window);
- disconnect_view (window, window->content_view);
+
+ views = g_list_copy (window->views);
+
+ g_list_foreach (views, disconnect_view_callback, window);
+
+ g_list_free (views);
}
void
@@ -2240,7 +1947,8 @@ nautilus_window_manage_views_finalize (NautilusWindow *window)
}
void
-nautilus_window_back_or_forward (NautilusWindow *window, gboolean back, guint distance)
+nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
+ gboolean back, guint distance)
{
GList *list;
char *uri;
@@ -2265,7 +1973,7 @@ nautilus_window_back_or_forward (NautilusWindow *window, gboolean back, guint di
uri = nautilus_bookmark_get_uri (bookmark);
scroll_pos = nautilus_bookmark_get_scroll_pos (bookmark);
begin_location_change
- (window,
+ (NAUTILUS_WINDOW (window),
uri,
back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD,
distance,
diff --git a/src/nautilus-window-manage-views.h b/src/nautilus-window-manage-views.h
index a108b13a7..b5826beee 100644
--- a/src/nautilus-window-manage-views.h
+++ b/src/nautilus-window-manage-views.h
@@ -28,6 +28,7 @@
#define NAUTILUS_WINDOW_MANAGE_VIEWS_H
#include "nautilus-window.h"
+#include "nautilus-navigation-window.h"
void nautilus_window_manage_views_destroy (NautilusWindow *window);
void nautilus_window_manage_views_finalize (NautilusWindow *window);
@@ -39,13 +40,21 @@ void nautilus_window_open_location_with_selection (NautilusWi
void nautilus_window_stop_loading (NautilusWindow *window);
void nautilus_window_set_content_view (NautilusWindow *window,
NautilusViewIdentifier *id);
-void nautilus_window_set_sidebar_panels (NautilusWindow *window,
- GList *view_identifier_list);
-void nautilus_window_back_or_forward (NautilusWindow *window,
- gboolean back,
- guint distance);
+
gboolean nautilus_window_content_view_matches_iid (NautilusWindow *window,
const char *iid);
NautilusViewIdentifier *nautilus_window_get_content_view_id (NautilusWindow *window);
+void nautilus_window_connect_extra_view (NautilusWindow *window,
+ NautilusViewFrame *view,
+ NautilusViewIdentifier *id);
+void nautilus_window_disconnect_extra_view (NautilusWindow *window,
+ NautilusViewFrame *view);
+char *nautilus_window_get_view_frame_label (NautilusViewFrame *view);
+
+void nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window,
+ GList *view_identifier_list);
+void nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
+ gboolean back,
+ guint distance);
#endif /* NAUTILUS_WINDOW_MANAGE_VIEWS_H */
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 454ac0842..a178df21b 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -30,9 +30,6 @@
#include <locale.h>
#include "nautilus-application.h"
-#include "nautilus-bookmark-list.h"
-#include "nautilus-bookmark-parsing.h"
-#include "nautilus-bookmarks-window.h"
#include "nautilus-file-management-properties.h"
#include "nautilus-property-browser.h"
#include "nautilus-signaller.h"
@@ -69,27 +66,17 @@
#include "nautilus-profiler.h"
#endif
-#define STATIC_BOOKMARKS_FILE_NAME "static_bookmarks.xml"
-
/* Private menu definitions; others are in <libnautilus/nautilus-bonobo-ui.h>.
* These are not part of the published set, either because they are
* development-only or because we expect to change them and
* don't want other code relying on their existence.
*/
-#define COMMAND_PATH_TOGGLE_FIND_MODE "/commands/Find"
-#define COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE "/commands/Toggle Find Mode"
-
#define MENU_PATH_SHOW_HIDE_SIDEBAR "/menu/View/Show Hide Placeholder/Show Hide Sidebar"
#define MENU_PATH_SHOW_HIDE_TOOLBAR "/menu/View/Show Hide Placeholder/Show Hide Toolbar"
#define MENU_PATH_SHOW_HIDE_LOCATION_BAR "/menu/View/Show Hide Placeholder/Show Hide Location Bar"
#define MENU_PATH_SHOW_HIDE_STATUS_BAR "/menu/View/Show Hide Placeholder/Show Hide Statusbar"
-#define MENU_PATH_HISTORY_PLACEHOLDER "/menu/Go/History Placeholder"
-
-#define MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER "/menu/Bookmarks/Built-in Bookmarks Placeholder"
-#define MENU_PATH_BOOKMARKS_PLACEHOLDER "/menu/Bookmarks/Bookmarks Placeholder"
-
#define COMMAND_PATH_CLOSE_WINDOW "/commands/Close"
#define COMMAND_SHOW_HIDE_SIDEBAR "/commands/Show Hide Sidebar"
#define COMMAND_SHOW_HIDE_TOOLBAR "/commands/Show Hide Toolbar"
@@ -105,53 +92,33 @@
#define START_HERE_URI "start-here:"
#define BURN_CD_URI "burn:"
-#define RESPONSE_FORGET 1000
-
-static GtkWindow *bookmarks_window = NULL;
-
-static void append_bookmark_to_menu (NautilusWindow *window,
- NautilusBookmark *bookmark,
- const char *parent_path,
- guint index_in_parent,
- gboolean is_in_bookmarks_menu);
-static void append_dynamic_bookmarks (NautilusWindow *window);
-static NautilusBookmarkList *get_bookmark_list (void);
-static void refresh_go_menu (NautilusWindow *window);
-static void refresh_bookmarks_menu (NautilusWindow *window);
-static void schedule_refresh_go_menu (NautilusWindow *window);
-static void schedule_refresh_bookmarks_menu (NautilusWindow *window);
-static void edit_bookmarks (NautilusWindow *window);
-static void add_bookmark_for_current_location (NautilusWindow *window);
-
/* Struct that stores all the info necessary to activate a bookmark. */
typedef struct {
NautilusBookmark *bookmark;
NautilusWindow *window;
- gboolean prompt_for_removal;
guint changed_handler_id;
+ NautilusBookmarkFailedCallback failed_callback;
} BookmarkHolder;
static BookmarkHolder *
bookmark_holder_new (NautilusBookmark *bookmark,
NautilusWindow *window,
- gboolean is_bookmarks_menu)
+ GCallback refresh_callback,
+ NautilusBookmarkFailedCallback failed_callback)
{
BookmarkHolder *new_bookmark_holder;
new_bookmark_holder = g_new (BookmarkHolder, 1);
new_bookmark_holder->window = window;
new_bookmark_holder->bookmark = bookmark;
+ new_bookmark_holder->failed_callback = failed_callback;
/* Ref the bookmark because it might be unreffed away while
* we're holding onto it (not an issue for window).
*/
g_object_ref (bookmark);
- new_bookmark_holder->prompt_for_removal = is_bookmarks_menu;
-
new_bookmark_holder->changed_handler_id =
g_signal_connect_object (bookmark, "appearance_changed",
- is_bookmarks_menu
- ? G_CALLBACK (schedule_refresh_bookmarks_menu)
- : G_CALLBACK (schedule_refresh_go_menu),
+ refresh_callback,
window, G_CONNECT_SWAPPED);
return new_bookmark_holder;
@@ -180,6 +147,84 @@ bookmark_holder_free_cover (gpointer callback_data, GClosure *closure)
}
static void
+activate_bookmark_in_menu_item (BonoboUIComponent *component, gpointer user_data, const char *path)
+{
+ BookmarkHolder *holder;
+ char *uri;
+
+ holder = (BookmarkHolder *)user_data;
+
+ if (nautilus_bookmark_uri_known_not_to_exist (holder->bookmark)) {
+ holder->failed_callback (holder->window, holder->bookmark);
+ } else {
+ uri = nautilus_bookmark_get_uri (holder->bookmark);
+ nautilus_window_go_to (holder->window, uri);
+ g_free (uri);
+ }
+}
+
+void
+nautilus_menus_append_bookmark_to_menu (NautilusWindow *window,
+ BonoboUIComponent *uic,
+ NautilusBookmark *bookmark,
+ const char *parent_path,
+ guint index_in_parent,
+ GCallback refresh_callback,
+ NautilusBookmarkFailedCallback failed_callback)
+{
+ BookmarkHolder *bookmark_holder;
+ char *raw_name, *display_name, *truncated_name, *verb_name;
+ char *ui_path;
+ GdkPixbuf *pixbuf;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
+
+ nautilus_window_ui_freeze (window);
+
+ bookmark_holder = bookmark_holder_new (bookmark, window, refresh_callback, failed_callback);
+
+ /* We double the underscores here to escape them so Bonobo will know they are
+ * not keyboard accelerator character prefixes. If we ever find we need to
+ * escape more than just the underscores, we'll add a menu helper function
+ * instead of a string utility. (Like maybe escaping control characters.)
+ */
+ raw_name = nautilus_bookmark_get_name (bookmark);
+ truncated_name = eel_truncate_text_for_menu_item (raw_name);
+ display_name = eel_str_double_underscores (truncated_name);
+ g_free (raw_name);
+ g_free (truncated_name);
+
+ /* Create menu item with pixbuf */
+ pixbuf = nautilus_bookmark_get_pixbuf (bookmark, NAUTILUS_ICON_SIZE_FOR_MENUS, FALSE);
+ nautilus_bonobo_add_numbered_menu_item
+ (uic,
+ parent_path,
+ index_in_parent,
+ display_name,
+ pixbuf);
+ g_object_unref (pixbuf);
+ g_free (display_name);
+
+ /* Add the status tip */
+ ui_path = nautilus_bonobo_get_numbered_menu_item_path
+ (uic, parent_path, index_in_parent);
+ nautilus_bonobo_set_tip (uic, ui_path, _("Go to the location specified by this bookmark"));
+ g_free (ui_path);
+
+ /* Add verb to new bookmark menu item */
+ verb_name = nautilus_bonobo_get_numbered_menu_item_command
+ (uic, parent_path, index_in_parent);
+ bonobo_ui_component_add_verb_full (uic, verb_name,
+ g_cclosure_new (G_CALLBACK (activate_bookmark_in_menu_item),
+ bookmark_holder,
+ bookmark_holder_free_cover));
+ g_free (verb_name);
+
+ nautilus_window_ui_thaw (window);
+}
+
+static void
file_menu_new_window_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
@@ -188,7 +233,7 @@ file_menu_new_window_callback (BonoboUIComponent *component,
NautilusWindow *new_window;
current_window = NAUTILUS_WINDOW (user_data);
- new_window = nautilus_application_create_window (
+ new_window = nautilus_application_create_navigation_window (
current_window->application,
gtk_window_get_screen (GTK_WINDOW (current_window)));
nautilus_window_go_home (new_window);
@@ -203,37 +248,11 @@ file_menu_close_window_callback (BonoboUIComponent *component,
}
static void
-file_menu_close_all_windows_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_application_close_all_windows ();
-}
-
-static void
file_menu_burn_cd_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
- GError *error;
- char *argv[] = { "nautilus-cd-burner", NULL};
- char *text;
-
- error = NULL;
- if (!g_spawn_async (NULL,
- argv, NULL,
- G_SPAWN_SEARCH_PATH,
- NULL, NULL,
- NULL,
- &error)) {
- text = g_strdup_printf (_("Unable to launch the cd burner application:\n%s"), error->message);
- eel_show_error_dialog (text,
- _("Can't launch cd burner"),
- GTK_WINDOW (user_data));
- g_free (text);
- g_error_free (error);
- }
-
+ nautilus_window_launch_cd_burner (NAUTILUS_WINDOW (user_data));
}
static gboolean
@@ -254,20 +273,6 @@ have_burn_uri (void)
return res;
}
-static void
-nautilus_window_show_location_bar_temporarily (NautilusWindow *window,
- gboolean in_search_mode)
-{
- if (!nautilus_window_location_bar_showing (window)) {
- nautilus_window_show_location_bar (window, FALSE);
- window->details->temporary_navigation_bar = TRUE;
- }
- nautilus_window_set_search_mode
- (window, in_search_mode);
- nautilus_switchable_navigation_bar_activate
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar));
-}
-
#ifdef HAVE_MEDUSA
static void
file_menu_find_callback (BonoboUIComponent *component,
@@ -309,10 +314,7 @@ go_menu_location_callback (BonoboUIComponent *component,
window = NAUTILUS_WINDOW (user_data);
- if (!window->details->updating_bonobo_state) {
- nautilus_window_show_location_bar_temporarily
- (window, FALSE);
- }
+ nautilus_window_prompt_for_location (window);
}
static void
@@ -333,22 +335,6 @@ edit_menu_undo_callback (BonoboUIComponent *component,
}
static void
-go_menu_back_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_back (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-go_menu_forward_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- nautilus_window_go_forward (NAUTILUS_WINDOW (user_data));
-}
-
-static void
go_menu_up_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
@@ -392,60 +378,6 @@ go_menu_go_to_burn_cd_callback (BonoboUIComponent *component,
}
static void
-forget_history_if_yes (GtkDialog *dialog, int response, gpointer callback_data)
-{
- if (response == RESPONSE_FORGET) {
- nautilus_forget_history ();
- }
- gtk_object_destroy (GTK_OBJECT (dialog));
-}
-
-static void
-forget_history_if_confirmed (NautilusWindow *window)
-{
- GtkDialog *dialog;
- char *prompt;
-
- /* Confirm before forgetting history because it's a rare operation that
- * is hard to recover from. We don't want people doing it accidentally
- * when they intended to choose another Go menu item.
- */
- if ((rand() % 10) == 0) {
- /* This is a little joke, shows up occasionally. I only
- * implemented this feature so I could use this joke.
- */
- prompt = g_strdup (_("Are you sure you want to forget history? "
- "If you do, you will be doomed to repeat it."));
- } else {
- prompt = g_strdup (_("Are you sure you want to clear the list "
- "of locations you have visited?"));
- }
-
- dialog = eel_create_question_dialog (prompt,
- _("Clear History"),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_CLEAR, RESPONSE_FORGET,
- GTK_WINDOW (window));
-
- gtk_widget_show (GTK_WIDGET (dialog));
-
- g_free (prompt);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (forget_history_if_yes), NULL);
-
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
-}
-
-static void
-go_menu_forget_history_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- forget_history_if_confirmed (NAUTILUS_WINDOW (user_data));
-}
-
-static void
view_menu_reload_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
@@ -454,75 +386,6 @@ view_menu_reload_callback (BonoboUIComponent *component,
}
static void
-view_menu_show_hide_sidebar_state_changed_callback (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (strcmp (state, "") == 0) {
- /* State goes blank when component is removed; ignore this. */
- return;
- }
-
- if (!strcmp (state, "1")) {
- nautilus_window_show_sidebar (window);
- } else {
- nautilus_window_hide_sidebar (window);
- }
-}
-
-static void
-view_menu_show_hide_toolbar_state_changed_callback (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (strcmp (state, "") == 0) {
- /* State goes blank when component is removed; ignore this. */
- return;
- }
-
- if (!strcmp (state, "1")) {
- nautilus_window_show_toolbar (window);
- } else {
- nautilus_window_hide_toolbar (window);
- }
-}
-
-static void
-view_menu_show_hide_location_bar_state_changed_callback (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (strcmp (state, "") == 0) {
- /* State goes blank when component is removed; ignore this. */
- return;
- }
-
- if (!strcmp (state, "1")) {
- nautilus_window_show_location_bar (window, TRUE);
- } else {
- nautilus_window_hide_location_bar (window, TRUE);
- }
-}
-
-static void
view_menu_show_hide_statusbar_state_changed_callback (BonoboUIComponent *component,
const char *path,
Bonobo_UIComponent_EventType type,
@@ -555,15 +418,6 @@ nautilus_window_update_show_hide_menu_items (NautilusWindow *window)
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- COMMAND_SHOW_HIDE_SIDEBAR,
- nautilus_window_sidebar_showing (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- COMMAND_SHOW_HIDE_TOOLBAR,
- nautilus_window_toolbar_showing (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- COMMAND_SHOW_HIDE_LOCATION_BAR,
- nautilus_window_location_bar_showing (window));
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
COMMAND_SHOW_HIDE_STATUS_BAR,
nautilus_window_status_bar_showing (window));
@@ -605,22 +459,6 @@ view_menu_view_as_callback (BonoboUIComponent *component,
}
static void
-bookmarks_menu_add_bookmark_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- add_bookmark_for_current_location (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component,
- gpointer user_data,
- const char *verb)
-{
- edit_bookmarks (NAUTILUS_WINDOW (user_data));
-}
-
-static void
preferences_respond_callback (GtkDialog *dialog,
gint response_id)
{
@@ -778,440 +616,6 @@ help_menu_nautilus_manual_callback (BonoboUIComponent *component,
}
}
-static void
-remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callback_data)
-{
- const char *uri;
-
- g_assert (GTK_IS_DIALOG (dialog));
- g_assert (callback_data != NULL);
-
- if (response == GTK_RESPONSE_YES) {
- uri = callback_data;
- nautilus_bookmark_list_delete_items_with_uri (get_bookmark_list (), uri);
- }
-
- gtk_object_destroy (GTK_OBJECT (dialog));
-}
-
-static void
-show_bogus_bookmark_window (BookmarkHolder *holder)
-{
- GtkDialog *dialog;
- char *uri;
- char *uri_for_display;
- char *prompt;
-
- uri = nautilus_bookmark_get_uri (holder->bookmark);
- uri_for_display = eel_format_uri_for_display (uri);
-
- if (holder->prompt_for_removal) {
- prompt = g_strdup_printf (_("The location \"%s\" does not exist. Do you "
- "want to remove any bookmarks with this "
- "location from your list?"), uri_for_display);
- dialog = eel_show_yes_no_dialog (prompt,
- _("Bookmark for Nonexistent Location"),
- _("Remove"), GTK_STOCK_CANCEL,
- GTK_WINDOW (holder->window));
-
- eel_gtk_signal_connect_free_data
- (GTK_OBJECT (dialog),
- "response",
- G_CALLBACK (remove_bookmarks_for_uri_if_yes),
- g_strdup (uri));
-
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_NO);
- } else {
- prompt = g_strdup_printf (_("The location \"%s\" no longer exists."), uri_for_display);
- dialog = eel_show_info_dialog (prompt, _("Go to Nonexistent Location"), GTK_WINDOW (holder->window));
- }
-
- g_free (uri);
- g_free (uri_for_display);
- g_free (prompt);
-}
-
-static void
-activate_bookmark_in_menu_item (BonoboUIComponent *component, gpointer user_data, const char *path)
-{
- BookmarkHolder *holder;
- char *uri;
-
- holder = (BookmarkHolder *)user_data;
-
- if (nautilus_bookmark_uri_known_not_to_exist (holder->bookmark)) {
- show_bogus_bookmark_window (holder);
- } else {
- uri = nautilus_bookmark_get_uri (holder->bookmark);
- nautilus_window_go_to (holder->window, uri);
- g_free (uri);
- }
-}
-
-static void
-append_bookmark_to_menu (NautilusWindow *window,
- NautilusBookmark *bookmark,
- const char *parent_path,
- guint index_in_parent,
- gboolean is_bookmarks_menu)
-{
- BookmarkHolder *bookmark_holder;
- char *raw_name, *display_name, *truncated_name, *verb_name;
- char *ui_path;
- GdkPixbuf *pixbuf;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
- g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
-
- nautilus_window_ui_freeze (window);
-
- bookmark_holder = bookmark_holder_new (bookmark, window, is_bookmarks_menu);
-
- /* We double the underscores here to escape them so Bonobo will know they are
- * not keyboard accelerator character prefixes. If we ever find we need to
- * escape more than just the underscores, we'll add a menu helper function
- * instead of a string utility. (Like maybe escaping control characters.)
- */
- raw_name = nautilus_bookmark_get_name (bookmark);
- truncated_name = eel_truncate_text_for_menu_item (raw_name);
- display_name = eel_str_double_underscores (truncated_name);
- g_free (raw_name);
- g_free (truncated_name);
-
- /* Create menu item with pixbuf */
- pixbuf = nautilus_bookmark_get_pixbuf (bookmark, NAUTILUS_ICON_SIZE_FOR_MENUS, FALSE);
- nautilus_bonobo_add_numbered_menu_item
- (window->details->shell_ui,
- parent_path,
- index_in_parent,
- display_name,
- pixbuf);
- g_object_unref (pixbuf);
- g_free (display_name);
-
- /* Add the status tip */
- ui_path = nautilus_bonobo_get_numbered_menu_item_path
- (window->details->shell_ui, parent_path, index_in_parent);
- nautilus_bonobo_set_tip (window->details->shell_ui, ui_path, _("Go to the location specified by this bookmark"));
- g_free (ui_path);
-
- /* Add verb to new bookmark menu item */
- verb_name = nautilus_bonobo_get_numbered_menu_item_command
- (window->details->shell_ui, parent_path, index_in_parent);
- bonobo_ui_component_add_verb_full (window->details->shell_ui, verb_name,
- g_cclosure_new (G_CALLBACK (activate_bookmark_in_menu_item),
- bookmark_holder,
- bookmark_holder_free_cover));
- g_free (verb_name);
-
- nautilus_window_ui_thaw (window);
-}
-
-#ifdef WEB_NAVIGATION_ENABLED
-static char *
-get_static_bookmarks_file_path (void)
-{
- char *update_xml_file_path, *built_in_xml_file_path;
- char *update_uri, *built_in_uri;
- char *user_directory_path;
- gboolean update_exists, built_in_exists;
- GnomeVFSFileInfo *update_info, *built_in_info;
- char *result;
-
- /* see if there is a static bookmarks file in the updates directory and get its mod-date */
- user_directory_path = nautilus_get_user_directory ();
- update_xml_file_path = g_strdup_printf ("%s/updates/%s", user_directory_path, STATIC_BOOKMARKS_FILE_NAME);
- update_exists = g_file_test (update_xml_file_path, G_FILE_TEST_EXISTS);
- g_free (user_directory_path);
-
- /* get the mod date of the built-in static bookmarks file */
- built_in_xml_file_path = g_build_filename (NAUTILUS_DATADIR, STATIC_BOOKMARKS_FILE_NAME, NULL);
- built_in_exists = g_file_test (built_in_xml_file_path, G_FILE_TEST_EXISTS);
-
- /* if we only have one file, return its path as the one to use */
- if (built_in_exists && !update_exists) {
- g_free (update_xml_file_path);
- return built_in_xml_file_path;
- }
-
- if (!built_in_exists && update_exists) {
- g_free (built_in_xml_file_path);
- return update_xml_file_path;
- }
-
- /* if we have neither file, return NULL */
- if (!built_in_exists && !update_exists) {
- g_free (built_in_xml_file_path);
- g_free (update_xml_file_path);
- return NULL;
- }
-
- /* both files exist, so use the one with the most recent mod-date */
- update_uri = gnome_vfs_get_uri_from_local_path (update_xml_file_path);
- update_info = gnome_vfs_file_info_new ();
- gnome_vfs_get_file_info (update_uri, update_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- g_free (update_uri);
-
- built_in_uri = gnome_vfs_get_uri_from_local_path (built_in_xml_file_path);
- built_in_info = gnome_vfs_file_info_new ();
- gnome_vfs_get_file_info (built_in_uri, built_in_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- g_free (built_in_uri);
-
- /* see which is most recent */
- if (update_info->mtime <= built_in_info->mtime) {
- result = built_in_xml_file_path;
- g_free (update_xml_file_path);
- } else {
- result = update_xml_file_path;
- g_free (built_in_xml_file_path);
- }
-
- gnome_vfs_file_info_unref (update_info);
- gnome_vfs_file_info_unref (built_in_info);
-
- return result;
-}
-#endif
-
-static void
-append_separator (NautilusWindow *window, const char *path)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_add_menu_separator (window->details->shell_ui, path);
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-create_menu_item_from_node (NautilusWindow *window,
- xmlNodePtr node,
- const char *menu_path,
- int *index)
-{
- NautilusBookmark *bookmark;
- xmlChar *xml_folder_name;
- int sub_index;
- char *sub_menu_path, *escaped_name;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (node->type != XML_ELEMENT_NODE) {
- return;
- }
-
- nautilus_window_ui_freeze (window);
-
- if (strcmp (node->name, "bookmark") == 0) {
- bookmark = nautilus_bookmark_new_from_node (node);
- append_bookmark_to_menu (window, bookmark, menu_path, *index, TRUE);
- g_object_unref (bookmark);
- } else if (strcmp (node->name, "separator") == 0) {
- append_separator (window, menu_path);
- } else if (strcmp (node->name, "folder") == 0) {
- xml_folder_name = eel_xml_get_property_translated (node, "name");
- nautilus_bonobo_add_submenu (window->details->shell_ui, menu_path, xml_folder_name, NULL);
-
- /* Construct path and make sure it is escaped properly */
- escaped_name = gnome_vfs_escape_string (xml_folder_name);
- sub_menu_path = g_strdup_printf ("%s/%s", menu_path, escaped_name);
- g_free (escaped_name);
-
- for (node = eel_xml_get_children (node), sub_index = 0;
- node != NULL;
- node = node->next) {
- create_menu_item_from_node (window, node, sub_menu_path, &sub_index);
- }
- g_free (sub_menu_path);
- xmlFree (xml_folder_name);
- } else {
- g_warning ("found unknown node '%s', ignoring", node->name);
- }
-
- (*index)++;
-
- nautilus_window_ui_thaw (window);
-}
-
-#ifdef WEB_NAVIGATION_ENABLED
-static void
-append_static_bookmarks (NautilusWindow *window, const char *menu_path)
-{
- xmlDocPtr doc;
- xmlNodePtr node;
- char *file_path;
- int index;
-
- /* Walk through XML tree creating bookmarks, folders, and separators. */
- file_path = get_static_bookmarks_file_path ();
-
- if (file_path == NULL) {
- return;
- }
-
- doc = xmlParseFile (file_path);
- g_free (file_path);
-
- node = eel_xml_get_root_children (doc);
- index = 0;
-
- for (index = 0; node != NULL; node = node->next) {
- create_menu_item_from_node (window, node, menu_path, &index);
- }
-
- xmlFreeDoc(doc);
-}
-#endif
-
-static NautilusBookmarkList *bookmarks = NULL;
-
-static void
-free_bookmark_list (void)
-{
- g_object_unref (bookmarks);
-}
-
-static NautilusBookmarkList *
-get_bookmark_list (void)
-{
- if (bookmarks == NULL) {
- bookmarks = nautilus_bookmark_list_new ();
- eel_debug_call_at_shutdown (free_bookmark_list);
- }
-
- return bookmarks;
-}
-
-static GtkWindow *
-get_or_create_bookmarks_window (GObject *undo_manager_source)
-{
- if (bookmarks_window == NULL) {
- bookmarks_window = create_bookmarks_window (get_bookmark_list(), undo_manager_source);
- }
- return bookmarks_window;
-}
-
-/**
- * nautilus_bookmarks_exiting:
- *
- * Last chance to save state before app exits.
- * Called when application exits; don't call from anywhere else.
- **/
-void
-nautilus_bookmarks_exiting (void)
-{
- if (bookmarks_window != NULL) {
- nautilus_bookmarks_window_save_geometry (bookmarks_window);
- }
-}
-
-/**
- * add_bookmark_for_current_location
- *
- * Add a bookmark for the displayed location to the bookmarks menu.
- * Does nothing if there's already a bookmark for the displayed location.
- */
-static void
-add_bookmark_for_current_location (NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- nautilus_bookmark_list_append (get_bookmark_list (), window->current_location_bookmark);
-}
-
-static void
-edit_bookmarks (NautilusWindow *window)
-{
- GtkWindow *dialog;
-
- dialog = get_or_create_bookmarks_window (G_OBJECT (window));
-
- gtk_window_set_screen (
- dialog, gtk_window_get_screen (GTK_WINDOW (window)));
- gtk_window_present (dialog);
-}
-
-void
-nautilus_window_bookmarks_preference_changed_callback (gpointer user_data)
-{
- refresh_bookmarks_menu (NAUTILUS_WINDOW (user_data));
-}
-
-static void
-refresh_bookmarks_menu (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- /* Unregister any pending call to this function. */
- nautilus_window_remove_bookmarks_menu_callback (window);
-
- g_object_ref (G_OBJECT (window));
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
-
- nautilus_window_remove_bookmarks_menu_items (window);
-
-#ifdef WEB_NAVIGATION_ENABLED
- if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS)) {
- append_static_bookmarks (window, MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER);
- }
-#endif
-
- append_dynamic_bookmarks (window);
-
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
- g_object_unref (G_OBJECT (window));
-}
-
-/**
- * nautilus_window_initialize_bookmarks_menu
- *
- * Fill in bookmarks menu with stored bookmarks, and wire up signals
- * so we'll be notified when bookmark list changes.
- */
-static void
-nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- /* Construct the initial set of bookmarks. */
- refresh_bookmarks_menu (window);
-
- /* Recreate static & dynamic part of menu if preference about
- * showing static bookmarks changes.
- */
- eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
- nautilus_window_bookmarks_preference_changed_callback,
- window,
- G_OBJECT (window));
-
- /* Recreate dynamic part of menu if bookmark list changes */
- g_signal_connect_object (get_bookmark_list (), "contents_changed",
- G_CALLBACK (schedule_refresh_bookmarks_menu),
- window, G_CONNECT_SWAPPED);
-
- /* Recreate static & dynamic parts of menu if icon theme changes */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (schedule_refresh_bookmarks_menu),
- window, G_CONNECT_SWAPPED);
-}
-
-/**
- * nautilus_window_initialize_go_menu
- *
- * Wire up signals so we'll be notified when history list changes.
- */
-static void
-nautilus_window_initialize_go_menu (NautilusWindow *window)
-{
- /* Recreate bookmarks part of menu if history list changes
- * or if icon theme changes.
- */
- g_signal_connect_object (nautilus_signaller_get_current (), "history_list_changed",
- G_CALLBACK (schedule_refresh_go_menu), window, G_CONNECT_SWAPPED);
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (schedule_refresh_go_menu), window, G_CONNECT_SWAPPED);
-}
-
/**
* nautilus_window_initialize_menus
*
@@ -1225,29 +629,23 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
BONOBO_UI_VERB ("New Window", file_menu_new_window_callback),
BONOBO_UI_VERB ("Close", file_menu_close_window_callback),
BONOBO_UI_VERB ("Burn CD", file_menu_burn_cd_callback),
- BONOBO_UI_VERB ("Close All Windows", file_menu_close_all_windows_callback),
#ifdef HAVE_MEDUSA
BONOBO_UI_VERB ("Find", file_menu_find_callback),
BONOBO_UI_VERB ("Toggle Find Mode", toolbar_toggle_find_mode_callback),
#endif
BONOBO_UI_VERB ("Undo", edit_menu_undo_callback),
BONOBO_UI_VERB ("Backgrounds and Emblems", backgrounds_and_emblems_callback),
- BONOBO_UI_VERB ("Back", go_menu_back_callback),
- BONOBO_UI_VERB ("Forward", go_menu_forward_callback),
BONOBO_UI_VERB ("Up", go_menu_up_callback),
BONOBO_UI_VERB ("Home", go_menu_home_callback),
BONOBO_UI_VERB ("Start Here", go_menu_start_here_callback),
BONOBO_UI_VERB ("Go to Trash", go_menu_go_to_trash_callback),
BONOBO_UI_VERB ("Go to Burn CD", go_menu_go_to_burn_cd_callback),
BONOBO_UI_VERB ("Go to Location", go_menu_location_callback),
- BONOBO_UI_VERB ("Clear History", go_menu_forget_history_callback),
BONOBO_UI_VERB ("Reload", view_menu_reload_callback),
BONOBO_UI_VERB ("Zoom In", view_menu_zoom_in_callback),
BONOBO_UI_VERB ("Zoom Out", view_menu_zoom_out_callback),
BONOBO_UI_VERB ("Zoom Normal", view_menu_zoom_normal_callback),
BONOBO_UI_VERB ("View as", view_menu_view_as_callback),
- BONOBO_UI_VERB ("Add Bookmark", bookmarks_menu_add_bookmark_callback),
- BONOBO_UI_VERB ("Edit Bookmarks", bookmarks_menu_edit_bookmarks_callback),
#ifdef ENABLE_PROFILER
BONOBO_UI_VERB ("Start Profiling", nautilus_profiler_bonobo_ui_start_callback),
@@ -1274,21 +672,6 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
bonobo_ui_component_add_listener
(window->details->shell_ui,
- ID_SHOW_HIDE_SIDEBAR,
- view_menu_show_hide_sidebar_state_changed_callback,
- window);
- bonobo_ui_component_add_listener
- (window->details->shell_ui,
- ID_SHOW_HIDE_TOOLBAR,
- view_menu_show_hide_toolbar_state_changed_callback,
- window);
- bonobo_ui_component_add_listener
- (window->details->shell_ui,
- ID_SHOW_HIDE_LOCATION_BAR,
- view_menu_show_hide_location_bar_state_changed_callback,
- window);
- bonobo_ui_component_add_listener
- (window->details->shell_ui,
ID_SHOW_HIDE_STATUS_BAR,
view_menu_show_hide_statusbar_state_changed_callback,
window);
@@ -1309,182 +692,6 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
nautilus_bonobo_set_hidden (window->details->shell_ui, NAUTILUS_MENU_PATH_PROFILER, TRUE);
#endif
-#ifndef HAVE_MEDUSA
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE,
- TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE,
- TRUE);
- /* Also set these items insensitive so that keyboard shortcuts do not trigger
- warnings */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE,
- FALSE);
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- COMMAND_PATH_TOGGLE_FIND_MODE_WITH_STATE,
- FALSE);
-
-#endif
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_initialize_menus_part_2 (NautilusWindow *window)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_window_initialize_bookmarks_menu (window);
- nautilus_window_initialize_go_menu (window);
-
nautilus_window_ui_thaw (window);
}
-void
-nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window)
-{
- if (window->details->refresh_bookmarks_menu_idle_id != 0) {
- g_source_remove (window->details->refresh_bookmarks_menu_idle_id);
- window->details->refresh_bookmarks_menu_idle_id = 0;
- }
-}
-
-void
-nautilus_window_remove_go_menu_callback (NautilusWindow *window)
-{
- if (window->details->refresh_go_menu_idle_id != 0) {
- g_source_remove (window->details->refresh_go_menu_idle_id);
- window->details->refresh_go_menu_idle_id = 0;
- }
-}
-
-void
-nautilus_window_remove_bookmarks_menu_items (NautilusWindow *window)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui,
- MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER);
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui,
- MENU_PATH_BOOKMARKS_PLACEHOLDER);
-
- nautilus_window_ui_thaw (window);
-}
-
-void
-nautilus_window_remove_go_menu_items (NautilusWindow *window)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_remove_menu_items_and_commands
- (window->details->shell_ui,
- MENU_PATH_HISTORY_PLACEHOLDER);
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-append_dynamic_bookmarks (NautilusWindow *window)
-{
- NautilusBookmarkList *bookmarks;
- guint bookmark_count;
- guint index;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- bookmarks = get_bookmark_list ();
-
- /* append new set of bookmarks */
- bookmark_count = nautilus_bookmark_list_length (bookmarks);
- for (index = 0; index < bookmark_count; ++index) {
- append_bookmark_to_menu (window,
- nautilus_bookmark_list_item_at (bookmarks, index),
- MENU_PATH_BOOKMARKS_PLACEHOLDER,
- index,
- TRUE);
- }
-}
-
-static gboolean
-refresh_bookmarks_menu_idle_callback (gpointer data)
-{
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- refresh_bookmarks_menu (NAUTILUS_WINDOW (data));
-
- /* Don't call this again (unless rescheduled) */
- return FALSE;
-}
-
-static void
-schedule_refresh_bookmarks_menu (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->details->refresh_bookmarks_menu_idle_id == 0) {
- window->details->refresh_bookmarks_menu_idle_id
- = g_idle_add (refresh_bookmarks_menu_idle_callback,
- window);
- }
-}
-
-/**
- * refresh_go_menu:
- *
- * Refresh list of bookmarks at end of Go menu to match centralized history list.
- * @window: The NautilusWindow whose Go menu will be refreshed.
- **/
-static void
-refresh_go_menu (NautilusWindow *window)
-{
- GList *node;
- int index;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- /* Unregister any pending call to this function. */
- nautilus_window_remove_go_menu_callback (window);
-
- bonobo_ui_component_freeze (window->details->shell_ui, NULL);
-
- /* Remove old set of history items. */
- nautilus_window_remove_go_menu_items (window);
-
- /* Add in a new set of history items. */
- for (node = nautilus_get_history_list (), index = 0;
- node != NULL && index < 10;
- node = node->next, index++) {
- append_bookmark_to_menu (window,
- NAUTILUS_BOOKMARK (node->data),
- MENU_PATH_HISTORY_PLACEHOLDER,
- index,
- FALSE);
- }
-
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
-}
-
-static gboolean
-refresh_go_menu_idle_callback (gpointer data)
-{
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- refresh_go_menu (NAUTILUS_WINDOW (data));
-
- /* Don't call this again (unless rescheduled) */
- return FALSE;
-}
-
-static void
-schedule_refresh_go_menu (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->details->refresh_go_menu_idle_id == 0) {
- window->details->refresh_go_menu_idle_id
- = g_idle_add (refresh_go_menu_idle_callback,
- window);
- }
-}
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index a196519cc..6ddd7d85d 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -29,6 +29,9 @@
#define NAUTILUS_WINDOW_PRIVATE_H
#include "nautilus-window.h"
+#include "nautilus-spatial-window.h"
+#include "nautilus-navigation-window.h"
+
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-ui-container.h>
#include <bonobo/bonobo-ui-toolbar-button-item.h>
@@ -57,14 +60,8 @@ struct NautilusWindowDetails
gboolean ui_pending_initialize_menus_part_2;
/* Menus. */
- guint refresh_bookmarks_menu_idle_id;
guint refresh_go_menu_idle_id;
- /* Toolbar. */
- GtkTooltips *tooltips;
- GtkWidget *back_button_item;
- GtkWidget *forward_button_item;
-
/* Current location. */
char *location;
GList *selection;
@@ -84,14 +81,13 @@ struct NautilusWindowDetails
GList *short_list_viewers;
NautilusViewIdentifier *extra_viewer;
- /* Throbber. */
- gboolean throbber_active;
- gboolean throbber_activating;
- Bonobo_PropertyBag throbber_property_bag;
-
/* Deferred location change. */
char *location_to_change_to_at_idle;
guint location_change_at_idle_id;
+};
+
+struct _NautilusNavigationWindowDetails {
+ GtkWidget *content_paned;
/* Location bar */
gboolean temporary_navigation_bar;
@@ -99,6 +95,20 @@ struct NautilusWindowDetails
/* Side Pane */
int side_pane_width;
GtkWidget *current_side_panel;
+
+ /* Menus */
+ guint refresh_bookmarks_menu_idle_id;
+
+ /* Toolbar */
+ GtkTooltips *tooltips;
+
+ GtkWidget *back_button_item;
+ GtkWidget *forward_button_item;
+
+ /* Throbber */
+ gboolean throbber_active;
+ gboolean throbber_activating;
+ Bonobo_PropertyBag throbber_property_bag;
};
#define NAUTILUS_MENU_PATH_BACK_ITEM "/menu/Go/Back"
@@ -129,29 +139,35 @@ struct NautilusWindowDetails
#define NAUTILUS_WINDOW_MIN_WIDTH 200
#define NAUTILUS_WINDOW_MIN_HEIGHT 200
-#define NAUTILUS_WINDOW_DEFAULT_WIDTH 800
-#define NAUTILUS_WINDOW_DEFAULT_HEIGHT 550
+#define NAUTILUS_WINDOW_DEFAULT_WIDTH 500
+#define NAUTILUS_WINDOW_DEFAULT_HEIGHT 300
+
+typedef void (*NautilusBookmarkFailedCallback) (NautilusWindow *window,
+ NautilusBookmark *bookmark);
void nautilus_window_set_status (NautilusWindow *window,
const char *status);
void nautilus_window_load_view_as_menus (NautilusWindow *window);
-void nautilus_window_synch_view_as_menus (NautilusWindow *window);
void nautilus_window_initialize_menus_part_1 (NautilusWindow *window);
void nautilus_window_initialize_menus_part_2 (NautilusWindow *window);
-void nautilus_window_initialize_toolbars (NautilusWindow *window);
-void nautilus_window_activate_throbber (NautilusWindow *window);
+void nautilus_menus_append_bookmark_to_menu (NautilusWindow *window,
+ BonoboUIComponent *uic,
+ NautilusBookmark *bookmark,
+ const char *parent_path,
+ guint index_in_parent,
+ GCallback refresh_callback,
+ NautilusBookmarkFailedCallback failed_callback);
+
void nautilus_window_handle_ui_event_callback (BonoboUIComponent *ui,
const char *id,
Bonobo_UIComponent_EventType type,
const char *state,
NautilusWindow *window);
-void nautilus_window_go_back (NautilusWindow *window);
-void nautilus_window_go_forward (NautilusWindow *window);
+#if NEW_UI_COMPLETE
void nautilus_window_go_up (NautilusWindow *window);
+#endif
void nautilus_window_update_find_menu_item (NautilusWindow *window);
-void nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window);
void nautilus_window_remove_go_menu_callback (NautilusWindow *window);
-void nautilus_window_remove_bookmarks_menu_items (NautilusWindow *window);
void nautilus_window_remove_go_menu_items (NautilusWindow *window);
void nautilus_window_update_show_hide_menu_items (NautilusWindow *window);
void nautilus_window_zoom_in (NautilusWindow *window);
@@ -162,10 +178,6 @@ void nautilus_window_zoom_to_fit (Nautil
void nautilus_window_show_view_as_dialog (NautilusWindow *window);
void nautilus_window_set_content_view_widget (NautilusWindow *window,
NautilusViewFrame *content_view);
-void nautilus_window_add_sidebar_panel (NautilusWindow *window,
- NautilusViewFrame *sidebar_panel);
-void nautilus_window_remove_sidebar_panel (NautilusWindow *window,
- NautilusViewFrame *sidebar_panel);
Bonobo_UIContainer nautilus_window_get_ui_container (NautilusWindow *window);
void nautilus_window_set_viewed_file (NautilusWindow *window,
NautilusFile *file);
@@ -176,4 +188,21 @@ GList * nautilus_get_history_list (void);
void nautilus_window_bookmarks_preference_changed_callback (gpointer user_data);
void nautilus_window_update_icon (NautilusWindow *window);
+
+/* Navigation window menus */
+void nautilus_navigation_window_initialize_menus_part_1 (NautilusNavigationWindow *window);
+void nautilus_navigation_window_initialize_menus_part_2 (NautilusNavigationWindow *window);
+void nautilus_navigation_window_remove_bookmarks_menu_callback (NautilusNavigationWindow *window);
+
+void nautilus_navigation_window_remove_bookmarks_menu_items (NautilusNavigationWindow *window);
+void nautilus_navigation_window_update_show_hide_menu_items (NautilusNavigationWindow *window);
+
+/* Navigation window toolbar */
+void nautilus_navigation_window_activate_throbber (NautilusNavigationWindow *window);
+void nautilus_navigation_window_initialize_toolbars (NautilusNavigationWindow *window);
+void nautilus_navigation_window_set_throbber_active (NautilusNavigationWindow *window,
+ gboolean active);
+void nautilus_navigation_window_go_back (NautilusNavigationWindow *window);
+void nautilus_navigation_window_go_forward (NautilusNavigationWindow *window);
+
#endif /* NAUTILUS_WINDOW_PRIVATE_H */
diff --git a/src/nautilus-window-toolbars.c b/src/nautilus-window-toolbars.c
index f0e0ada1a..dae2b77ac 100644
--- a/src/nautilus-window-toolbars.c
+++ b/src/nautilus-window-toolbars.c
@@ -66,39 +66,40 @@ enum {
static void
activate_back_or_forward_menu_item (GtkMenuItem *menu_item,
- NautilusWindow *window,
+ NautilusNavigationWindow *window,
gboolean back)
{
int index;
g_assert (GTK_IS_MENU_ITEM (menu_item));
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "user_data"));
- nautilus_window_back_or_forward (window, back, index);
+
+ nautilus_navigation_window_back_or_forward (window, back, index);
}
static void
-activate_back_menu_item_callback (GtkMenuItem *menu_item, NautilusWindow *window)
+activate_back_menu_item_callback (GtkMenuItem *menu_item, NautilusNavigationWindow *window)
{
activate_back_or_forward_menu_item (menu_item, window, TRUE);
}
static void
-activate_forward_menu_item_callback (GtkMenuItem *menu_item, NautilusWindow *window)
+activate_forward_menu_item_callback (GtkMenuItem *menu_item, NautilusNavigationWindow *window)
{
activate_back_or_forward_menu_item (menu_item, window, FALSE);
}
static GtkMenu *
-create_back_or_forward_menu (NautilusWindow *window, gboolean back)
+create_back_or_forward_menu (NautilusNavigationWindow *window, gboolean back)
{
GtkMenu *menu;
GtkWidget *menu_item;
GList *list_link;
int index;
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
menu = GTK_MENU (gtk_menu_new ());
@@ -124,13 +125,13 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back)
}
static GtkWidget *
-get_back_button (NautilusWindow *window)
+get_back_button (NautilusNavigationWindow *window)
{
return window->details->back_button_item;
}
static GtkWidget *
-get_forward_button (NautilusWindow *window)
+get_forward_button (NautilusNavigationWindow *window)
{
return window->details->forward_button_item;
}
@@ -163,20 +164,20 @@ back_or_forward_button_pressed_callback (GtkWidget *widget,
GdkEventButton *event,
gpointer *user_data)
{
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
gboolean back;
g_return_val_if_fail (GTK_IS_BUTTON (widget), FALSE);
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (user_data), FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (user_data), FALSE);
- window = NAUTILUS_WINDOW (user_data);
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
back = widget == get_back_button (window);
g_assert (back || widget == get_forward_button (window));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- gnome_popup_menu_do_popup_modal (GTK_WIDGET (create_back_or_forward_menu (NAUTILUS_WINDOW (user_data), back)),
+ gnome_popup_menu_do_popup_modal (GTK_WIDGET (create_back_or_forward_menu (NAUTILUS_NAVIGATION_WINDOW (user_data), back)),
menu_position_under_widget, widget, event, widget, widget);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
@@ -200,7 +201,7 @@ back_or_forward_key_pressed_callback (GtkWidget *widget,
}
static GtkWidget *
-create_back_or_forward_toolbar_item (NautilusWindow *window,
+create_back_or_forward_toolbar_item (NautilusNavigationWindow *window,
const char *tooltip,
const char *control_path)
{
@@ -226,7 +227,7 @@ create_back_or_forward_toolbar_item (NautilusWindow *window,
G_CALLBACK (back_or_forward_button_pressed_callback),
window, 0);
- bonobo_ui_component_widget_set (window->details->shell_ui,
+ bonobo_ui_component_widget_set (NAUTILUS_WINDOW (window)->details->shell_ui,
control_path,
button,
NULL);
@@ -235,7 +236,7 @@ create_back_or_forward_toolbar_item (NautilusWindow *window,
}
static void
-throbber_set_throbbing (NautilusWindow *window,
+throbber_set_throbbing (NautilusNavigationWindow *window,
gboolean throbbing)
{
CORBA_boolean b;
@@ -256,7 +257,7 @@ throbber_created_callback (Bonobo_Unknown throbber,
gpointer user_data)
{
char *exception_as_text;
- NautilusWindow *window;
+ NautilusNavigationWindow *window;
if (BONOBO_EX (ev)) {
exception_as_text = bonobo_exception_get_text (ev);
@@ -265,13 +266,13 @@ throbber_created_callback (Bonobo_Unknown throbber,
return;
}
- g_return_if_fail (NAUTILUS_IS_WINDOW (user_data));
+ g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (user_data));
- window = NAUTILUS_WINDOW (user_data);
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
window->details->throbber_activating = FALSE;
- bonobo_ui_component_object_set (window->details->shell_ui,
+ bonobo_ui_component_object_set (NAUTILUS_WINDOW (window)->details->shell_ui,
"/Toolbar/ThrobberWrapper",
throbber, ev);
CORBA_exception_free (ev);
@@ -292,7 +293,8 @@ throbber_created_callback (Bonobo_Unknown throbber,
}
void
-nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
+nautilus_navigation_window_set_throbber_active (NautilusNavigationWindow *window,
+ gboolean allow)
{
if (( window->details->throbber_active && allow) ||
(!window->details->throbber_active && !allow)) {
@@ -304,23 +306,17 @@ nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
else
access ("nautilus-throbber: stop", 0);
- window->details->throbber_active = allow;
-
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ nautilus_bonobo_set_sensitive (NAUTILUS_WINDOW (window)->details->shell_ui,
NAUTILUS_COMMAND_STOP, allow);
+ window->details->throbber_active = allow;
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
throbber_set_throbbing (window, allow);
}
-
- nautilus_window_ui_thaw (window);
}
-
void
-nautilus_window_activate_throbber (NautilusWindow *window)
+nautilus_navigation_window_activate_throbber (NautilusNavigationWindow *window)
{
CORBA_Environment ev;
char *exception_as_text;
@@ -355,13 +351,11 @@ nautilus_window_activate_throbber (NautilusWindow *window)
}
void
-nautilus_window_initialize_toolbars (NautilusWindow *window)
+nautilus_navigation_window_initialize_toolbars (NautilusNavigationWindow *window)
{
- nautilus_window_ui_freeze (window);
+ nautilus_window_ui_freeze (NAUTILUS_WINDOW (window));
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- nautilus_window_activate_throbber (window);
- }
+ nautilus_navigation_window_activate_throbber (window);
window->details->back_button_item = create_back_or_forward_toolbar_item
(window, _("Go back a few pages"),
@@ -370,5 +364,5 @@ nautilus_window_initialize_toolbars (NautilusWindow *window)
(window, _("Go forward a number of pages"),
"/Toolbar/ForwardMenu");
- nautilus_window_ui_thaw (window);
+ nautilus_window_ui_thaw (NAUTILUS_WINDOW (window));
}
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 300f43ecb..d8f1c9bc2 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -47,6 +47,7 @@
#include <eel/eel-generous-bin.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
+#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkx.h>
@@ -114,12 +115,10 @@ enum {
ARG_APP
};
-static GList *history_list;
-static int side_pane_width_auto_value = SIDE_PANE_MINIMUM_WIDTH;
-
-static void add_sidebar_panels (NautilusWindow *window);
static void cancel_view_as_callback (NautilusWindow *window);
+static GList *history_list;
+
GNOME_CLASS_BOILERPLATE (NautilusWindow, nautilus_window,
BonoboWindow, BONOBO_TYPE_WINDOW)
@@ -170,13 +169,6 @@ nautilus_window_instance_init (NautilusWindow *window)
window->details->ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
bonobo_object_ref (window->details->ui_container);
- window->details->tooltips = gtk_tooltips_new ();
- g_object_ref (G_OBJECT (window->details->tooltips));
- gtk_object_sink (GTK_OBJECT (window->details->tooltips));
-
- /* Set last geometry to NULL */
- window->last_geometry = NULL;
-
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
@@ -229,7 +221,11 @@ ui_idle_handler (gpointer data)
old_updating_bonobo_state = window->details->updating_bonobo_state;
if (window->details->ui_pending_initialize_menus_part_2) {
- nautilus_window_initialize_menus_part_2 (window);
+#if !NEW_UI_COMPLETE
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ nautilus_navigation_window_initialize_menus_part_2 (NAUTILUS_NAVIGATION_WINDOW (window));
+ }
+#endif
window->details->ui_pending_initialize_menus_part_2 = FALSE;
}
@@ -361,63 +357,158 @@ nautilus_window_go_to (NautilusWindow *window, const char *uri)
nautilus_window_open_location (window, uri);
}
-char *
-nautilus_window_get_location (NautilusWindow *window)
+void
+nautilus_window_go_up (NautilusWindow *window)
{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
+ GnomeVFSURI *current_uri;
+ GnomeVFSURI *parent_uri;
+ GList *selection;
+ char *parent_uri_string;
+
+ if (window->details->location == NULL) {
+ return;
+ }
+
+ current_uri = gnome_vfs_uri_new (window->details->location);
+ parent_uri = gnome_vfs_uri_get_parent (current_uri);
+ gnome_vfs_uri_unref (current_uri);
- return g_strdup (window->details->location);
+ if (parent_uri == NULL) {
+ g_warning ("Can't go Up from here. The UI should have prevented us from getting this far.");
+ return;
+ }
+
+ parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
+ gnome_vfs_uri_unref (parent_uri);
+
+ selection = g_list_prepend (NULL, g_strdup (window->details->location));
+
+ nautilus_window_open_location_with_selection (window, parent_uri_string, selection);
+
+ g_free (parent_uri_string);
+ eel_g_list_free_deep (selection);
}
-static void
-go_to_callback (GtkWidget *widget,
- const char *uri,
- NautilusWindow *window)
+void
+nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+
+ nautilus_window_ui_freeze (window);
- nautilus_window_go_to (window, uri);
+ nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ NAUTILUS_COMMAND_UP, allow);
+
+ nautilus_window_ui_thaw (window);
}
-static void
-navigation_bar_location_changed_callback (GtkWidget *widget,
- const char *uri,
- NautilusWindow *window)
+void
+nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- if (window->details->temporary_navigation_bar) {
- if (nautilus_window_location_bar_showing (window)) {
- nautilus_window_hide_location_bar (window, FALSE);
- }
- window->details->temporary_navigation_bar = FALSE;
- }
+ nautilus_window_ui_freeze (window);
+
+ nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ NAUTILUS_COMMAND_STOP, allow);
- nautilus_window_go_to (window, uri);
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ set_throbber_active, (window, allow));
+
+ nautilus_window_ui_thaw (window);
}
-static void
-navigation_bar_mode_changed_callback (GtkWidget *widget,
- NautilusSwitchableNavigationBarMode mode,
- NautilusWindow *window)
+void
+nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
{
- window->details->updating_bonobo_state = TRUE;
+ g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+
+ nautilus_window_ui_freeze (window);
- g_assert (mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION
- || mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
+ nautilus_bonobo_set_sensitive (window->details->shell_ui,
+ NAUTILUS_COMMAND_RELOAD, allow);
+
+ nautilus_window_ui_thaw (window);
+}
+
+void
+nautilus_window_allow_burn_cd (NautilusWindow *window, gboolean allow)
+{
+ g_return_if_fail (NAUTILUS_IS_WINDOW (window));
nautilus_window_ui_freeze (window);
- nautilus_bonobo_set_toggle_state (window->details->shell_ui,
- NAUTILUS_COMMAND_TOGGLE_FIND_MODE,
- mode == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
-
- window->details->updating_bonobo_state = FALSE;
+ nautilus_bonobo_set_hidden (window->details->shell_ui,
+ NAUTILUS_COMMAND_BURN_CD, !allow);
nautilus_window_ui_thaw (window);
}
void
+nautilus_window_go_home (NautilusWindow *window)
+{
+ char *home_uri;
+
+#if !NEW_UI_COMPLETE
+ /* Hrm, this probably belongs in any location switch, not
+ * just when going home. */
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ nautilus_navigation_window_set_search_mode (NAUTILUS_NAVIGATION_WINDOW (window), FALSE);
+ }
+#endif
+
+#ifdef WEB_NAVIGATION_ENABLED
+ home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
+#else
+ home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+#endif
+
+ g_assert (home_uri != NULL);
+ nautilus_window_go_to (window, home_uri);
+ g_free (home_uri);
+}
+
+void
+nautilus_window_launch_cd_burner (NautilusWindow *window)
+{
+ GError *error;
+ char *argv[] = { "nautilus-cd-burner", NULL};
+ char *text;
+
+ error = NULL;
+ if (!g_spawn_async (NULL,
+ argv, NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL, NULL,
+ NULL,
+ &error)) {
+ text = g_strdup_printf (_("Unable to launch the cd burner application:\n%s"), error->message);
+ eel_show_error_dialog (text,
+ _("Can't launch cd burner"),
+ GTK_WINDOW (window));
+ g_free (text);
+ g_error_free (error);
+ }
+}
+
+void
+nautilus_window_prompt_for_location (NautilusWindow *window)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ prompt_for_location, (window));
+}
+
+char *
+nautilus_window_get_location (NautilusWindow *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
+
+ return g_strdup (window->details->location);
+}
+
+void
nautilus_window_zoom_in (NautilusWindow *window)
{
if (window->content_view != NULL) {
@@ -507,332 +598,40 @@ set_initial_window_geometry (NautilusWindow *window)
max_height_for_screen));
}
-/* Add a dummy menu with a "View as ..." item when we first create the
- * view_as_option_menu -- without this the menu draws empty and shrunk,
- * once we populate it it grows and forces the toolbar and all the other
- * views to re-layout.
- */
-static void
-set_dummy_initial_view_as_menu (NautilusWindow *window)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
-
- new_menu = gtk_menu_new ();
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
-}
-
-static void
-side_pane_close_requested_callback (GtkWidget *widget,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- nautilus_window_hide_sidebar (window);
-}
-
-static void
-side_pane_size_allocate_callback (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer user_data)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (user_data);
-
- if (allocation->width != window->details->side_pane_width) {
- window->details->side_pane_width = allocation->width;
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH)) {
- eel_preferences_set_integer
- (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
- allocation->width);
- }
- }
-}
-
-static void
-setup_side_pane_width (NautilusWindow *window)
-{
- static gboolean setup_auto_value= TRUE;
-
- g_return_if_fail (window->sidebar != NULL);
-
- if (setup_auto_value) {
- setup_auto_value = FALSE;
- eel_preferences_add_auto_integer
- (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
- &side_pane_width_auto_value);
- }
-
- window->details->side_pane_width = side_pane_width_auto_value;
-
- /* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
- /* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
-
- gtk_paned_set_position (GTK_PANED (window->content_hbox),
- side_pane_width_auto_value);
-}
-
-static void
-side_panel_set_open (GtkWidget *view,
- gboolean open)
-{
- CORBA_Environment ev;
- Bonobo_PropertyBag property_bag;
- Bonobo_Control control;
-
- if (!view || !NAUTILUS_IS_VIEW_FRAME (view)) {
- return;
- }
-
- control = nautilus_view_frame_get_control (NAUTILUS_VIEW_FRAME (view));
-
- if (control != CORBA_OBJECT_NIL) {
- CORBA_exception_init (&ev);
- property_bag = Bonobo_Control_getProperties (control, &ev);
- if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
- /* For some reason this was implemented as 'close'
- * before, but open seems more natural */
- bonobo_property_bag_client_set_value_gboolean
- (property_bag, "close", !open, &ev);
- bonobo_object_release_unref (property_bag, NULL);
- }
- }
-}
-
-static void
-set_current_side_panel (NautilusWindow *window,
- GtkWidget *panel)
-{
- if (window->details->current_side_panel) {
- side_panel_set_open (window->details->current_side_panel,
- FALSE);
- eel_remove_weak_pointer (&window->details->current_side_panel);
- }
-
- side_panel_set_open (panel, TRUE);
- window->details->current_side_panel = panel;
- eel_add_weak_pointer (&window->details->current_side_panel);
-}
-
static void
-side_pane_switch_page_callback (NautilusSidePane *side_pane,
- GtkWidget *panel,
- NautilusWindow *window)
+real_merge_menus (NautilusWindow *window)
{
- const char *view_iid;
-
- set_current_side_panel (window, panel);
-
- if (NAUTILUS_IS_VIEW_FRAME (panel)) {
- view_iid = nautilus_view_frame_get_view_iid (NAUTILUS_VIEW_FRAME (panel));
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) {
- eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW,
- view_iid);
- }
-
- } else {
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) {
- eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW, "");
- }
- }
-}
-
-static void
-nautilus_window_set_up_sidebar (NautilusWindow *window)
-{
- window->sidebar = nautilus_side_pane_new ();
-
- gtk_paned_pack1 (GTK_PANED (window->content_hbox),
- GTK_WIDGET (window->sidebar),
- FALSE, TRUE);
-
- setup_side_pane_width (window);
- g_signal_connect (window->sidebar,
- "size_allocate",
- G_CALLBACK (side_pane_size_allocate_callback),
- window);
-
- window->information_panel = nautilus_information_panel_new ();
-
- if (window->details->location != NULL &&
- window->details->title != NULL) {
- nautilus_information_panel_set_uri (window->information_panel,
- window->details->location,
- window->details->title);
- }
-
- g_signal_connect_object (window->information_panel, "location_changed",
- G_CALLBACK (go_to_callback), window, 0);
-
- /* Set up the sidebar panels. */
- nautilus_side_pane_add_panel (NAUTILUS_SIDE_PANE (window->sidebar),
- GTK_WIDGET (window->information_panel),
- _("Information"));
-
- add_sidebar_panels (window);
-
- g_signal_connect (window->sidebar,
- "close_requested",
- G_CALLBACK (side_pane_close_requested_callback),
- window);
-
- g_signal_connect (window->sidebar,
- "switch_page",
- G_CALLBACK (side_pane_switch_page_callback),
- window);
-
- gtk_widget_show (GTK_WIDGET (window->information_panel));
-
- gtk_widget_show (GTK_WIDGET (window->sidebar));
-}
-
-static void
-nautilus_window_tear_down_sidebar (NautilusWindow *window)
-{
- g_signal_handlers_disconnect_by_func (window->sidebar,
- side_pane_switch_page_callback,
- window);
-
- nautilus_window_set_sidebar_panels (window, NULL);
- gtk_widget_destroy (GTK_WIDGET (window->sidebar));
- window->sidebar = NULL;
- window->information_panel = NULL;
-}
-
-static void
-nautilus_window_constructed (NautilusWindow *window)
-{
- GtkWidget *location_bar_box;
- GtkWidget *view_as_menu_vbox;
- BonoboControl *location_bar_wrapper;
-
- nautilus_window_ui_freeze (window);
-
/* Load the user interface from the XML file. */
bonobo_ui_util_set_ui (window->details->shell_ui,
DATADIR,
"nautilus-shell-ui.xml",
"nautilus", NULL);
-
- /* set up location bar */
- location_bar_box = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (location_bar_box), GNOME_PAD_SMALL);
-
- window->navigation_bar = nautilus_switchable_navigation_bar_new (window);
- gtk_widget_show (GTK_WIDGET (window->navigation_bar));
-
- g_signal_connect_object (window->navigation_bar, "location_changed",
- G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
- g_signal_connect_object (window->navigation_bar, "mode_changed",
- G_CALLBACK (navigation_bar_mode_changed_callback), window, 0);
-
- gtk_box_pack_start (GTK_BOX (location_bar_box), window->navigation_bar,
- TRUE, TRUE, GNOME_PAD_SMALL);
- /* Option menu for content view types; it's empty here, filled in when a uri is set.
- * Pack it into vbox so it doesn't grow vertically when location bar does.
- */
- view_as_menu_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_widget_show (view_as_menu_vbox);
- gtk_box_pack_end (GTK_BOX (location_bar_box), view_as_menu_vbox, FALSE, FALSE, 0);
-
- window->view_as_option_menu = gtk_option_menu_new ();
- gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), window->view_as_option_menu, TRUE, FALSE, 0);
- gtk_widget_show (window->view_as_option_menu);
- /* Make sure there is something in the option menu to prevent it from
- * growing later.
- */
- set_dummy_initial_view_as_menu (window);
-
- /* Allocate the zoom control and place on the right next to the menu.
- * It gets shown later, if the view-frame contains something zoomable.
- */
- window->zoom_control = nautilus_zoom_control_new ();
- g_signal_connect_object (window->zoom_control, "zoom_in",
- G_CALLBACK (nautilus_window_zoom_in),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_out",
- G_CALLBACK (nautilus_window_zoom_out),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_level",
- G_CALLBACK (nautilus_window_zoom_to_level),
- window, G_CONNECT_SWAPPED);
- g_signal_connect_object (window->zoom_control, "zoom_to_fit",
- G_CALLBACK (nautilus_window_zoom_to_fit),
- window, G_CONNECT_SWAPPED);
- gtk_box_pack_end (GTK_BOX (location_bar_box), window->zoom_control, FALSE, FALSE, 0);
-
- gtk_widget_show (location_bar_box);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- window->content_hbox = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
- } else {
- set_initial_window_geometry (window);
-
- window->content_hbox = nautilus_horizontal_splitter_new ();
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_set_up_sidebar (window);
- }
- }
-
- gtk_widget_show (window->content_hbox);
- bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- LOCATION_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- TOOLBAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- STATUS_BAR_PATH, TRUE);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- MENU_BAR_PATH, TRUE);
- }
-
- /* Wrap the location bar in a control and set it up. */
- location_bar_wrapper = bonobo_control_new (location_bar_box);
- bonobo_ui_component_object_set (window->details->shell_ui,
- "/Location Bar/Wrapper",
- BONOBO_OBJREF (location_bar_wrapper),
- NULL);
bonobo_ui_component_thaw (window->details->shell_ui, NULL);
- bonobo_object_unref (location_bar_wrapper);
/* initalize the menus and toolbars */
nautilus_window_initialize_menus_part_1 (window);
- nautilus_window_initialize_toolbars (window);
/* We'll do the second part later (bookmarks and go menus) */
window->details->ui_pending_initialize_menus_part_2 = TRUE;
+}
+
+static void
+nautilus_window_constructed (NautilusWindow *window)
+{
+ nautilus_window_ui_freeze (window);
+
+ set_initial_window_geometry (window);
- /* 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);
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ merge_menus, (window));
+ nautilus_window_allow_stop (window, FALSE);
nautilus_window_allow_burn_cd (window, FALSE);
-
+
/* Set up undo manager */
nautilus_undo_manager_attach (window->application->undo_manager, G_OBJECT (window));
@@ -906,21 +705,6 @@ free_stored_viewers (NautilusWindow *window)
}
static void
-nautilus_window_unrealize (GtkWidget *widget)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
-
- if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
- window->details->throbber_property_bag = CORBA_OBJECT_NIL;
- }
-
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
-}
-
-static void
nautilus_window_destroy (GtkObject *object)
{
NautilusWindow *window;
@@ -929,25 +713,11 @@ nautilus_window_destroy (GtkObject *object)
nautilus_window_manage_views_destroy (window);
- window->sidebar = NULL;
- eel_g_object_list_free (window->sidebar_panels);
- window->sidebar_panels = NULL;
-
- window->view_as_option_menu = NULL;
- window->navigation_bar = NULL;
- window->content_hbox = NULL;
- window->zoom_control = NULL;
-
if (window->content_view) {
gtk_object_destroy (GTK_OBJECT (window->content_view));
window->content_view = NULL;
}
- if (window->details->tooltips) {
- g_object_unref (G_OBJECT (window->details->tooltips));
- window->details->tooltips = NULL;
- }
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -961,7 +731,6 @@ nautilus_window_finalize (GObject *object)
nautilus_window_manage_views_finalize (window);
nautilus_window_set_viewed_file (window, NULL);
- nautilus_window_remove_bookmarks_menu_callback (window);
nautilus_window_remove_go_menu_callback (window);
if (window->details->ui_idle_id != 0) {
@@ -988,9 +757,6 @@ nautilus_window_finalize (GObject *object)
eel_g_list_free_deep (window->details->selection);
eel_g_list_free_deep (window->details->pending_selection);
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
if (window->current_location_bookmark != NULL) {
g_object_unref (window->current_location_bookmark);
}
@@ -1008,32 +774,10 @@ nautilus_window_finalize (GObject *object)
g_free (window->details);
- g_free (window->last_geometry);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
-nautilus_window_save_geometry (NautilusWindow *window)
-{
- char *geometry_string;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (GTK_WIDGET(window)->window &&
- !(gdk_window_get_state (GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
- geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
-
- nautilus_file_set_metadata (window->details->viewed_file,
- NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY,
- NULL,
- geometry_string);
-
- g_free (geometry_string);
- }
-}
-
-void
nautilus_window_close (NautilusWindow *window)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
@@ -1140,60 +884,6 @@ nautilus_window_handle_ui_event_callback (BonoboUIComponent *ui,
}
static void
-view_as_menu_switch_views_callback (GtkWidget *widget, gpointer data)
-{
- NautilusWindow *window;
- int viewer_index;
-
- g_assert (GTK_IS_MENU_ITEM (widget));
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- window = NAUTILUS_WINDOW (data);
-
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "extra viewer")) == TRUE) {
- activate_extra_viewer (window);
- } else {
- viewer_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "viewer index"));
- activate_nth_short_list_item (window, viewer_index);
- }
-}
-
-static GtkWidget *
-create_view_as_menu_item (NautilusWindow *window,
- NautilusViewIdentifier *identifier,
- guint index)
-{
- GtkWidget *menu_item;
- char *menu_label;
-
- menu_label = g_strdup (_(identifier->view_as_label));
- menu_item = gtk_menu_item_new_with_mnemonic (menu_label);
- g_free (menu_label);
-
- g_signal_connect_object (menu_item, "activate",
- G_CALLBACK (view_as_menu_switch_views_callback),
- window, 0);
-
- g_object_set_data (G_OBJECT (menu_item), "viewer index", GINT_TO_POINTER (index));
-
- gtk_widget_show (menu_item);
-
- return menu_item;
-}
-
-static GtkWidget *
-new_gtk_separator (void)
-{
- GtkWidget *result;
-
- result = gtk_menu_item_new ();
- gtk_widget_show (result);
- gtk_widget_set_sensitive (result, FALSE);
-
- return result;
-}
-
-static void
add_view_as_bonobo_menu_item (NautilusWindow *window,
const char *placeholder_path,
NautilusViewIdentifier *identifier,
@@ -1220,13 +910,6 @@ add_view_as_bonobo_menu_item (NautilusWindow *window,
g_free (tip);
}
-static void
-remove_first_child (GtkContainer *container)
-{
- gtk_container_remove (container,
- eel_gtk_container_get_first_child (container));
-}
-
/* Make a special first item in the "View as" option menu that represents
* the current content view. This should only be called if the current
* content view isn't already in the "View as" option menu.
@@ -1235,8 +918,6 @@ static void
update_extra_viewer_in_view_as_menus (NautilusWindow *window,
const NautilusViewIdentifier *id)
{
- GtkWidget *menu;
- GtkWidget *new_menu_item;
gboolean had_extra_viewer;
had_extra_viewer = window->details->extra_viewer != NULL;
@@ -1254,37 +935,6 @@ update_extra_viewer_in_view_as_menus (NautilusWindow *window,
nautilus_view_identifier_free (window->details->extra_viewer);
window->details->extra_viewer = nautilus_view_identifier_copy (id);
- /* Update the View As option menu */
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove menu before changing contents so it is resized properly
- * when reattached later in this function.
- */
- g_object_ref (menu);
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (window->view_as_option_menu));
-
- /* Remove old menu item, and either remove or add separator. */
- if (had_extra_viewer) {
- remove_first_child (GTK_CONTAINER (menu));
- if (id == NULL) {
- remove_first_child (GTK_CONTAINER (menu));
- }
- } else {
- if (id != NULL) {
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_gtk_separator ());
- }
- }
-
- /* Add new menu item. */
- if (id != NULL) {
- new_menu_item = create_view_as_menu_item (window, window->details->extra_viewer, 0);
- g_object_set_data (G_OBJECT (new_menu_item), "extra viewer", GINT_TO_POINTER (TRUE));
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), new_menu_item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu), menu);
- g_object_unref (menu);
-
/* Also update the Bonobo View menu item */
if (id == NULL) {
nautilus_bonobo_remove_menu_items_and_commands
@@ -1322,7 +972,7 @@ replace_extra_viewer_in_view_as_menus (NautilusWindow *window)
*
* @window: The NautilusWindow whose "View as" option menu should be synched.
*/
-void
+static void
nautilus_window_synch_view_as_menus (NautilusWindow *window)
{
int index;
@@ -1354,9 +1004,6 @@ nautilus_window_synch_view_as_menus (NautilusWindow *window)
g_assert (numbered_menu_item_container_path != NULL);
- /* Make option menu show the right item */
- gtk_option_menu_set_history (GTK_OPTION_MENU (window->view_as_option_menu), index);
-
/* Make View menu in menu bar mark the right item */
verb_name = nautilus_bonobo_get_numbered_menu_item_command
(window->details->shell_ui,
@@ -1410,29 +1057,6 @@ nautilus_window_show_view_as_dialog (NautilusWindow *window)
}
static void
-view_as_menu_choose_view_callback (GtkWidget *widget, gpointer data)
-{
- NautilusWindow *window;
-
- g_assert (GTK_IS_MENU_ITEM (widget));
- g_assert (NAUTILUS_IS_WINDOW (data));
-
- window = NAUTILUS_WINDOW (data);
-
- /* Set the option menu back to its previous setting (Don't
- * leave it on this dialog-producing "View as..."
- * setting). If the menu choice causes a content view change,
- * this will be updated again later, in
- * nautilus_window_load_view_as_menus. Do this right away so
- * the user never sees the option menu set to "View as
- * Other...".
- */
- nautilus_window_synch_view_as_menus (window);
-
- nautilus_window_show_view_as_dialog (window);
-}
-
-static void
refresh_stored_viewers (NautilusWindow *window)
{
GList *components, *node, *viewers;
@@ -1451,19 +1075,11 @@ refresh_stored_viewers (NautilusWindow *window)
}
static void
-load_view_as_menus_callback (NautilusFile *file,
- gpointer callback_data)
-{
- GtkWidget *new_menu;
- GtkWidget *menu_item;
- GList *node;
- NautilusWindow *window;
+real_load_view_as_menu (NautilusWindow *window)
+{
+ GList *node;
int index;
- window = NAUTILUS_WINDOW (callback_data);
-
- g_assert (GTK_IS_OPTION_MENU (window->view_as_option_menu));
-
/* Clear out the menu items created last time. For the option menu, we need do
* nothing since we replace the entire menu. For the View menu, we have
* to do this explicitly.
@@ -1475,18 +1091,11 @@ load_view_as_menus_callback (NautilusFile *file,
refresh_stored_viewers (window);
- new_menu = gtk_menu_new ();
-
+
/* Add a menu item for each view in the preferred list for this location. */
for (node = window->details->short_list_viewers, index = 0;
node != NULL;
node = node->next, ++index) {
- /* Menu item in option menu. This doesn't use Bonobo, for various
- * historical and technical reasons.
- */
- menu_item = create_view_as_menu_item (window, node->data, index);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
/* Menu item in View menu. */
add_view_as_bonobo_menu_item (window,
NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER,
@@ -1494,31 +1103,26 @@ load_view_as_menus_callback (NautilusFile *file,
index);
}
- /* Add/Show separator before "View as..." if there are any other viewers in menu. */
- if (window->details->short_list_viewers != NULL) {
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), new_gtk_separator ());
- }
nautilus_bonobo_set_hidden (window->details->shell_ui,
NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR,
window->details->short_list_viewers == NULL);
- /* Add "View as..." extra bonus choice. */
- menu_item = gtk_menu_item_new_with_label (_("View as..."));
- g_signal_connect_object (menu_item, "activate",
- G_CALLBACK (view_as_menu_choose_view_callback), window, 0);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
-
- /* We create and attach a new menu here because adding/removing
- * items from existing menu screws up the size of the option menu.
- */
- gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu),
- new_menu);
-
nautilus_window_synch_view_as_menus (window);
}
static void
+load_view_as_menus_callback (NautilusFile *file,
+ gpointer callback_data)
+{
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (callback_data);
+
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ load_view_as_menu, (window));
+}
+
+static void
cancel_view_as_callback (NautilusWindow *window)
{
nautilus_file_cancel_call_when_ready (window->details->viewed_file,
@@ -1543,205 +1147,276 @@ nautilus_window_load_view_as_menus (NautilusWindow *window)
}
void
-nautilus_window_add_sidebar_panel (NautilusWindow *window,
- NautilusViewFrame *sidebar_panel)
+nautilus_window_display_error (NautilusWindow *window, const char *error_msg)
{
- char *label;
- const char *view_iid;
- char *default_iid;
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, error_msg, NULL);
+ gtk_widget_show (dialog);
+}
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
- g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar));
- g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL);
+static char *
+compute_default_title (const char *text_uri)
+{
+ NautilusFile *file;
+ char *title;
- label = nautilus_view_frame_get_label (sidebar_panel);
-
- nautilus_side_pane_add_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel),
- label);
- g_free (label);
+ if (text_uri == NULL) {
+ title = g_strdup ("");
+ } else {
+ file = nautilus_file_get (text_uri);
+ title = nautilus_file_get_display_name (file);
+ nautilus_file_unref (file);
+ }
+
+ return title;
+}
- g_object_ref (sidebar_panel);
- window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel);
+static char *
+real_get_title (NautilusWindow *window)
+{
+ char *title;
- view_iid = nautilus_view_frame_get_view_iid (sidebar_panel);
- default_iid = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW);
+ title = NULL;
+
+ if (window->new_content_view != NULL) {
+ title = nautilus_view_frame_get_title (window->new_content_view);
+ } else if (window->content_view != NULL) {
+ title = nautilus_view_frame_get_title (window->content_view);
+ }
+
+ if (title == NULL) {
+ title = compute_default_title (window->details->location);
+ }
- if (view_iid && default_iid && !strcmp (view_iid, default_iid)) {
- nautilus_side_pane_show_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- }
+ return title;
+}
- g_free (default_iid);
+static char *
+nautilus_window_get_title (NautilusWindow *window)
+{
+ return EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, window,
+ get_title, (window));
}
-void
-nautilus_window_remove_sidebar_panel (NautilusWindow *window, NautilusViewFrame *sidebar_panel)
+static void
+real_set_title (NautilusWindow *window,
+ const char *title)
{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel));
+ g_free (window->details->title);
+ window->details->title = g_strdup (title);
- if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL) {
- return;
- }
+ if (window->details->title [0] != '\0' && window->current_location_bookmark &&
+ nautilus_bookmark_set_name (window->current_location_bookmark, window->details->title)) {
+ /* Name of item in history list changed, tell listeners. */
+ nautilus_send_history_list_changed ();
+ }
- nautilus_side_pane_remove_panel (window->sidebar,
- GTK_WIDGET (sidebar_panel));
- window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel);
- g_object_unref (sidebar_panel);
+ /* warn all views and sidebar panels of the potential title change */
+ if (window->content_view != NULL) {
+ nautilus_view_frame_title_changed (window->content_view, title);
+ }
}
-void
-nautilus_window_go_back (NautilusWindow *window)
+static void
+nautilus_window_set_title (NautilusWindow *window,
+ const char *title)
{
- nautilus_window_back_or_forward (window, TRUE, 0);
+ if (window->details->title != NULL
+ && strcmp (title, window->details->title) == 0) {
+ return;
+ }
+
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ set_title, (window, title));
}
void
-nautilus_window_go_forward (NautilusWindow *window)
+nautilus_window_update_title (NautilusWindow *window)
{
- nautilus_window_back_or_forward (window, FALSE, 0);
+ char *title;
+
+ title = nautilus_window_get_title (window);
+ nautilus_window_set_title (window, title);
+
+ g_free (title);
}
-void
-nautilus_window_go_up (NautilusWindow *window)
+static void
+real_set_content_view_widget (NautilusWindow *window,
+ NautilusViewFrame *new_view)
{
- GnomeVFSURI *current_uri;
- GnomeVFSURI *parent_uri;
- GList *selection;
- char *parent_uri_string;
+ g_return_if_fail (NAUTILUS_IS_WINDOW (window));
+ g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view));
- if (window->details->location == NULL) {
+ if (new_view == window->content_view) {
return;
}
- current_uri = gnome_vfs_uri_new (window->details->location);
- parent_uri = gnome_vfs_uri_get_parent (current_uri);
- gnome_vfs_uri_unref (current_uri);
+ if (window->content_view != NULL) {
+ gtk_object_destroy (GTK_OBJECT (window->content_view));
+ window->content_view = NULL;
+ }
- if (parent_uri == NULL) {
- g_warning ("Can't go Up from here. The UI should have prevented us from getting this far.");
- return;
+ if (new_view != NULL) {
+ gtk_widget_show (GTK_WIDGET (new_view));
+
+ /* When creating the desktop window the UI needs to
+ * be in sync. Otherwise I get failed assertions in
+ * bonobo while trying to reference something called
+ * `/commands/Unmount Volume Conditional'
+ */
+ nautilus_window_ui_update (window);
}
-
- parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (parent_uri);
- selection = g_list_prepend (NULL, g_strdup (window->details->location));
-
- nautilus_window_open_location_with_selection (window, parent_uri_string, selection);
-
- g_free (parent_uri_string);
- eel_g_list_free_deep (selection);
+ window->content_view = new_view;
+
+ /* Update displayed view in menu. Only do this if we're not switching
+ * locations though, because if we are switching locations we'll
+ * install a whole new set of views in the menu later (the current
+ * views in the menu are for the old location).
+ */
+ if (window->details->pending_location == NULL) {
+ nautilus_window_synch_view_as_menus (window);
+ }
}
void
-nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode)
+nautilus_window_set_content_view_widget (NautilusWindow *window,
+ NautilusViewFrame *frame)
{
- nautilus_switchable_navigation_bar_set_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar),
- search_mode
- ? NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH
- : NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION);
-
+ g_assert (NAUTILUS_IS_WINDOW (window));
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ set_content_view_widget, (window, frame));
}
-gboolean
-nautilus_window_get_search_mode (NautilusWindow *window)
+static void
+show_dock_item (NautilusWindow *window, const char *dock_item_path)
{
- return nautilus_switchable_navigation_bar_get_mode
- (NAUTILUS_SWITCHABLE_NAVIGATION_BAR (window->navigation_bar))
- == NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH;
-}
+ if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
+ return;
+ }
-void
-nautilus_window_go_home (NautilusWindow *window)
-{
- char *home_uri;
+ nautilus_window_ui_freeze (window);
- nautilus_window_set_search_mode (window, FALSE);
+ nautilus_bonobo_set_hidden (window->details->shell_ui,
+ dock_item_path,
+ FALSE);
+ nautilus_window_update_show_hide_menu_items (window);
-#ifdef WEB_NAVIGATION_ENABLED
- home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
-#else
- home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-#endif
-
- g_assert (home_uri != NULL);
- nautilus_window_go_to (window, home_uri);
- g_free (home_uri);
+ nautilus_window_ui_thaw (window);
}
-void
-nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
+static void
+hide_dock_item (NautilusWindow *window, const char *dock_item_path)
{
nautilus_window_ui_freeze (window);
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_BACK, allow);
- /* Have to handle non-standard Back button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->back_button_item), allow);
+ nautilus_bonobo_set_hidden (window->details->shell_ui,
+ dock_item_path,
+ TRUE);
+ nautilus_window_update_show_hide_menu_items (window);
nautilus_window_ui_thaw (window);
}
-void
-nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
+static gboolean
+dock_item_showing (NautilusWindow *window, const char *dock_item_path)
{
- nautilus_window_ui_freeze (window);
+ return !nautilus_bonobo_get_hidden (window->details->shell_ui,
+ dock_item_path);
+}
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_FORWARD, allow);
- /* Have to handle non-standard Forward button explicitly (it's
- * non-standard to support right-click menu).
- */
- gtk_widget_set_sensitive
- (GTK_WIDGET (window->details->forward_button_item), allow);
+void
+nautilus_window_hide_status_bar (NautilusWindow *window)
+{
+ hide_dock_item (window, STATUS_BAR_PATH);
- nautilus_window_ui_thaw (window);
+ nautilus_window_update_show_hide_menu_items (window);
+ if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
+ eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, FALSE);
+ }
}
-void
-nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
+void
+nautilus_window_show_status_bar (NautilusWindow *window)
{
- nautilus_window_ui_freeze (window);
-
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_UP, allow);
+ show_dock_item (window, STATUS_BAR_PATH);
- nautilus_window_ui_thaw (window);
+ nautilus_window_update_show_hide_menu_items (window);
+ if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
+ eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE);
+ }
}
-void
-nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
+gboolean
+nautilus_window_status_bar_showing (NautilusWindow *window)
{
- nautilus_window_ui_freeze (window);
+ return dock_item_showing (window, STATUS_BAR_PATH);
+}
- /* Because of verbs, we set the sensitivity of the menu to
- * control both the menu and toolbar.
- */
- nautilus_bonobo_set_sensitive (window->details->shell_ui,
- NAUTILUS_COMMAND_RELOAD, allow);
+/**
+ * nautilus_window_show:
+ * @widget: GtkWidget
+ *
+ * Call parent and then show/hide window items
+ * base on user prefs.
+ */
+static void
+nautilus_window_show (GtkWidget *widget)
+{
+ NautilusWindow *window;
- nautilus_window_ui_thaw (window);
+ window = NAUTILUS_WINDOW (widget);
+
+ GTK_WIDGET_CLASS (parent_class)->show (widget);
+
+ if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
+ nautilus_window_show_status_bar (window);
+ } else {
+ nautilus_window_hide_status_bar (window);
+ }
+
+ nautilus_window_ui_update (window);
+}
+
+Bonobo_UIContainer
+nautilus_window_get_ui_container (NautilusWindow *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), CORBA_OBJECT_NIL);
+
+ return BONOBO_OBJREF (window->details->ui_container);
}
void
-nautilus_window_allow_burn_cd (NautilusWindow *window, gboolean allow)
+nautilus_window_set_viewed_file (NautilusWindow *window,
+ NautilusFile *file)
{
- nautilus_window_ui_freeze (window);
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- NAUTILUS_COMMAND_BURN_CD, !allow);
- nautilus_window_ui_thaw (window);
+ NautilusFileAttributes attributes;
+
+ if (window->details->viewed_file == file) {
+ return;
+ }
+
+ nautilus_file_ref (file);
+
+ cancel_view_as_callback (window);
+ cancel_chose_component_callback (window);
+
+ if (window->details->viewed_file != NULL) {
+ nautilus_file_monitor_remove (window->details->viewed_file,
+ window);
+ }
+
+ if (file != NULL) {
+ attributes = NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
+ nautilus_file_monitor_add (file, window, attributes);
+ }
+
+ nautilus_file_unref (window->details->viewed_file);
+ window->details->viewed_file = file;
}
void
@@ -1787,7 +1462,7 @@ static void
add_to_history_list (NautilusBookmark *bookmark)
{
/* Note that the history is shared amongst all windows so
- * this is not a NautilusWindow function. Perhaps it belongs
+ * this is not a NautilusNavigationWindow function. Perhaps it belongs
* in its own file.
*/
int i;
@@ -1837,39 +1512,24 @@ nautilus_remove_from_history_list_no_notify (const char *uri)
static void
real_add_current_location_to_history_list (NautilusWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- add_to_history_list (window->current_location_bookmark);
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ add_to_history_list (window->current_location_bookmark);
}
void
nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_WINDOW (window));
EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
-}
-
-void
-nautilus_window_clear_forward_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->forward_list);
- window->forward_list = NULL;
-}
-
-void
-nautilus_window_clear_back_list (NautilusWindow *window)
-{
- eel_g_object_list_free (window->back_list);
- window->back_list = NULL;
+ add_current_location_to_history_list, (window));
}
void
nautilus_forget_history (void)
{
GList *window_node;
- NautilusWindow *window;
/* Clear out each window's back & forward lists. Also, remove
* each window's current location bookmark from history list
@@ -1879,15 +1539,19 @@ nautilus_forget_history (void)
window_node != NULL;
window_node = window_node->next) {
- window = NAUTILUS_WINDOW (window_node->data);
-
- nautilus_window_clear_back_list (window);
- nautilus_window_clear_forward_list (window);
-
- nautilus_window_allow_back (window, FALSE);
- nautilus_window_allow_forward (window, FALSE);
-
- history_list = g_list_remove (history_list, window->current_location_bookmark);
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window_node->data)) {
+ NautilusNavigationWindow *window;
+
+ window = NAUTILUS_NAVIGATION_WINDOW (window_node->data);
+
+ nautilus_navigation_window_clear_back_list (window);
+ nautilus_navigation_window_clear_forward_list (window);
+
+ nautilus_navigation_window_allow_back (window, FALSE);
+ nautilus_navigation_window_allow_forward (window, FALSE);
+ }
+
+ history_list = g_list_remove (history_list, NAUTILUS_WINDOW (window_node->data)->current_location_bookmark);
}
/* Clobber history list. */
@@ -1897,9 +1561,10 @@ nautilus_forget_history (void)
for (window_node = nautilus_application_get_window_list ();
window_node != NULL;
window_node = window_node->next) {
-
+ NautilusWindow *window;
+
window = NAUTILUS_WINDOW (window_node->data);
- nautilus_window_add_current_location_to_history_list (window);
+ nautilus_window_add_current_location_to_history_list (NAUTILUS_WINDOW (window));
}
}
@@ -1909,357 +1574,6 @@ nautilus_get_history_list (void)
return history_list;
}
-void
-nautilus_window_display_error (NautilusWindow *window, const char *error_msg)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, error_msg, NULL);
- gtk_widget_show (dialog);
-}
-
-void
-nautilus_window_set_content_view_widget (NautilusWindow *window,
- NautilusViewFrame *new_view)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view));
-
- if (new_view == window->content_view) {
- return;
- }
-
- if (window->content_view != NULL) {
- gtk_object_destroy (GTK_OBJECT (window->content_view));
- window->content_view = NULL;
- }
-
- if (new_view != NULL) {
- gtk_widget_show (GTK_WIDGET (new_view));
-
- /* When creating the desktop window the UI needs to
- * be in sync. Otherwise I get failed assertions in
- * bonobo while trying to reference something called
- * `/commands/Unmount Volume Conditional'
- */
- nautilus_window_ui_update (window);
-
- /* FIXME bugzilla.gnome.org 41243:
- * We should use inheritance instead of these special cases
- * for the desktop window.
- */
- if (!GTK_IS_PANED (window->content_hbox)) {
- gtk_container_add (GTK_CONTAINER (window->content_hbox),
- GTK_WIDGET (new_view));
- } else {
- nautilus_horizontal_splitter_pack2 (
- NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
- GTK_WIDGET (new_view));
- }
- }
-
- /* Display or hide zoom control */
- if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) {
- gtk_widget_show (window->zoom_control);
- } else {
- gtk_widget_hide (window->zoom_control);
- }
-
- window->content_view = new_view;
-}
-
-/**
- * add_sidebar_panels:
- * @window: A NautilusWindow
- *
- * Adds all sidebars available
- *
- */
-static void
-add_sidebar_panels (NautilusWindow *window)
-{
- GList *identifier_list;
-
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- if (window->sidebar == NULL) {
- return;
- }
-
- identifier_list = nautilus_sidebar_get_all_sidebar_panel_view_identifiers ();
- nautilus_window_set_sidebar_panels (window, identifier_list);
- nautilus_view_identifier_list_free (identifier_list);
-
- set_current_side_panel
- (window,
- nautilus_side_pane_get_current_panel (window->sidebar));
-}
-
-static void
-show_dock_item (NautilusWindow *window, const char *dock_item_path)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
- return;
- }
-
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- dock_item_path,
- FALSE);
- nautilus_window_update_show_hide_menu_items (window);
-
- nautilus_window_ui_thaw (window);
-}
-
-static void
-hide_dock_item (NautilusWindow *window, const char *dock_item_path)
-{
- nautilus_window_ui_freeze (window);
-
- nautilus_bonobo_set_hidden (window->details->shell_ui,
- dock_item_path,
- TRUE);
- nautilus_window_update_show_hide_menu_items (window);
-
- nautilus_window_ui_thaw (window);
-}
-
-static gboolean
-dock_item_showing (NautilusWindow *window, const char *dock_item_path)
-{
- return !nautilus_bonobo_get_hidden (window->details->shell_ui,
- dock_item_path);
-}
-
-void
-nautilus_window_hide_location_bar (NautilusWindow *window, gboolean save_preference)
-{
- window->details->temporary_navigation_bar = FALSE;
- hide_dock_item (window, LOCATION_BAR_PATH);
- if (save_preference &&
- eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_location_bar (NautilusWindow *window, gboolean save_preference)
-{
- show_dock_item (window, LOCATION_BAR_PATH);
- if (save_preference &&
- eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_location_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, LOCATION_BAR_PATH);
-}
-
-void
-nautilus_window_hide_toolbar (NautilusWindow *window)
-{
- hide_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_toolbar (NautilusWindow *window)
-{
- nautilus_window_activate_throbber (window);
- show_dock_item (window, TOOLBAR_PATH);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_toolbar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, TOOLBAR_PATH);
-}
-
-void
-nautilus_window_hide_sidebar (NautilusWindow *window)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar == NULL) {
- return;
- }
-
- nautilus_window_tear_down_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_sidebar (NautilusWindow *window)
-{
- if (NAUTILUS_IS_DESKTOP_WINDOW (window) || window->sidebar != NULL) {
- return;
- }
-
- nautilus_window_set_up_sidebar (window);
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_sidebar_showing (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), FALSE);
-
- return (window->sidebar != NULL) && GTK_IS_PANED (window->content_hbox)
- && nautilus_horizontal_splitter_is_hidden (NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox));
-}
-
-void
-nautilus_window_hide_status_bar (NautilusWindow *window)
-{
- hide_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, FALSE);
- }
-}
-
-void
-nautilus_window_show_status_bar (NautilusWindow *window)
-{
- show_dock_item (window, STATUS_BAR_PATH);
-
- nautilus_window_update_show_hide_menu_items (window);
- if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE);
- }
-}
-
-gboolean
-nautilus_window_status_bar_showing (NautilusWindow *window)
-{
- return dock_item_showing (window, STATUS_BAR_PATH);
-}
-
-/**
- * nautilus_window_get_base_page_index:
- * @window: Window to get index from
- *
- * Returns the index of the base page in the history list.
- * Base page is not the currently displayed page, but the page
- * that acts as the base from which the back and forward commands
- * navigate from.
- */
-gint
-nautilus_window_get_base_page_index (NautilusWindow *window)
-{
- gint forward_count;
-
- forward_count = g_list_length (window->forward_list);
-
- /* If forward is empty, the base it at the top of the list */
- if (forward_count == 0) {
- return 0;
- }
-
- /* The forward count indicate the relative postion of the base page
- * in the history list
- */
- return forward_count;
-}
-
-/**
- * nautilus_window_show:
- * @widget: GtkWidget
- *
- * Call parent and then show/hide window items
- * base on user prefs.
- */
-static void
-nautilus_window_show (GtkWidget *widget)
-{
- NautilusWindow *window;
-
- window = NAUTILUS_WINDOW (widget);
-
- GTK_WIDGET_CLASS (parent_class)->show (widget);
-
- /* Initially show or hide views based on preferences; once the window is displayed
- * these can be controlled on a per-window basis from View menu items.
- */
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) {
- nautilus_window_show_toolbar (window);
- } else {
- nautilus_window_hide_toolbar (window);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
- nautilus_window_show_location_bar (window, FALSE);
- } else {
- nautilus_window_hide_location_bar (window, FALSE);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
- nautilus_window_show_status_bar (window);
- } else {
- nautilus_window_hide_status_bar (window);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
- nautilus_window_show_sidebar (window);
- } else {
- nautilus_window_hide_sidebar (window);
- }
-
- nautilus_window_ui_update (window);
-}
-
-Bonobo_UIContainer
-nautilus_window_get_ui_container (NautilusWindow *window)
-{
- g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), CORBA_OBJECT_NIL);
-
- return BONOBO_OBJREF (window->details->ui_container);
-}
-
-void
-nautilus_window_set_viewed_file (NautilusWindow *window,
- NautilusFile *file)
-{
- NautilusFileAttributes attributes;
-
- if (window->details->viewed_file == file) {
- return;
- }
-
- nautilus_file_ref (file);
-
- cancel_view_as_callback (window);
- cancel_chose_component_callback (window);
-
- if (window->details->viewed_file != NULL) {
- nautilus_file_monitor_remove (window->details->viewed_file,
- window);
- }
-
- if (file != NULL) {
- attributes = NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
- nautilus_file_monitor_add (file, window, attributes);
- }
-
- nautilus_file_unref (window->details->viewed_file);
- window->details->viewed_file = file;
-}
-
static void
nautilus_window_class_init (NautilusWindowClass *class)
{
@@ -2268,9 +1582,13 @@ nautilus_window_class_init (NautilusWindowClass *class)
G_OBJECT_CLASS (class)->set_property = nautilus_window_set_property;
GTK_OBJECT_CLASS (class)->destroy = nautilus_window_destroy;
GTK_WIDGET_CLASS (class)->show = nautilus_window_show;
- GTK_WIDGET_CLASS (class)->unrealize = nautilus_window_unrealize;
GTK_WIDGET_CLASS (class)->size_request = nautilus_window_size_request;
class->add_current_location_to_history_list = real_add_current_location_to_history_list;
+ class->get_title = real_get_title;
+ class->set_title = real_set_title;
+ class->merge_menus = real_merge_menus;
+ class->set_content_view_widget = real_set_content_view_widget;
+ class->load_view_as_menu = real_load_view_as_menu;
g_object_class_install_property (G_OBJECT_CLASS (class),
ARG_APP_ID,
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index a14157094..57b56180c 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -60,7 +60,18 @@ typedef struct {
* NautilusWindow's idea of the "current location" to the history
* list, or nothing at all.
*/
- void (* add_current_location_to_history_list) (NautilusWindow *window);
+ void (* add_current_location_to_history_list) (NautilusWindow *window);
+
+ char * (* get_title) (NautilusWindow *window);
+ void (* set_title) (NautilusWindow *window, const char *title);
+
+ void (* merge_menus) (NautilusWindow *window);
+ void (* load_view_as_menu) (NautilusWindow *window);
+ void (* set_content_view_widget) (NautilusWindow *window,
+ NautilusViewFrame *frame);
+ void (* set_throbber_active) (NautilusWindow *window,
+ gboolean active);
+ void (* prompt_for_location) (NautilusWindow *window);
} NautilusWindowClass;
typedef enum {
@@ -76,42 +87,24 @@ struct NautilusWindow {
NautilusWindowDetails *details;
- /** UI stuff **/
- NautilusSidePane *sidebar;
- NautilusInformationPanel *information_panel;
- GtkWidget *content_hbox;
- GtkWidget *view_as_option_menu;
- GtkWidget *navigation_bar;
-
- char *last_geometry;
-
- guint save_geometry_timeout_id;
-
/** CORBA-related elements **/
NautilusApplication *application;
/** State information **/
- /* Information about current location/selection */
-
- /* Back/Forward chain, and history list.
- * The data in these lists are NautilusBookmark pointers.
- */
- GList *back_list, *forward_list;
-
- NautilusBookmark *current_location_bookmark;
+ /* Information about current location/selection */
+ NautilusBookmark *current_location_bookmark;
NautilusBookmark *last_location_bookmark;
-
+
/* Current views stuff */
NautilusViewFrame *content_view;
- GList *sidebar_panels;
-
- /* Widgets to keep track of (for state changes, etc) */
- GtkWidget *zoom_control;
/* Pending changes */
NautilusViewFrame *new_content_view;
+ /* All views */
+ GList *views;
+
/* Window showed state (for saved_window_positions) */
NautilusWindowShowState show_state;
};
@@ -123,44 +116,25 @@ void nautilus_window_close (NautilusWindow *window
char * nautilus_window_get_location (NautilusWindow *window);
void nautilus_window_go_to (NautilusWindow *window,
const char *location);
-gboolean nautilus_window_get_search_mode (NautilusWindow *window);
-void nautilus_window_set_search_mode (NautilusWindow *window,
- gboolean search_mode);
void nautilus_window_go_home (NautilusWindow *window);
+void nautilus_window_go_up (NautilusWindow *window);
+void nautilus_window_prompt_for_location (NautilusWindow *window);
+void nautilus_window_launch_cd_burner (NautilusWindow *window);
+void nautilus_window_update_title (NautilusWindow *window);
void nautilus_window_display_error (NautilusWindow *window,
const char *error_msg);
-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_reload (NautilusWindow *window);
+
+void nautilus_window_hide_status_bar (NautilusWindow *window);
+void nautilus_window_show_status_bar (NautilusWindow *window);
+gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
void nautilus_window_allow_reload (NautilusWindow *window,
gboolean allow);
-void nautilus_window_allow_stop (NautilusWindow *window,
+void nautilus_window_allow_up (NautilusWindow *window,
+ gboolean allow);
+void nautilus_window_allow_stop (NautilusWindow *window,
gboolean allow);
void nautilus_window_allow_burn_cd (NautilusWindow *window,
gboolean allow);
-void nautilus_window_clear_back_list (NautilusWindow *window);
-void nautilus_window_clear_forward_list (NautilusWindow *window);
-void nautilus_forget_history (void);
-void nautilus_bookmarks_exiting (void);
-void nautilus_window_reload (NautilusWindow *window);
-gint nautilus_window_get_base_page_index (NautilusWindow *window);
-void nautilus_window_hide_location_bar (NautilusWindow *window,
- gboolean save_preference);
-void nautilus_window_show_location_bar (NautilusWindow *window,
- gboolean save_preference);
-gboolean nautilus_window_location_bar_showing (NautilusWindow *window);
-void nautilus_window_hide_toolbar (NautilusWindow *window);
-void nautilus_window_show_toolbar (NautilusWindow *window);
-gboolean nautilus_window_toolbar_showing (NautilusWindow *window);
-void nautilus_window_hide_sidebar (NautilusWindow *window);
-void nautilus_window_show_sidebar (NautilusWindow *window);
-gboolean nautilus_window_sidebar_showing (NautilusWindow *window);
-void nautilus_window_hide_status_bar (NautilusWindow *window);
-void nautilus_window_show_status_bar (NautilusWindow *window);
-gboolean nautilus_window_status_bar_showing (NautilusWindow *window);
-void nautilus_window_save_geometry (NautilusWindow *window);
#endif