diff options
author | Ted Gould <ted@canonical.com> | 2009-08-20 13:20:54 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-08-20 13:20:54 -0500 |
commit | 2a110cf96860653b68d1a165c7e3b7ddb1f993f8 (patch) | |
tree | ded57e77fc69d718a3460bacec0b1daa208223a3 /libdbusmenu-glib | |
parent | 69fe6b5ac33dfd64163d5b41f9a0719b23912e40 (diff) | |
download | libdbusmenu-2a110cf96860653b68d1a165c7e3b7ddb1f993f8.tar.gz libdbusmenu-2a110cf96860653b68d1a165c7e3b7ddb1f993f8.tar.bz2 libdbusmenu-2a110cf96860653b68d1a165c7e3b7ddb1f993f8.zip |
Making things a little more type safe. Only one evil cast.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/client.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a4e4f72..5809e1e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -72,6 +72,14 @@ struct _DbusmenuClientPrivate GHashTable * type_handlers; }; +typedef struct _newItemPropData newItemPropData; +struct _newItemPropData +{ + DbusmenuClient * client; + DbusmenuMenuitem * item; + DbusmenuMenuitem * parent; +}; + #define DBUSMENU_CLIENT_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_CLIENT, DbusmenuClientPrivate)) @@ -529,30 +537,30 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError 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]); + newItemPropData * propdata = (newItemPropData *)data; + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(propdata->client); - menuitem_get_properties_cb (proxy, properties, error, unpackarray[1]); + menuitem_get_properties_cb (proxy, properties, error, propdata->item); gboolean handled = FALSE; const gchar * type; DbusmenuClientTypeHandler newfunc = NULL; - type = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(unpackarray[1]), "type"); + type = dbusmenu_menuitem_property_get(propdata->item, "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])); + handled = newfunc(propdata->item, propdata->parent); } if (!handled) { - g_signal_emit(G_OBJECT(unpackarray[0]), signals[NEW_MENUITEM], 0, unpackarray[1], TRUE); + g_signal_emit(G_OBJECT(propdata->client), signals[NEW_MENUITEM], 0, propdata->item, TRUE); } - g_free(unpackarray); + g_free(propdata); return; } @@ -606,13 +614,13 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activate), client); /* Get the properties queued up for this item */ - /* Not happy about this, but I need both of these :( */ - gpointer * packarray = g_new0(gpointer, 3); - packarray[0] = client; - packarray[1] = item; - packarray[2] = parent; + /* Not happy about this, but I need these :( */ + newItemPropData * propdata = g_new0(newItemPropData, 1); + propdata->client = client; + propdata->item = item; + propdata->parent = parent; - org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, packarray); + org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, propdata); } xmlNodePtr children; |