nautilus r14663 - in trunk: . src
- From: cneumair svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r14663 - in trunk: . src
- Date: Wed, 24 Sep 2008 18:08:17 +0000 (UTC)
Author: cneumair
Date: Wed Sep 24 18:08:17 2008
New Revision: 14663
URL: http://svn.gnome.org/viewvc/nautilus?rev=14663&view=rev
Log:
2008-09-24 Christian Neumair <cneumair gnome org>
* src/nautilus-application.c (count_slots_of_windows),
(get_first_navigation_slot), (mount_removed_callback):
* src/nautilus-navigation-window-slot.c
(nautilus_navigation_window_slot_should_close_with_mount):
* src/nautilus-navigation-window-slot.h:
When unmounting, close all slots that only displayed locations on the
mount. Never close all open slots, though.
Modified:
trunk/ChangeLog
trunk/src/nautilus-application.c
trunk/src/nautilus-navigation-window-slot.c
trunk/src/nautilus-navigation-window-slot.h
Modified: trunk/src/nautilus-application.c
==============================================================================
--- trunk/src/nautilus-application.c (original)
+++ trunk/src/nautilus-application.c Wed Sep 24 18:08:17 2008
@@ -50,6 +50,8 @@
#include "nautilus-main.h"
#include "nautilus-spatial-window.h"
#include "nautilus-navigation-window.h"
+#include "nautilus-window-slot.h"
+#include "nautilus-navigation-window-slot.h"
#include "nautilus-shell-interface.h"
#include "nautilus-shell.h"
#include "nautilus-window-bookmarks.h"
@@ -1446,6 +1448,40 @@
nautilus_autorun (mount, autorun_show_window, application);
}
+static inline int
+count_slots_of_windows (GList *window_list)
+{
+ NautilusWindow *window;
+ GList *slots, *l;
+ int count;
+
+ count = 0;
+
+ for (l = window_list; l != NULL; l = l->next) {
+ window = NAUTILUS_WINDOW (l->data);
+
+ slots = nautilus_window_get_slots (window);
+ count += g_list_length (slots);
+ g_list_free (slots);
+ }
+
+ return count;
+}
+
+static NautilusWindowSlot *
+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 NULL;
+}
+
/* Called whenever a mount is unmounted. Check and see if there are
* any windows open displaying contents on the mount. If there are,
* close them. It would also be cool to save open window and position
@@ -1461,9 +1497,11 @@
GList *window_list, *node, *close_list;
NautilusWindow *window;
NautilusWindowSlot *slot;
+ NautilusWindowSlot *force_no_close_slot;
GFile *root;
close_list = NULL;
+ force_no_close_slot = NULL;
/* Check and see if any of the open windows are displaying contents from the unmounted mount */
window_list = nautilus_application_get_window_list ();
@@ -1486,11 +1524,21 @@
}
}
+ if (nautilus_application_desktop_windows == NULL &&
+ g_list_length (close_list) != 0 &&
+ g_list_length (close_list) == count_slots_of_windows (window_list)) {
+ /* We are trying to close all open slots. Keep one navigation slot open. */
+ force_no_close_slot = get_first_navigation_slot (close_list);
+ }
+
/* Handle the windows in the close list. */
for (node = close_list; node != NULL; node = node->next) {
slot = node->data;
window = slot->window;
- if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
+
+ if (NAUTILUS_IS_SPATIAL_WINDOW (window) ||
+ (nautilus_navigation_window_slot_should_close_with_mount (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), mount) &&
+ slot != force_no_close_slot)) {
nautilus_window_slot_close (slot);
} else {
nautilus_window_slot_go_home (slot, FALSE);
Modified: trunk/src/nautilus-navigation-window-slot.c
==============================================================================
--- trunk/src/nautilus-navigation-window-slot.c (original)
+++ trunk/src/nautilus-navigation-window-slot.c Wed Sep 24 18:08:17 2008
@@ -36,6 +36,43 @@
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;
+
+ 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_object_unref (bookmark_location);
+
+ if (!close_with_mount) {
+ break;
+ }
+ }
+
+ close_with_mount &= g_file_has_prefix (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)
{
Modified: trunk/src/nautilus-navigation-window-slot.h
==============================================================================
--- trunk/src/nautilus-navigation-window-slot.h (original)
+++ trunk/src/nautilus-navigation-window-slot.h Wed Sep 24 18:08:17 2008
@@ -66,6 +66,9 @@
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]