diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2011-02-17 14:40:07 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2011-02-17 16:37:39 -0500 |
commit | 9af483dbbea8fc6fc41f4bc726522d7583ccf677 (patch) | |
tree | d70a3721e3c21294b2dbd344a86ca04c7dd0b80d /src | |
parent | 238bc1452138e1aae44dcc95121b749ab4d805d0 (diff) | |
download | nautilus-9af483dbbea8fc6fc41f4bc726522d7583ccf677.tar.gz |
all: merge NautilusNavigationWindowSlot into NautilusWindowSlot
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/nautilus-application.c | 8 | ||||
-rw-r--r-- | src/nautilus-navigation-action.c | 5 | ||||
-rw-r--r-- | src/nautilus-navigation-window-slot.c | 216 | ||||
-rw-r--r-- | src/nautilus-navigation-window-slot.h | 68 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 7 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 103 | ||||
-rw-r--r-- | src/nautilus-window-pane.c | 14 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 114 | ||||
-rw-r--r-- | src/nautilus-window-slot.h | 13 | ||||
-rw-r--r-- | src/nautilus-window.c | 9 |
11 files changed, 172 insertions, 387 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index a7e6d5566..0a955bee8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,8 +105,6 @@ nautilus_SOURCES = \ nautilus-navigation-window-menus.c \ nautilus-navigation-window.c \ nautilus-navigation-window.h \ - nautilus-navigation-window-slot.c \ - nautilus-navigation-window-slot.h \ nautilus-notebook.c \ nautilus-notebook.h \ nautilus-pathbar.c \ diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 8de6f70a6..d437d2e0a 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -40,7 +40,6 @@ #include "nautilus-image-properties-page.h" #include "nautilus-list-view.h" #include "nautilus-navigation-window.h" -#include "nautilus-navigation-window-slot.h" #include "nautilus-progress-ui-handler.h" #include "nautilus-self-check-functions.h" #include "nautilus-window-bookmarks.h" @@ -893,9 +892,7 @@ get_first_navigation_slot (GList *slot_list) GList *l; for (l = slot_list; l != NULL; l = l->next) { - if (NAUTILUS_IS_NAVIGATION_WINDOW_SLOT (l->data)) { - return l->data; - } + return l->data; } return NULL; @@ -907,8 +904,7 @@ should_close_slot_with_mount (NautilusWindow *window, NautilusWindowSlot *slot, GMount *mount) { - return nautilus_navigation_window_slot_should_close_with_mount (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), - mount); + return nautilus_window_slot_should_close_with_mount (slot, mount); } /* Called whenever a mount is unmounted. Check and see if there are diff --git a/src/nautilus-navigation-action.c b/src/nautilus-navigation-action.c index 836bcf0d0..24de50623 100644 --- a/src/nautilus-navigation-action.c +++ b/src/nautilus-navigation-action.c @@ -33,7 +33,6 @@ #include "nautilus-navigation-action.h" #include "nautilus-navigation-window.h" -#include "nautilus-navigation-window-slot.h" #include <gtk/gtk.h> #include <eel/eel-gtk-extensions.h> @@ -106,14 +105,14 @@ fill_menu (NautilusNavigationWindow *window, GtkWidget *menu, gboolean back) { - NautilusNavigationWindowSlot *slot; + NautilusWindowSlot *slot; GtkWidget *menu_item; int index; GList *list; g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (nautilus_window_get_active_slot (NAUTILUS_WINDOW (window))); + slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window)); list = back ? slot->back_list : slot->forward_list; index = 0; diff --git a/src/nautilus-navigation-window-slot.c b/src/nautilus-navigation-window-slot.c deleted file mode 100644 index 0eb76e31c..000000000 --- a/src/nautilus-navigation-window-slot.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - - nautilus-navigation-window-slot.c: Nautilus navigation window slot - - Copyright (C) 2008 Free Software Foundation, Inc. - - This program 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. - - This program 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., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Christian Neumair <cneumair@gnome.org> -*/ - -#include "nautilus-window-slot.h" -#include "nautilus-navigation-window-slot.h" -#include "nautilus-window-private.h" -#include "nautilus-search-bar.h" -#include "nautilus-window-pane.h" -#include <libnautilus-private/nautilus-file.h> -#include <eel/eel-gtk-macros.h> - -static void nautilus_navigation_window_slot_init (NautilusNavigationWindowSlot *slot); -static void nautilus_navigation_window_slot_class_init (NautilusNavigationWindowSlotClass *class); - -G_DEFINE_TYPE (NautilusNavigationWindowSlot, nautilus_navigation_window_slot, NAUTILUS_TYPE_WINDOW_SLOT) -#define parent_class nautilus_navigation_window_slot_parent_class - -gboolean -nautilus_navigation_window_slot_should_close_with_mount (NautilusNavigationWindowSlot *slot, - GMount *mount) -{ - NautilusBookmark *bookmark; - GFile *mount_location, *bookmark_location; - GList *l; - gboolean close_with_mount; - - if (slot->parent.pane->window->details->initiated_unmount) { - return FALSE; - } - - mount_location = g_mount_get_root (mount); - - close_with_mount = TRUE; - - for (l = slot->back_list; l != NULL; l = l->next) { - bookmark = NAUTILUS_BOOKMARK (l->data); - - bookmark_location = nautilus_bookmark_get_location (bookmark); - close_with_mount &= g_file_has_prefix (bookmark_location, mount_location) || - g_file_equal (bookmark_location, mount_location); - g_object_unref (bookmark_location); - - if (!close_with_mount) { - break; - } - } - - close_with_mount &= g_file_has_prefix (NAUTILUS_WINDOW_SLOT (slot)->location, mount_location) || - g_file_equal (NAUTILUS_WINDOW_SLOT (slot)->location, mount_location); - - /* we could also consider the forward list here, but since the “go home” request - * in nautilus-window-manager-views.c:mount_removed_callback() would discard those - * anyway, we don't consider them. - */ - - g_object_unref (mount_location); - - return close_with_mount; -} - -void -nautilus_navigation_window_slot_clear_forward_list (NautilusNavigationWindowSlot *slot) -{ - g_assert (NAUTILUS_IS_NAVIGATION_WINDOW_SLOT (slot)); - - g_list_free_full (slot->forward_list, g_object_unref); - slot->forward_list = NULL; -} - -void -nautilus_navigation_window_slot_clear_back_list (NautilusNavigationWindowSlot *slot) -{ - g_assert (NAUTILUS_IS_NAVIGATION_WINDOW_SLOT (slot)); - - g_list_free_full (slot->back_list, g_object_unref); - slot->back_list = NULL; -} - -static void -query_editor_changed_callback (NautilusSearchBar *bar, - NautilusQuery *query, - gboolean reload, - NautilusWindowSlot *slot) -{ - NautilusDirectory *directory; - - g_assert (NAUTILUS_IS_FILE (slot->viewed_file)); - - directory = nautilus_directory_get_for_file (slot->viewed_file); - g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory)); - - nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory), - query); - if (reload) { - nautilus_window_slot_reload (slot); - } - - nautilus_directory_unref (directory); -} - - -static void -nautilus_navigation_window_slot_update_query_editor (NautilusWindowSlot *slot) -{ - NautilusDirectory *directory; - NautilusSearchDirectory *search_directory; - NautilusQuery *query; - GtkWidget *query_editor; - - g_assert (slot->pane->window != NULL); - - query_editor = NULL; - - directory = nautilus_directory_get (slot->location); - if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) { - search_directory = NAUTILUS_SEARCH_DIRECTORY (directory); - - if (nautilus_search_directory_is_saved_search (search_directory)) { - query_editor = nautilus_query_editor_new (TRUE, - nautilus_search_directory_is_indexed (search_directory)); - } else { - query_editor = nautilus_query_editor_new_with_bar (FALSE, - nautilus_search_directory_is_indexed (search_directory), - slot->pane->window->details->active_pane->active_slot == slot, - NAUTILUS_SEARCH_BAR (slot->pane->search_bar), - slot); - } - } - - slot->query_editor = NAUTILUS_QUERY_EDITOR (query_editor); - - if (query_editor != NULL) { - g_signal_connect_object (query_editor, "changed", - G_CALLBACK (query_editor_changed_callback), slot, 0); - - query = nautilus_search_directory_get_query (search_directory); - if (query != NULL) { - nautilus_query_editor_set_query (NAUTILUS_QUERY_EDITOR (query_editor), - query); - g_object_unref (query); - } else { - nautilus_query_editor_set_default_query (NAUTILUS_QUERY_EDITOR (query_editor)); - } - - nautilus_window_slot_add_extra_location_widget (slot, query_editor); - gtk_widget_show (query_editor); - nautilus_query_editor_grab_focus (NAUTILUS_QUERY_EDITOR (query_editor)); - } - - nautilus_directory_unref (directory); -} - -static void -nautilus_navigation_window_slot_active (NautilusWindowSlot *slot) -{ - NautilusWindowPane *pane; - int page_num; - - pane = slot->pane; - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (pane->notebook), - slot->content_box); - g_assert (page_num >= 0); - - gtk_notebook_set_current_page (GTK_NOTEBOOK (pane->notebook), page_num); - - EEL_CALL_PARENT (NAUTILUS_WINDOW_SLOT_CLASS, active, (slot)); -} - -static void -nautilus_navigation_window_slot_dispose (GObject *object) -{ - NautilusNavigationWindowSlot *slot; - - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (object); - - nautilus_navigation_window_slot_clear_forward_list (slot); - nautilus_navigation_window_slot_clear_back_list (slot); - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -nautilus_navigation_window_slot_init (NautilusNavigationWindowSlot *slot) -{ -} - -static void -nautilus_navigation_window_slot_class_init (NautilusNavigationWindowSlotClass *class) -{ - NAUTILUS_WINDOW_SLOT_CLASS (class)->active = nautilus_navigation_window_slot_active; - NAUTILUS_WINDOW_SLOT_CLASS (class)->update_query_editor = nautilus_navigation_window_slot_update_query_editor; - - G_OBJECT_CLASS (class)->dispose = nautilus_navigation_window_slot_dispose; -} - diff --git a/src/nautilus-navigation-window-slot.h b/src/nautilus-navigation-window-slot.h deleted file mode 100644 index 07ef93bd3..000000000 --- a/src/nautilus-navigation-window-slot.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - - nautilus-navigation-window-slot.h: Nautilus navigation window slot - - Copyright (C) 2008 Free Software Foundation, Inc. - - This program 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. - - This program 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., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Christian Neumair <cneumair@gnome.org> -*/ - -#ifndef NAUTILUS_NAVIGATION_WINDOW_SLOT_H -#define NAUTILUS_NAVIGATION_WINDOW_SLOT_H - -#include "nautilus-window-slot.h" - -typedef struct NautilusNavigationWindowSlot NautilusNavigationWindowSlot; -typedef struct NautilusNavigationWindowSlotClass NautilusNavigationWindowSlotClass; - - -#define NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT (nautilus_navigation_window_slot_get_type()) -#define NAUTILUS_NAVIGATION_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_NAVIGATION_WINDOW_SLOT_CLASS, NautilusNavigationWindowSlotClass)) -#define NAUTILUS_NAVIGATION_WINDOW_SLOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT, NautilusNavigationWindowSlot)) -#define NAUTILUS_IS_NAVIGATION_WINDOW_SLOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT)) -#define NAUTILUS_IS_NAVIGATION_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT)) -#define NAUTILUS_NAVIGATION_WINDOW_SLOT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT, NautilusNavigationWindowSlotClass)) - -struct NautilusNavigationWindowSlot { - NautilusWindowSlot parent; - - GtkTreeModel *viewer_model; - int num_viewers; - - /* Back/Forward chain, and history list. - * The data in these lists are NautilusBookmark pointers. - */ - GList *back_list, *forward_list; - - /* Current views stuff */ - GList *sidebar_panels; -}; - -struct NautilusNavigationWindowSlotClass { - NautilusWindowSlotClass parent; -}; - -GType nautilus_navigation_window_slot_get_type (void); - -gboolean nautilus_navigation_window_slot_should_close_with_mount (NautilusNavigationWindowSlot *slot, - GMount *mount); - -void nautilus_navigation_window_slot_clear_forward_list (NautilusNavigationWindowSlot *slot); -void nautilus_navigation_window_slot_clear_back_list (NautilusNavigationWindowSlot *slot); - -#endif /* NAUTILUS_NAVIGATION_WINDOW_SLOT_H */ diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index ad35081b6..74dfc42d6 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -37,7 +37,6 @@ #include "nautilus-location-bar.h" #include "nautilus-query-editor.h" #include "nautilus-search-bar.h" -#include "nautilus-navigation-window-slot.h" #include "nautilus-notebook.h" #include "nautilus-places-sidebar.h" #include "nautilus-tree-sidebar.h" @@ -456,10 +455,10 @@ nautilus_navigation_window_set_search_button (NautilusNavigationWindow *window, gint nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window) { - NautilusNavigationWindowSlot *slot; + NautilusWindowSlot *slot; gint forward_count; - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_pane->active_slot); + slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; forward_count = g_list_length (slot->forward_list); @@ -560,7 +559,7 @@ real_open_slot (NautilusWindowPane *pane, { NautilusWindowSlot *slot; - slot = (NautilusWindowSlot *) g_object_new (NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT, NULL); + slot = (NautilusWindowSlot *) g_object_new (NAUTILUS_TYPE_WINDOW_SLOT, NULL); slot->pane = pane; nautilus_window_pane_add_slot_in_tab (pane, slot, flags); diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index a5444d4f8..6bce2daf6 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -35,7 +35,6 @@ #include "nautilus-pathbar.h" #include "nautilus-window-private.h" #include "nautilus-window-slot.h" -#include "nautilus-navigation-window-slot.h" #include "nautilus-trash-bar.h" #include "nautilus-view-factory.h" #include "nautilus-x-content-bar.h" @@ -159,19 +158,16 @@ check_last_bookmark_location_matches_slot (NautilusWindowSlot *slot) } static void -handle_go_back (NautilusNavigationWindowSlot *navigation_slot, +handle_go_back (NautilusWindowSlot *slot, GFile *location) { - NautilusWindowSlot *slot; guint i; GList *link; NautilusBookmark *bookmark; - slot = NAUTILUS_WINDOW_SLOT (navigation_slot); - /* Going back. Move items from the back list to the forward list. */ - g_assert (g_list_length (navigation_slot->back_list) > slot->location_change_distance); - check_bookmark_location_matches (NAUTILUS_BOOKMARK (g_list_nth_data (navigation_slot->back_list, + g_assert (g_list_length (slot->back_list) > slot->location_change_distance); + check_bookmark_location_matches (NAUTILUS_BOOKMARK (g_list_nth_data (slot->back_list, slot->location_change_distance)), location); g_assert (slot->location != NULL); @@ -181,40 +177,37 @@ handle_go_back (NautilusNavigationWindowSlot *navigation_slot, check_last_bookmark_location_matches_slot (slot); /* Use the first bookmark in the history list rather than creating a new one. */ - navigation_slot->forward_list = g_list_prepend (navigation_slot->forward_list, - slot->last_location_bookmark); - g_object_ref (navigation_slot->forward_list->data); + slot->forward_list = g_list_prepend (slot->forward_list, + slot->last_location_bookmark); + g_object_ref (slot->forward_list->data); /* Move extra links from Back to Forward list */ for (i = 0; i < slot->location_change_distance; ++i) { - bookmark = NAUTILUS_BOOKMARK (navigation_slot->back_list->data); - navigation_slot->back_list = - g_list_remove (navigation_slot->back_list, bookmark); - navigation_slot->forward_list = - g_list_prepend (navigation_slot->forward_list, bookmark); + bookmark = NAUTILUS_BOOKMARK (slot->back_list->data); + slot->back_list = + g_list_remove (slot->back_list, bookmark); + slot->forward_list = + g_list_prepend (slot->forward_list, bookmark); } /* One bookmark falls out of back/forward lists and becomes viewed location */ - link = navigation_slot->back_list; - navigation_slot->back_list = g_list_remove_link (navigation_slot->back_list, link); + link = slot->back_list; + slot->back_list = g_list_remove_link (slot->back_list, link); g_object_unref (link->data); g_list_free_1 (link); } static void -handle_go_forward (NautilusNavigationWindowSlot *navigation_slot, +handle_go_forward (NautilusWindowSlot *slot, GFile *location) { - NautilusWindowSlot *slot; guint i; GList *link; NautilusBookmark *bookmark; - slot = NAUTILUS_WINDOW_SLOT (navigation_slot); - /* Going forward. Move items from the forward list to the back list. */ - g_assert (g_list_length (navigation_slot->forward_list) > slot->location_change_distance); - check_bookmark_location_matches (NAUTILUS_BOOKMARK (g_list_nth_data (navigation_slot->forward_list, + g_assert (g_list_length (slot->forward_list) > slot->location_change_distance); + check_bookmark_location_matches (NAUTILUS_BOOKMARK (g_list_nth_data (slot->forward_list, slot->location_change_distance)), location); g_assert (slot->location != NULL); @@ -223,22 +216,22 @@ handle_go_forward (NautilusNavigationWindowSlot *navigation_slot, check_last_bookmark_location_matches_slot (slot); /* Use the first bookmark in the history list rather than creating a new one. */ - navigation_slot->back_list = g_list_prepend (navigation_slot->back_list, - slot->last_location_bookmark); - g_object_ref (navigation_slot->back_list->data); + slot->back_list = g_list_prepend (slot->back_list, + slot->last_location_bookmark); + g_object_ref (slot->back_list->data); /* Move extra links from Forward to Back list */ - for (i = 0; i < slot->location_change_distance; ++i) { - bookmark = NAUTILUS_BOOKMARK (navigation_slot->forward_list->data); - navigation_slot->forward_list = - g_list_remove (navigation_slot->back_list, bookmark); - navigation_slot->back_list = - g_list_prepend (navigation_slot->forward_list, bookmark); + for (i = 0; i < slot->location_change_distance; ++i) { + bookmark = NAUTILUS_BOOKMARK (slot->forward_list->data); + slot->forward_list = + g_list_remove (slot->back_list, bookmark); + slot->back_list = + g_list_prepend (slot->forward_list, bookmark); } /* One bookmark falls out of back/forward lists and becomes viewed location */ - link = navigation_slot->forward_list; - navigation_slot->forward_list = g_list_remove_link (navigation_slot->forward_list, link); + link = slot->forward_list; + slot->forward_list = g_list_remove_link (slot->forward_list, link); g_object_unref (link->data); g_list_free_1 (link); } @@ -247,27 +240,21 @@ static void handle_go_elsewhere (NautilusWindowSlot *slot, GFile *location) { - NautilusNavigationWindowSlot *navigation_slot; - - if (NAUTILUS_IS_NAVIGATION_WINDOW_SLOT (slot)) { - navigation_slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (slot); - - /* Clobber the entire forward list, and move displayed location to back list */ - nautilus_navigation_window_slot_clear_forward_list (navigation_slot); + /* Clobber the entire forward list, and move displayed location to back list */ + nautilus_window_slot_clear_forward_list (slot); - if (slot->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 (!g_file_equal (slot->location, location)) { - /* Store bookmark for current location in back list, unless there is no current location */ - check_last_bookmark_location_matches_slot (slot); - /* Use the first bookmark in the history list rather than creating a new one. */ - navigation_slot->back_list = g_list_prepend (navigation_slot->back_list, - slot->last_location_bookmark); - g_object_ref (navigation_slot->back_list->data); - } + if (slot->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 (!g_file_equal (slot->location, location)) { + /* Store bookmark for current location in back list, unless there is no current location */ + check_last_bookmark_location_matches_slot (slot); + /* Use the first bookmark in the history list rather than creating a new one. */ + slot->back_list = g_list_prepend (slot->back_list, + slot->last_location_bookmark); + g_object_ref (slot->back_list->data); } } } @@ -404,10 +391,10 @@ update_history (NautilusWindowSlot *slot, /* for reload there is no work to do */ return; case NAUTILUS_LOCATION_CHANGE_BACK: - handle_go_back (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), new_location); + handle_go_back (slot, new_location); return; case NAUTILUS_LOCATION_CHANGE_FORWARD: - handle_go_forward (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), new_location); + handle_go_forward (slot, new_location); return; case NAUTILUS_LOCATION_CHANGE_REDIRECT: /* for the redirect case, the caller can do the updating */ @@ -1778,15 +1765,13 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window, gboolean back, guint distance, gboolean new_tab) { NautilusWindowSlot *slot; - NautilusNavigationWindowSlot *navigation_slot; GList *list; GFile *location; guint len; NautilusBookmark *bookmark; slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot; - navigation_slot = (NautilusNavigationWindowSlot *) slot; - list = back ? navigation_slot->back_list : navigation_slot->forward_list; + list = back ? slot->back_list : slot->forward_list; len = (guint) g_list_length (list); diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c index 8b4884350..03496f1bd 100644 --- a/src/nautilus-window-pane.c +++ b/src/nautilus-window-pane.c @@ -28,7 +28,6 @@ #include "nautilus-clipboard.h" #include "nautilus-location-bar.h" -#include "nautilus-navigation-window-slot.h" #include "nautilus-notebook.h" #include "nautilus-pathbar.h" #include "nautilus-toolbar.h" @@ -190,10 +189,10 @@ path_bar_location_changed_callback (GtkWidget *widget, GFile *location, NautilusWindowPane *pane) { - NautilusNavigationWindowSlot *slot; + NautilusWindowSlot *slot; int i; - slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (pane->active_slot); + slot = pane->active_slot; /* check whether we already visited the target location */ i = bookmark_list_get_uri_index (slot->back_list, location); @@ -694,8 +693,7 @@ nautilus_window_pane_show (NautilusWindowPane *pane) void nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane) { - NautilusNavigationWindowSlot *navigation_slot; - NautilusWindowSlot *slot; + NautilusWindowSlot *slot, *active_slot; slot = pane->active_slot; @@ -717,11 +715,11 @@ nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane) nautilus_window_update_up_button (pane->window); /* Check if the back and forward buttons need enabling or disabling. */ - navigation_slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (pane->window->details->active_pane->active_slot); + active_slot = pane->window->details->active_pane->active_slot; nautilus_navigation_window_allow_back (NAUTILUS_NAVIGATION_WINDOW (pane->window), - navigation_slot->back_list != NULL); + active_slot->back_list != NULL); nautilus_navigation_window_allow_forward (NAUTILUS_NAVIGATION_WINDOW (pane->window), - navigation_slot->forward_list != NULL); + active_slot->forward_list != NULL); } } diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 598916be0..5a91de0f1 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -22,7 +22,6 @@ Author: Christian Neumair <cneumair@gnome.org> */ #include "nautilus-window-slot.h" -#include "nautilus-navigation-window-slot.h" #include "nautilus-desktop-window.h" #include "nautilus-window-private.h" @@ -51,6 +50,8 @@ query_editor_changed_callback (NautilusSearchBar *bar, { NautilusDirectory *directory; + g_assert (NAUTILUS_IS_FILE (slot->viewed_file)); + directory = nautilus_directory_get_for_file (slot->viewed_file); g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory)); @@ -66,23 +67,34 @@ query_editor_changed_callback (NautilusSearchBar *bar, static void real_update_query_editor (NautilusWindowSlot *slot) { - GtkWidget *query_editor; - NautilusQuery *query; NautilusDirectory *directory; NautilusSearchDirectory *search_directory; + NautilusQuery *query; + GtkWidget *query_editor; - directory = nautilus_directory_get (slot->location); + g_assert (slot->pane->window != NULL); + + query_editor = NULL; + directory = nautilus_directory_get (slot->location); if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) { search_directory = NAUTILUS_SEARCH_DIRECTORY (directory); - query_editor = nautilus_query_editor_new (nautilus_search_directory_is_saved_search (search_directory), - nautilus_search_directory_is_indexed (search_directory)); + if (nautilus_search_directory_is_saved_search (search_directory)) { + query_editor = nautilus_query_editor_new (TRUE, + nautilus_search_directory_is_indexed (search_directory)); + } else { + query_editor = nautilus_query_editor_new_with_bar (FALSE, + nautilus_search_directory_is_indexed (search_directory), + slot->pane->window->details->active_pane->active_slot == slot, + NAUTILUS_SEARCH_BAR (slot->pane->search_bar), + slot); + } + } - slot->query_editor = NAUTILUS_QUERY_EDITOR (query_editor); + slot->query_editor = NAUTILUS_QUERY_EDITOR (query_editor); - nautilus_window_slot_add_extra_location_widget (slot, query_editor); - gtk_widget_show (query_editor); + if (query_editor != NULL) { g_signal_connect_object (query_editor, "changed", G_CALLBACK (query_editor_changed_callback), slot, 0); @@ -94,19 +106,31 @@ real_update_query_editor (NautilusWindowSlot *slot) } else { nautilus_query_editor_set_default_query (NAUTILUS_QUERY_EDITOR (query_editor)); } - } + + nautilus_window_slot_add_extra_location_widget (slot, query_editor); + gtk_widget_show (query_editor); + nautilus_query_editor_grab_focus (NAUTILUS_QUERY_EDITOR (query_editor)); + } nautilus_directory_unref (directory); } - static void real_active (NautilusWindowSlot *slot) { NautilusWindow *window; + NautilusWindowPane *pane; + int page_num; window = slot->pane->window; + pane = slot->pane; + page_num = gtk_notebook_page_num (GTK_NOTEBOOK (pane->notebook), + slot->content_box); + g_assert (page_num >= 0); + + gtk_notebook_set_current_page (GTK_NOTEBOOK (pane->notebook), page_num); + /* sync window to new slot */ nautilus_window_sync_status (window); nautilus_window_sync_allow_stop (window, slot); @@ -170,6 +194,9 @@ nautilus_window_slot_dispose (GObject *object) slot = NAUTILUS_WINDOW_SLOT (object); + nautilus_window_slot_clear_forward_list (slot); + nautilus_window_slot_clear_back_list (slot); + if (slot->content_view) { widget = nautilus_view_get_widget (slot->content_view); gtk_widget_destroy (widget); @@ -222,7 +249,6 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *class) { class->active = real_active; class->inactive = real_inactive; - class->update_query_editor = real_update_query_editor; signals[ACTIVE] = g_signal_new ("active", @@ -464,8 +490,7 @@ nautilus_window_slot_update_query_editor (NautilusWindowSlot *slot) g_assert (slot->query_editor == NULL); } - EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot, - update_query_editor, (slot)); + real_update_query_editor (slot); eel_add_weak_pointer (&slot->query_editor); } @@ -583,3 +608,64 @@ nautilus_window_slot_go_up (NautilusWindowSlot *slot, g_object_unref (parent); g_list_free_full (selection, g_object_unref); } + +void +nautilus_window_slot_clear_forward_list (NautilusWindowSlot *slot) +{ + g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); + + g_list_free_full (slot->forward_list, g_object_unref); + slot->forward_list = NULL; +} + +void +nautilus_window_slot_clear_back_list (NautilusWindowSlot *slot) +{ + g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); + + g_list_free_full (slot->back_list, g_object_unref); + slot->back_list = NULL; +} + +gboolean +nautilus_window_slot_should_close_with_mount (NautilusWindowSlot *slot, + GMount *mount) +{ + NautilusBookmark *bookmark; + GFile *mount_location, *bookmark_location; + GList *l; + gboolean close_with_mount; + + if (slot->pane->window->details->initiated_unmount) { + return FALSE; + } + + mount_location = g_mount_get_root (mount); + + close_with_mount = TRUE; + + for (l = slot->back_list; l != NULL; l = l->next) { + bookmark = NAUTILUS_BOOKMARK (l->data); + + bookmark_location = nautilus_bookmark_get_location (bookmark); + close_with_mount &= g_file_has_prefix (bookmark_location, mount_location) || + g_file_equal (bookmark_location, mount_location); + g_object_unref (bookmark_location); + + if (!close_with_mount) { + break; + } + } + + close_with_mount &= g_file_has_prefix (NAUTILUS_WINDOW_SLOT (slot)->location, mount_location) || + g_file_equal (NAUTILUS_WINDOW_SLOT (slot)->location, mount_location); + + /* we could also consider the forward list here, but since the “go home” request + * in nautilus-window-manager-views.c:mount_removed_callback() would discard those + * anyway, we don't consider them. + */ + + g_object_unref (mount_location); + + return close_with_mount; +} diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h index 66d9b88eb..7546ca13d 100644 --- a/src/nautilus-window-slot.h +++ b/src/nautilus-window-slot.h @@ -52,8 +52,6 @@ struct NautilusWindowSlotClass { /* wrapped NautilusWindowInfo signals, for overloading */ void (* active) (NautilusWindowSlot *slot); void (* inactive) (NautilusWindowSlot *slot); - - void (* update_query_editor) (NautilusWindowSlot *slot); }; /* Each NautilusWindowSlot corresponds to @@ -113,6 +111,11 @@ struct NautilusWindowSlot { GCancellable *find_mount_cancellable; gboolean visible; + + /* Back/Forward chain, and history list. + * The data in these lists are NautilusBookmark pointers. + */ + GList *back_list, *forward_list; }; GType nautilus_window_slot_get_type (void); @@ -179,4 +182,10 @@ char * nautilus_window_slot_get_current_uri (NautilusWindowSlot * NautilusWindow * nautilus_window_slot_get_window (NautilusWindowSlot *slot); void nautilus_window_slot_make_hosting_pane_active (NautilusWindowSlot *slot); +gboolean nautilus_window_slot_should_close_with_mount (NautilusWindowSlot *slot, + GMount *mount); + +void nautilus_window_slot_clear_forward_list (NautilusWindowSlot *slot); +void nautilus_window_slot_clear_back_list (NautilusWindowSlot *slot); + #endif /* NAUTILUS_WINDOW_SLOT_H */ diff --git a/src/nautilus-window.c b/src/nautilus-window.c index ad2fef7c7..f3f0e8f19 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -35,7 +35,6 @@ #include "nautilus-application.h" #include "nautilus-bookmarks-window.h" #include "nautilus-mime-actions.h" -#include "nautilus-navigation-window-slot.h" #include "nautilus-search-bar.h" #include "nautilus-src-marshal.h" #include "nautilus-view-factory.h" @@ -1428,7 +1427,7 @@ nautilus_window_get_slot_for_view (NautilusWindow *window, void nautilus_forget_history (void) { - NautilusNavigationWindowSlot *navigation_slot; + NautilusWindowSlot *slot; GList *window_node, *l, *walk; NautilusApplication *app; @@ -1449,10 +1448,10 @@ nautilus_forget_history (void) 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; + slot = l->data; - nautilus_navigation_window_slot_clear_back_list (navigation_slot); - nautilus_navigation_window_slot_clear_forward_list (navigation_slot); + nautilus_window_slot_clear_back_list (slot); + nautilus_window_slot_clear_forward_list (slot); } } |