diff options
author | Ted Gould <ted@canonical.com> | 2009-08-20 13:05:24 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-08-20 13:05:24 -0500 |
commit | 69fe6b5ac33dfd64163d5b41f9a0719b23912e40 (patch) | |
tree | 4a0bb857b845376a42d4d3f893248fb0336a98c9 | |
parent | 5583309ea061bc9a384d15b79193d8240e5f46a1 (diff) | |
download | libdbusmenu-69fe6b5ac33dfd64163d5b41f9a0719b23912e40.tar.gz libdbusmenu-69fe6b5ac33dfd64163d5b41f9a0719b23912e40.tar.bz2 libdbusmenu-69fe6b5ac33dfd64163d5b41f9a0719b23912e40.zip |
Makin' it so that if we have a type handler we use that, otherwise we pass things up. Also making it so that type handlers can report an error.
-rw-r--r-- | libdbusmenu-glib/client.c | 22 | ||||
-rw-r--r-- | libdbusmenu-glib/client.h | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 9eb8b55..a4e4f72 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -530,10 +530,27 @@ static void menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) { gpointer * unpackarray = (gpointer *)data; + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(unpackarray[0]); menuitem_get_properties_cb (proxy, properties, error, unpackarray[1]); - g_signal_emit(G_OBJECT(unpackarray[0]), signals[NEW_MENUITEM], 0, unpackarray[1], TRUE); + gboolean handled = FALSE; + + const gchar * type; + DbusmenuClientTypeHandler newfunc = NULL; + + type = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(unpackarray[1]), "type"); + if (type != NULL) { + newfunc = g_hash_table_lookup(priv->type_handlers, type); + } + + if (newfunc != NULL) { + handled = newfunc(DBUSMENU_MENUITEM(unpackarray[1]), DBUSMENU_MENUITEM(unpackarray[2])); + } + + if (!handled) { + g_signal_emit(G_OBJECT(unpackarray[0]), signals[NEW_MENUITEM], 0, unpackarray[1], TRUE); + } g_free(unpackarray); @@ -590,9 +607,10 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Get the properties queued up for this item */ /* Not happy about this, but I need both of these :( */ - gpointer * packarray = g_new0(gpointer, 2); + gpointer * packarray = g_new0(gpointer, 3); packarray[0] = client; packarray[1] = item; + packarray[2] = parent; org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, packarray); } diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 20156d8..9298d4e 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -90,7 +90,7 @@ struct _DbusmenuClient { GObject parent; }; -typedef void (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent); +typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent); GType dbusmenu_client_get_type (void); DbusmenuClient * dbusmenu_client_new (const gchar * name, |