diff options
author | Ted Gould <ted@canonical.com> | 2009-09-21 15:39:26 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-09-21 15:39:26 -0500 |
commit | 644c59589fe88f3faaa8a4dcc7ad9c893cb51965 (patch) | |
tree | df5833615ab5f1a220237e065b1c9f8c489d34bf /libdbusmenu-glib/server.c | |
parent | a89f124d4b3d8210e3cbe36d4c508afa69a8fb71 (diff) | |
parent | 152034b24234c6d06649a48ae29643c5075c4bb1 (diff) | |
download | libdbusmenu-644c59589fe88f3faaa8a4dcc7ad9c893cb51965.tar.gz libdbusmenu-644c59589fe88f3faaa8a4dcc7ad9c893cb51965.tar.bz2 libdbusmenu-644c59589fe88f3faaa8a4dcc7ad9c893cb51965.zip |
Trying a revision ID
Diffstat (limited to 'libdbusmenu-glib/server.c')
-rw-r--r-- | libdbusmenu-glib/server.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index f4c1dcb..1ac1da6 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -47,6 +47,7 @@ struct _DbusmenuServerPrivate { DbusmenuMenuitem * root; gchar * dbusobject; + gint layout_revision; }; #define DBUSMENU_SERVER_GET_PRIVATE(o) \ @@ -142,6 +143,8 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) /** DbusmenuServer::layout-update: @arg0: The #DbusmenuServer emitting the signal. + @arg1: A revision number representing which revision the update + represents itself as. This signal is emitted any time the layout of the menuitems under this server is changed. @@ -151,8 +154,8 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuServerClass, layout_update), NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); g_object_class_install_property (object_class, PROP_DBUS_OBJECT, @@ -183,6 +186,7 @@ dbusmenu_server_init (DbusmenuServer *self) priv->root = NULL; priv->dbusobject = NULL; + priv->layout_revision = 1; return; } @@ -235,7 +239,8 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) } else { g_debug("Setting root node to NULL"); } - g_signal_emit(obj, signals[LAYOUT_UPDATE], 0, TRUE); + priv->layout_revision++; + g_signal_emit(obj, signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); break; case PROP_LAYOUT: /* Can't set this, fall through to error */ @@ -275,9 +280,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) GPtrArray * xmlarray = g_ptr_array_new(); if (priv->root == NULL) { /* g_debug("Getting layout without root node!"); */ - g_ptr_array_add(xmlarray, g_strdup("<menu />")); + g_ptr_array_add(xmlarray, g_strdup_printf("<menu revision=\"%d\" />", priv->layout_revision)); } else { - dbusmenu_menuitem_buildxml(priv->root, xmlarray); + dbusmenu_menuitem_buildxml(priv->root, xmlarray, priv->layout_revision); } g_ptr_array_add(xmlarray, NULL); @@ -310,7 +315,9 @@ menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint { menuitem_signals_create(child, server); /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, TRUE); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + priv->layout_revision++; + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); return; } @@ -319,14 +326,18 @@ menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, Dbu { menuitem_signals_remove(child, server); /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, TRUE); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + priv->layout_revision++; + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); return; } static void menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, guint oldpos, DbusmenuServer * server) { - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, TRUE); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + priv->layout_revision++; + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); return; } |