diff options
author | Alexander Larsson <alexl@redhat.com> | 2009-12-07 15:12:04 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2009-12-10 18:06:35 +0100 |
commit | e7f2144e38c02f6aeba7b563e8bc1fb195616477 (patch) | |
tree | d72adff7e56c55c7cd690ce540104510ecb7c019 | |
parent | d3ee81d3021204786c3c51bf9f651fffbd10ff0b (diff) | |
download | nautilus-e7f2144e38c02f6aeba7b563e8bc1fb195616477.tar.gz |
Move slots from NautilusWindow to NautilusWindowPane
A window does not hold lists of slots anymore, but lists of panes, which
in turn hold lists of slots, making a slot effectively a layer between
a window and a slot. Much of the remaining part of the patch is
simply replacing "window->details->active_slot" with
"window->details->active_pane->active_slot" and similar changes. Commits
to move corresponding parts of the logic out of the window into the pane
are to follow.
-rw-r--r-- | src/nautilus-application.c | 35 | ||||
-rw-r--r-- | src/nautilus-location-bar.c | 2 | ||||
-rw-r--r-- | src/nautilus-location-dialog.c | 2 | ||||
-rw-r--r-- | src/nautilus-navigation-action.c | 2 | ||||
-rw-r--r-- | src/nautilus-navigation-window-menus.c | 6 | ||||
-rw-r--r-- | src/nautilus-navigation-window-slot.c | 2 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 10 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 19 | ||||
-rw-r--r-- | src/nautilus-window-bookmarks.c | 2 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 27 | ||||
-rw-r--r-- | src/nautilus-window-pane.c | 4 | ||||
-rw-r--r-- | src/nautilus-window-pane.h | 6 | ||||
-rw-r--r-- | src/nautilus-window-private.h | 7 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 19 | ||||
-rw-r--r-- | src/nautilus-window-toolbars.c | 2 | ||||
-rw-r--r-- | src/nautilus-window.c | 224 |
16 files changed, 209 insertions, 160 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 50388c7d8..8b57a83e2 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -1105,7 +1105,7 @@ nautilus_application_get_existing_spatial_window (GFile *location) l != NULL; l = l->next) { GFile *window_location; - slot = NAUTILUS_WINDOW (l->data)->details->active_slot; + slot = NAUTILUS_WINDOW (l->data)->details->active_pane->active_slot; window_location = slot->location; if (window_location != NULL) { if (g_file_equal (location, window_location)) { @@ -1124,7 +1124,7 @@ find_parent_spatial_window (NautilusSpatialWindow *window) NautilusWindowSlot *slot; GFile *location; - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; location = slot->location; if (location == NULL) { @@ -1303,7 +1303,7 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication GFile *existing_location; existing_window = NAUTILUS_WINDOW (l->data); - slot = existing_window->details->active_slot; + slot = existing_window->details->active_pane->active_slot; existing_location = slot->pending_location; if (existing_location == NULL) { @@ -1640,17 +1640,22 @@ mount_removed_callback (GVolumeMonitor *monitor, /* Construct a list of windows to be closed. Do not add the non-closable windows to the list. */ for (node = window_list; node != NULL; node = node->next) { window = NAUTILUS_WINDOW (node->data); - if (window != NULL && window_can_be_closed (window)) { + if (window != NULL && window_can_be_closed (window)) { GList *l; - GFile *location; - - for (l = window->details->slots; l != NULL; l = l->next) { - slot = l->data; - location = slot->location; - if (g_file_has_prefix (location, root)) { - close_list = g_list_prepend (close_list, slot); - } - } + GList *lp; + GFile *location; + + for (lp = window->details->panes; lp != NULL; lp = lp->next) { + NautilusWindowPane *pane; + pane = (NautilusWindowPane*) lp->data; + for (l = pane->slots; l != NULL; l = l->next) { + slot = l->data; + location = slot->location; + if (g_file_has_prefix (location, root)) { + close_list = g_list_prepend (close_list, slot); + } + } /* for all slots */ + } /* for all panes */ } } @@ -1994,7 +1999,7 @@ nautilus_application_load_session (NautilusApplication *application) NautilusWindowSlot *slot; if (i == 0) { - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; } else { slot = nautilus_window_open_slot (window, NAUTILUS_WINDOW_OPEN_SLOT_APPEND); } @@ -2015,7 +2020,7 @@ nautilus_application_load_session (NautilusApplication *application) if (i == 0) { /* This may be an old session file */ location = g_file_new_for_uri (location_uri); - nautilus_window_slot_open_location (window->details->active_slot, location, FALSE); + nautilus_window_slot_open_location (window->details->active_pane->active_slot, location, FALSE); g_object_unref (location); } } else if (!strcmp (type, "spatial")) { diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c index 743c6311d..c6b44ed11 100644 --- a/src/nautilus-location-bar.c +++ b/src/nautilus-location-bar.c @@ -266,7 +266,7 @@ label_button_pressed_callback (GtkWidget *widget, } window = nautilus_location_bar_get_window (widget->parent); - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; view = slot->content_view; label = GTK_BIN (widget)->child; /* only pop-up if the URI in the entry matches the displayed location */ diff --git a/src/nautilus-location-dialog.c b/src/nautilus-location-dialog.c index 8d2ceb48e..2a1f50219 100644 --- a/src/nautilus-location-dialog.c +++ b/src/nautilus-location-dialog.c @@ -232,7 +232,7 @@ nautilus_location_dialog_new (NautilusWindow *window) NAUTILUS_LOCATION_DIALOG (dialog)->details->window = window; } - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; location = slot->location; if (location != NULL) { diff --git a/src/nautilus-navigation-action.c b/src/nautilus-navigation-action.c index 9ac11531b..f735a7041 100644 --- a/src/nautilus-navigation-action.c +++ b/src/nautilus-navigation-action.c @@ -139,7 +139,7 @@ fill_menu (NautilusNavigationWindow *window, g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_slot); + slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_pane->active_slot); list = back ? slot->back_list : slot->forward_list; index = 0; diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c index 1fc2cab22..d00b87af8 100644 --- a/src/nautilus-navigation-window-menus.c +++ b/src/nautilus-navigation-window-menus.c @@ -682,7 +682,7 @@ action_new_tab_callback (GtkAction *action, } window = NAUTILUS_WINDOW (user_data); - current_slot = window->details->active_slot; + current_slot = window->details->active_pane->active_slot; location = nautilus_window_slot_get_location (current_slot); window = NAUTILUS_WINDOW (current_slot->pane->window); @@ -718,7 +718,7 @@ action_folder_window_callback (GtkAction *action, GFile *current_location; current_window = NAUTILUS_WINDOW (user_data); - slot = current_window->details->active_slot; + slot = current_window->details->active_pane->active_slot; current_location = nautilus_window_slot_get_location (slot); nautilus_application_present_spatial_window ( current_window->application, @@ -781,7 +781,7 @@ action_show_hide_search_callback (GtkAction *action, NautilusWindowSlot *slot; GFile *location = NULL; - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; /* Use the location bar as the return location */ if (slot->query_editor == NULL){ diff --git a/src/nautilus-navigation-window-slot.c b/src/nautilus-navigation-window-slot.c index f18960778..d80418e37 100644 --- a/src/nautilus-navigation-window-slot.c +++ b/src/nautilus-navigation-window-slot.c @@ -138,7 +138,7 @@ nautilus_navigation_window_slot_update_query_editor (NautilusWindowSlot *slot) } else { query_editor = nautilus_query_editor_new_with_bar (FALSE, nautilus_search_directory_is_indexed (search_directory), - slot->pane->window->details->active_slot == slot, + slot->pane->window->details->active_pane->active_slot == slot, NAUTILUS_SEARCH_BAR (navigation_window->search_bar), slot); } diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 3bbbf6cd7..c7207c5db 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -606,7 +606,7 @@ path_bar_location_changed_callback (GtkWidget *widget, g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_slot); + slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_pane->active_slot); /* check whether we already visited the target location */ i = bookmark_list_get_uri_index (slot->back_list, location); @@ -1126,7 +1126,7 @@ real_sync_title (NautilusWindow *window, EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, sync_title, (window, slot)); - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { full_title = g_strdup_printf (_("%s - File Browser"), slot->title); window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH); @@ -1344,7 +1344,7 @@ search_bar_activate_callback (NautilusSearchBar *bar, query = nautilus_search_bar_get_query (NAUTILUS_SEARCH_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->search_bar)); if (query != NULL) { - NautilusWindowSlot *slot = window->details->active_slot; + NautilusWindowSlot *slot = window->details->active_pane->active_slot; if (!nautilus_search_directory_is_indexed (search_directory)) { current_uri = nautilus_window_slot_get_location_uri (slot); nautilus_query_set_location (query, current_uri); @@ -1415,7 +1415,7 @@ real_sync_search_widgets (NautilusWindow *window) navigation_window = NAUTILUS_NAVIGATION_WINDOW (window); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; search_directory = NULL; @@ -1728,7 +1728,7 @@ nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window NautilusNavigationWindowSlot *slot; gint forward_count; - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_slot); + slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_pane->active_slot); forward_count = g_list_length (slot->forward_list); diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index bfb8b30c7..af2aa584c 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -190,7 +190,7 @@ nautilus_spatial_window_state_event (GtkWidget *widget, NautilusFile *viewed_file; window = NAUTILUS_WINDOW (widget); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; viewed_file = slot->viewed_file; if (!NAUTILUS_IS_DESKTOP_WINDOW (widget)) { @@ -496,8 +496,9 @@ real_window_close (NautilusWindow *window) * close is too late, by then the widgets have been unrealized. * This is for the close by WM case, if you're closing via Ctrl-W that * means we close the slots first and this is not an issue */ - if (window->details->slots != NULL) { - slot = window->details->slots->data; + if (window->details->active_pane != NULL && + window->details->active_pane->active_slot != NULL) { + slot = window->details->active_pane->active_slot; save_spatial_data (slot); NAUTILUS_SPATIAL_WINDOW (window)->details->saved_data_on_close = TRUE; @@ -517,7 +518,7 @@ location_menu_item_activated_callback (GtkWidget *menu_item, GFile *dest; GdkEvent *event; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; location = nautilus_window_slot_get_location_uri (slot); current = g_file_new_for_uri (location); @@ -643,7 +644,7 @@ location_button_pressed_callback (GtkWidget *widget, { NautilusView *view; - view = window->details->active_slot->content_view; + view = window->details->active_pane->active_slot->content_view; if (event->button == 3 && view != NULL) { nautilus_view_pop_up_location_context_menu (view, event, NULL); @@ -663,7 +664,7 @@ location_button_clicked_callback (GtkWidget *widget, GFile *child_uri; GMainLoop *loop; - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; popup = gtk_menu_new (); first_item = NULL; @@ -755,7 +756,7 @@ get_dnd_icon_size (NautilusSpatialWindow *window) NautilusZoomLevel zoom_level; parent = NAUTILUS_WINDOW(window); - view = parent->details->active_slot->content_view; + view = parent->details->active_pane->active_slot->content_view; if (view == NULL) { return NAUTILUS_ICON_SIZE_STANDARD; @@ -774,7 +775,7 @@ location_button_drag_begin_callback (GtkWidget *widget, NautilusWindowSlot *slot; GdkPixbuf *pixbuf; - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; pixbuf = nautilus_file_get_icon_pixbuf (slot->viewed_file, get_dnd_icon_size (window), @@ -802,7 +803,7 @@ get_data_binder (NautilusDragEachSelectedItemDataGet iteratee, g_assert (NAUTILUS_IS_SPATIAL_WINDOW (iterator_context)); window = NAUTILUS_SPATIAL_WINDOW (iterator_context); - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; location = nautilus_window_slot_get_location_uri (slot); icon_size = get_dnd_icon_size (window); diff --git a/src/nautilus-window-bookmarks.c b/src/nautilus-window-bookmarks.c index 6e2ee3783..e1b6574da 100644 --- a/src/nautilus-window-bookmarks.c +++ b/src/nautilus-window-bookmarks.c @@ -158,7 +158,7 @@ nautilus_window_add_bookmark_for_current_location (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; bookmark = slot->current_location_bookmark; if (!nautilus_bookmark_list_contains (nautilus_get_bookmark_list (), bookmark)) { diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 1c17997f1..9321f8070 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -301,7 +301,7 @@ update_up_button (NautilusWindow *window) gboolean allowed; GFile *parent; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; allowed = FALSE; if (slot->location != NULL) { @@ -326,6 +326,7 @@ viewed_file_changed_callback (NautilusFile *file, window = slot->pane->window; g_assert (NAUTILUS_IS_FILE (file)); + g_assert (NAUTILUS_IS_WINDOW_PANE (slot->pane)); g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (file == slot->viewed_file); @@ -376,7 +377,7 @@ viewed_file_changed_callback (NautilusFile *file, /* the path bar URI will be set to go_to_uri immediately * in begin_location_change, but we don't want the * inexistant children to show up anymore */ - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { /* multiview-TODO also update NautilusWindowSlot * [which as of writing doesn't save/store any path bar state] */ @@ -401,7 +402,7 @@ viewed_file_changed_callback (NautilusFile *file, slot->location)) { g_object_unref (slot->location); slot->location = new_location; - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { nautilus_window_sync_location_widgets (window); } } else { @@ -609,7 +610,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot, if (target_window == window) { target_slot = slot; } else { - target_slot = target_window->details->active_slot; + target_slot = target_window->details->active_pane->active_slot; } } @@ -1136,13 +1137,13 @@ got_file_info_for_view_selection_callback (NautilusFile *file, if (!nautilus_is_root_directory (location)) { if (!nautilus_is_home_directory (location)) { - nautilus_window_slot_go_home (NAUTILUS_WINDOW (window)->details->active_slot, FALSE); + nautilus_window_slot_go_home (NAUTILUS_WINDOW (window)->details->active_pane->active_slot, FALSE); } else { GFile *root; root = g_file_new_for_path ("/"); /* the last fallback is to go to a known place that can't be deleted! */ - nautilus_window_slot_go_to (NAUTILUS_WINDOW (window)->details->active_slot, location, FALSE); + nautilus_window_slot_go_to (NAUTILUS_WINDOW (window)->details->active_pane->active_slot, location, FALSE); g_object_unref (root); } } else { @@ -1351,7 +1352,7 @@ nautilus_window_report_location_change (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); location = NULL; @@ -1549,7 +1550,7 @@ nautilus_window_sync_location_widgets (NautilusWindow *window) NautilusWindowSlot *slot; char *uri; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { NautilusNavigationWindowSlot *navigation_slot; @@ -1626,12 +1627,12 @@ update_for_new_location (NautilusWindowSlot *slot) G_CALLBACK (viewed_file_changed_callback), slot, 0); nautilus_file_unref (file); - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { /* Check if we can go up. */ update_up_button (window); } - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { nautilus_window_sync_zoom_widgets (window); /* Set up the content view menu for this new location. */ nautilus_window_load_view_as_menus (window); @@ -1674,7 +1675,7 @@ update_for_new_location (NautilusWindowSlot *slot) slot_add_extension_extra_widgets (slot); } - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { nautilus_window_sync_location_widgets (window); if (location_really_changed) { @@ -2052,7 +2053,7 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window, guint len; NautilusBookmark *bookmark; - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; navigation_slot = (NautilusNavigationWindowSlot *) slot; list = back ? navigation_slot->back_list : navigation_slot->forward_list; @@ -2129,6 +2130,6 @@ nautilus_window_reload (NautilusWindow *window) { g_assert (NAUTILUS_IS_WINDOW (window)); - nautilus_window_slot_reload (window->details->active_slot); + nautilus_window_slot_reload (window->details->active_pane->active_slot); } diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c index cdb881eff..4551ed7cc 100644 --- a/src/nautilus-window-pane.c +++ b/src/nautilus-window-pane.c @@ -37,6 +37,9 @@ G_DEFINE_TYPE (NautilusWindowPane, static void nautilus_window_pane_init (NautilusWindowPane *pane) { + pane->slots = NULL; + pane->active_slots = NULL; + pane->active_slot = NULL; } static void @@ -50,7 +53,6 @@ nautilus_window_pane_dispose (GObject *object) { NautilusWindowPane *pane = NAUTILUS_WINDOW_PANE (object); - /* the slots list should now be empty */ g_assert (pane->slots == NULL); pane->window = NULL; diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h index cae4ba352..5a370d449 100644 --- a/src/nautilus-window-pane.h +++ b/src/nautilus-window-pane.h @@ -56,6 +56,12 @@ struct _NautilusWindowPane { /* hosting window */ NautilusWindow *window; + + /* available slots, and active slot. + * Both of them may never be NULL. */ + GList *slots; + GList *active_slots; + NautilusWindowSlot *active_slot; }; GType nautilus_window_pane_get_type (void); diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h index b3440607c..c0e6b66c9 100644 --- a/src/nautilus-window-private.h +++ b/src/nautilus-window-private.h @@ -55,13 +55,6 @@ struct NautilusWindowDetails guint refresh_bookmarks_menu_idle_id; guint bookmarks_merge_id; - /* available slots, and active slot. - * Both of them may never be NULL. - */ - GList *slots; - GList *active_slots; - NautilusWindowSlot *active_slot; - NautilusWindowShowHiddenFilesMode show_hidden_files_mode; /* View As menu */ diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index d556bf530..5d4bfd8e7 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -128,12 +128,14 @@ static void nautilus_window_slot_active (NautilusWindowSlot *slot) { NautilusWindow *window; + NautilusWindowPane *pane; g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); + pane = NAUTILUS_WINDOW_PANE (slot->pane); window = NAUTILUS_WINDOW (slot->pane->window); - g_assert (g_list_find (window->details->slots, slot) != NULL); - g_assert (slot == window->details->active_slot); + g_assert (g_list_find (pane->slots, slot) != NULL); + g_assert (slot == window->details->active_pane->active_slot); EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot, active, (slot)); @@ -145,19 +147,22 @@ real_inactive (NautilusWindowSlot *slot) NautilusWindow *window; window = NAUTILUS_WINDOW (slot->pane->window); - g_assert (slot == window->details->active_slot); + g_assert (slot == window->details->active_pane->active_slot); } static void nautilus_window_slot_inactive (NautilusWindowSlot *slot) { NautilusWindow *window; + NautilusWindowPane *pane; g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); - window = NAUTILUS_WINDOW (slot->pane->window); - g_assert (g_list_find (window->details->slots, slot) != NULL); - g_assert (slot == window->details->active_slot); + pane = NAUTILUS_WINDOW_PANE (slot->pane); + window = NAUTILUS_WINDOW (pane->window); + + g_assert (g_list_find (pane->slots, slot) != NULL); + g_assert (slot == window->details->active_pane->active_slot); EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot, inactive, (slot)); @@ -468,7 +473,7 @@ nautilus_window_slot_set_status (NautilusWindowSlot *slot, slot->status_text = g_strdup (status); window = NAUTILUS_WINDOW (slot->pane->window); - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { nautilus_window_sync_status (window); } } diff --git a/src/nautilus-window-toolbars.c b/src/nautilus-window-toolbars.c index 7d0d26aa2..8dccb65fb 100644 --- a/src/nautilus-window-toolbars.c +++ b/src/nautilus-window-toolbars.c @@ -143,7 +143,7 @@ get_extension_toolbar_items (NautilusNavigationWindow *window) providers = nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_MENU_PROVIDER); items = NULL; - slot = NAUTILUS_WINDOW (window)->details->active_slot; + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; for (l = providers; l != NULL; l = l->next) { NautilusMenuProvider *provider; diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 33bac40cb..9e3dfe96c 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -225,7 +225,7 @@ nautilus_window_sync_status (NautilusWindow *window) { NautilusWindowSlot *slot; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; nautilus_window_push_status (window, slot->status_text); } @@ -234,7 +234,7 @@ nautilus_window_go_to (NautilusWindow *window, GFile *location) { g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - nautilus_window_slot_go_to (window->details->active_slot, location, FALSE); + nautilus_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE); } void @@ -242,7 +242,7 @@ nautilus_window_go_to_with_selection (NautilusWindow *window, GFile *location, G { g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - nautilus_window_slot_go_to_with_selection (window->details->active_slot, location, new_selection); + nautilus_window_slot_go_to_with_selection (window->details->active_pane->active_slot, location, new_selection); } static gboolean @@ -262,7 +262,7 @@ nautilus_window_go_up (NautilusWindow *window, gboolean close_behind, gboolean n g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->location == NULL) { return; @@ -325,7 +325,7 @@ update_cursor (NautilusWindow *window) NautilusWindowSlot *slot; GdkCursor *cursor; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->allow_stop) { cursor = gdk_cursor_new (GDK_WATCH); @@ -349,9 +349,9 @@ nautilus_window_sync_allow_stop (NautilusWindow *window, NAUTILUS_ACTION_STOP); allow_stop = gtk_action_get_sensitive (action); - if (slot != window->details->active_slot || + if (slot != window->details->active_pane->active_slot || allow_stop != slot->allow_stop) { - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { gtk_action_set_sensitive (action, slot->allow_stop); } @@ -381,7 +381,7 @@ nautilus_window_go_home (NautilusWindow *window) { g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - nautilus_window_slot_go_home (window->details->active_slot, FALSE); + nautilus_window_slot_go_home (window->details->active_pane->active_slot, FALSE); } void @@ -401,7 +401,7 @@ nautilus_window_get_location_uri (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->location) { return g_file_get_uri (slot->location); @@ -425,7 +425,7 @@ nautilus_window_zoom_in (NautilusWindow *window) g_assert (window != NULL); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view != NULL) { nautilus_view_bump_zoom_level (slot->content_view, 1); } @@ -439,7 +439,7 @@ nautilus_window_zoom_to_level (NautilusWindow *window, g_assert (window != NULL); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view != NULL) { nautilus_view_zoom_to_level (slot->content_view, level); } @@ -452,7 +452,7 @@ nautilus_window_zoom_out (NautilusWindow *window) g_assert (window != NULL); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view != NULL) { nautilus_view_bump_zoom_level (slot->content_view, -1); } @@ -465,7 +465,7 @@ nautilus_window_zoom_to_default (NautilusWindow *window) g_assert (window != NULL); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view != NULL) { nautilus_view_restore_default_zoom_level (slot->content_view); } @@ -610,6 +610,7 @@ nautilus_window_destroy (GtkObject *object) /* the panes list should now be empty */ g_assert (window->details->panes == NULL); + g_assert (window->details->active_pane == NULL); GTK_OBJECT_CLASS (nautilus_window_parent_class)->destroy (object); } @@ -627,7 +628,7 @@ nautilus_window_finalize (GObject *object) free_stored_viewers (window); /* nautilus_window_close() should have run */ - g_assert (window->details->slots == NULL); + g_assert (window->details->panes == NULL); g_object_unref (window->details->ui_manager); @@ -659,23 +660,26 @@ void nautilus_window_show_window (NautilusWindow *window) { NautilusWindowSlot *slot; - GList *l; + GList *l, *walk; g_return_if_fail (NAUTILUS_IS_WINDOW (window)); EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window, show_window, (window)); - for (l = window->details->slots; l != NULL; l = l->next) { - slot = l->data; + for (walk = window->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + for (l = pane->slots; l != NULL; l = l->next) { + slot = l->data; - nautilus_window_slot_update_title (slot); - nautilus_window_slot_update_icon (slot); + nautilus_window_slot_update_title (slot); + nautilus_window_slot_update_icon (slot); + } } gtk_widget_show (GTK_WIDGET (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->viewed_file) { if (NAUTILUS_IS_SPATIAL_WINDOW (window)) { @@ -709,7 +713,7 @@ nautilus_window_open_slot (NautilusWindow *window, g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); g_assert (window == slot->pane->window); - window->details->slots = g_list_append (window->details->slots, slot); + window->details->active_pane->slots = g_list_append (window->details->active_pane->slots, slot); return slot; } @@ -718,21 +722,20 @@ void nautilus_window_close_pane (NautilusWindowPane *pane) { NautilusWindow *window; - GList *slots_copy; g_assert (NAUTILUS_IS_WINDOW_PANE (pane)); g_assert (NAUTILUS_IS_WINDOW (pane->window)); g_assert (g_list_find (pane->window->details->panes, pane) != NULL); - window = pane->window; + while (pane->slots != NULL) { + NautilusWindowSlot *slot = pane->slots->data; - /* close all slots safely */ - slots_copy = g_list_copy (pane->slots); - g_list_foreach (slots_copy, (GFunc) nautilus_window_close_slot, NULL); - g_list_free (slots_copy); + nautilus_window_close_slot (pane, slot); + } + + window = pane->window; - /* the slots list should now be empty */ - g_assert (pane->slots == NULL); + window->details->panes = g_list_remove (window->details->panes, pane); /* if the pane was active, select the next one, or NULL */ if (window->details->active_pane == pane) { @@ -743,7 +746,6 @@ nautilus_window_close_pane (NautilusWindowPane *pane) } } - window->details->panes = g_list_remove (window->details->panes, pane); g_object_unref (pane); } @@ -763,13 +765,13 @@ nautilus_window_close_slot (NautilusWindow *window, g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); g_assert (window == slot->pane->window); - g_assert (g_list_find (window->details->slots, slot) != NULL); + g_assert (g_list_find (window->details->active_pane->slots, slot) != NULL); EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window, close_slot, (window, slot)); - window->details->slots = g_list_remove (window->details->slots, slot); - window->details->active_slots = g_list_remove (window->details->active_slots, slot); + window->details->active_pane->slots = g_list_remove (window->details->active_pane->slots, slot); + window->details->active_pane->active_slots = g_list_remove (window->details->active_pane->active_slots, slot); } @@ -793,16 +795,27 @@ nautilus_window_set_active_slot (NautilusWindow *window, NautilusWindowSlot *new_slot) { NautilusWindowSlot *old_slot; + NautilusWindowPane *new_pane; + GList *walk; g_assert (NAUTILUS_IS_WINDOW (window)); + /* find the pane that contains the new slot */ + for (walk = window->details->panes; walk; walk = walk->next) { + new_pane = walk->data; + if (g_list_find (new_pane->slots, new_slot)) { + nautilus_window_set_active_pane (window, new_pane); + break; + } + } + if (new_slot != NULL) { g_assert (NAUTILUS_IS_WINDOW_SLOT (new_slot)); g_assert (window == new_slot->pane->window); - g_assert (g_list_find (window->details->slots, new_slot) != NULL); + g_assert (g_list_find (window->details->active_pane->slots, new_slot) != NULL); } - old_slot = window->details->active_slot; + old_slot = window->details->active_pane->active_slot; if (old_slot == new_slot) { return; @@ -818,12 +831,12 @@ nautilus_window_set_active_slot (NautilusWindow *window, g_signal_emit_by_name (old_slot, "inactive"); } - window->details->active_slot = new_slot; + window->details->active_pane->active_slot = new_slot; if (new_slot != NULL) { - window->details->active_slots = g_list_remove (window->details->active_slots, new_slot); - window->details->active_slots = g_list_prepend (window->details->active_slots, new_slot); + window->details->active_pane->active_slots = g_list_remove (window->details->active_pane->active_slots, new_slot); + window->details->active_pane->active_slots = g_list_prepend (window->details->active_pane->active_slots, new_slot); /* inform sidebar panels */ nautilus_window_report_location_change (window); @@ -840,14 +853,14 @@ nautilus_window_set_active_slot (NautilusWindow *window, } static inline NautilusWindowSlot * -get_first_inactive_slot (NautilusWindow *window) +get_first_inactive_slot (NautilusWindowPane *pane) { GList *l; NautilusWindowSlot *slot; - for (l = window->details->slots; l != NULL; l = l->next) { + for (l = pane->slots; l != NULL; l = l->next) { slot = NAUTILUS_WINDOW_SLOT (l->data); - if (slot != window->details->active_slot) { + if (slot != pane->active_slot) { return slot; } } @@ -860,28 +873,31 @@ nautilus_window_slot_close (NautilusWindowSlot *slot) { NautilusWindow *window; NautilusWindowSlot *next_slot; + GList *walk; window = slot->pane->window; if (window != NULL) { - if (window->details->active_slot == slot) { - g_assert (window->details->active_slots != NULL); - g_assert (window->details->active_slots->data == slot); + for (walk = window->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + if (pane->active_slot == slot) { + g_assert (pane->active_slots != NULL); - next_slot = NULL; - if (window->details->active_slots->next != NULL) { - next_slot = NAUTILUS_WINDOW_SLOT (window->details->active_slots->next->data); - } + next_slot = NULL; + if (pane->active_slots->next != NULL) { + next_slot = NAUTILUS_WINDOW_SLOT (pane->active_slots->next->data); + } - if (next_slot == NULL) { - next_slot = get_first_inactive_slot (window); - } + if (next_slot == NULL) { + next_slot = get_first_inactive_slot (pane); + } - nautilus_window_set_active_slot (window, next_slot); + nautilus_window_set_active_slot (pane->window, next_slot); + } } nautilus_window_close_slot (window, slot); - if (g_list_length (window->details->slots) == 0) { + if (g_list_length (window->details->active_pane->slots) == 0) { nautilus_window_close (window); } } @@ -995,7 +1011,7 @@ action_view_as_callback (GtkAction *action, window = data->window; if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; nautilus_window_slot_set_content_view (slot, data->id); } @@ -1128,7 +1144,7 @@ replace_extra_viewer_in_view_as_menus (NautilusWindow *window) NautilusWindowSlot *slot; const char *id; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; id = nautilus_window_slot_get_content_view_id (slot); update_extra_viewer_in_view_as_menus (window, id); @@ -1154,7 +1170,7 @@ nautilus_window_synch_view_as_menus (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view == NULL) { return; @@ -1200,7 +1216,7 @@ refresh_stored_viewers (NautilusWindow *window) GList *viewers; char *uri, *mimetype; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; uri = nautilus_file_get_uri (slot->viewed_file); mimetype = nautilus_file_get_mime_type (slot->viewed_file); @@ -1222,7 +1238,7 @@ load_view_as_menu (NautilusWindow *window) int index; guint merge_id; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (window->details->short_list_merge_id != 0) { gtk_ui_manager_remove_ui (window->details->ui_manager, @@ -1283,7 +1299,7 @@ load_view_as_menus_callback (NautilusFile *file, slot = callback_data; window = NAUTILUS_WINDOW (slot->pane->window); - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { load_view_as_menu (window); } } @@ -1306,7 +1322,7 @@ nautilus_window_load_view_as_menus (NautilusWindow *window) attributes = nautilus_mime_actions_get_required_file_attributes (); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; cancel_view_as_callback (slot); nautilus_file_call_when_ready (slot->viewed_file, @@ -1332,7 +1348,7 @@ real_get_title (NautilusWindow *window) { g_assert (NAUTILUS_IS_WINDOW (window)); - return nautilus_window_slot_get_title (window->details->active_slot); + return nautilus_window_slot_get_title (window->details->active_pane->active_slot); } static void @@ -1341,7 +1357,7 @@ real_sync_title (NautilusWindow *window, { char *copy; - if (slot == window->details->active_slot) { + if (slot == window->details->active_pane->active_slot) { copy = g_strdup (slot->title); g_signal_emit_by_name (window, "title_changed", slot->title); @@ -1367,7 +1383,7 @@ nautilus_window_sync_zoom_widgets (NautilusWindow *window) gboolean can_zoom, can_zoom_in, can_zoom_out; NautilusZoomLevel zoom_level; - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; view = slot->content_view; if (view != NULL) { @@ -1645,13 +1661,17 @@ nautilus_window_get_slot_for_view (NautilusWindow *window, NautilusView *view) { NautilusWindowSlot *slot; - GList *l; + GList *l, *walk; - for (l = window->details->slots; l != NULL; l = l->next) { - slot = l->data; - if (slot->content_view == view || - slot->new_content_view == view) { - return slot; + for (walk = window->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + + for (l = pane->slots; l != NULL; l = l->next) { + slot = l->data; + if (slot->content_view == view || + slot->new_content_view == view) { + return slot; + } } } @@ -1663,13 +1683,16 @@ nautilus_window_get_slot_for_content_box (NautilusWindow *window, GtkWidget *content_box) { NautilusWindowSlot *slot; - GList *l; + GList *l, *walk; - for (l = window->details->slots; l != NULL; l = l->next) { - slot = NAUTILUS_WINDOW_SLOT (l->data); + for (walk = window->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + for (l = pane->slots; l != NULL; l = l->next) { + slot = NAUTILUS_WINDOW_SLOT (l->data); - if (slot->content_box == content_box) { - return slot; + if (slot->content_box == content_box) { + return slot; + } } } @@ -1681,7 +1704,7 @@ nautilus_forget_history (void) { NautilusWindowSlot *slot; NautilusNavigationWindowSlot *navigation_slot; - GList *window_node, *l; + GList *window_node, *l, *walk; /* Clear out each window's back & forward lists. Also, remove * each window's current location bookmark from history list @@ -1696,25 +1719,28 @@ nautilus_forget_history (void) window = NAUTILUS_NAVIGATION_WINDOW (window_node->data); - for (l = NAUTILUS_WINDOW (window_node->data)->details->slots; - l != NULL; l = l->next) { - navigation_slot = l->data; + for (walk = NAUTILUS_WINDOW (window_node->data)->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + for (l = pane->slots; l != NULL; l = l->next) { + navigation_slot = l->data; - nautilus_navigation_window_slot_clear_back_list (navigation_slot); - nautilus_navigation_window_slot_clear_forward_list (navigation_slot); + nautilus_navigation_window_slot_clear_back_list (navigation_slot); + nautilus_navigation_window_slot_clear_forward_list (navigation_slot); + } } nautilus_navigation_window_allow_back (window, FALSE); nautilus_navigation_window_allow_forward (window, FALSE); } - for (l = NAUTILUS_WINDOW (window_node->data)->details->slots; - l != NULL; l = l->next) { - slot = l->data; - history_list = g_list_remove (history_list, - slot->current_location_bookmark); + for (walk = NAUTILUS_WINDOW (window_node->data)->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + for (l = pane->slots; l != NULL; l = l->next) { + slot = l->data; + history_list = g_list_remove (history_list, + slot->current_location_bookmark); + } } - } /* Clobber history list. */ @@ -1729,9 +1755,12 @@ nautilus_forget_history (void) GList *l; window = NAUTILUS_WINDOW (window_node->data); - for (l = window->details->slots; l != NULL; l = l->next) { - slot = NAUTILUS_WINDOW_SLOT (l->data); - nautilus_window_slot_add_current_location_to_history_list (slot); + for (walk = window->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + for (l = pane->slots; l != NULL; l = l->next) { + slot = NAUTILUS_WINDOW_SLOT (l->data); + nautilus_window_slot_add_current_location_to_history_list (slot); + } } } } @@ -1764,7 +1793,7 @@ nautilus_window_get_selection_count (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view != NULL) { return nautilus_view_get_selection_count (slot->content_view); @@ -1780,7 +1809,7 @@ nautilus_window_get_selection (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; if (slot->content_view != NULL) { return nautilus_view_get_selection (slot->content_view); @@ -1816,7 +1845,7 @@ nautilus_window_get_cached_title (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); - slot = window->details->active_slot; + slot = window->details->active_pane->active_slot; return g_strdup (slot->title); } @@ -1826,15 +1855,22 @@ nautilus_window_get_active_slot (NautilusWindow *window) { g_assert (NAUTILUS_IS_WINDOW (window)); - return window->details->active_slot; + return window->details->active_pane->active_slot; } GList * nautilus_window_get_slots (NautilusWindow *window) { + GList *walk,*list; + g_assert (NAUTILUS_IS_WINDOW (window)); - return g_list_copy (window->details->slots); + list = NULL; + for (walk = window->details->panes; walk; walk = walk->next) { + NautilusWindowPane *pane = walk->data; + list = g_list_concat (list, g_list_copy(pane->slots)); + } + return list; } static void |