diff options
author | Ted Gould <ted@gould.cx> | 2010-07-20 12:27:03 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-07-20 12:27:03 -0500 |
commit | fe213d96ed2ff025c1c60cbffb4e0dd562d1c154 (patch) | |
tree | 0b26219e5c811478b44b55d84ea20ec674e5fe89 /libdbusmenu-glib/server.c | |
parent | 8c9e1febb85e0bd28cfc175cd015a4a1934baf55 (diff) | |
download | libdbusmenu-fe213d96ed2ff025c1c60cbffb4e0dd562d1c154.tar.gz libdbusmenu-fe213d96ed2ff025c1c60cbffb4e0dd562d1c154.tar.bz2 libdbusmenu-fe213d96ed2ff025c1c60cbffb4e0dd562d1c154.zip |
Adding in an idle function that queues the updates.
Diffstat (limited to 'libdbusmenu-glib/server.c')
-rw-r--r-- | libdbusmenu-glib/server.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7a39f1e..4afd0c2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -60,6 +60,7 @@ struct _DbusmenuServerPrivate DbusmenuMenuitem * root; gchar * dbusobject; gint layout_revision; + guint layout_idle; }; #define DBUSMENU_SERVER_GET_PRIVATE(o) \ @@ -201,6 +202,7 @@ dbusmenu_server_init (DbusmenuServer *self) priv->root = NULL; priv->dbusobject = NULL; priv->layout_revision = 1; + priv->layout_idle = 0; return; } @@ -210,6 +212,10 @@ dbusmenu_server_dispose (GObject *object) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(object); + if (priv->layout_idle != 0) { + g_source_remove(priv->layout_idle); + } + if (priv->root != NULL) { dbusmenu_menuitem_foreach(priv->root, menuitem_signals_remove, object); g_object_unref(priv->root); @@ -306,13 +312,32 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) return; } +/* Handle actually signalling in the idle loop. This way we collect all + the updates. */ +static gboolean +layout_update_idle (gpointer user_data) +{ + DbusmenuServer * server = DBUSMENU_SERVER(user_data); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + + priv->layout_idle = 0; + + return FALSE; +} + /* Signals that the layout has been updated */ static void layout_update_signal (DbusmenuServer * server) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + + if (priv->layout_idle == 0) { + priv->layout_idle = g_idle_add(layout_update_idle, server); + } + return; } |