diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2011-09-29 01:30:09 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2011-10-17 10:02:48 -0400 |
commit | f7429d0c6793a2f6ad1d19ebcd928fba5f61ff52 (patch) | |
tree | 7395d38382e187b274fd5bf2e47b80194b30fdf9 | |
parent | f28821eb53b292e95cfde21a7e870f6178d4d78b (diff) | |
download | nautilus-f7429d0c6793a2f6ad1d19ebcd928fba5f61ff52.tar.gz |
all: remove initiated_unmount logic from NautilusWindow
We don't really need this, and it makes the behavior way less
convoluted.
Now we always try to close the current slot on mount remove, except when
it would be the last window at all to be closed.
-rw-r--r-- | src/nautilus-application.c | 33 | ||||
-rw-r--r-- | src/nautilus-places-sidebar.c | 10 | ||||
-rw-r--r-- | src/nautilus-view.c | 18 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 4 |
4 files changed, 10 insertions, 55 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 506de19cb..b72d980c6 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -604,18 +604,6 @@ mount_added_callback (GVolumeMonitor *monitor, } } -static NautilusWindowSlot * -get_first_navigation_slot (GList *slot_list) -{ - GList *l; - - for (l = slot_list; l != NULL; l = l->next) { - 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 @@ -631,12 +619,12 @@ mount_removed_callback (GVolumeMonitor *monitor, NautilusWindowSlot *slot; NautilusWindowSlot *force_no_close_slot; GFile *root, *computer; - gboolean unclosed_slot; gchar *uri; + gint n_slots; close_list = NULL; force_no_close_slot = NULL; - unclosed_slot = FALSE; + n_slots = 0; /* Check and see if any of the open windows are displaying contents from the unmounted mount */ window_list = gtk_application_get_windows (GTK_APPLICATION (application)); @@ -659,20 +647,20 @@ mount_removed_callback (GVolumeMonitor *monitor, pane = (NautilusWindowPane*) lp->data; for (l = pane->slots; l != NULL; l = l->next) { slot = l->data; - close_list = g_list_prepend (close_list, slot); - if (!nautilus_window_slot_should_close_with_mount (slot, mount)) { - /* We'll be redirecting this, not closing */ - unclosed_slot = TRUE; + n_slots++; + if (nautilus_window_slot_should_close_with_mount (slot, mount)) { + close_list = g_list_prepend (close_list, slot); } } /* for all slots */ } /* for all panes */ } } - if (nautilus_application_desktop_windows == NULL && - !unclosed_slot) { + if ((nautilus_application_desktop_windows == NULL) && + (close_list != NULL) && + (g_list_length (close_list) == n_slots)) { /* We are trying to close all open slots. Keep one navigation slot open. */ - force_no_close_slot = get_first_navigation_slot (close_list); + force_no_close_slot = close_list->data; } /* Handle the windows in the close list. */ @@ -680,8 +668,7 @@ mount_removed_callback (GVolumeMonitor *monitor, slot = node->data; window = slot->pane->window; - if (nautilus_window_slot_should_close_with_mount (slot, mount) && - slot != force_no_close_slot) { + if (slot != force_no_close_slot) { nautilus_window_pane_slot_close (slot->pane, slot); } else { computer = g_file_new_for_path (g_get_home_dir ()); diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c index 33b9086cd..81aa9ec57 100644 --- a/src/nautilus-places-sidebar.c +++ b/src/nautilus-places-sidebar.c @@ -2046,7 +2046,6 @@ unmount_done (gpointer data) NautilusWindow *window; window = data; - nautilus_window_set_initiated_unmount (window, FALSE); g_object_unref (window); } @@ -2055,7 +2054,6 @@ do_unmount (GMount *mount, NautilusPlacesSidebar *sidebar) { if (mount != NULL) { - nautilus_window_set_initiated_unmount (sidebar->window, TRUE); nautilus_file_operations_unmount_mount_full (NULL, mount, FALSE, TRUE, unmount_done, g_object_ref (sidebar->window)); @@ -2100,7 +2098,6 @@ drive_eject_cb (GObject *source_object, char *name; window = user_data; - nautilus_window_set_initiated_unmount (window, FALSE); g_object_unref (window); error = NULL; @@ -2129,7 +2126,6 @@ volume_eject_cb (GObject *source_object, char *name; window = user_data; - nautilus_window_set_initiated_unmount (window, FALSE); g_object_unref (window); error = NULL; @@ -2158,7 +2154,6 @@ mount_eject_cb (GObject *source_object, char *name; window = user_data; - nautilus_window_set_initiated_unmount (window, FALSE); g_object_unref (window); error = NULL; @@ -2186,15 +2181,12 @@ do_eject (GMount *mount, mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar)))); if (mount != NULL) { - nautilus_window_set_initiated_unmount (sidebar->window, TRUE); g_mount_eject_with_operation (mount, 0, mount_op, NULL, mount_eject_cb, g_object_ref (sidebar->window)); } else if (volume != NULL) { - nautilus_window_set_initiated_unmount (sidebar->window, TRUE); g_volume_eject_with_operation (volume, 0, mount_op, NULL, volume_eject_cb, g_object_ref (sidebar->window)); } else if (drive != NULL) { - nautilus_window_set_initiated_unmount (sidebar->window, TRUE); g_drive_eject_with_operation (drive, 0, mount_op, NULL, drive_eject_cb, g_object_ref (sidebar->window)); } @@ -2402,7 +2394,6 @@ drive_stop_cb (GObject *source_object, char *name; window = user_data; - nautilus_window_set_initiated_unmount (window, FALSE); g_object_unref (window); error = NULL; @@ -2439,7 +2430,6 @@ stop_shortcut_cb (GtkMenuItem *item, GMountOperation *mount_op; mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar)))); - nautilus_window_set_initiated_unmount (sidebar->window, TRUE); g_drive_stop (drive, G_MOUNT_UNMOUNT_NONE, mount_op, NULL, drive_stop_cb, g_object_ref (sidebar->window)); g_object_unref (mount_op); diff --git a/src/nautilus-view.c b/src/nautilus-view.c index 295b1db00..dca1413ac 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -6140,16 +6140,6 @@ file_mount_callback (NautilusFile *file, } static void -nautilus_view_set_initiated_unmount (NautilusView *view, - gboolean initiated_unmount) -{ - if (view->details->window != NULL) { - nautilus_window_set_initiated_unmount(view->details->window, - initiated_unmount); - } -} - -static void file_unmount_callback (NautilusFile *file, GFile *result_location, GError *error, @@ -6158,7 +6148,6 @@ file_unmount_callback (NautilusFile *file, NautilusView *view; view = NAUTILUS_VIEW (callback_data); - nautilus_view_set_initiated_unmount (view, FALSE); g_object_unref (view); if (error != NULL && @@ -6179,7 +6168,6 @@ file_eject_callback (NautilusFile *file, NautilusView *view; view = NAUTILUS_VIEW (callback_data); - nautilus_view_set_initiated_unmount (view, FALSE); g_object_unref (view); if (error != NULL && @@ -6249,7 +6237,6 @@ action_unmount_volume_callback (GtkAction *action, if (nautilus_file_can_unmount (file)) { GMountOperation *mount_op; mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view)); - nautilus_view_set_initiated_unmount (view, TRUE); nautilus_file_unmount (file, mount_op, NULL, file_unmount_callback, g_object_ref (view)); g_object_unref (mount_op); @@ -6275,7 +6262,6 @@ action_eject_volume_callback (GtkAction *action, if (nautilus_file_can_eject (file)) { GMountOperation *mount_op; mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view)); - nautilus_view_set_initiated_unmount (view, TRUE); nautilus_file_eject (file, mount_op, NULL, file_eject_callback, g_object_ref (view)); g_object_unref (mount_op); @@ -6408,7 +6394,6 @@ action_self_unmount_volume_callback (GtkAction *action, } mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view)); - nautilus_view_set_initiated_unmount (view, TRUE); nautilus_file_unmount (file, mount_op, NULL, file_unmount_callback, g_object_ref (view)); g_object_unref (mount_op); } @@ -6429,7 +6414,6 @@ action_self_eject_volume_callback (GtkAction *action, } mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view)); - nautilus_view_set_initiated_unmount (view, TRUE); nautilus_file_eject (file, mount_op, NULL, file_eject_callback, g_object_ref (view)); g_object_unref (mount_op); } @@ -6529,7 +6513,6 @@ action_location_unmount_volume_callback (GtkAction *action, } mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view)); - nautilus_view_set_initiated_unmount (view, TRUE); nautilus_file_unmount (file, mount_op, NULL, file_unmount_callback, g_object_ref (view)); g_object_unref (mount_op); @@ -6551,7 +6534,6 @@ action_location_eject_volume_callback (GtkAction *action, } mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view)); - nautilus_view_set_initiated_unmount (view, TRUE); nautilus_file_eject (file, mount_op, NULL, file_eject_callback, g_object_ref (view)); g_object_unref (mount_op); diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index b47071af6..a604441b0 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -745,10 +745,6 @@ nautilus_window_slot_should_close_with_mount (NautilusWindowSlot *slot, GFile *mount_location; gboolean close_with_mount; - if (slot->pane->window->details->initiated_unmount) { - return FALSE; - } - mount_location = g_mount_get_root (mount); close_with_mount = g_file_has_prefix (NAUTILUS_WINDOW_SLOT (slot)->location, mount_location) || |