[Xfce4-commits] <thunar:master> Also watch the bookmark files.

Nick Schermer noreply at xfce.org
Thu Nov 8 21:18:01 CET 2012


Updating branch refs/heads/master
         to 877b8ea466ab74b2386af92b1ffe707c97a749a2 (commit)
       from 574c7dfa31dbe24e0f907945e21f411408a69b03 (commit)

commit 877b8ea466ab74b2386af92b1ffe707c97a749a2
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Nov 8 21:03:42 2012 +0100

    Also watch the bookmark files.

 thunar/thunar-window.c |   47 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 211f6a5..a7db93d 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1883,14 +1883,9 @@ thunar_window_merge_custom_preferences (ThunarWindow *window)
 
 
 static void
-thunar_window_bookmark_changed (GFileMonitor      *monitor,
-                                GFile             *file,
-                                GFile             *other_file,
-                                GFileMonitorEvent  event_type,
-                                ThunarWindow      *window)
+thunar_window_bookmark_changed (ThunarWindow *window)
 {
   _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
-  _thunar_return_if_fail (window->bookmark_monitor == monitor);
 
   if (window->bookmark_reload_idle_id == 0)
     window->bookmark_reload_idle_id = g_idle_add (thunar_window_bookmark_merge, window);
@@ -1899,6 +1894,26 @@ thunar_window_bookmark_changed (GFileMonitor      *monitor,
 
 
 static void
+thunar_window_bookmark_release_file (gpointer data)
+{
+  ThunarFile *file = THUNAR_FILE (data);
+
+  /* stop watching */
+  thunar_file_unwatch (file);
+
+  /* disconnect changed and destroy signals */
+  g_signal_handlers_disconnect_matched (file,
+                                        G_SIGNAL_MATCH_FUNC, 0,
+                                        0, NULL,
+                                        G_CALLBACK (thunar_window_bookmark_changed),
+                                        NULL);
+
+  g_object_unref (file);
+}
+
+
+
+static void
 thunar_window_bookmark_merge_line (GFile       *file_path,
                                    const gchar *name,
                                    gint         line_num,
@@ -1944,7 +1959,16 @@ thunar_window_bookmark_merge_line (GFile       *file_path,
             name = thunar_file_get_display_name (file);
 
           action = gtk_action_new (unique_name, name, tooltip, GTK_STOCK_DIRECTORY);
-          g_object_set_data_full (G_OBJECT (action), I_("thunar-file"), file, g_object_unref);
+          g_object_set_data_full (G_OBJECT (action), I_("thunar-file"), file,
+                                  thunar_window_bookmark_release_file);
+
+          /* watch the file */
+          thunar_file_watch (file);
+
+          g_signal_connect_swapped (G_OBJECT (file), "destroy",
+                                    G_CALLBACK (thunar_window_bookmark_changed), window);
+          g_signal_connect_swapped (G_OBJECT (file), "changed",
+                                    G_CALLBACK (thunar_window_bookmark_changed), window);
         }
       else
         {
@@ -2012,7 +2036,10 @@ thunar_window_bookmark_merge (gpointer user_data)
 
   /* remove old actions */
   if (window->bookmark_items_actions_merge_id != 0)
-    gtk_ui_manager_remove_ui (window->ui_manager, window->bookmark_items_actions_merge_id);
+    {
+      gtk_ui_manager_remove_ui (window->ui_manager, window->bookmark_items_actions_merge_id);
+      gtk_ui_manager_ensure_update (window->ui_manager);
+    }
 
   /* drop old bookmarks action group */
   if (window->bookmark_action_group != NULL)
@@ -2031,8 +2058,8 @@ thunar_window_bookmark_merge (gpointer user_data)
       window->bookmark_monitor = g_file_monitor_file (window->bookmark_file, G_FILE_MONITOR_NONE, NULL, NULL);
       if (G_LIKELY (window->bookmark_monitor != NULL))
         {
-          g_signal_connect (window->bookmark_monitor, "changed",
-                            G_CALLBACK (thunar_window_bookmark_changed), window);
+          g_signal_connect_swapped (window->bookmark_monitor, "changed",
+                                    G_CALLBACK (thunar_window_bookmark_changed), window);
         }
     }
 


More information about the Xfce4-commits mailing list