← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/appmenu-gtk/timer-per-toplevel2 into lp:appmenu-gtk

 

Cody Russell has proposed merging lp:~bratsche/appmenu-gtk/timer-per-toplevel2 into lp:appmenu-gtk.

Requested reviews:
  Canonical Desktop Experience Team (canonical-dx-team)

-- 
https://code.launchpad.net/~bratsche/appmenu-gtk/timer-per-toplevel2/+merge/29052
Your team ayatana-commits is subscribed to branch lp:appmenu-gtk.
=== modified file 'src/bridge.c'
--- src/bridge.c	2010-06-29 16:08:41 +0000
+++ src/bridge.c	2010-07-02 05:11:22 +0000
@@ -96,7 +96,7 @@
 
 G_DEFINE_DYNAMIC_TYPE(AppMenuBridge, app_menu_bridge, UBUNTU_TYPE_MENU_PROXY)
 
-static guint rebuild_id = 0;
+static GHashTable *rebuild_ids = NULL;
 
 static void
 app_menu_bridge_setup_proxy (AppMenuBridge *bridge)
@@ -599,6 +599,13 @@
 {
   rebuild_window_items (data->bridge,
                         data->widget);
+
+  g_hash_table_remove (rebuild_ids, data->widget);
+  if (g_hash_table_size (rebuild_ids) == 0)
+    {
+      g_hash_table_destroy (rebuild_ids);
+    }
+
   g_free (data);
 
   return FALSE;
@@ -608,19 +615,34 @@
 rebuild (AppMenuBridge *bridge,
          GtkWidget     *toplevel)
 {
-  if (rebuild_id > 0)
+  guint id = 0;
+
+  if (rebuild_ids != NULL)
     {
-      g_source_remove (rebuild_id);
-      rebuild_id = 0;
+      id = GPOINTER_TO_UINT (g_hash_table_lookup (rebuild_ids, toplevel));
+
+      if (id > 0)
+        {
+          g_source_remove (id);
+          g_hash_table_remove (rebuild_ids, toplevel);
+          id = 0;
+        }
     }
 
   RebuildData *data = g_new0 (RebuildData, 1);
   data->bridge = bridge;
   data->widget = toplevel;
 
-  rebuild_id = g_timeout_add (500,
-                              (GSourceFunc)do_rebuild,
-                              data);
+  id = g_timeout_add (500,
+                      (GSourceFunc)do_rebuild,
+                      data);
+
+  if (rebuild_ids == NULL)
+    {
+      rebuild_ids = g_hash_table_new (g_direct_hash, g_direct_equal);
+    }
+
+  g_hash_table_insert (rebuild_ids, GUINT_TO_POINTER (id), toplevel);
 }
 
 static void


Follow ups