Am Montag, den 19.09.2005, 15:06 +0200 schrieb Alexander Larsson: > On Wed, 2005-09-07 at 23:55 +0200, Christian Neumair wrote: > > Also covered by bug 116217 [1]. Since users typically set this once, I > > think it would be quiet nice to give instant feedback to show them what > > they actually changed. > > > > [1] http://bugzilla.gnome.org/show_bug.cgi?id=116217 > > > - > - /* We don't invalidate the files in desktop, since they are always > - up to date. (And we don't ever want to mark them invalid.) */ > + nautilus_directory_force_reload_internal (NAUTILUS_DIRECTORY (desktop), > + nautilus_file_get_all_attributes ()); > } > > Why did you change this? I don't believe this should be needed, and it > worries me. I don't remember all the details about > NautilusDesktopIconFile exactly, but I don't think invalidating > attributes for them are right at all, and i'm not sure they'll ever be > validated again. Good question. I blindly did it, because I thought that the desktop directory would only pick up the removal of the old files from the desktop if all of them are invalidated. I was wrong. The attached patch seems to work as well, although I don't fully understand how exactly all the old files are removed from the desktop. The new ones are correctly added of course, because the "files-added" signal is proxied. -- Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-desktop-directory.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-directory.c,v retrieving revision 1.3 diff -u -p -r1.3 nautilus-desktop-directory.c --- libnautilus-private/nautilus-desktop-directory.c 11 Oct 2004 11:49:00 -0000 1.3 +++ libnautilus-private/nautilus-desktop-directory.c 20 Sep 2005 16:47:28 -0000 @@ -31,8 +31,10 @@ #include "nautilus-file.h" #include "nautilus-file-private.h" #include "nautilus-file-utilities.h" +#include "nautilus-global-preferences.h" #include <eel/eel-glib-extensions.h> #include <libgnomevfs/gnome-vfs-utils.h> +#include <gtk/gtkmain.h> #include <gtk/gtksignal.h> #include <libgnome/gnome-macros.h> @@ -63,6 +65,7 @@ typedef struct { NautilusFileAttributes monitor_attributes; } MergedMonitor; +static void desktop_directory_changed_callback (gpointer data); GNOME_CLASS_BOILERPLATE (NautilusDesktopDirectory, nautilus_desktop_directory, NautilusDirectory, NAUTILUS_TYPE_DIRECTORY) @@ -424,6 +424,10 @@ desktop_finalize (GObject *object) g_hash_table_destroy (desktop->details->callbacks); g_hash_table_destroy (desktop->details->monitors); g_free (desktop->details); + + eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, + desktop_directory_changed_callback, + desktop); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -452,38 +456,64 @@ forward_files_changed_cover (NautilusDir nautilus_directory_emit_files_changed (NAUTILUS_DIRECTORY (callback_data), files); } - static void -nautilus_desktop_directory_instance_init (NautilusDesktopDirectory *desktop) +update_desktop_directory (NautilusDesktopDirectory *desktop) { char *desktop_path; char *desktop_uri; NautilusDirectory *real_directory; - - desktop->details = g_new0 (NautilusDesktopDirectoryDetails, 1); + + real_directory = desktop->details->real_directory; + if (real_directory != NULL) { + g_hash_table_foreach_remove (desktop->details->callbacks, (GHRFunc) gtk_true, NULL); + g_hash_table_foreach_remove (desktop->details->monitors, (GHRFunc) gtk_true, NULL); + + g_signal_handlers_disconnect_by_func (real_directory, done_loading_callback, desktop); + g_signal_handlers_disconnect_by_func (real_directory, forward_files_added_cover, desktop); + g_signal_handlers_disconnect_by_func (real_directory, forward_files_changed_cover, desktop); + + nautilus_directory_unref (real_directory); + } desktop_path = nautilus_get_desktop_directory (); desktop_uri = gnome_vfs_get_uri_from_local_path (desktop_path); - desktop->details->real_directory = nautilus_directory_get (desktop_uri); + real_directory = nautilus_directory_get (desktop_uri); g_free (desktop_uri); g_free (desktop_path); - desktop->details->callbacks = g_hash_table_new_full - (merged_callback_hash, merged_callback_equal, - NULL, (GDestroyNotify)merged_callback_destroy); - desktop->details->monitors = g_hash_table_new_full (NULL, NULL, - NULL, (GDestroyNotify)merged_monitor_destroy); - - real_directory = desktop->details->real_directory; - g_signal_connect_object (real_directory, "done_loading", G_CALLBACK (done_loading_callback), desktop, 0); - g_signal_connect_object (real_directory, "files_added", G_CALLBACK (forward_files_added_cover), desktop, 0); g_signal_connect_object (real_directory, "files_changed", G_CALLBACK (forward_files_changed_cover), desktop, 0); + desktop->details->real_directory = real_directory; +} + +static void +desktop_directory_changed_callback (gpointer data) +{ + update_desktop_directory (NAUTILUS_DESKTOP_DIRECTORY (data)); + nautilus_directory_force_reload (NAUTILUS_DIRECTORY (data)); +} + +static void +nautilus_desktop_directory_instance_init (NautilusDesktopDirectory *desktop) +{ + desktop->details = g_new0 (NautilusDesktopDirectoryDetails, 1); + + desktop->details->callbacks = g_hash_table_new_full + (merged_callback_hash, merged_callback_equal, + NULL, (GDestroyNotify)merged_callback_destroy); + desktop->details->monitors = g_hash_table_new_full (NULL, NULL, + NULL, (GDestroyNotify)merged_monitor_destroy); + + update_desktop_directory (NAUTILUS_DESKTOP_DIRECTORY (desktop)); + + eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, + desktop_directory_changed_callback, + desktop); } static void
Attachment:
signature.asc
Description: This is a digitally signed message part