aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-20 12:54:53 -0500
committerTed Gould <ted@canonical.com>2009-08-20 12:54:53 -0500
commit236ddb030b31aa78842c81fef0cd107a6b615124 (patch)
tree54e7d392814a3ec1e361e502ff79115141b795ab
parent76cb1c3fd2545f1e7bcec62f788335fb6232178f (diff)
downloadlibdbusmenu-236ddb030b31aa78842c81fef0cd107a6b615124.tar.gz
libdbusmenu-236ddb030b31aa78842c81fef0cd107a6b615124.tar.bz2
libdbusmenu-236ddb030b31aa78842c81fef0cd107a6b615124.zip
Switching the new signal to be after the properties are gotten and adding a hashtable for type handlers.
-rw-r--r--libdbusmenu-glib/client.c34
-rw-r--r--libdbusmenu-glib/client.h12
2 files changed, 41 insertions, 5 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 212071b..9eb8b55 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -68,6 +68,8 @@ struct _DbusmenuClientPrivate
DBusGProxyCall * layoutcall;
DBusGProxy * dbusproxy;
+
+ GHashTable * type_handlers;
};
#define DBUSMENU_CLIENT_GET_PRIVATE(o) \
@@ -187,6 +189,9 @@ dbusmenu_client_init (DbusmenuClient *self)
priv->dbusproxy = NULL;
+ priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
return;
}
@@ -230,6 +235,10 @@ dbusmenu_client_finalize (GObject *object)
g_free(priv->dbus_name);
g_free(priv->dbus_object);
+ if (priv->type_handlers != NULL) {
+ g_hash_table_destroy(priv->type_handlers);
+ }
+
G_OBJECT_CLASS (dbusmenu_client_parent_class)->finalize (object);
return;
}
@@ -515,6 +524,22 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError
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
+menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data)
+{
+ gpointer * unpackarray = (gpointer *)data;
+
+ menuitem_get_properties_cb (proxy, properties, error, unpackarray[1]);
+
+ g_signal_emit(G_OBJECT(unpackarray[0]), signals[NEW_MENUITEM], 0, unpackarray[1], TRUE);
+
+ g_free(unpackarray);
+
+ return;
+}
+
static void
menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
{
@@ -562,9 +587,14 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it
dbusmenu_menuitem_set_root(item, TRUE);
}
g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activate), client);
- g_signal_emit(G_OBJECT(client), signals[NEW_MENUITEM], 0, item, TRUE);
+
/* Get the properties queued up for this item */
- org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, item);
+ /* Not happy about this, but I need both of these :( */
+ gpointer * packarray = g_new0(gpointer, 2);
+ packarray[0] = client;
+ packarray[1] = item;
+
+ org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, packarray);
}
xmlNodePtr children;
diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h
index 35f7122..20156d8 100644
--- a/libdbusmenu-glib/client.h
+++ b/libdbusmenu-glib/client.h
@@ -90,9 +90,15 @@ struct _DbusmenuClient {
GObject parent;
};
-GType dbusmenu_client_get_type (void);
-DbusmenuClient * dbusmenu_client_new (const gchar * name, const gchar * object);
-DbusmenuMenuitem * dbusmenu_client_get_root (DbusmenuClient * client);
+typedef void (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent);
+
+GType dbusmenu_client_get_type (void);
+DbusmenuClient * dbusmenu_client_new (const gchar * name,
+ const gchar * object);
+DbusmenuMenuitem * dbusmenu_client_get_root (DbusmenuClient * client);
+gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client,
+ const gchar * type,
+ DbusmenuClientTypeHandler newfunc);
/**
SECTION:client