From 20ceebe17ffc956f59ce28834d528d436e66f796 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 15 Nov 2012 10:56:33 +0200 Subject: [directory-background] Use weak refs instead of EelBackground destroy signal i.e. don't connect to the destroy signal of EelBackground, in favor of g_object_weak_ref() and g_object_weak_unref() Though Nautilus removed code for setting non-desktop window backgrounds: http://git.gnome.org/browse/nautilus/commit/?id=c9be35b3ee6c468a9a102b317b82b8b639637d0f ..this is a tad similar: directory-background: don't user the 'destroy' signal of EelBackground http://git.gnome.org/browse/nautilus/commit/?id=fbb6b024128e3c35aeb1d74f8e287e8870c9999f&context=12 --- libcaja-private/caja-directory-background.c | 52 +++++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-directory-background.c b/libcaja-private/caja-directory-background.c index 21aea675..a445aab7 100644 --- a/libcaja-private/caja-directory-background.c +++ b/libcaja-private/caja-directory-background.c @@ -296,11 +296,12 @@ desktop_background_settings_notify_cb (GSettings *settings, gchar *key, gpointer } static void -desktop_background_destroyed_callback (EelBackground *background, void *georgeWBush) +desktop_background_weak_notify (gpointer data, + GObject *object) { g_signal_handlers_disconnect_by_func(mate_background_preferences, G_CALLBACK (desktop_background_settings_notify_cb), - background); + object); } static void @@ -309,10 +310,10 @@ caja_file_background_receive_settings_changes (EelBackground *background) g_signal_connect (mate_background_preferences, "changed", G_CALLBACK (desktop_background_settings_notify_cb), - background); + G_OBJECT (background)); - g_signal_connect (background, "destroy", - G_CALLBACK (desktop_background_destroyed_callback), NULL); + g_object_weak_ref (G_OBJECT (background), + desktop_background_weak_notify, NULL); } /* return true if the background is not in the default state */ @@ -563,9 +564,11 @@ background_reset_callback (EelBackground *background, /* handle the background destroyed signal */ static void -background_destroyed_callback (EelBackground *background, - CajaFile *file) +background_weak_notify (gpointer data, + GObject *background) { + CajaFile *file = CAJA_FILE (data); + g_signal_handlers_disconnect_by_func (file, G_CALLBACK (saved_settings_changed_callback), background); @@ -598,23 +601,26 @@ caja_connect_background_to_file_metadata (GtkWidget *widget, if (old_file != NULL) { g_assert (CAJA_IS_FILE (old_file)); - g_signal_handlers_disconnect_by_func - (background, - G_CALLBACK (background_changed_callback), old_file); - g_signal_handlers_disconnect_by_func - (background, - G_CALLBACK (background_destroyed_callback), old_file); - g_signal_handlers_disconnect_by_func - (background, - G_CALLBACK (background_reset_callback), old_file); - g_signal_handlers_disconnect_by_func - (old_file, - G_CALLBACK (saved_settings_changed_callback), background); + + g_signal_handlers_disconnect_by_func (background, + G_CALLBACK (background_changed_callback), + old_file); + + g_signal_handlers_disconnect_by_func (background, + G_CALLBACK (background_reset_callback), + old_file); + + g_object_weak_unref (G_OBJECT (background), background_weak_notify, old_file); + + g_signal_handlers_disconnect_by_func (old_file, + G_CALLBACK (saved_settings_changed_callback), + background); + caja_file_monitor_remove (old_file, background); + g_signal_handlers_disconnect_by_func (caja_preferences, caja_file_background_theme_changed, background); - } /* Attach the new directory. */ @@ -629,13 +635,15 @@ caja_connect_background_to_file_metadata (GtkWidget *widget, { g_signal_connect_object (background, "settings_changed", G_CALLBACK (background_changed_callback), file, 0); - g_signal_connect_object (background, "destroy", - G_CALLBACK (background_destroyed_callback), file, 0); + g_signal_connect_object (background, "reset", G_CALLBACK (background_reset_callback), file, 0); + g_signal_connect_object (file, "changed", G_CALLBACK (saved_settings_changed_callback), background, 0); + g_object_weak_ref (G_OBJECT (background), background_weak_notify, file); + /* arrange to receive file metadata */ caja_file_monitor_add (file, background, -- cgit v1.2.1