[Xfce4-commits] <garcon:jannis/global-monitoring> Stop monitoring properly. Start/stop monitoring for submenus as well.

Jannis Pohlmann noreply at xfce.org
Sun Sep 5 14:50:15 CEST 2010


Updating branch refs/heads/jannis/global-monitoring
         to 79683094e2414643c87ff889ba664c7f04536079 (commit)
       from e1eeab804d67b848eb6d529769a42b1d07f48944 (commit)

commit 79683094e2414643c87ff889ba664c7f04536079
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Mar 8 21:51:31 2010 +0100

    Stop monitoring properly. Start/stop monitoring for submenus as well.

 garcon/garcon-menu.c      |   28 +++++++++++++++++++++-------
 tests/test-display-menu.c |    4 ++--
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/garcon/garcon-menu.c b/garcon/garcon-menu.c
index 9ef7f38..579fc01 100644
--- a/garcon/garcon-menu.c
+++ b/garcon/garcon-menu.c
@@ -1668,8 +1668,6 @@ garcon_menu_start_monitoring (GarconMenu *menu)
       monitor = g_file_monitor (menu->priv->file, G_FILE_MONITOR_NONE, NULL, NULL);
       if (monitor != NULL)
         {
-          g_debug ("monitoring menu file %s", g_file_get_path (menu->priv->file));
-
           menu->priv->monitors = g_list_prepend (menu->priv->monitors, monitor);
           g_signal_connect_swapped (monitor, "changed", 
                                     G_CALLBACK (garcon_menu_file_changed), menu);
@@ -1680,8 +1678,6 @@ garcon_menu_start_monitoring (GarconMenu *menu)
           monitor = g_file_monitor (lp->data, G_FILE_MONITOR_NONE, NULL, NULL);
           if (monitor != NULL)
             {
-              g_debug ("monitoring merged file %s", g_file_get_path (lp->data));
-
               menu->priv->monitors = g_list_prepend (menu->priv->monitors, monitor);
               g_signal_connect_swapped (monitor, "changed", 
                                         G_CALLBACK (garcon_menu_merge_file_changed), menu);
@@ -1693,8 +1689,6 @@ garcon_menu_start_monitoring (GarconMenu *menu)
           monitor = g_file_monitor (lp->data, G_FILE_MONITOR_NONE, NULL, NULL);
           if (monitor != NULL)
             {
-              g_debug ("monitoring merged dir %s", g_file_get_path (lp->data));
-
               menu->priv->monitors = g_list_prepend (menu->priv->monitors, monitor);
               g_signal_connect_swapped (monitor, "changed",
                                         G_CALLBACK (garcon_menu_merge_dir_changed), menu);
@@ -1706,7 +1700,9 @@ garcon_menu_start_monitoring (GarconMenu *menu)
 
   /* TODO monitor desktop directories */
 
-  /* TODO recurse into child menus */
+  /* Recurse into child menus */
+  for (lp = menu->priv->submenus; lp != NULL; lp = lp->next)
+    garcon_menu_start_monitoring (lp->data);
 }
 
 
@@ -1759,5 +1755,23 @@ garcon_menu_merge_dir_changed (GarconMenu       *menu,
 static void
 garcon_menu_stop_monitoring (GarconMenu *menu)
 {
+  GList *lp;
+
   g_return_if_fail (GARCON_IS_MENU (menu));
+
+  /* Recurse into submenus */
+  for (lp = menu->priv->submenus; lp != NULL; lp = lp->next)
+    garcon_menu_stop_monitoring (lp->data);
+
+  /* Disconnect and destroy all monitors */
+  for (lp = menu->priv->monitors; lp != NULL; lp = lp->next)
+    {
+      g_signal_handlers_disconnect_matched (lp->data, G_SIGNAL_MATCH_DATA,
+                                            0, 0, NULL, NULL, menu);
+      g_object_unref (lp->data);
+    }
+
+  /* Free the monitor list */
+  g_list_free (menu->priv->monitors);
+  menu->priv->monitors = NULL;
 }
diff --git a/tests/test-display-menu.c b/tests/test-display-menu.c
index 53ab92e..13773fd 100644
--- a/tests/test-display-menu.c
+++ b/tests/test-display-menu.c
@@ -328,7 +328,7 @@ reload_menu (GError **error)
 
 
 static void
-rebuild_required (GarconMenu *menu)
+reload_required (GarconMenu *menu)
 {
   GError *error = NULL;
 
@@ -369,7 +369,7 @@ main (gint    argc,
       create_main_window ();
 
       /* be notified when a menu rebuild is required */
-      g_signal_connect (root, "rebuild-required", G_CALLBACK (rebuild_required), NULL);
+      g_signal_connect (root, "reload-required", G_CALLBACK (reload_required), NULL);
 
       /* Enter main loop */
       gtk_main ();



More information about the Xfce4-commits mailing list