← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/appmenu-gtk/timing into lp:appmenu-gtk

 

Cody Russell has proposed merging lp:~bratsche/appmenu-gtk/timing into lp:appmenu-gtk.

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

-- 
https://code.launchpad.net/~bratsche/appmenu-gtk/timing/+merge/28797
Your team ayatana-commits is subscribed to branch lp:appmenu-gtk.
=== modified file 'src/bridge.c'
--- src/bridge.c	2010-06-28 20:42:21 +0000
+++ src/bridge.c	2010-06-29 20:43:22 +0000
@@ -60,6 +60,8 @@
                                             UbuntuMenuProxy   *proxy);
 static void     rebuild_window_items       (AppMenuBridge     *bridge,
                                             GtkWidget         *toplevel);
+static void     rebuild                    (AppMenuBridge     *bridge,
+                                            GtkWidget         *toplevel);
 
 typedef struct _AppWindowContext AppWindowContext;
 
@@ -94,6 +96,8 @@
 
 G_DEFINE_DYNAMIC_TYPE(AppMenuBridge, app_menu_bridge, UBUNTU_TYPE_MENU_PROXY)
 
+static guint rebuild_id = 0;
+
 static void
 app_menu_bridge_setup_proxy (AppMenuBridge *bridge)
 {
@@ -417,7 +421,7 @@
 
       if (toplevel == window)
         {
-          rebuild_window_items (context->bridge, window);
+          rebuild (context->bridge, window);
         }
 
       /* We only care about this once, so let's disconnect now. */
@@ -585,6 +589,40 @@
     }
 }
 
+typedef struct _RebuildData {
+  AppMenuBridge *bridge;
+  GtkWidget     *widget;
+} RebuildData;
+
+static gboolean
+do_rebuild (RebuildData *data)
+{
+  rebuild_window_items (data->bridge,
+                        data->widget);
+  g_free (data);
+
+  return FALSE;
+}
+
+static void
+rebuild (AppMenuBridge *bridge,
+         GtkWidget     *toplevel)
+{
+  if (rebuild_id > 0)
+    {
+      g_source_remove (rebuild_id);
+      rebuild_id = 0;
+    }
+
+  RebuildData *data = g_new0 (RebuildData, 1);
+  data->bridge = bridge;
+  data->widget = toplevel;
+
+  rebuild_id = g_timeout_add (500,
+                              (GSourceFunc)do_rebuild,
+                              data);
+}
+
 static void
 rebuild_window_items (AppMenuBridge *bridge,
                       GtkWidget     *toplevel)
@@ -676,6 +714,8 @@
 
       dbusmenu_server_set_root (context->server, context->root);
     }
+
+  register_application_windows (bridge);
 }
 
 
@@ -687,8 +727,8 @@
 
   if (GTK_IS_WINDOW (widget))
     {
-      rebuild_window_items (bridge, widget);
-      register_application_windows (bridge);
+      rebuild (bridge, widget);
+      //register_application_windows (bridge);
 
       return;
     }
@@ -704,7 +744,7 @@
       GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
       AppMenuBridge *bridge = APP_MENU_BRIDGE (proxy);
 
-      rebuild_window_items (bridge, toplevel);
+      rebuild (bridge, toplevel);
     }
 }
 
@@ -719,7 +759,7 @@
 
       g_object_get (widget, "attach-widget", &attach, NULL);
 
-      rebuild_window_items (bridge, attach);
+      rebuild (bridge, attach);
     }
 }
 
@@ -775,7 +815,7 @@
         {
           toplevel = gtk_widget_get_toplevel (attach);
 
-          rebuild_window_items (bridge, toplevel);
+          rebuild (bridge, toplevel);
         }
     }
 


Follow ups