[PATCH] close window when moving file to trash



Reported as bug 319537 [1].

The attached patch makes Nautilus close all windows displaying a
location that was moved to trash. This is neccessary for making it
consistent with the trash applet. When the applet moves a location to
trash, file monitors will just receive a delete event for the source
location, and the file_is_gone check will pass. When Nautilus moves a
file to the trash, nautilus_file_changes_queue_file_moved is invoked,
but the file is not marked gone, so the windows displaying it will not
be closed.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=319537

-- 
Christian Neumair <chris gnome-de org>
Index: src/nautilus-window-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-private.h,v
retrieving revision 1.111
diff -u -p -r1.111 nautilus-window-private.h
--- src/nautilus-window-private.h	12 Dec 2005 16:59:11 -0000	1.111
+++ src/nautilus-window-private.h	2 Mar 2006 14:29:11 -0000
@@ -72,6 +72,7 @@ struct NautilusWindowDetails
 	char *title;
 	NautilusFile *viewed_file;
         gboolean viewed_file_seen;
+	gboolean viewed_file_in_trash;
 	gboolean allow_stop;
 
         /* New location. */
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.363
diff -u -p -r1.363 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	27 Feb 2006 14:52:58 -0000	1.363
+++ src/nautilus-window-manage-views.c	2 Mar 2006 14:29:12 -0000
@@ -296,6 +296,7 @@ viewed_file_changed_callback (NautilusFi
                               NautilusWindow *window)
 {
         char *new_location;
+	gboolean is_in_trash, was_in_trash;
 
         g_assert (NAUTILUS_IS_FILE (file));
 	g_assert (NAUTILUS_IS_WINDOW (window));
@@ -305,8 +306,12 @@ viewed_file_changed_callback (NautilusFi
                 window->details->viewed_file_seen = TRUE;
         }
 
-	/* Close window if the file it's viewing has been deleted. */
-	if (nautilus_file_is_gone (file)) {
+	was_in_trash = window->details->viewed_file_in_trash;
+
+	window->details->viewed_file_in_trash = is_in_trash = nautilus_file_is_in_trash (file);
+
+	/* Close window if the file it's viewing has been deleted or moved to trash. */
+	if (nautilus_file_is_gone (file) || (is_in_trash && !was_in_trash)) {
                 /* Don't close the window in the case where the
                  * file was never seen in the first place.
                  */
@@ -1196,6 +1201,7 @@ update_for_new_location (NautilusWindow 
         file = nautilus_file_get (window->details->location);
         nautilus_window_set_viewed_file (window, file);
         window->details->viewed_file_seen = !nautilus_file_is_not_yet_confirmed (file);
+        window->details->viewed_file_in_trash = nautilus_file_is_in_trash (file);
         nautilus_file_monitor_add (file, &window->details->viewed_file, 0);
         g_signal_connect_object (file, "changed",
                                  G_CALLBACK (viewed_file_changed_callback), window, 0);

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]