diff options
author | Ted Gould <ted@gould.cx> | 2010-02-05 10:48:48 -0800 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-05 10:48:48 -0800 |
commit | 0f6f4c9cdd83d80dfd77fbedcc9a9468cb16eaae (patch) | |
tree | e81f340114a5f8de6ff97a4805ce6106e283945b /libdbusmenu-glib | |
parent | f3a0de2eec4a60c9ca7a70b4e0b78f2d148f36f5 (diff) | |
download | libdbusmenu-0f6f4c9cdd83d80dfd77fbedcc9a9468cb16eaae.tar.gz libdbusmenu-0f6f4c9cdd83d80dfd77fbedcc9a9468cb16eaae.tar.bz2 libdbusmenu-0f6f4c9cdd83d80dfd77fbedcc9a9468cb16eaae.zip |
For IDs that we recycle (often the root id) we need to update the properties. Adds a new function to support syncing the properties in the menuitem.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/client.c | 21 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 20 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.h | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8ff090d..2302110 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -570,6 +570,22 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError return; } +static void +menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) +{ + GList * current_props = NULL; + + for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); + current_props != NULL ; current_props = g_list_next(current_props)) { + if (g_hash_table_lookup(properties, current_props->data) == NULL) { + dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->data); + } + } + + menuitem_get_properties_cb(proxy, properties, error, data); + return; +} + /* This is a different get properites call back that also sends new signals. It basically is a small wrapper around the original. */ static void @@ -648,6 +664,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it #ifdef MASSIVEDEBUGGING g_debug("Client looking at node with id: %d", id); #endif + /* If we don't have any item, or the IDs don't match */ if (item == NULL || dbusmenu_menuitem_get_id(item) != id) { if (item != NULL) { if (parent != NULL) { @@ -676,6 +693,10 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } else { g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); } + } else { + /* Refresh the properties */ + gchar * properties[1] = {NULL}; /* This gets them all */ + org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item); } xmlNodePtr children; diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 8350b41..a2d2682 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -988,6 +988,26 @@ dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property) } /** + dbusmenu_menuitem_property_remove: + @mi: The #DbusmenuMenuitem to remove the property on. + @property: The property to look for. + + Removes a property from the menuitem. +*/ +void +dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property) +{ + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + g_return_if_fail(property != NULL); + + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + g_hash_table_remove(priv->properties, property); + + return; +} + +/** dbusmenu_menuitem_properties_list: @mi: #DbusmenuMenuitem to list the properties on diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 69f82e5..1382335 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -152,6 +152,7 @@ gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * pr gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); +void dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property); void dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root); gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); |