From 148a60fb5dd3c97252b370b138b0129f6f3a5e0e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 27 Sep 2010 21:36:44 -0500 Subject: Adding a globbed signal of properties --- libdbusmenu-glib/dbus-menu.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 9e8013c..61c7a7b 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -328,6 +328,16 @@ License version 3 and version 2.1 along with this program. If not, see + + + Triggered when there are lots of property updates across many items + so they all get grouped into a single dbus message. The format is + the ID of the item with a hashtable of names and values for those + properties. + + + + Triggered by the application to notify display of a layout update, up to -- cgit v1.2.3 From a5d8069f4b20f376cebcfc48b68b1c6101ab5da7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 27 Sep 2010 21:38:01 -0500 Subject: Wrong tense --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 61c7a7b..6b72c72 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -328,7 +328,7 @@ License version 3 and version 2.1 along with this program. If not, see - + Triggered when there are lots of property updates across many items so they all get grouped into a single dbus message. The format is -- cgit v1.2.3 From fd954bb9d7e00405e23acd03a7dda5d97fb66e02 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:22:49 -0400 Subject: Dropping the other signals --- libdbusmenu-glib/dbus-menu.xml | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 6b72c72..aa2d635 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -309,25 +309,6 @@ License version 3 and version 2.1 along with this program. If not, see - - - Triggered by the application to notify the applet that the property @a property - from item @a id has changed to @a value. - - - - - - - - - Triggered by the application to notify the applet that all properties of item - - - id which should be considered outdated - - - Triggered when there are lots of property updates across many items @@ -337,7 +318,6 @@ License version 3 and version 2.1 along with this program. If not, see - Triggered by the application to notify display of a layout update, up to -- cgit v1.2.3 From d9c757bcc71e269cf4180fc007f0e619beb3cad1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:26:06 -0400 Subject: Changing the return from the 'GetLayout' function --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 9e8013c..4632352 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -201,7 +201,7 @@ License version 3 and version 2.1 along with this program. If not, see The revision number of the layout. For matching with layoutUpdated signals. - + The layout as an XML string of IDs. -- cgit v1.2.3 From 38882b4705957a5f0d1f80a92aa8c6e7c24fd380 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:27:45 -0400 Subject: Getting the property names with the layout --- libdbusmenu-glib/dbus-menu.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 4632352..2c195fa 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -201,6 +201,13 @@ License version 3 and version 2.1 along with this program. If not, see The revision number of the layout. For matching with layoutUpdated signals. + + + The list of item properties we are + interested in. If there are no entries in the list all of + the properties will be sent. + + The layout as an XML string of IDs. -- cgit v1.2.3 From e879b3574445305c4d672869dd8307f570f6bd6c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:32:33 -0400 Subject: Changing the comment to describe the new parameters --- libdbusmenu-glib/dbus-menu.xml | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 2c195fa..17f3348 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -174,25 +174,15 @@ License version 3 and version 2.1 along with this program. If not, see - # Root container - # First level menu, for example "File" - ~ Second level menu, for example "Open" - - ... - - # Another first level menu, say "Edit" - ... - - ... - - @endverbatim - ]]> + + Provides the layout and propertiers that are attached to the entries + that are in the layout. It only gives the items that are children + of the item that is specified in @parentId. It will return all of the + properties or specific ones depending of the value in @propertyNames. + + The format is recursive, where the second 'v' is in the same format + as the original 'a(ia(sv)a(v))'. + The ID of the parent node for the layout. For grabbing the layout from the root node use zero. -- cgit v1.2.3 From e6ddf5b8b4bb0fb444ee672b37cfeed0c3395d5d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:36:05 -0400 Subject: Adding in the ability to do recursive --- libdbusmenu-glib/dbus-menu.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 17f3348..9b6dfaa 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -181,12 +181,19 @@ License version 3 and version 2.1 along with this program. If not, see properties or specific ones depending of the value in @propertyNames. The format is recursive, where the second 'v' is in the same format - as the original 'a(ia(sv)a(v))'. + as the original 'a(ia(sv)a(v))'. If the @recursive flag is set to + false than the second array will have zero entries. The ID of the parent node for the layout. For grabbing the layout from the root node use zero. + + + Recurse to all children of the parent and include them in the + structure that is returned. + + The revision number of the layout. For matching with layoutUpdated signals. -- cgit v1.2.3 From a687c6c7b85f5c80ac37b275572dc7dcb1a188a5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:36:38 -0400 Subject: Grouping the 'in' parameters --- libdbusmenu-glib/dbus-menu.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 9b6dfaa..24ca04a 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -194,10 +194,6 @@ License version 3 and version 2.1 along with this program. If not, see structure that is returned. - - The revision number of the layout. For matching - with layoutUpdated signals. - The list of item properties we are @@ -205,6 +201,10 @@ License version 3 and version 2.1 along with this program. If not, see the properties will be sent. + + The revision number of the layout. For matching + with layoutUpdated signals. + The layout as an XML string of IDs. -- cgit v1.2.3 From 1aec3e7f92f5de256e73ca99eb44bdaf769456f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 14:37:40 -0400 Subject: Dropping 'GetChildren' and 'GetProperties' as they're not really useful anymore --- libdbusmenu-glib/dbus-menu.xml | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 24ca04a..ec9e525 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -240,35 +240,12 @@ License version 3 and version 2.1 along with this program. If not, see - - - - - - - - - - Returns multiple properties in one call. This is more efficient than - GetProperty. - - - - - The item whose properties we want to retrieve. - - - List of string name of the properties we want. If the list contains no entries, all properties are sent. - - - - Date: Wed, 27 Oct 2010 14:42:29 -0400 Subject: Adding annotations into the 'GetProperty' method --- libdbusmenu-glib/dbus-menu.xml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index fc3d82b..bd3ea0b 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -241,9 +241,20 @@ License version 3 and version 2.1 along with this program. If not, see - - - + + Get a signal property on a single item. This is not useful if you're + going to implement this interface, it should only be used if you're + debugging via a commandline tool. + + + the id of the item which received the event + + + the name of the property to get + + + the value of the property + -- cgit v1.2.3 From 3a572218ff8520ca284966d9395c2fd06544d233 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 Oct 2010 17:48:48 -0400 Subject: Changing recurse to an int for the number of levels --- libdbusmenu-glib/dbus-menu.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index bd3ea0b..82de533 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -182,16 +182,16 @@ License version 3 and version 2.1 along with this program. If not, see The format is recursive, where the second 'v' is in the same format as the original 'a(ia(sv)a(v))'. If the @recursive flag is set to - false than the second array will have zero entries. + less than one then the second array will have zero entries. The ID of the parent node for the layout. For grabbing the layout from the root node use zero. - + - Recurse to all children of the parent and include them in the - structure that is returned. + The amount of levels of recursion to use. -1, as value would + deliver all the items under the @parentId. -- cgit v1.2.3 From 47401712546246e6213659e06fd3b6972906ced7 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Mon, 31 Jan 2011 09:10:49 -0500 Subject: fix variant type of props return --- libdbusmenu-glib/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index adb9f91..777e4ef 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -946,9 +946,9 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho ret = g_variant_builder_end(&builder); } else { GError * error = NULL; - ret = g_variant_parse(g_variant_type_new("a(ia(sv))"), "[]", NULL, NULL, NULL); + ret = g_variant_parse(g_variant_type_new("a(ia{sv})"), "[]", NULL, NULL, NULL); if (error != NULL) { - g_warning("Unable to parse '[]' as a 'a(ia(sv))': %s", error->message); + g_warning("Unable to parse '[]' as a 'a(ia{sv})': %s", error->message); g_error_free(error); ret = NULL; } -- cgit v1.2.3 From 6a6a292ffadadf9f5389fe0c8507ef047daffce1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 08:58:18 -0600 Subject: Keep a ref to the client through-out the call to the update --- libdbusmenu-glib/client.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b196c9f..f59dcf6 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1553,11 +1553,6 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) DbusmenuClient * client = DBUSMENU_CLIENT(data); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - if (priv->layoutcall != NULL) { - g_object_unref(priv->layoutcall); - priv->layoutcall = NULL; - } - GError * error = NULL; GVariant * params = NULL; @@ -1566,7 +1561,7 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) if (error != NULL) { g_warning("Getting layout failed: %s", error->message); g_error_free(error); - return; + goto out; } guint rev; @@ -1580,7 +1575,7 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) if (parseable == 0) { g_warning("Unable to parse layout!"); - return; + goto out; } priv->my_revision = rev; @@ -1596,6 +1591,13 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) update_layout(client); } +out: + if (priv->layoutcall != NULL) { + g_object_unref(priv->layoutcall); + priv->layoutcall = NULL; + } + + g_object_unref(G_OBJECT(client)); return; } @@ -1622,6 +1624,7 @@ update_layout (DbusmenuClient * client) priv->layoutcall = g_cancellable_new(); + g_object_ref(G_OBJECT(client)); g_dbus_proxy_call(priv->menuproxy, "GetLayout", g_variant_new("(i)", 0), /* root */ -- cgit v1.2.3 From 565cc0962042839e4b35f8ae2d01a64864bc665c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 10:48:21 -0600 Subject: Switching the properties callback to use custom structure so that we can reference the client throughout the callback. --- libdbusmenu-glib/client.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f59dcf6..5e492a3 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -129,6 +129,12 @@ struct _type_handler_t { gchar * type; }; +typedef struct _properties_callback_t properties_callback_t; +struct _properties_callback_t { + DbusmenuClient * client; + GArray * listeners; +}; + #define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) #define DBUSMENU_INTERFACE "com.canonical.dbusmenu" @@ -512,7 +518,8 @@ find_listener (GArray * listeners, guint index, gint id) static void get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) { - GArray * listeners = (GArray *)user_data; + properties_callback_t * cbdata = (properties_callback_t *)user_data; + GArray * listeners = cbdata->listeners; int i; GError * error = NULL; GVariant * params = NULL; @@ -526,9 +533,8 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); listener->callback(NULL, error, listener->user_data); } - g_array_free(listeners, TRUE); g_error_free(error); - return; + goto out; } /* Callback all the folks we can find */ @@ -575,8 +581,11 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) g_error_free(localerror); } +out: /* Clean up */ g_array_free(listeners, TRUE); + g_object_unref(cbdata->client); + g_free(user_data); return; } @@ -586,6 +595,7 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) static gboolean get_properties_idle (gpointer user_data) { + properties_callback_t * cbdata = NULL; DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); g_return_val_if_fail(priv->menuproxy != NULL, TRUE); @@ -616,6 +626,11 @@ get_properties_idle (gpointer user_data) g_variant_builder_add_value(&builder, variant_props); GVariant * variant_params = g_variant_builder_end(&builder); + cbdata = g_new(properties_callback_t, 1); + cbdata->listeners = priv->delayed_property_listeners; + cbdata->client = DBUSMENU_CLIENT(user_data); + g_object_ref(G_OBJECT(user_data)); + g_dbus_proxy_call(priv->menuproxy, "GetGroupProperties", variant_params, @@ -623,7 +638,7 @@ get_properties_idle (gpointer user_data) -1, /* timeout */ NULL, /* cancellable */ get_properties_callback, - priv->delayed_property_listeners); + cbdata); /* Free properties */ gchar ** dataregion = (gchar **)g_array_free(priv->delayed_property_list, FALSE); -- cgit v1.2.3 From 3548a02da37917e95564dfda60e97870274a53fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 4 Feb 2011 11:00:07 -0600 Subject: take_children() shouldn't unref the items as they might get deleted before the caller would be abel to use them. Making sure to put those annotations in the docs. --- libdbusmenu-glib/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index b40195c..159463b 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -547,7 +547,6 @@ take_children_signal (gpointer data, gpointer user_data) g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(user_data), LABEL(user_data), ID(data), LABEL(data)); #endif g_signal_emit(G_OBJECT(user_data), signals[CHILD_REMOVED], 0, DBUSMENU_MENUITEM(data), TRUE); - g_object_unref(G_OBJECT(data)); return; } @@ -561,7 +560,8 @@ take_children_signal (gpointer data, gpointer user_data) on the children it has taken. A lot of responsibility involved in taking children. - Return value: A #GList of pointers to #DbusmenuMenuitem objects. + Return value: (transfer full) (array) (element-type Dbusmenu.Menuitem) + A #GList of pointers to #DbusmenuMenuitem objects. */ GList * dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) -- cgit v1.2.3 From 880714ebc6850a2383c4caebfa6aeda66a422937 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 7 Feb 2011 17:07:23 -0600 Subject: Basic outline of the function mapped out, no compile. --- libdbusmenu-glib/server.c | 97 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 777e4ef..b54f4a3 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -633,12 +633,25 @@ layout_update_signal (DbusmenuServer * server) return; } -static void -menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * variant, DbusmenuServer * server) +typedef struct _prop_idle_item_t prop_idle_item_t; +struct _prop_idle_item_t { + guint id; + GArray * array; +}; + +typedef struct _prop_idle_prop_t prop_idle_prop_t; +struct _prop_idle_prop_t { + gchar * property; + GVariant * variant; +}; + +/* Works in the idle to send a set of property updates so that they'll + all update in a single dbus message. */ +static gboolean +menuitem_property_idle (gpointer user_data) { - DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(user_data); - g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, variant, TRUE); if (priv->dbusobject != NULL && priv->bus != NULL) { g_dbus_connection_emit_signal(priv->bus, @@ -649,6 +662,82 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v g_variant_new("(isv)", dbusmenu_menuitem_get_id(mi), property, variant), NULL); } + + return FALSE; +} + +static void +menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * variant, DbusmenuServer * server) +{ + int i; + guint item_id; + + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + item_id = dbusmenu_menuitem_get_id(mi); + + g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, item_id, property, variant, TRUE); + + /* See if we have a property array, if not, we need to + build one of these suckers */ + if (priv->prop_array == NULL) { + priv->prop_array = g_array_new(); + } + + /* Look to see if we already have this item in the list + and use it if so */ + prop_idle_item_t * item = NULL; + for (i = 0; i < priv->prop_array->len; i++) { + prop_idle_item_t * iitem = &g_array_index(prop_idle_item_t, i); + if (iitem->id == item_id) { + item = iitem; + break; + } + } + + GArray * properties = NULL; + /* If not, we'll need to build ourselves one */ + if (item == NULL) { + prop_idle_item_t myitem; + myitem.id = item_id; + myitem.array = g_array_new(); + + g_array_append(priv->prop_array, myitem); + properties = myitem.array; + } else { + properties = item->array; + } + + /* Check to see if this property is in the list */ + prop_idle_prop_t * prop = NULL; + for (i = 0; i < properties->len; i++) { + prop_idle_prop_t * iprop = &g_array_index(properties, prop_idle_prop_t, i); + if (g_strcmp0(iprop->name, property)) { + prop = iprop; + break; + } + } + + /* If so, we need to swap the value */ + if (prop != NULL) { + g_variant_unref(prop->variant); + prop->variant = variant; + } else { + /* else we need to add it */ + prop_idle_prop_t myprop; + myprop.property = g_strdup(property); + myprop.variant = variant; + + g_array_append(properties, myprop); + } + g_variant_ref(variant); + + /* Check to see if the idle is already queued, and queue it + if not. */ + if (priv->property_idle == 0) { + priv->property_idle = g_idle_add(menuitem_property_idle, server); + } + return; } -- cgit v1.2.3 From a7a9436eab6dab746787cb6550cf3e82a5801cd8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 7 Feb 2011 17:19:36 -0600 Subject: Fleshing out the add function and making this thing compile! --- libdbusmenu-glib/server.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index b54f4a3..aafff11 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -54,6 +54,9 @@ struct _DbusmenuServerPrivate GDBusConnection * bus; GCancellable * bus_lookup; guint dbus_registration; + + GArray * prop_array; + guint property_idle; }; #define DBUSMENU_SERVER_GET_PRIVATE(o) (DBUSMENU_SERVER(o)->priv) @@ -156,6 +159,7 @@ static void menuitem_signals_create (DbusmenuMenuitem * mi, static void menuitem_signals_remove (DbusmenuMenuitem * mi, gpointer data); static GQuark error_quark (void); +static void prop_array_teardown (GArray * prop_array); static void bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); @@ -354,6 +358,17 @@ dbusmenu_server_dispose (GObject *object) if (priv->layout_idle != 0) { g_source_remove(priv->layout_idle); + priv->layout_idle = 0; + } + + if (priv->property_idle != 0) { + g_source_remove(priv->property_idle); + priv->property_idle = 0; + } + + if (priv->prop_array != NULL) { + prop_array_teardown(priv->prop_array); + priv->prop_array = NULL; } if (priv->root != NULL) { @@ -645,14 +660,23 @@ struct _prop_idle_prop_t { GVariant * variant; }; +/* Takes appart our data structure so we don't leak any + memory or references. */ +static void +prop_array_teardown (GArray * prop_array) +{ + + return; +} + /* Works in the idle to send a set of property updates so that they'll all update in a single dbus message. */ static gboolean menuitem_property_idle (gpointer user_data) { +/* DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(user_data); - if (priv->dbusobject != NULL && priv->bus != NULL) { g_dbus_connection_emit_signal(priv->bus, NULL, @@ -662,7 +686,7 @@ menuitem_property_idle (gpointer user_data) g_variant_new("(isv)", dbusmenu_menuitem_get_id(mi), property, variant), NULL); } - +*/ return FALSE; } @@ -681,14 +705,14 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v /* See if we have a property array, if not, we need to build one of these suckers */ if (priv->prop_array == NULL) { - priv->prop_array = g_array_new(); + priv->prop_array = g_array_new(FALSE, FALSE, sizeof(prop_idle_item_t)); } /* Look to see if we already have this item in the list and use it if so */ prop_idle_item_t * item = NULL; for (i = 0; i < priv->prop_array->len; i++) { - prop_idle_item_t * iitem = &g_array_index(prop_idle_item_t, i); + prop_idle_item_t * iitem = &g_array_index(priv->prop_array, prop_idle_item_t, i); if (iitem->id == item_id) { item = iitem; break; @@ -700,9 +724,9 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v if (item == NULL) { prop_idle_item_t myitem; myitem.id = item_id; - myitem.array = g_array_new(); + myitem.array = g_array_new(FALSE, FALSE, sizeof(prop_idle_prop_t)); - g_array_append(priv->prop_array, myitem); + g_array_append_val(priv->prop_array, myitem); properties = myitem.array; } else { properties = item->array; @@ -712,7 +736,7 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v prop_idle_prop_t * prop = NULL; for (i = 0; i < properties->len; i++) { prop_idle_prop_t * iprop = &g_array_index(properties, prop_idle_prop_t, i); - if (g_strcmp0(iprop->name, property)) { + if (g_strcmp0(iprop->property, property)) { prop = iprop; break; } @@ -728,7 +752,7 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v myprop.property = g_strdup(property); myprop.variant = variant; - g_array_append(properties, myprop); + g_array_append_val(properties, myprop); } g_variant_ref(variant); -- cgit v1.2.3 From 7a787b6d5cc1427cb309f3b1bfd246f3f02f7ee5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Feb 2011 08:23:58 -0600 Subject: Fleshing out the teardown of the array --- libdbusmenu-glib/server.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index aafff11..0189b35 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -665,6 +665,22 @@ struct _prop_idle_prop_t { static void prop_array_teardown (GArray * prop_array) { + int i, j; + + for (i = 0; i < prop_array->len; i++) { + prop_idle_item_t * iitem = &g_array_index(prop_array, prop_idle_item_t, i); + + for (j = 0; j < iitem->array->len; j++) { + prop_idle_prop_t * iprop = &g_array_index(iitem->array, prop_idle_prop_t, j); + + g_free(iprop->property); + g_variant_unref(iprop->variant); + } + + g_array_free(iitem->array, TRUE); + } + + g_array_free(prop_array, TRUE); return; } -- cgit v1.2.3 From a816313a42ede72443bf7659fe55916d11a21396 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Feb 2011 09:04:47 -0600 Subject: Fleshing out the transformation from arrays to dbus signals. --- libdbusmenu-glib/server.c | 52 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 0189b35..136038e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -690,19 +690,63 @@ prop_array_teardown (GArray * prop_array) static gboolean menuitem_property_idle (gpointer user_data) { -/* DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(user_data); + /* Source will get removed as we return */ + priv->property_idle = 0; + + /* If there are no items, let's just not signal */ + if (priv->prop_array == NULL) { + return FALSE; + } + + int i, j; + GVariantBuilder itembuilder; + g_variant_builder_init(&itembuilder, G_VARIANT_TYPE_ARRAY); + + for (i = 0; i < priv->prop_array->len; i++) { + prop_idle_item_t * iitem = &g_array_index(priv->prop_array, prop_idle_item_t, i); + + GVariantBuilder tuplebuilder; + g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); + + g_variant_builder_add_value(&tuplebuilder, g_variant_new_uint32(iitem->id)); + + GVariantBuilder dictbuilder; + g_variant_builder_init(&dictbuilder, G_VARIANT_TYPE_DICTIONARY); + + for (j = 0; j < iitem->array->len; j++) { + prop_idle_prop_t * iprop = &g_array_index(iitem->array, prop_idle_prop_t, j); + + GVariant * entry = g_variant_new_dict_entry(g_variant_new_string(iprop->property), + g_variant_new_variant(iprop->variant)); + + g_variant_builder_add_value(&dictbuilder, entry); + } + + g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&dictbuilder)); + + g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder)); + } + + GVariant * megadata = g_variant_builder_end(&itembuilder); + if (priv->dbusobject != NULL && priv->bus != NULL) { g_dbus_connection_emit_signal(priv->bus, NULL, priv->dbusobject, DBUSMENU_INTERFACE, - "ItemPropertyUpdated", - g_variant_new("(isv)", dbusmenu_menuitem_get_id(mi), property, variant), + "ItemPropertiesUpdated", + g_variant_new_tuple(&megadata, 1), NULL); + } else { + g_variant_unref(megadata); } -*/ + + /* Clean everything up */ + prop_array_teardown(priv->prop_array); + priv->prop_array = NULL; + return FALSE; } -- cgit v1.2.3 From fd553bb625a37ac77d84e8100bd2404748ea21e2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Feb 2011 09:14:41 -0600 Subject: Handling and unrolling the properties updated signal --- libdbusmenu-glib/client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5e492a3..aa0b3f0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1035,6 +1035,22 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian guint revision; gint parent; g_variant_get(params, "(ui)", &revision, &parent); layout_update(proxy, revision, parent, client); + } else if (g_strcmp0(signal, "ItemPropertiesUpdated") == 0) { + GVariantIter items; + g_variant_iter_init(&items, g_variant_get_child_value(params, 0)); + + GVariant * item; + while ((item = g_variant_iter_next_value(&items)) != NULL) { + gint id = g_variant_get_int32(g_variant_get_child_value(item, 0)); + GVariantIter properties; + g_variant_iter_init(&properties, g_variant_get_child_value(item, 1)); + gchar * property; + GVariant * value; + + while (g_variant_iter_next(&properties, "{sv}", &property, &value)) { + id_prop_update(proxy, id, property, value, client); + } + } } else if (g_strcmp0(signal, "ItemPropertyUpdated") == 0) { gint id; gchar * property; GVariant * value; g_variant_get(params, "(isv)", &id, &property, &value); -- cgit v1.2.3 From 51e83f5cfca82f53478fd783943e2e972492595c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Feb 2011 09:17:18 -0600 Subject: IDs should be signed --- libdbusmenu-glib/server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 136038e..86ea0f0 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -650,7 +650,7 @@ layout_update_signal (DbusmenuServer * server) typedef struct _prop_idle_item_t prop_idle_item_t; struct _prop_idle_item_t { - guint id; + gint id; GArray * array; }; @@ -710,7 +710,7 @@ menuitem_property_idle (gpointer user_data) GVariantBuilder tuplebuilder; g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add_value(&tuplebuilder, g_variant_new_uint32(iitem->id)); + g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id)); GVariantBuilder dictbuilder; g_variant_builder_init(&dictbuilder, G_VARIANT_TYPE_DICTIONARY); @@ -754,7 +754,7 @@ static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * variant, DbusmenuServer * server) { int i; - guint item_id; + gint item_id; DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); -- cgit v1.2.3 From 436d5042bbb97d2bec691a655e79875e8a1d7573 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Feb 2011 11:17:31 -0600 Subject: Unbox the variants if they're boxed --- libdbusmenu-glib/client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index aa0b3f0..cb90789 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1048,7 +1048,12 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian GVariant * value; while (g_variant_iter_next(&properties, "{sv}", &property, &value)) { - id_prop_update(proxy, id, property, value, client); + GVariant * internalvalue = value; + if (G_LIKELY(g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT))) { + /* Unboxing if needed */ + internalvalue = g_variant_get_variant(value); + } + id_prop_update(proxy, id, property, internalvalue, client); } } } else if (g_strcmp0(signal, "ItemPropertyUpdated") == 0) { -- cgit v1.2.3 From 0ee9e9fe667565a0f141694447599aac39e2c310 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Wed, 9 Feb 2011 12:45:41 -0500 Subject: Fix the name used for the Dbusmenu-Glib-0.4 typelib so it can be properly used with GI. It should be Dbusmenu-0.4 (LP: #713099) --- libdbusmenu-glib/Makefile.am | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index a139f7c..e6877b6 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -138,18 +138,18 @@ if HAVE_INTROSPECTION introspection_sources = $(libdbusmenu_glibinclude_HEADERS) -Dbusmenu_Glib-0.4.gir: libdbusmenu-glib.la -Dbusmenu_Glib_0_4_gir_INCLUDES = \ +Dbusmenu-0.4.gir: libdbusmenu-glib.la +Dbusmenu_0_4_gir_INCLUDES = \ GObject-2.0 -Dbusmenu_Glib_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) -I$(top_srcdir) -Dbusmenu_Glib_0_4_gir_LIBS = libdbusmenu-glib.la -Dbusmenu_Glib_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -Dbusmenu_Glib_0_4_gir_NAMESPACE = Dbusmenu -Dbusmenu_Glib_0_4_gir_VERSION = Glib-0.4 -Dbusmenu_Glib_0_4_gir_EXPORT_PACKAGES = dbusmenu-glib-0.4 -Dbusmenu_Glib_0_4_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) +Dbusmenu_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) -I$(top_srcdir) +Dbusmenu_0_4_gir_LIBS = libdbusmenu-glib.la +Dbusmenu_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) +Dbusmenu_0_4_gir_NAMESPACE = Dbusmenu +Dbusmenu_0_4_gir_VERSION = 0.4 +Dbusmenu_0_4_gir_EXPORT_PACKAGES = dbusmenu-glib-0.4 +Dbusmenu_0_4_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) -INTROSPECTION_GIRS += Dbusmenu-Glib-0.4.gir +INTROSPECTION_GIRS += Dbusmenu-0.4.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -168,10 +168,10 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = Dbusmenu-Glib-0.4.vapi +vapi_DATA = Dbusmenu-0.4.vapi -Dbusmenu-Glib-0.4.vapi: Dbusmenu-Glib-0.4.gir - $(VALA_API_GEN) --library=Dbusmenu-Glib-0.4 $< +Dbusmenu-0.4.vapi: Dbusmenu-0.4.gir + $(VALA_API_GEN) --library=Dbusmenu-0.4 $< CLEANFILES += $(vapi_DATA) -- cgit v1.2.3 From 69e2d39c27c35386156929c44a419cb19b647316 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 11 Feb 2011 16:45:39 -0600 Subject: Explicitly destroying and recreating the properties on the root node when changed. --- libdbusmenu-glib/server.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 86ea0f0..abfa5f0 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -433,6 +433,15 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) if (priv->root != NULL) { dbusmenu_menuitem_foreach(priv->root, menuitem_signals_remove, obj); dbusmenu_menuitem_set_root(priv->root, FALSE); + + GList * properties = dbusmenu_menuitem_properties_list(priv->root); + GList * iter; + for (iter = properties; iter != NULL; iter = g_list_next(iter)) { + gchar * property = (gchar *)iter->data; + menuitem_property_changed(priv->root, property, g_variant_new_int32(0), DBUSMENU_SERVER(obj)); + } + g_list_free(properties); + g_object_unref(G_OBJECT(priv->root)); priv->root = NULL; } @@ -441,6 +450,14 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) g_object_ref(G_OBJECT(priv->root)); dbusmenu_menuitem_set_root(priv->root, TRUE); dbusmenu_menuitem_foreach(priv->root, menuitem_signals_create, obj); + + GList * properties = dbusmenu_menuitem_properties_list(priv->root); + GList * iter; + for (iter = properties; iter != NULL; iter = g_list_next(iter)) { + gchar * property = (gchar *)iter->data; + menuitem_property_changed(priv->root, property, dbusmenu_menuitem_property_get_variant(priv->root, property), DBUSMENU_SERVER(obj)); + } + g_list_free(properties); } else { g_debug("Setting root node to NULL"); } -- cgit v1.2.3 From 8e2df412c61b984a9a463c8dc45b42d190cf5e01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 11 Feb 2011 21:49:13 -0600 Subject: Setting value to something more obviously wrong --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index abfa5f0..d6e81c5 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -438,7 +438,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GList * iter; for (iter = properties; iter != NULL; iter = g_list_next(iter)) { gchar * property = (gchar *)iter->data; - menuitem_property_changed(priv->root, property, g_variant_new_int32(0), DBUSMENU_SERVER(obj)); + menuitem_property_changed(priv->root, property, g_variant_new_string("deadvalue"), DBUSMENU_SERVER(obj)); } g_list_free(properties); -- cgit v1.2.3 From e417951544c716a7f8ed3f7b348135e409cf1356 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 11 Feb 2011 21:53:26 -0600 Subject: Checking the strcmp0 value properly --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index d6e81c5..6a65b56 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -813,7 +813,7 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v prop_idle_prop_t * prop = NULL; for (i = 0; i < properties->len; i++) { prop_idle_prop_t * iprop = &g_array_index(properties, prop_idle_prop_t, i); - if (g_strcmp0(iprop->property, property)) { + if (g_strcmp0(iprop->property, property) == 0) { prop = iprop; break; } -- cgit v1.2.3 From 09e2617ff1b76c1a3dfc6bb7177bab2c1ac65924 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 08:57:05 -0600 Subject: Adding a removed field to the signal --- libdbusmenu-glib/dbus-menu.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 0742140..b5f5627 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -317,6 +317,7 @@ License version 3 and version 2.1 along with this program. If not, see properties. + -- cgit v1.2.3 From a557b5f43a20bfcacf69769f4726b9411aceaf06 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 09:00:42 -0600 Subject: Adding a function to check if the property is a default --- libdbusmenu-glib/menuitem-private.h | 1 + libdbusmenu-glib/menuitem.c | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-private.h b/libdbusmenu-glib/menuitem-private.h index 2028464..7f8ba23 100644 --- a/libdbusmenu-glib/menuitem-private.h +++ b/libdbusmenu-glib/menuitem-private.h @@ -37,6 +37,7 @@ void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array); gboolean dbusmenu_menuitem_realized (DbusmenuMenuitem * mi); void dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi); GVariant * dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi); +gboolean dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * property); G_END_DECLS diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 159463b..3f85efa 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1473,3 +1473,13 @@ dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp) return; } + +/* Checks to see if the value of this property is unique or just the + default value. */ +/* TODO: Implement this */ +gboolean +dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * property) +{ + /* No defaults system yet */ + return FALSE; +} -- cgit v1.2.3 From 4b7ed0aa2ddeb47107bb0c67cddc90789378c6c2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 10:40:59 -0600 Subject: Adding the remove items list to the message as well. --- libdbusmenu-glib/server.c | 102 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 15 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 6a65b56..fb5e9ae 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -719,34 +719,105 @@ menuitem_property_idle (gpointer user_data) int i, j; GVariantBuilder itembuilder; - g_variant_builder_init(&itembuilder, G_VARIANT_TYPE_ARRAY); + gboolean item_init = FALSE; + + GVariantBuilder removeitembuilder; + gboolean removeitem_init = FALSE; for (i = 0; i < priv->prop_array->len; i++) { prop_idle_item_t * iitem = &g_array_index(priv->prop_array, prop_idle_item_t, i); - GVariantBuilder tuplebuilder; - g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); - - g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id)); - GVariantBuilder dictbuilder; - g_variant_builder_init(&dictbuilder, G_VARIANT_TYPE_DICTIONARY); + gboolean dictinit = FALSE; + + GVariantBuilder removedictbuilder; + gboolean removedictinit = FALSE; + /* Go throught each item and see if it should go in the removal list + or the additive list. */ for (j = 0; j < iitem->array->len; j++) { prop_idle_prop_t * iprop = &g_array_index(iitem->array, prop_idle_prop_t, j); - GVariant * entry = g_variant_new_dict_entry(g_variant_new_string(iprop->property), - g_variant_new_variant(iprop->variant)); + if (iprop->variant != NULL) { + if (!dictinit) { + g_variant_builder_init(&dictbuilder, G_VARIANT_TYPE_DICTIONARY); + dictinit = TRUE; + } + + GVariant * entry = g_variant_new_dict_entry(g_variant_new_string(iprop->property), + g_variant_new_variant(iprop->variant)); + + g_variant_builder_add_value(&dictbuilder, entry); + } else { + if (!removedictinit) { + g_variant_builder_init(&removedictbuilder, G_VARIANT_TYPE_ARRAY); + removedictinit = TRUE; + } + + g_variant_builder_add_value(&removedictbuilder, g_variant_new_string(iprop->property)); + } + } + + /* If we've got new values that are real values we need to add that + to the list of items to send the value of */ + if (dictinit) { + GVariantBuilder tuplebuilder; + g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); + + g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id)); + g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&dictbuilder)); + + if (!item_init) { + g_variant_builder_init(&itembuilder, G_VARIANT_TYPE_ARRAY); + item_init = TRUE; + } + + g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder)); + } + + /* If we've got properties that have been removed then we need to add + them to the list of removed items */ + if (removedictinit) { + GVariantBuilder tuplebuilder; + g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add_value(&dictbuilder, entry); + g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id)); + g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&removedictbuilder)); + + if (!removeitem_init) { + g_variant_builder_init(&removeitembuilder, G_VARIANT_TYPE_ARRAY); + removeitem_init = TRUE; + } + + g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder)); } + } - g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&dictbuilder)); + GVariant * megadata[2]; - g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder)); + if (item_init) { + megadata[0] = g_variant_builder_end(&itembuilder); + } else { + GError * error = NULL; + megadata[0] = g_variant_parse(G_VARIANT_TYPE("a(ia{sv})"), "[ ]", NULL, NULL, &error); + + if (error != NULL) { + g_warning("Unable to parse '[ ]' as a 'a(ia{sv})': %s", error->message); + g_error_free(error); + } } - GVariant * megadata = g_variant_builder_end(&itembuilder); + if (removeitem_init) { + megadata[1] = g_variant_builder_end(&removeitembuilder); + } else { + GError * error = NULL; + megadata[1] = g_variant_parse(G_VARIANT_TYPE("a(ia(s))"), "[ ]", NULL, NULL, &error); + + if (error != NULL) { + g_warning("Unable to parse '[ ]' as a 'a(ia(s))': %s", error->message); + g_error_free(error); + } + } if (priv->dbusobject != NULL && priv->bus != NULL) { g_dbus_connection_emit_signal(priv->bus, @@ -754,10 +825,11 @@ menuitem_property_idle (gpointer user_data) priv->dbusobject, DBUSMENU_INTERFACE, "ItemPropertiesUpdated", - g_variant_new_tuple(&megadata, 1), + g_variant_new_tuple(megadata, 2), NULL); } else { - g_variant_unref(megadata); + g_variant_unref(megadata[0]); + g_variant_unref(megadata[1]); } /* Clean everything up */ -- cgit v1.2.3 From e2d75efe023912f9b4a52c295980137d1717ad14 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 11:00:28 -0600 Subject: If we get default values of properties, treat them like a clear --- libdbusmenu-glib/server.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index fb5e9ae..bee3199 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -891,6 +891,13 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v } } + /* If it's the default value we want to treat it like a clearing + of the value so that it doesn't get sent over dbus and waste + bandwidth */ + if (dbusmenu_menuitem_property_is_default(mi, property)) { + variant = NULL; + } + /* If so, we need to swap the value */ if (prop != NULL) { g_variant_unref(prop->variant); -- cgit v1.2.3 From 4bc497b169ebee9e0ac00232a5fda6af49fc7a48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 11:00:45 -0600 Subject: Use NULL to clear all the values in the root item --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index bee3199..28ff9e4 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -438,7 +438,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GList * iter; for (iter = properties; iter != NULL; iter = g_list_next(iter)) { gchar * property = (gchar *)iter->data; - menuitem_property_changed(priv->root, property, g_variant_new_string("deadvalue"), DBUSMENU_SERVER(obj)); + menuitem_property_changed(priv->root, property, NULL, DBUSMENU_SERVER(obj)); } g_list_free(properties); -- cgit v1.2.3 From b1ec6fff879179f0fdcc9aff72d770ca5020dee6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 13:04:28 -0600 Subject: Adding removing properties on the client side of things. --- libdbusmenu-glib/client.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index cb90789..63fa089 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1030,12 +1030,37 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian { g_return_if_fail(DBUSMENU_IS_CLIENT(user_data)); DbusmenuClient * client = DBUSMENU_CLIENT(user_data); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); if (g_strcmp0(signal, "LayoutUpdated") == 0) { guint revision; gint parent; g_variant_get(params, "(ui)", &revision, &parent); layout_update(proxy, revision, parent, client); } else if (g_strcmp0(signal, "ItemPropertiesUpdated") == 0) { + /* Remove before adding just incase there is a duplicate, against the + rules, but we can handle it so let's do it. */ + GVariantIter ritems; + g_variant_iter_init(&ritems, g_variant_get_child_value(params, 1)); + + GVariant * ritem; + while ((ritem = g_variant_iter_next_value(&ritems)) != NULL) { + gint id = g_variant_get_int32(g_variant_get_child_value(ritem, 0)); + DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); + + if (menuitem == NULL) { + continue; + } + + GVariantIter properties; + g_variant_iter_init(&properties, g_variant_get_child_value(ritem, 1)); + gchar * property; + + while (g_variant_iter_next(&properties, "s", &property)) { + g_debug("Removing property '%s' on %d", property, id); + dbusmenu_menuitem_property_remove(menuitem, property); + } + } + GVariantIter items; g_variant_iter_init(&items, g_variant_get_child_value(params, 0)); -- cgit v1.2.3 From 702af6f9968684a01689c7ee86f1e5c0229fff52 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 13:30:52 -0600 Subject: Make sure to put these in the right list --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 28ff9e4..362e2cb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -789,7 +789,7 @@ menuitem_property_idle (gpointer user_data) removeitem_init = TRUE; } - g_variant_builder_add_value(&itembuilder, g_variant_builder_end(&tuplebuilder)); + g_variant_builder_add_value(&removeitembuilder, g_variant_builder_end(&tuplebuilder)); } } -- cgit v1.2.3 From 1f1eb89cbf0317ea9e464354cd47b11502efc9de Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 13:32:49 -0600 Subject: Ignore signals if there's no root node --- libdbusmenu-glib/client.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 63fa089..9502bfd 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1036,6 +1036,9 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian guint revision; gint parent; g_variant_get(params, "(ui)", &revision, &parent); layout_update(proxy, revision, parent, client); + } else if (priv->root == NULL) { + /* Drop out here, all the rest of these really need to have a root + node so we can just ignore them if there isn't one. */ } else if (g_strcmp0(signal, "ItemPropertiesUpdated") == 0) { /* Remove before adding just incase there is a duplicate, against the rules, but we can handle it so let's do it. */ -- cgit v1.2.3 From 8600ea3459e8307da36e6da90640ff49226e90ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 14:43:27 -0600 Subject: Swapt out building XML for building a big variant structure --- libdbusmenu-glib/menuitem-private.h | 4 +-- libdbusmenu-glib/menuitem.c | 42 ++++++++++++++++------ libdbusmenu-glib/menuitem.h | 11 +++--- libdbusmenu-glib/server.c | 69 +++++++++++++++---------------------- 4 files changed, 67 insertions(+), 59 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-private.h b/libdbusmenu-glib/menuitem-private.h index 2028464..caa1377 100644 --- a/libdbusmenu-glib/menuitem-private.h +++ b/libdbusmenu-glib/menuitem-private.h @@ -33,10 +33,10 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array); +GVariant * dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties); gboolean dbusmenu_menuitem_realized (DbusmenuMenuitem * mi); void dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi); -GVariant * dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi); +GVariant * dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** properties); G_END_DECLS diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 159463b..309f435 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1264,7 +1264,7 @@ variant_helper (gpointer in_key, gpointer in_value, gpointer user_data) Return Value: A GVariant of type "a{sv}" or NULL on error. */ GVariant * -dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi) +dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** properties) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); @@ -1322,7 +1322,7 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) /** - dbusmenu_menuitem_buildxml: + dbusmenu_menuitem_buildvariant: @mi: #DbusmenuMenuitem to represent in XML @array: (element-type utf8): A list of string that will be turned into an XML file @@ -1332,28 +1332,50 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) start tag and one that is a closing tag. It will allow it's children to place their own tags in the array in between those two. */ -void -dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array) +GVariant * +dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties) { - g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); gint id = 0; if (!dbusmenu_menuitem_get_root(mi)) { id = dbusmenu_menuitem_get_id(mi); } + /* This is the tuple that'll build up being a representation of + this entry */ + GVariantBuilder tupleb; + g_variant_builder_init(&tupleb, G_VARIANT_TYPE_TUPLE); + + /* Add our ID */ + g_variant_builder_add_value(&tupleb, g_variant_new_int32(id)); + + /* Figure out the properties */ + GVariant * props = dbusmenu_menuitem_properties_variant(mi, properties); + if (props != NULL) { + g_variant_builder_add_value(&tupleb, props); + } else { + g_variant_builder_add_value(&tupleb, g_variant_parse(G_VARIANT_TYPE("a{sv}"), "[ ]", NULL, NULL, NULL)); + } + + /* Pillage the children */ GList * children = dbusmenu_menuitem_get_children(mi); if (children == NULL) { - g_ptr_array_add(array, g_strdup_printf("", id)); + g_variant_builder_add_value(&tupleb, g_variant_parse(G_VARIANT_TYPE("a(v)"), "[ ]", NULL, NULL, NULL)); } else { - g_ptr_array_add(array, g_strdup_printf("", id)); + GVariantBuilder childrenbuilder; + g_variant_builder_init(&childrenbuilder, G_VARIANT_TYPE_ARRAY); + for ( ; children != NULL; children = children->next) { - dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array); + GVariant * child = dbusmenu_menuitem_build_variant(DBUSMENU_MENUITEM(children->data), properties); + + g_variant_builder_add_value(&childrenbuilder, g_variant_new_variant(child)); } - g_ptr_array_add(array, g_strdup("")); + + g_variant_builder_add_value(&tupleb, g_variant_builder_end(&childrenbuilder)); } - return; + return g_variant_builder_end(&tupleb); } typedef struct { diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index a4c7611..c36e0e9 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -111,14 +111,15 @@ struct _DbusmenuMenuitem typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpointer user_data); /** - * dbusmenu_menuitem_buildxml_slot_t: + * dbusmenu_menuitem_buildvariant_slot_t: * @mi: (in): Menu item that should be built from - * @stringarray: (inout) (transfer none) (array) (element-type utf8): An array of strings that can be combined into an XML file. * * This is the function that is called to represent this menu item - * as an XML fragment. Should call it's own children. + * as a variant. Should call it's own children. + * + * Return value: (transfer full) A variant representing this item and it's children */ -typedef void (*dbusmenu_menuitem_buildxml_slot_t) (DbusmenuMenuitem * mi, GPtrArray* stringarray); +typedef GVariant * (*dbusmenu_menuitem_buildvariant_slot_t) (DbusmenuMenuitem * mi, gchar ** properties); /** * DbusmenuMenuitemClass: @@ -155,7 +156,7 @@ struct _DbusmenuMenuitemClass void (*realized) (void); /* Virtual functions */ - dbusmenu_menuitem_buildxml_slot_t buildxml; + dbusmenu_menuitem_buildvariant_slot_t buildvariant; void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); void (*send_about_to_show) (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 6a65b56..3e71f07 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -471,17 +471,6 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) return; } -static void -xmlarray_foreach_free (gpointer arrayentry, gpointer userdata) -{ - if (arrayentry != NULL) { - /* g_debug("Freeing pointer: %s", (gchar *)arrayentry); */ - g_free(arrayentry); - } - - return; -} - static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) { @@ -947,26 +936,28 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - gint parent = 0; - g_variant_get(params, "(i)", &parent); + /* Input */ + gint parent = g_variant_get_int32(g_variant_get_child_value(params, 0)); + //gint recurse = g_variant_get_int32(g_variant_get_child_value(params, 1)); + const gchar ** props = g_variant_get_strv(g_variant_get_child_value(params, 2), NULL); + /* Output */ guint revision = priv->layout_revision; - GPtrArray * xmlarray = g_ptr_array_new(); + GVariant * items = NULL; - if (parent == 0) { - if (priv->root == NULL) { - /* g_debug("Getting layout without root node!"); */ - g_ptr_array_add(xmlarray, g_strdup("")); - } else { - dbusmenu_menuitem_buildxml(priv->root, xmlarray); - } - } else { - DbusmenuMenuitem * item = NULL; - if (priv->root != NULL) { - item = dbusmenu_menuitem_find_id(priv->root, parent); - } + if (priv->root != NULL) { + items = dbusmenu_menuitem_build_variant(priv->root, props); + } - if (item == NULL) { + /* What happens if we don't have anything? */ + if (items == NULL) { + if (parent == 0) { + /* We should always have a root, so we'll make up one for + right now. */ + items = g_variant_parse(G_VARIANT_TYPE("(ia{sv}a(v))"), "(0, [], [])", NULL, NULL, NULL); + } else { + /* If we were looking for a specific ID that's an error that + we should send back, so let's do that. */ g_dbus_method_invocation_return_error(invocation, error_quark(), INVALID_MENUITEM_ID, @@ -974,23 +965,17 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio parent); return; } - dbusmenu_menuitem_buildxml(item, xmlarray); } - g_ptr_array_add(xmlarray, NULL); - /* build string */ - gchar * layout = g_strjoinv("", (gchar **)xmlarray->pdata); + /* Build the final variant tuple */ + GVariantBuilder tuplebuilder; + g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); - g_ptr_array_foreach(xmlarray, xmlarray_foreach_free, NULL); - g_ptr_array_free(xmlarray, TRUE); + g_variant_builder_add_value(&tuplebuilder, g_variant_new_uint32(revision)); + g_variant_builder_add_value(&tuplebuilder, items); g_dbus_method_invocation_return_value(invocation, - g_variant_new("(us)", - revision, - layout)); - - g_free(layout); - + g_variant_builder_end(&tuplebuilder)); return; } @@ -1064,7 +1049,7 @@ bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvoc return; } - GVariant * dict = dbusmenu_menuitem_properties_variant(mi); + GVariant * dict = dbusmenu_menuitem_properties_variant(mi, NULL); g_dbus_method_invocation_return_value(invocation, g_variant_new("(a{sv})", dict)); @@ -1112,7 +1097,7 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho GVariantBuilder wbuilder; g_variant_builder_init(&wbuilder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add(&wbuilder, "i", id); - GVariant * props = dbusmenu_menuitem_properties_variant(mi); + GVariant * props = dbusmenu_menuitem_properties_variant(mi, NULL); if (props == NULL) { GError * error = NULL; @@ -1172,7 +1157,7 @@ serialize_menuitem(gpointer data, gpointer user_data) gint id = dbusmenu_menuitem_get_id(mi); g_variant_builder_add_value(&tuple, g_variant_new_int32(id)); - GVariant * props = dbusmenu_menuitem_properties_variant(mi); + GVariant * props = dbusmenu_menuitem_properties_variant(mi, NULL); g_variant_builder_add_value(&tuple, props); g_variant_builder_add_value(builder, g_variant_builder_end(&tuple)); -- cgit v1.2.3 From 5da30c365a2196d488f9ea97f3455eefa3c3b058 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 14:46:36 -0600 Subject: Use the recurse parameter --- libdbusmenu-glib/menuitem-private.h | 2 +- libdbusmenu-glib/menuitem.c | 6 +++--- libdbusmenu-glib/server.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-private.h b/libdbusmenu-glib/menuitem-private.h index caa1377..07704ca 100644 --- a/libdbusmenu-glib/menuitem-private.h +++ b/libdbusmenu-glib/menuitem-private.h @@ -33,7 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -GVariant * dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties); +GVariant * dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties, gint recurse); gboolean dbusmenu_menuitem_realized (DbusmenuMenuitem * mi); void dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi); GVariant * dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** properties); diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 309f435..6a33499 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1333,7 +1333,7 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) children to place their own tags in the array in between those two. */ GVariant * -dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties) +dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties, gint recurse) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); @@ -1360,14 +1360,14 @@ dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** propertie /* Pillage the children */ GList * children = dbusmenu_menuitem_get_children(mi); - if (children == NULL) { + if (children == NULL && recurse != 0) { g_variant_builder_add_value(&tupleb, g_variant_parse(G_VARIANT_TYPE("a(v)"), "[ ]", NULL, NULL, NULL)); } else { GVariantBuilder childrenbuilder; g_variant_builder_init(&childrenbuilder, G_VARIANT_TYPE_ARRAY); for ( ; children != NULL; children = children->next) { - GVariant * child = dbusmenu_menuitem_build_variant(DBUSMENU_MENUITEM(children->data), properties); + GVariant * child = dbusmenu_menuitem_build_variant(DBUSMENU_MENUITEM(children->data), properties, recurse - 1); g_variant_builder_add_value(&childrenbuilder, g_variant_new_variant(child)); } diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 3e71f07..26e324e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -938,7 +938,7 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio /* Input */ gint parent = g_variant_get_int32(g_variant_get_child_value(params, 0)); - //gint recurse = g_variant_get_int32(g_variant_get_child_value(params, 1)); + gint recurse = g_variant_get_int32(g_variant_get_child_value(params, 1)); const gchar ** props = g_variant_get_strv(g_variant_get_child_value(params, 2), NULL); /* Output */ @@ -946,7 +946,7 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio GVariant * items = NULL; if (priv->root != NULL) { - items = dbusmenu_menuitem_build_variant(priv->root, props); + items = dbusmenu_menuitem_build_variant(priv->root, props, recurse); } /* What happens if we don't have anything? */ -- cgit v1.2.3 From 7930b8fa5e726b4b5136d71871a7a98a4885bbeb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 15:59:40 -0600 Subject: Changing the client over from XML to taking in the variant structures --- libdbusmenu-glib/client.c | 118 +++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 75 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index cb90789..574a8e0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -151,9 +151,8 @@ static void layout_update (GDBusProxy * proxy, guint revision, gint parent, Dbus static void id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GVariant * value, DbusmenuClient * client); static void id_update (GDBusProxy * proxy, gint id, DbusmenuClient * client); static void build_proxies (DbusmenuClient * client); -static gint parse_node_get_id (xmlNodePtr node); -static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, GDBusProxy * proxy); -static gint parse_layout (DbusmenuClient * client, const gchar * layout); +static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, GDBusProxy * proxy); +static gint parse_layout (DbusmenuClient * client, GVariant * layout); static void update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data); static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (GVariant * properties, GError * error, gpointer data); @@ -1075,40 +1074,6 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian return; } -/* Get the ID attribute of the node, parse it and - return it. Also we're checking to ensure the node - is a 'menu' here. */ -static gint -parse_node_get_id (xmlNodePtr node) -{ - if (node == NULL) { - return -1; - } - if (node->type != XML_ELEMENT_NODE) { - return -1; - } - if (g_strcmp0((gchar *)node->name, "menu") != 0) { - /* This kills some nodes early */ - g_warning("XML Node is not 'menu' it is '%s'", node->name); - return -1; - } - - xmlAttrPtr attrib; - for (attrib = node->properties; attrib != NULL; attrib = attrib->next) { - if (g_strcmp0((gchar *)attrib->name, "id") == 0) { - if (attrib->children != NULL) { - gint id = (guint)g_ascii_strtoll((gchar *)attrib->children->content, NULL, 10); - /* g_debug ("Found ID: %d", id); */ - return id; - } - break; - } - } - - g_warning("Unable to find an ID on the node"); - return -1; -} - /* This is the callback for the properties on a menu item. There should be all of them in the Hash, and they we use foreach to copy them into the menuitem. @@ -1411,10 +1376,14 @@ parse_layout_update (DbusmenuMenuitem * item, DbusmenuClient * client) /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * -parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, GDBusProxy * proxy) +parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, GDBusProxy * proxy) { + if (layout == NULL) { + return NULL; + } + /* First verify and figure out what we've got */ - gint id = parse_node_get_id(node); + gint id = g_variant_get_int32(g_variant_get_child_value(layout, 0)); if (id < 0) { return NULL; } @@ -1426,20 +1395,26 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it g_return_val_if_fail(id == dbusmenu_menuitem_get_id(item), NULL); /* Some variables */ - xmlNodePtr children; - guint position; + GVariantIter children; + g_variant_iter_init(&children, g_variant_get_child_value(layout, 2)); + GVariant * child; + + guint position = 0; GList * oldchildren = g_list_copy(dbusmenu_menuitem_get_children(item)); /* g_debug("Starting old children: %d", g_list_length(oldchildren)); */ /* Go through all the XML Nodes and make sure that we have menuitems to cover those XML nodes. */ - for (children = node->children, position = 0; children != NULL; children = children->next, position++) { + while ((child = g_variant_iter_next_value(&children)) != NULL) { /* g_debug("Looking at child: %d", position); */ - gint childid = parse_node_get_id(children); + if (g_variant_is_of_type(child, G_VARIANT_TYPE_VARIANT)) { + child = g_variant_get_variant(child); + } + + gint childid = g_variant_get_uint32(g_variant_get_child_value(child, 0)); if (childid < 0) { /* Don't increment the position when there isn't a valid node in the XML tree. It's probably a comment. */ - position--; continue; } DbusmenuMenuitem * childmi = NULL; @@ -1472,6 +1447,8 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it dbusmenu_menuitem_child_reorder(item, childmi, position); parse_layout_update(childmi, client); } + + position++; } /* Remove any children that are no longer used by this version of @@ -1494,14 +1471,16 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } /* now it's time to recurse down the tree. */ - children = node->children; + g_variant_iter_init(&children, g_variant_get_child_value(layout, 2)); + + child = g_variant_iter_next_value(&children); GList * childmis = dbusmenu_menuitem_get_children(item); - while (children != NULL && childmis != NULL) { - gint xmlid = parse_node_get_id(children); + while (child != NULL && childmis != NULL) { + gint xmlid = g_variant_get_uint32(g_variant_get_child_value(child, 0)); /* If this isn't a valid menu item we need to move on until we have one. This avoids things like comments. */ if (xmlid < 0) { - children = children->next; + child = g_variant_iter_next_value(&children); continue; } @@ -1510,13 +1489,14 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it g_debug("Recursing parse_layout_xml. XML ID: %d MI ID: %d", xmlid, miid); #endif - parse_layout_xml(client, children, DBUSMENU_MENUITEM(childmis->data), item, proxy); + parse_layout_xml(client, child, DBUSMENU_MENUITEM(childmis->data), item, proxy); - children = children->next; + child = g_variant_iter_next_value(&children); childmis = g_list_next(childmis); } - if (children != NULL) { - g_warning("Sync failed, now we've got extra XML nodes."); + + if (child != NULL) { + g_warning("Sync failed, now we've got extra layout nodes."); } if (childmis != NULL) { g_warning("Sync failed, now we've got extra menu items."); @@ -1528,7 +1508,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Take the layout passed to us over DBus and turn it into a set of beautiful objects */ static gint -parse_layout (DbusmenuClient * client, const gchar * layout) +parse_layout (DbusmenuClient * client, GVariant * layout) { #ifdef MASSIVEDEBUGGING g_debug("Client Parsing a new layout"); @@ -1536,17 +1516,6 @@ parse_layout (DbusmenuClient * client, const gchar * layout) DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - xmlDocPtr xmldoc; - - /* No one should need more characters than this! */ - xmldoc = xmlReadMemory(layout, g_utf8_strlen(layout, 1024*1024), "dbusmenu.xml", NULL, 0); - - xmlNodePtr root = xmlDocGetRootElement(xmldoc); - - if (root == NULL) { - g_warning("Unable to get root node of menu XML"); - } - DbusmenuMenuitem * oldroot = priv->root; if (priv->root == NULL) { @@ -1555,11 +1524,10 @@ parse_layout (DbusmenuClient * client, const gchar * layout) parse_layout_update(priv->root, client); } - priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); - xmlFreeDoc(xmldoc); + priv->root = parse_layout_xml(client, layout, priv->root, NULL, priv->menuproxy); if (priv->root == NULL) { - g_warning("Unable to parse layout on client %s object %s: %s", priv->dbus_name, priv->dbus_object, layout); + g_warning("Unable to parse layout on client %s object %s: %s", priv->dbus_name, priv->dbus_object, g_variant_print(layout, TRUE)); } if (priv->root != oldroot) { @@ -1600,14 +1568,10 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) goto out; } - guint rev; - gchar * xml; - - g_variant_get(params, "(us)", &rev, &xml); - g_variant_unref(params); + guint rev = g_variant_get_uint32(g_variant_get_child_value(params, 0)); + GVariant * layout = g_variant_get_child_value(params, 1); - guint parseable = parse_layout(client, xml); - g_free(xml); + guint parseable = parse_layout(client, layout); if (parseable == 0) { g_warning("Unable to parse layout!"); @@ -1633,6 +1597,10 @@ out: priv->layoutcall = NULL; } + if (params != NULL) { + g_variant_unref(params); + } + g_object_unref(G_OBJECT(client)); return; } @@ -1663,7 +1631,7 @@ update_layout (DbusmenuClient * client) g_object_ref(G_OBJECT(client)); g_dbus_proxy_call(priv->menuproxy, "GetLayout", - g_variant_new("(i)", 0), /* root */ + g_variant_new("(iia(s))", 0, -1, NULL), /* root */ G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ priv->layoutcall, /* cancellable */ -- cgit v1.2.3 From 9e1ab7f70ffee850bd09660d27199ece367b0c5d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 16:00:51 -0600 Subject: Dropping libxml --- libdbusmenu-glib/client.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 574a8e0..fb4509b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -32,9 +32,6 @@ License version 3 and version 2.1 along with this program. If not, see #include -#include -#include - #include "client.h" #include "menuitem.h" #include "menuitem-private.h" -- cgit v1.2.3 From bf3230927208a3bcd5f8f5edb000e14481ffb9b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 16:19:09 -0600 Subject: Making the build of the message more explicit and correct --- libdbusmenu-glib/client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index fb4509b..60ec1ee 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1625,10 +1625,17 @@ update_layout (DbusmenuClient * client) priv->layoutcall = g_cancellable_new(); + GVariantBuilder tupleb; + g_variant_builder_init(&tupleb, G_VARIANT_TYPE_TUPLE); + + g_variant_builder_add_value(&tupleb, g_variant_new_int32(0)); // root + g_variant_builder_add_value(&tupleb, g_variant_new_int32(-1)); // recurse + g_variant_builder_add_value(&tupleb, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); // props + g_object_ref(G_OBJECT(client)); g_dbus_proxy_call(priv->menuproxy, "GetLayout", - g_variant_new("(iia(s))", 0, -1, NULL), /* root */ + g_variant_builder_end(&tupleb), G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ priv->layoutcall, /* cancellable */ -- cgit v1.2.3 From a34c2408b86a40324d378095e701a1b0e76649d7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 16:20:47 -0600 Subject: Making the properties a dictionary --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 4a4d166..0b238a4 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -205,7 +205,7 @@ License version 3 and version 2.1 along with this program. If not, see The revision number of the layout. For matching with layoutUpdated signals. - + The layout as an XML string of IDs. -- cgit v1.2.3 From bb4167eeb1810687c8c56a376a0a0566c1e46f41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 16:35:57 -0600 Subject: Splitting out the args for easier debugging --- libdbusmenu-glib/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 60ec1ee..7721787 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1632,10 +1632,13 @@ update_layout (DbusmenuClient * client) g_variant_builder_add_value(&tupleb, g_variant_new_int32(-1)); // recurse g_variant_builder_add_value(&tupleb, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); // props + GVariant * args = g_variant_builder_end(&tupleb); + // g_debug("Args (type: %s): %s", g_variant_get_type_string(args), g_variant_print(args, TRUE)); + g_object_ref(G_OBJECT(client)); g_dbus_proxy_call(priv->menuproxy, "GetLayout", - g_variant_builder_end(&tupleb), + args, G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ priv->layoutcall, /* cancellable */ -- cgit v1.2.3 From d65675fb78f9bcf3dd5a991e9de22d24c4cfaac6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 16:36:09 -0600 Subject: Fixing the type of the return structure --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 0b238a4..8ca947b 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -205,7 +205,7 @@ License version 3 and version 2.1 along with this program. If not, see The revision number of the layout. For matching with layoutUpdated signals. - + The layout as an XML string of IDs. -- cgit v1.2.3 From 8470e56b0fbc5ddf21100e2e9e4ec38c70c35717 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 16:54:25 -0600 Subject: More explicit function calling --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 6a33499..da34ff0 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1361,7 +1361,7 @@ dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** propertie /* Pillage the children */ GList * children = dbusmenu_menuitem_get_children(mi); if (children == NULL && recurse != 0) { - g_variant_builder_add_value(&tupleb, g_variant_parse(G_VARIANT_TYPE("a(v)"), "[ ]", NULL, NULL, NULL)); + g_variant_builder_add_value(&tupleb, g_variant_new_array(G_VARIANT_TYPE_VARIANT, NULL, 0)); } else { GVariantBuilder childrenbuilder; g_variant_builder_init(&childrenbuilder, G_VARIANT_TYPE_ARRAY); -- cgit v1.2.3 From db7578d5a6690a7170b449624e4092b9c1e69371 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 17:00:43 -0600 Subject: Changing type to make GDBus happy. Eh. --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 8ca947b..e0e70d7 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -205,7 +205,7 @@ License version 3 and version 2.1 along with this program. If not, see The revision number of the layout. For matching with layoutUpdated signals. - + The layout as an XML string of IDs. -- cgit v1.2.3 From b145235e39b4ac35c1cad312d04e7c0471c518d7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 17:09:04 -0600 Subject: Get the IDs properly. ints and unpacked --- libdbusmenu-glib/client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7721787..fa3b1d2 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1408,7 +1408,7 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * child = g_variant_get_variant(child); } - gint childid = g_variant_get_uint32(g_variant_get_child_value(child, 0)); + gint childid = g_variant_get_int32(g_variant_get_child_value(child, 0)); if (childid < 0) { /* Don't increment the position when there isn't a valid node in the XML tree. It's probably a comment. */ @@ -1473,7 +1473,11 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * child = g_variant_iter_next_value(&children); GList * childmis = dbusmenu_menuitem_get_children(item); while (child != NULL && childmis != NULL) { - gint xmlid = g_variant_get_uint32(g_variant_get_child_value(child, 0)); + if (g_variant_is_of_type(child, G_VARIANT_TYPE_VARIANT)) { + child = g_variant_get_variant(child); + } + + gint xmlid = g_variant_get_int32(g_variant_get_child_value(child, 0)); /* If this isn't a valid menu item we need to move on until we have one. This avoids things like comments. */ if (xmlid < 0) { -- cgit v1.2.3 From 931994f499108dec95c7e6c9022848667b69848f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 17:14:46 -0600 Subject: Fixing the type to match dbus-menu.xml --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 26e324e..4da8ae0 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -954,7 +954,7 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio if (parent == 0) { /* We should always have a root, so we'll make up one for right now. */ - items = g_variant_parse(G_VARIANT_TYPE("(ia{sv}a(v))"), "(0, [], [])", NULL, NULL, NULL); + items = g_variant_parse(G_VARIANT_TYPE("(ia{sv}av)"), "(0, [], [])", NULL, NULL, NULL); } else { /* If we were looking for a specific ID that's an error that we should send back, so let's do that. */ -- cgit v1.2.3 From 331a9b26f51f79a1c06dde2ca5c1364431e471be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 22:35:51 -0600 Subject: Protecting from the cases of NULL variants --- libdbusmenu-glib/server.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4fe7bdc..ed23d16 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -680,7 +680,10 @@ prop_array_teardown (GArray * prop_array) prop_idle_prop_t * iprop = &g_array_index(iitem->array, prop_idle_prop_t, j); g_free(iprop->property); - g_variant_unref(iprop->variant); + + if (iprop->variant != NULL) { + g_variant_unref(iprop->variant); + } } g_array_free(iitem->array, TRUE); @@ -899,7 +902,9 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v g_array_append_val(properties, myprop); } - g_variant_ref(variant); + if (variant != NULL) { + g_variant_ref(variant); + } /* Check to see if the idle is already queued, and queue it if not. */ -- cgit v1.2.3 From b0c5bfe2e4d50d12dc4b8ab9828b67b47abbd5a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 23:11:28 -0600 Subject: Splitting a few of these out so they're easier to follow --- libdbusmenu-glib/menuitem.c | 6 ++++-- libdbusmenu-glib/server.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 7ea54e2..044138e 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1250,7 +1250,9 @@ dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) static void variant_helper (gpointer in_key, gpointer in_value, gpointer user_data) { - g_variant_builder_add((GVariantBuilder *)user_data, "{sv}", in_key, in_value); + GVariant * value = g_variant_new_dict_entry(g_variant_new_string((gchar *)in_key), + g_variant_new_variant((GVariant *)in_value)); + g_variant_builder_add_value((GVariantBuilder *)user_data, value); return; } @@ -1274,7 +1276,7 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** prop if (g_hash_table_size(priv->properties) > 0) { GVariantBuilder builder; - g_variant_builder_init(&builder, g_variant_type_new("a{sv}")); + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); g_hash_table_foreach(priv->properties, variant_helper, &builder); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index ed23d16..2852b7b 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1058,8 +1058,10 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio g_variant_builder_add_value(&tuplebuilder, g_variant_new_uint32(revision)); g_variant_builder_add_value(&tuplebuilder, items); + GVariant * retval = g_variant_builder_end(&tuplebuilder); + // g_debug("Sending layout type: %s", g_variant_get_type_string(retval)); g_dbus_method_invocation_return_value(invocation, - g_variant_builder_end(&tuplebuilder)); + retval); return; } -- cgit v1.2.3 From 7a7981e687543d6abcf0109bec2551b366906303 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Feb 2011 07:55:22 -0600 Subject: Should sink as well if given a floating reference. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 044138e..55d17f1 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1009,7 +1009,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro if (value != NULL) { gchar * lprop = g_strdup(property); - g_variant_ref(value); + g_variant_ref_sink(value); if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) { g_hash_table_replace(priv->properties, lprop, value); -- cgit v1.2.3 From ee4fda3072d31b828c5d607b9ac0a4ab6c7ee320 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Feb 2011 11:42:52 -0600 Subject: Making sure all refs sink incase of floating variants --- libdbusmenu-glib/client.c | 2 +- libdbusmenu-glib/menuitem.c | 2 +- libdbusmenu-glib/server.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 6a9dc23..ba4ae7e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1276,7 +1276,7 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name edata->event = g_strdup(name); edata->timestamp = timestamp; edata->variant = variant; - g_variant_ref(variant); + g_variant_ref_sink(variant); g_dbus_proxy_call(priv->menuproxy, "Event", diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 55d17f1..54d2540 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1213,7 +1213,7 @@ copy_helper (gpointer in_key, gpointer in_value, gpointer in_data) GHashTable * table = (GHashTable *)in_data; gchar * key = (gchar *)in_key; GVariant * value = (GVariant *)in_value; - g_variant_ref(value); + g_variant_ref_sink(value); g_hash_table_insert(table, g_strdup(key), value); return; } diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 2852b7b..aa39991 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -903,7 +903,7 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v g_array_append_val(properties, myprop); } if (variant != NULL) { - g_variant_ref(variant); + g_variant_ref_sink(variant); } /* Check to see if the idle is already queued, and queue it @@ -1366,7 +1366,7 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i event_data->variant = g_variant_get_variant(event_data->variant); } - g_variant_ref(event_data->variant); + g_variant_ref_sink(event_data->variant); g_timeout_add(0, event_local_handler, event_data); -- cgit v1.2.3 From 1847903e5d6eb97203ba77a9ee0a0648b5fdeb0c Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Feb 2011 18:00:55 +0100 Subject: Fix g-ir-scanner file list As the annotations are in the .c files, g-ir-scanner actually needs to read them. --- libdbusmenu-glib/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index e6877b6..92de502 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -122,21 +122,21 @@ if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --warn-all \ --add-include-path=$(srcdir) \ - $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) \ + $(addprefix --c-include=libdbusmenu-glib/, $(libdbusmenu_glibinclude_HEADERS)) \ --symbol-prefix=dbusmenu \ --identifier-prefix=Dbusmenu else INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --warn-all \ --add-include-path=$(srcdir) \ - $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) + $(addprefix --c-include=libdbusmenu-glib/, $(libdbusmenu_glibinclude_HEADERS)) endif INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) if HAVE_INTROSPECTION -introspection_sources = $(libdbusmenu_glibinclude_HEADERS) +introspection_sources = $(libdbusmenu_glibinclude_HEADERS) $(libdbusmenu_glib_la_SOURCES) Dbusmenu-0.4.gir: libdbusmenu-glib.la Dbusmenu_0_4_gir_INCLUDES = \ -- cgit v1.2.3 From bafe476c0fa84277c6136605680c3d349430db50 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Feb 2011 20:34:17 +0100 Subject: Fix GI annotations for Dbusmenu Now everything is introspectable except for dbusmenu_client_add_type_handler{,_full}(). These do not take a standard GDestroyNotify argument, and thus the newfunc callback cannot get any valid scope annotation. To fix this we need to break the API and ABI. --- libdbusmenu-glib/client.c | 136 +++---- libdbusmenu-glib/client.h | 2 +- libdbusmenu-glib/menuitem-proxy.c | 34 +- libdbusmenu-glib/menuitem.c | 723 +++++++++++++++++++------------------- libdbusmenu-glib/menuitem.h | 4 +- 5 files changed, 450 insertions(+), 449 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5e492a3..8a1d213 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1654,17 +1654,17 @@ update_layout (DbusmenuClient * client) /* Public API */ /** - dbusmenu_client_new: - @name: The DBus name for the server to connect to - @object: The object on the server to monitor - - This function creates a new client that connects to a specific - server on DBus. That server is at a specific location sharing - a known object. The interface is assumed by the code to be - the DBus menu interface. The newly created client will start - sending out events as it syncs up with the server. - - Return value: A brand new #DbusmenuClient + * dbusmenu_client_new: + * @name: The DBus name for the server to connect to + * @object: The object on the server to monitor + * + * This function creates a new client that connects to a specific + * server on DBus. That server is at a specific location sharing + * a known object. The interface is assumed by the code to be + * the DBus menu interface. The newly created client will start + * sending out events as it syncs up with the server. + * + * Return value: A brand new #DbusmenuClient */ DbusmenuClient * dbusmenu_client_new (const gchar * name, const gchar * object) @@ -1678,21 +1678,21 @@ dbusmenu_client_new (const gchar * name, const gchar * object) } /** - dbusmenu_client_get_root: - @client: The #DbusmenuClient to get the root node from - - Grabs the root node for the specified client @client. This - function may block. It will block if there is currently a - call to update the layout, it will block on that layout - updated and then return the newly updated layout. Chances - are that this update is in the queue for the mainloop as - it would have been requested some time ago, but in theory - it could block longer. - - Return value: A #DbusmenuMenuitem representing the root of - menu on the server. If there is no server or there is - an error receiving its layout it'll return #NULL. -*/ + * dbusmenu_client_get_root: + * @client: The #DbusmenuClient to get the root node from + * + * Grabs the root node for the specified client @client. This + * function may block. It will block if there is currently a + * call to update the layout, it will block on that layout + * updated and then return the newly updated layout. Chances + * are that this update is in the queue for the mainloop as + * it would have been requested some time ago, but in theory + * it could block longer. + * + * Return value: (transfer none): A #DbusmenuMenuitem representing the root of + * menu on the server. If there is no server or there is + * an error receiving its layout it'll return #NULL. + */ DbusmenuMenuitem * dbusmenu_client_get_root (DbusmenuClient * client) { @@ -1721,25 +1721,25 @@ type_handler_destroy (gpointer user_data) } /** - dbusmenu_client_add_type_handler: - @client: Client where we're getting types coming in - @type: A text string that will be matched with the 'type' - property on incoming menu items - @newfunc: The function that will be executed with those new - items when they come in. - - This function connects into the type handling of the #DbusmenuClient. - Every new menuitem that comes in immediately gets asked for it's - properties. When we get those properties we check the 'type' - property and look to see if it matches a handler that is known - by the client. If so, the @newfunc function is executed on that - #DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem - signal is sent. - - In the future the known types will be sent to the server so that it - can make choices about the menu item types availble. - - Return value: If registering the new type was successful. + * dbusmenu_client_add_type_handler: + * @client: Client where we're getting types coming in + * @type: A text string that will be matched with the 'type' + * property on incoming menu items + * @newfunc: The function that will be executed with those new + * items when they come in. + * + * This function connects into the type handling of the #DbusmenuClient. + * Every new menuitem that comes in immediately gets asked for it's + * properties. When we get those properties we check the 'type' + * property and look to see if it matches a handler that is known + * by the client. If so, the @newfunc function is executed on that + * #DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem + * signal is sent. + * + * In the future the known types will be sent to the server so that it + * can make choices about the menu item types availble. + * + * Return value: If registering the new type was successful. */ gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc) @@ -1748,29 +1748,29 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D } /** - dbusmenu_client_add_type_handler_full: - @client: Client where we're getting types coming in - @type: A text string that will be matched with the 'type' - property on incoming menu items - @newfunc: The function that will be executed with those new - items when they come in. - @user_data: Data passed to @newfunc when it is called - @destroy_func: A function that is called when the type handler is - removed (usually on client destruction) which will free - the resources in @user_data. - - This function connects into the type handling of the #DbusmenuClient. - Every new menuitem that comes in immediately gets asked for it's - properties. When we get those properties we check the 'type' - property and look to see if it matches a handler that is known - by the client. If so, the @newfunc function is executed on that - #DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem - signal is sent. - - In the future the known types will be sent to the server so that it - can make choices about the menu item types availble. - - Return value: If registering the new type was successful. + * dbusmenu_client_add_type_handler_full: + * @client: Client where we're getting types coming in + * @type: A text string that will be matched with the 'type' + * property on incoming menu items + * @newfunc: The function that will be executed with those new + * items when they come in. + * @user_data: Data passed to @newfunc when it is called + * @destroy_func: A function that is called when the type handler is + * removed (usually on client destruction) which will free + * the resources in @user_data. + * + * This function connects into the type handling of the #DbusmenuClient. + * Every new menuitem that comes in immediately gets asked for it's + * properties. When we get those properties we check the 'type' + * property and look to see if it matches a handler that is known + * by the client. If so, the @newfunc function is executed on that + * #DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem + * signal is sent. + * + * In the future the known types will be sent to the server so that it + * can make choices about the menu item types availble. + * + * Return value: If registering the new type was successful. */ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, DbusmenuClientTypeDestroyHandler destroy_func) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 6d78edf..79c0ee2 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -145,7 +145,7 @@ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * cli const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, - DbusmenuClientTypeDestroyHandler destory_func); + DbusmenuClientTypeDestroyHandler destroy_func); void dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, diff --git a/libdbusmenu-glib/menuitem-proxy.c b/libdbusmenu-glib/menuitem-proxy.c index 1d97c4c..ae6a334 100644 --- a/libdbusmenu-glib/menuitem-proxy.c +++ b/libdbusmenu-glib/menuitem-proxy.c @@ -325,14 +325,14 @@ remove_menuitem (DbusmenuMenuitemProxy * pmi) } /** - dbusmenu_menuitem_proxy_new: - @mi: The #DbusmenuMenuitem to proxy - - Builds a new #DbusmenuMenuitemProxy object that proxies - all of the values for @mi. - - Return value: A new #DbusmenuMenuitemProxy object. -*/ + * dbusmenu_menuitem_proxy_new: + * @mi: The #DbusmenuMenuitem to proxy + * + * Builds a new #DbusmenuMenuitemProxy object that proxies + * all of the values for @mi. + * + * Return value: A new #DbusmenuMenuitemProxy object. + */ DbusmenuMenuitemProxy * dbusmenu_menuitem_proxy_new (DbusmenuMenuitem * mi) { @@ -344,15 +344,15 @@ dbusmenu_menuitem_proxy_new (DbusmenuMenuitem * mi) } /** - dbusmenu_menuitem_proxy_get_wrapped: - @pmi: #DbusmenuMenuitemProxy to look into - - Accesses the private variable of which #DbusmenuMenuitem - we are doing the proxying for. - - Return value: A #DbusmenuMenuitem object or a #NULL if we - don't have one or there is an error. -*/ + * dbusmenu_menuitem_proxy_get_wrapped: + * @pmi: #DbusmenuMenuitemProxy to look into + * + * Accesses the private variable of which #DbusmenuMenuitem + * we are doing the proxying for. + * + * Return value: (transfer none): A #DbusmenuMenuitem object or a #NULL if we + * don't have one or there is an error. + */ DbusmenuMenuitem * dbusmenu_menuitem_proxy_get_wrapped (DbusmenuMenuitemProxy * pmi) { diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 159463b..b5a87a4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -95,7 +95,7 @@ static void set_property (GObject * obj, guint id, const GValue * value, GParamS static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out); static void g_value_transform_STRING_INT (const GValue * in, GValue * out); -static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); +static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp); static void send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); /* GObject stuff */ @@ -428,12 +428,12 @@ send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gp /* Public interface */ /** - dbusmenu_menuitem_new: - - Create a new #DbusmenuMenuitem with all default values. - - Return value: A newly allocated #DbusmenuMenuitem. -*/ + * dbusmenu_menuitem_new: + * + * Create a new #DbusmenuMenuitem with all default values. + * + * Return value: A newly allocated #DbusmenuMenuitem. + */ DbusmenuMenuitem * dbusmenu_menuitem_new (void) { @@ -441,13 +441,13 @@ dbusmenu_menuitem_new (void) } /** - dbusmenu_menuitem_new_with_id: - @id: ID to use for this menuitem - - This creates a blank #DbusmenuMenuitem with a specific ID. - - Return value: A newly allocated #DbusmenuMenuitem. -*/ + * dbusmenu_menuitem_new_with_id: + * @id: ID to use for this menuitem + * + * This creates a blank #DbusmenuMenuitem with a specific ID. + * + * Return value: A newly allocated #DbusmenuMenuitem. + */ DbusmenuMenuitem * dbusmenu_menuitem_new_with_id (gint id) { @@ -457,13 +457,13 @@ dbusmenu_menuitem_new_with_id (gint id) } /** - dbusmenu_menuitem_get_id: - @mi: The #DbusmenuMenuitem to query. - - Gets the unique ID for @mi. - - Return value: The ID of the @mi. -*/ + * dbusmenu_menuitem_get_id: + * @mi: The #DbusmenuMenuitem to query. + * + * Gets the unique ID for @mi. + * + * Return value: The ID of the @mi. + */ gint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi) { @@ -480,17 +480,17 @@ dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi) } /** - dbusmenu_menuitem_realized: - @mi: #DbusmenuMenuitem to check on - - This function returns whether the menuitem has been realized or - not. This is significant mostly in client implementations that - can use this additional state to see if the second layers of - the implementation have been built yet. - - Return value: Returns whether or not the menu item has been realized - yet or not. -*/ + * dbusmenu_menuitem_realized: + * @mi: #DbusmenuMenuitem to check on + * + * This function returns whether the menuitem has been realized or + * not. This is significant mostly in client implementations that + * can use this additional state to see if the second layers of + * the implementation have been built yet. + * + * Return value: Returns whether or not the menu item has been realized + * yet or not. + */ gboolean dbusmenu_menuitem_realized (DbusmenuMenuitem * mi) { @@ -500,12 +500,12 @@ dbusmenu_menuitem_realized (DbusmenuMenuitem * mi) } /** - dbusmenu_menuitem_set_realized: - @mi: #DbusmenuMenuitem to realize - - Sets the internal variable tracking whether it's been realized and - signals the DbusmenuMenuitem::realized event. -*/ + * dbusmenu_menuitem_set_realized: + * @mi: #DbusmenuMenuitem to realize + * + * Sets the internal variable tracking whether it's been realized and + * signals the DbusmenuMenuitem::realized event. + */ void dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi) { @@ -520,15 +520,15 @@ dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi) } /** - dbusmenu_menuitem_get_children: - @mi: The #DbusmenuMenuitem to query. - - Returns simply the list of children that this menu item - has. The list is valid until another child related function - is called, where it might be changed. - - Return value: A #GList of pointers to #DbusmenuMenuitem objects. -*/ + * dbusmenu_menuitem_get_children: + * @mi: The #DbusmenuMenuitem to query. + * + * Returns simply the list of children that this menu item + * has. The list is valid until another child related function + * is called, where it might be changed. + * + * Return value: (transfer none): A #GList of pointers to #DbusmenuMenuitem objects. + */ GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi) { @@ -551,18 +551,18 @@ take_children_signal (gpointer data, gpointer user_data) } /** - dbusmenu_menuitem_take_children: - @mi: The #DbusmenMenuitem to take the children from. - - While the name sounds devious that's exactly what this function - does. It takes the list of children from the @mi and clears the - internal list. The calling function is now in charge of the ref's - on the children it has taken. A lot of responsibility involved - in taking children. - - Return value: (transfer full) (array) (element-type Dbusmenu.Menuitem) - A #GList of pointers to #DbusmenuMenuitem objects. -*/ + * dbusmenu_menuitem_take_children: + * @mi: The #DbusmenMenuitem to take the children from. + * + * While the name sounds devious that's exactly what this function + * does. It takes the list of children from the @mi and clears the + * internal list. The calling function is now in charge of the ref's + * on the children it has taken. A lot of responsibility involved + * in taking children. + * + * Return value: (transfer full) (element-type Dbusmenu.Menuitem): + * A #GList of pointers to #DbusmenuMenuitem objects. + */ GList * dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) { @@ -579,16 +579,16 @@ dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) } /** - dbusmenu_menuitem_get_position: - @mi: The #DbusmenuMenuitem to find the position of - @parent: The #DbusmenuMenuitem who's children contain @mi - - This function returns the position of the menu item @mi - in the children of @parent. It will return zero if the - menu item can't be found. - - Return value: The position of @mi in the children of @parent. -*/ + * dbusmenu_menuitem_get_position: + * @mi: The #DbusmenuMenuitem to find the position of + * @parent: The #DbusmenuMenuitem who's children contain @mi + * + * This function returns the position of the menu item @mi + * in the children of @parent. It will return zero if the + * menu item can't be found. + * + * Return value: The position of @mi in the children of @parent. + */ guint dbusmenu_menuitem_get_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent) { @@ -618,15 +618,15 @@ dbusmenu_menuitem_get_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent } /** - dbusmenu_menuitem_get_position_realized: - @mi: The #DbusmenuMenuitem to find the position of - @parent: The #DbusmenuMenuitem who's children contain @mi - - This function is very similar to #dbusmenu_menuitem_get_position - except that it only counts in the children that have been realized. - - Return value: The position of @mi in the realized children of @parent. -*/ + * dbusmenu_menuitem_get_position_realized: + * @mi: The #DbusmenuMenuitem to find the position of + * @parent: The #DbusmenuMenuitem who's children contain @mi + * + * This function is very similar to #dbusmenu_menuitem_get_position + * except that it only counts in the children that have been realized. + * + * Return value: The position of @mi in the realized children of @parent. + */ guint dbusmenu_menuitem_get_position_realized (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent) { @@ -662,15 +662,15 @@ dbusmenu_menuitem_get_position_realized (DbusmenuMenuitem * mi, DbusmenuMenuitem } /** - dbusmenu_menuitem_child_append: - @mi: The #DbusmenuMenuitem which will become a new parent - @child: The #DbusmenMenuitem that will be a child - - This function adds @child to the list of children on @mi at - the end of that list. - - Return value: Whether the child has been added successfully. -*/ + * dbusmenu_menuitem_child_append: + * @mi: The #DbusmenuMenuitem which will become a new parent + * @child: The #DbusmenMenuitem that will be a child + * + * This function adds @child to the list of children on @mi at + * the end of that list. + * + * Return value: Whether the child has been added successfully. + */ gboolean dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) { @@ -694,15 +694,15 @@ dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) } /** - dbusmenu_menuitem_child_prepend: - @mi: The #DbusmenuMenuitem which will become a new parent - @child: The #DbusmenMenuitem that will be a child - - This function adds @child to the list of children on @mi at - the beginning of that list. - - Return value: Whether the child has been added successfully. -*/ + * dbusmenu_menuitem_child_prepend: + * @mi: The #DbusmenuMenuitem which will become a new parent + * @child: The #DbusmenMenuitem that will be a child + * + * This function adds @child to the list of children on @mi at + * the beginning of that list. + * + * Return value: Whether the child has been added successfully. + */ gboolean dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) { @@ -726,16 +726,16 @@ dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child } /** - dbusmenu_menuitem_child_delete: - @mi: The #DbusmenuMenuitem which has @child as a child - @child: The child #DbusmenuMenuitem that you want to no longer - be a child of @mi. - - This function removes @child from the children list of @mi. It does - not call #g_object_unref on @child. - - Return value: If we were able to delete @child. -*/ + * dbusmenu_menuitem_child_delete: + * @mi: The #DbusmenuMenuitem which has @child as a child + * @child: The child #DbusmenuMenuitem that you want to no longer + * be a child of @mi. + * + * This function removes @child from the children list of @mi. It does + * not call #g_object_unref on @child. + * + * Return value: If we were able to delete @child. + */ gboolean dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) { @@ -758,17 +758,17 @@ dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) } /** - dbusmenu_menuitem_child_add_position: - @mi: The #DbusmenuMenuitem that we're adding the child @child to. - @child: The #DbusmenuMenuitem to make a child of @mi. - @position: Where in @mi object's list of chidren @child should be placed. - - Puts @child in the list of children for @mi at the location - specified in @position. If there is not enough entires available - then @child will be placed at the end of the list. - - Return value: Whether @child was added successfully. -*/ + * dbusmenu_menuitem_child_add_position: + * @mi: The #DbusmenuMenuitem that we're adding the child @child to. + * @child: The #DbusmenuMenuitem to make a child of @mi. + * @position: Where in @mi object's list of chidren @child should be placed. + * + * Puts @child in the list of children for @mi at the location + * specified in @position. If there is not enough entires available + * then @child will be placed at the end of the list. + * + * Return value: Whether @child was added successfully. + */ gboolean dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position) { @@ -792,17 +792,17 @@ dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * } /** - dbusmenu_menuitem_child_reorder: - @base: The #DbusmenuMenuitem that has children needing realignment - @child: The #DbusmenuMenuitem that is a child needing to be moved - @position: The position in the list to place it in - - This function moves a child on the list of children. It is - for a child that is already in the list, but simply needs a - new location. - - Return value: Whether the move was successful. -*/ + * dbusmenu_menuitem_child_reorder: + * @mi: The #DbusmenuMenuitem that has children needing realignment + * @child: The #DbusmenuMenuitem that is a child needing to be moved + * @position: The position in the list to place it in + * + * This function moves a child on the list of children. It is + * for a child that is already in the list, but simply needs a + * new location. + * + * Return value: Whether the move was successful. + */ gboolean dbusmenu_menuitem_child_reorder(DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position) { @@ -832,16 +832,16 @@ dbusmenu_menuitem_child_reorder(DbusmenuMenuitem * mi, DbusmenuMenuitem * child, } /** - dbusmenu_menuitem_child_find: - @mi: The #DbusmenuMenuitem who's children to look on - @id: The ID of the child that we're looking for. - - Search the children of @mi to find one with the ID of @id. - If it doesn't exist then we return #NULL. - - Return value: The menu item with the ID @id or #NULL if it - can't be found. -*/ + * dbusmenu_menuitem_child_find: + * @mi: The #DbusmenuMenuitem who's children to look on + * @id: The ID of the child that we're looking for. + * + * Search the children of @mi to find one with the ID of @id. + * If it doesn't exist then we return #NULL. + * + * Return value: (transfer none): The menu item with the ID @id or #NULL if it + * can't be found. + */ DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id) { @@ -885,18 +885,18 @@ find_id_helper (gpointer in_mi, gpointer in_find_id) } /** - dbusmenu_menuitem_find_id: - @mi: #DbusmenuMenuitem at the top of the tree to search - @id: ID of the #DbusmenuMenuitem to search for - - This function searchs the whole tree of children that - are attached to @mi. This could be quite a few nodes, all - the way down the tree. It is a depth first search. - - Return value: The #DbusmenuMenuitem with the ID of @id - or #NULL if there isn't such a menu item in the tree - represented by @mi. -*/ + * dbusmenu_menuitem_find_id: + * @mi: #DbusmenuMenuitem at the top of the tree to search + * @id: ID of the #DbusmenuMenuitem to search for + * + * This function searchs the whole tree of children that + * are attached to @mi. This could be quite a few nodes, all + * the way down the tree. It is a depth first search. + * + * Return value: (transfer none): The #DbusmenuMenuitem with the ID of @id + * or #NULL if there isn't such a menu item in the tree + * represented by @mi. + */ DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id) { @@ -913,20 +913,20 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id) } /** - dbusmenu_menuitem_property_set: - @mi: The #DbusmenuMenuitem to set the property on. - @property: Name of the property to set. - @value: The value of the property. - - Takes the pair of @property and @value and places them as a - property on @mi. If a property already exists by that name, - then the value is set to the new value. If not, the property - is added. If the value is changed or the property was previously - unset then the signal #DbusmenuMenuitem::prop-changed will be - emitted by this function. - - Return value: A boolean representing if the property value was set. -*/ + * dbusmenu_menuitem_property_set: + * @mi: The #DbusmenuMenuitem to set the property on. + * @property: Name of the property to set. + * @value: The value of the property. + * + * Takes the pair of @property and @value and places them as a + * property on @mi. If a property already exists by that name, + * then the value is set to the new value. If not, the property + * is added. If the value is changed or the property was previously + * unset then the signal #DbusmenuMenuitem::prop-changed will be + * emitted by this function. + * + * Return value: A boolean representing if the property value was set. + */ gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value) { @@ -938,20 +938,20 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c } /** - dbusmenu_menuitem_property_set_bool: - @mi: The #DbusmenuMenuitem to set the property on. - @property: Name of the property to set. - @value: The value of the property. - - Takes a boolean @value and sets it on @property as a - property on @mi. If a property already exists by that name, - then the value is set to the new value. If not, the property - is added. If the value is changed or the property was previously - unset then the signal #DbusmenuMenuitem::prop-changed will be - emitted by this function. - - Return value: A boolean representing if the property value was set. -*/ + * dbusmenu_menuitem_property_set_bool: + * @mi: The #DbusmenuMenuitem to set the property on. + * @property: Name of the property to set. + * @value: The value of the property. + * + * Takes a boolean @value and sets it on @property as a + * property on @mi. If a property already exists by that name, + * then the value is set to the new value. If not, the property + * is added. If the value is changed or the property was previously + * unset then the signal #DbusmenuMenuitem::prop-changed will be + * emitted by this function. + * + * Return value: A boolean representing if the property value was set. + */ gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value) { @@ -960,20 +960,20 @@ dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * proper } /** - dbusmenu_menuitem_property_set_int: - @mi: The #DbusmenuMenuitem to set the property on. - @property: Name of the property to set. - @value: The value of the property. - - Takes a boolean @value and sets it on @property as a - property on @mi. If a property already exists by that name, - then the value is set to the new value. If not, the property - is added. If the value is changed or the property was previously - unset then the signal #DbusmenuMenuitem::prop-changed will be - emitted by this function. - - Return value: A boolean representing if the property value was set. -*/ + * dbusmenu_menuitem_property_set_int: + * @mi: The #DbusmenuMenuitem to set the property on. + * @property: Name of the property to set. + * @value: The value of the property. + * + * Takes a boolean @value and sets it on @property as a + * property on @mi. If a property already exists by that name, + * then the value is set to the new value. If not, the property + * is added. If the value is changed or the property was previously + * unset then the signal #DbusmenuMenuitem::prop-changed will be + * emitted by this function. + * + * Return value: A boolean representing if the property value was set. + */ gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value) { @@ -982,20 +982,20 @@ dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * propert } /** - dbusmenu_menuitem_property_set_variant: - @mi: The #DbusmenuMenuitem to set the property on. - @property: Name of the property to set. - @value: The value of the property. - - Takes the pair of @property and @value and places them as a - property on @mi. If a property already exists by that name, - then the value is set to the new value. If not, the property - is added. If the value is changed or the property was previously - unset then the signal #DbusmenuMenuitem::prop-changed will be - emitted by this function. - - Return value: A boolean representing if the property value was set. -*/ + * dbusmenu_menuitem_property_set_variant: + * @mi: The #DbusmenuMenuitem to set the property on. + * @property: Name of the property to set. + * @value: The value of the property. + * + * Takes the pair of @property and @value and places them as a + * property on @mi. If a property already exists by that name, + * then the value is set to the new value. If not, the property + * is added. If the value is changed or the property was previously + * unset then the signal #DbusmenuMenuitem::prop-changed will be + * emitted by this function. + * + * Return value: A boolean representing if the property value was set. + */ gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value) { @@ -1034,18 +1034,18 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro } /** - dbusmenu_menuitem_property_get: - @mi: The #DbusmenuMenuitem to look for the property on. - @property: The property to grab. - - Look up a property on @mi and return the value of it if - it exits. #NULL will be returned if the property doesn't - exist. - - Return value: A string with the value of the property - that shouldn't be free'd. Or #NULL if the property - is not set or is not a string. -*/ + * dbusmenu_menuitem_property_get: + * @mi: The #DbusmenuMenuitem to look for the property on. + * @property: The property to grab. + * + * Look up a property on @mi and return the value of it if + * it exits. #NULL will be returned if the property doesn't + * exist. + * + * Return value: (transfer none): A string with the value of the property + * that shouldn't be free'd. Or #NULL if the property + * is not set or is not a string. + */ const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) { @@ -1056,16 +1056,16 @@ dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) } /** - dbusmenu_menuitem_property_get_variant: - @mi: The #DbusmenuMenuitem to look for the property on. - @property: The property to grab. - - Look up a property on @mi and return the value of it if - it exits. #NULL will be returned if the property doesn't - exist. - - Return value: A GVariant for the property. -*/ + * dbusmenu_menuitem_property_get_variant: + * @mi: The #DbusmenuMenuitem to look for the property on. + * @property: The property to grab. + * + * Look up a property on @mi and return the value of it if + * it exits. #NULL will be returned if the property doesn't + * exist. + * + * Return value: (transfer none): A GVariant for the property. + */ GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property) { @@ -1078,15 +1078,15 @@ dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * pro } /** - dbusmenu_menuitem_property_get_bool: - @mi: The #DbusmenuMenuitem to look for the property on. - @property: The property to grab. - - Look up a property on @mi and return the value of it if - it exits. Returns #FALSE if the property doesn't exist. - - Return value: The value of the property or #FALSE. -*/ + * dbusmenu_menuitem_property_get_bool: + * @mi: The #DbusmenuMenuitem to look for the property on. + * @property: The property to grab. + * + * Look up a property on @mi and return the value of it if + * it exits. Returns #FALSE if the property doesn't exist. + * + * Return value: The value of the property or #FALSE. + */ gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) { @@ -1112,15 +1112,15 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper } /** - dbusmenu_menuitem_property_get_int: - @mi: The #DbusmenuMenuitem to look for the property on. - @property: The property to grab. - - Look up a property on @mi and return the value of it if - it exits. Returns zero if the property doesn't exist. - - Return value: The value of the property or zero. -*/ + * dbusmenu_menuitem_property_get_int: + * @mi: The #DbusmenuMenuitem to look for the property on. + * @property: The property to grab. + * + * Look up a property on @mi and return the value of it if + * it exits. Returns zero if the property doesn't exist. + * + * Return value: The value of the property or zero. + */ gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) { @@ -1142,15 +1142,15 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert /** - dbusmenu_menuitem_property_exit: - @mi: The #DbusmenuMenuitem to look for the property on. - @property: The property to look for. - - Checkes to see if a particular property exists on @mi and - returns #TRUE if so. - - Return value: A boolean checking to see if the property is available -*/ + * dbusmenu_menuitem_property_exit: + * @mi: The #DbusmenuMenuitem to look for the property on. + * @property: The property to look for. + * + * Checkes to see if a particular property exists on @mi and + * returns #TRUE if so. + * + * Return value: A boolean checking to see if the property is available + */ gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property) { @@ -1165,12 +1165,12 @@ 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. -*/ + * 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) { @@ -1185,15 +1185,16 @@ dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property } /** - dbusmenu_menuitem_properties_list: - @mi: #DbusmenuMenuitem to list the properties on - - This functiong gets a list of the names of all the properties - that are set on this menu item. This data on the list is owned - by the menuitem but the list is not and should be freed using - g_list_free() when the calling function is done with it. - - Return value: A list of strings or NULL if there are none. + * dbusmenu_menuitem_properties_list: + * @mi: #DbusmenuMenuitem to list the properties on + * + * This functiong gets a list of the names of all the properties + * that are set on this menu item. This data on the list is owned + * by the menuitem but the list is not and should be freed using + * g_list_free() when the calling function is done with it. + * + * Return value: (transfer container): A list of strings or NULL if there are + * none. */ GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) @@ -1219,18 +1220,18 @@ copy_helper (gpointer in_key, gpointer in_value, gpointer in_data) } /** - dbusmenu_menuitem_properties_copy: - @mi: #DbusmenuMenuitem that we're interested in the properties of - - This function takes the properties of a #DbusmenuMenuitem - and puts them into a #GHashTable that is referenced by the - key of a string and has the value of a string. The hash - table may not have any entries if there aren't any or there - is an error in processing. It is the caller's responsibility - to destroy the created #GHashTable. - - Return value: A brand new #GHashTable that contains all of the - properties that are on this #DbusmenuMenuitem @mi. + * dbusmenu_menuitem_properties_copy: + * @mi: #DbusmenuMenuitem that we're interested in the properties of + * + * This function takes the properties of a #DbusmenuMenuitem + * and puts them into a #GHashTable that is referenced by the + * key of a string and has the value of a string. The hash + * table may not have any entries if there aren't any or there + * is an error in processing. It is the caller's responsibility + * to destroy the created #GHashTable. + * + * Return value: (transfer full): A brand new #GHashTable that contains all of + * theroperties that are on this #DbusmenuMenuitem @mi. */ GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) @@ -1255,14 +1256,14 @@ variant_helper (gpointer in_key, gpointer in_value, gpointer user_data) } /** - dbusmenu_menuitem_properties_variant: - @mi: #DbusmenuMenuitem to get properties from - - Grabs the properties of the menuitem as a GVariant with the - type "a{sv}". - - Return Value: A GVariant of type "a{sv}" or NULL on error. -*/ + * dbusmenu_menuitem_properties_variant: + * @mi: #DbusmenuMenuitem to get properties from + * + * Grabs the properties of the menuitem as a GVariant with the + * type "a{sv}". + * + * Return Value: (transfer full): A GVariant of type "a{sv}" or NULL on error. + */ GVariant * dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi) { @@ -1285,15 +1286,15 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi) } /** - dbusmenu_menuitem_set_root: - @mi: #DbusmenuMenuitem to set whether it's root - @root: Whether @mi is a root node or not - - This function sets the internal value of whether this is a - root node or not. - - Return value: None -*/ + * dbusmenu_menuitem_set_root: + * @mi: #DbusmenuMenuitem to set whether it's root + * @root: Whether @mi is a root node or not + * + * This function sets the internal value of whether this is a + * root node or not. + * + * Return value: None + */ void dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root) { @@ -1304,14 +1305,14 @@ dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root) } /** - dbusmenu_menuitem_get_root: - @mi: #DbusmenuMenuitem to see whether it's root - - This function returns the internal value of whether this is a - root node or not. - - Return value: #TRUE if this is a root node -*/ + * dbusmenu_menuitem_get_root: + * @mi: #DbusmenuMenuitem to see whether it's root + * + * This function returns the internal value of whether this is a + * root node or not. + * + * Return value: #TRUE if this is a root node + */ gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) { @@ -1322,16 +1323,16 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) /** - dbusmenu_menuitem_buildxml: - @mi: #DbusmenuMenuitem to represent in XML - @array: (element-type utf8): A list of string that will be turned into an XML file - - This function will add strings to the array @array. It will put - at least one entry if this menu item has no children. If it has - children it will put two for this entry, one representing the - start tag and one that is a closing tag. It will allow it's - children to place their own tags in the array in between those two. -*/ + * dbusmenu_menuitem_buildxml: + * @mi: #DbusmenuMenuitem to represent in XML + * @array: (element-type utf8): A list of string that will be turned into an XML file + * + * This function will add strings to the array @array. It will put + * at least one entry if this menu item has no children. If it has + * children it will put two for this entry, one representing the + * start tag and one that is a closing tag. It will allow it's + * children to place their own tags in the array in between those two. + */ void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array) { @@ -1369,15 +1370,15 @@ foreach_helper (gpointer data, gpointer user_data) } /** - dbusmenu_menuitem_foreach: - @mi: The #DbusmenItem to start from - @func: Function to call on every node in the tree - @data: (closure): User data to pass to the function - - This calls the function @func on this menu item and all - of the children of this item. And their children. And - their children. And... you get the point. It will get - called on the whole tree. + * dbusmenu_menuitem_foreach: + * @mi: The #DbusmenItem to start from + * @func: Function to call on every node in the tree + * @data: (closure): User data to pass to the function + * + * This calls the function @func on this menu item and all + * of the children of this item. And their children. And + * their children. And... you get the point. It will get + * called on the whole tree. */ void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data) @@ -1393,23 +1394,23 @@ dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem } /** - dbusmenu_menuitem_handle_event: - @mi: The #DbusmenuMenuitem to send the signal on. - @name: The name of the signal - @variant: A value that could be set for the event - @timestamp: The timestamp of when the event happened - - This function is called to create an event. It is likely - to be overrided by subclasses. The default menu item - will respond to the activate signal and do: - - Emits the #DbusmenuMenuitem::item-activate signal on this - menu item. Called by server objects when they get the - appropriate DBus signals from the client. - - If you subclass this function you should really think - about calling the parent function unless you have a good - reason not to. + * dbusmenu_menuitem_handle_event: + * @mi: The #DbusmenuMenuitem to send the signal on. + * @name: The name of the signal + * @variant: A value that could be set for the event + * @timestamp: The timestamp of when the event happened + * + * This function is called to create an event. It is likely + * to be overrided by subclasses. The default menu item + * will respond to the activate signal and do: + * + * Emits the #DbusmenuMenuitem::item-activate signal on this + * menu item. Called by server objects when they get the + * appropriate DBus signals from the client. + * + * If you subclass this function you should really think + * about calling the parent function unless you have a good + * reason not to. */ void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp) @@ -1427,16 +1428,16 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVari } /** - dbusmenu_menuitem_send_about_to_show: - @mi: The #DbusmenuMenuitem to send the signal on. - @cb: Callback to call when the call has returned. - @cb_data: (closure): Data to pass to the callback. - - This function is used to send the even that the submenu - of this item is about to be shown. Callers to this event - should delay showing the menu until their callback is - called if possible. -*/ + * dbusmenu_menuitem_send_about_to_show: + * @mi: The #DbusmenuMenuitem to send the signal on. + * @cb: Callback to call when the call has returned. + * @cb_data: (closure): Data to pass to the callback. + * + * This function is used to send the even that the submenu + * of this item is about to be shown. Callers to this event + * should delay showing the menu until their callback is + * called if possible. + */ void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data) { @@ -1456,14 +1457,14 @@ dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (Dbusmen } /** - dbusmenu_menuitem_show_to_user: - @mi: #DbusmenuMenuitem to show - @timestamp: The time that the user requested it to be shown - - Signals that this menu item should be shown to the user. If this is - server side the server will then take it and send it over the - bus. -*/ + * dbusmenu_menuitem_show_to_user: + * @mi: #DbusmenuMenuitem to show + * @timestamp: The time that the user requested it to be shown + * + * Signals that this menu item should be shown to the user. If this is + * server side the server will then take it and send it over the + * bus. + */ void dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp) { diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index a4c7611..9b538f6 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -156,7 +156,7 @@ struct _DbusmenuMenuitemClass /* Virtual functions */ dbusmenu_menuitem_buildxml_slot_t buildxml; - void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); + void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp); void (*send_about_to_show) (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data); @@ -207,7 +207,7 @@ void dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root); gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); -void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); +void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp); void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); void dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp); -- cgit v1.2.3 From e9e03b2d8a92adf458dc7b0dd849d99c36e77492 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 15:34:51 -0600 Subject: Adding in a defaults object --- libdbusmenu-glib/Makefile.am | 2 ++ libdbusmenu-glib/defaults.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/defaults.h | 31 ++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 libdbusmenu-glib/defaults.c create mode 100644 libdbusmenu-glib/defaults.h (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 92de502..5ddbeb8 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -24,6 +24,8 @@ libdbusmenu_glibinclude_HEADERS = \ libdbusmenu_glib_la_SOURCES = \ dbus-menu-clean.xml.h \ dbus-menu-clean.xml.c \ + defaults.h \ + defaults.c \ menuitem.h \ menuitem.c \ menuitem-marshal.h \ diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c new file mode 100644 index 0000000..cbd9bfa --- /dev/null +++ b/libdbusmenu-glib/defaults.c @@ -0,0 +1,49 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "defaults.h" + +typedef struct _DbusmenuDefaultsPrivate DbusmenuDefaultsPrivate; + +struct _DbusmenuDefaultsPrivate +{ +}; + +#define DBUSMENU_DEFAULTS_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_DEFAULTS_TYPE, DbusmenuDefaultsPrivate)) + +static void dbusmenu_defaults_class_init (DbusmenuDefaultsClass *klass); +static void dbusmenu_defaults_init (DbusmenuDefaults *self); +static void dbusmenu_defaults_dispose (GObject *object); +static void dbusmenu_defaults_finalize (GObject *object); + +G_DEFINE_TYPE (DbusmenuDefaults, dbusmenu_defaults, G_TYPE_OBJECT); + +static void +dbusmenu_defaults_class_init (DbusmenuDefaultsClass *klass) +{ +GObjectClass *object_class = G_OBJECT_CLASS (klass); + +g_type_class_add_private (klass, sizeof (DbusmenuDefaultsPrivate)); + +object_class->dispose = dbusmenu_defaults_dispose; +object_class->finalize = dbusmenu_defaults_finalize; +} + +static void +dbusmenu_defaults_init (DbusmenuDefaults *self) +{ +} + +static void +dbusmenu_defaults_dispose (GObject *object) +{ +G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->dispose (object); +} + +static void +dbusmenu_defaults_finalize (GObject *object) +{ +G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->finalize (object); +} diff --git a/libdbusmenu-glib/defaults.h b/libdbusmenu-glib/defaults.h new file mode 100644 index 0000000..a440371 --- /dev/null +++ b/libdbusmenu-glib/defaults.h @@ -0,0 +1,31 @@ +#ifndef __DBUSMENU_DEFAULTS_H__ +#define __DBUSMENU_DEFAULTS_H__ + +#include +#include + +G_BEGIN_DECLS + +#define DBUSMENU_TYPE_DEFAULTS (dbusmenu_defaults_get_type ()) +#define DBUSMENU_DEFAULTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaults)) +#define DBUSMENU_DEFAULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaultsClass)) +#define IS_DBUSMENU_DEFAULTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_DEFAULTS)) +#define IS_DBUSMENU_DEFAULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_DEFAULTS)) +#define DBUSMENU_DEFAULTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaultsClass)) + +typedef struct _DbusmenuDefaults DbusmenuDefaults; +typedef struct _DbusmenuDefaultsClass DbusmenuDefaultsClass; + +struct _DbusmenuDefaultsClass { + GObjectClass parent_class; +}; + +struct _DbusmenuDefaults { + GObject parent; +}; + +GType dbusmenu_defaults_get_type (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From cb9011e136912751fb01d2107435e3422863cbdc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 15:42:08 -0600 Subject: Setting up the private and some base documentation --- libdbusmenu-glib/defaults.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.h b/libdbusmenu-glib/defaults.h index a440371..9cd03fa 100644 --- a/libdbusmenu-glib/defaults.h +++ b/libdbusmenu-glib/defaults.h @@ -13,18 +13,34 @@ G_BEGIN_DECLS #define IS_DBUSMENU_DEFAULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_DEFAULTS)) #define DBUSMENU_DEFAULTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaultsClass)) -typedef struct _DbusmenuDefaults DbusmenuDefaults; -typedef struct _DbusmenuDefaultsClass DbusmenuDefaultsClass; - +typedef struct _DbusmenuDefaults DbusmenuDefaults; +typedef struct _DbusmenuDefaultsClass DbusmenuDefaultsClass; +typedef struct _DbusmenuDefaultsPrivate DbusmenuDefaultsPrivate; + +/** + * DbusmenuDefaultsClass: + * + * All of the signals and functions for #DbusmenuDefaults + */ struct _DbusmenuDefaultsClass { GObjectClass parent_class; }; +/** + * DbusmenuDefaults: + * + * A singleton to hold all of the defaults for the menuitems + * so they can use those easily. + */ struct _DbusmenuDefaults { GObject parent; + + /*< Private >*/ + DbusmenuDefaultsPrivate * priv; }; -GType dbusmenu_defaults_get_type (void); +GType dbusmenu_defaults_get_type (void); +DbusmenuDefaults * dbusmenu_defaults_ref_default (void); G_END_DECLS -- cgit v1.2.3 From 4f8113b14cbba9ef88b46be5545f3bb235060b10 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 15:42:18 -0600 Subject: License headers --- libdbusmenu-glib/defaults.c | 28 ++++++++++++++++++++++++++++ libdbusmenu-glib/defaults.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index cbd9bfa..450707f 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -1,3 +1,31 @@ +/* +A library to communicate a menu object set accross DBus and +track updates and maintain consistency. + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by +the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/libdbusmenu-glib/defaults.h b/libdbusmenu-glib/defaults.h index 9cd03fa..842b58b 100644 --- a/libdbusmenu-glib/defaults.h +++ b/libdbusmenu-glib/defaults.h @@ -1,3 +1,31 @@ +/* +A library to communicate a menu object set accross DBus and +track updates and maintain consistency. + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by +the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + #ifndef __DBUSMENU_DEFAULTS_H__ #define __DBUSMENU_DEFAULTS_H__ -- cgit v1.2.3 From 0d6f893deda7eebefab68be2b7566e8033f2be48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 15:43:11 -0600 Subject: Format sanely --- libdbusmenu-glib/defaults.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index 450707f..af86a90 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -34,8 +34,8 @@ License version 3 and version 2.1 along with this program. If not, see typedef struct _DbusmenuDefaultsPrivate DbusmenuDefaultsPrivate; -struct _DbusmenuDefaultsPrivate -{ +struct _DbusmenuDefaultsPrivate { + GHashTable * types; }; #define DBUSMENU_DEFAULTS_GET_PRIVATE(o) \ @@ -51,27 +51,34 @@ G_DEFINE_TYPE (DbusmenuDefaults, dbusmenu_defaults, G_TYPE_OBJECT); static void dbusmenu_defaults_class_init (DbusmenuDefaultsClass *klass) { -GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); -g_type_class_add_private (klass, sizeof (DbusmenuDefaultsPrivate)); + g_type_class_add_private (klass, sizeof (DbusmenuDefaultsPrivate)); -object_class->dispose = dbusmenu_defaults_dispose; -object_class->finalize = dbusmenu_defaults_finalize; + object_class->dispose = dbusmenu_defaults_dispose; + object_class->finalize = dbusmenu_defaults_finalize; + return; } static void dbusmenu_defaults_init (DbusmenuDefaults *self) { + + return; } static void dbusmenu_defaults_dispose (GObject *object) { -G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->dispose (object); + + G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->dispose (object); + return; } static void dbusmenu_defaults_finalize (GObject *object) { -G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->finalize (object); + + G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->finalize (object); + return; } -- cgit v1.2.3 From 1c1171f7a84e37dd96385cea1600465350217ae0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 15:47:40 -0600 Subject: Fleshing out the ref_default --- libdbusmenu-glib/defaults.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index af86a90..a6dd4a2 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -32,8 +32,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "defaults.h" -typedef struct _DbusmenuDefaultsPrivate DbusmenuDefaultsPrivate; - struct _DbusmenuDefaultsPrivate { GHashTable * types; }; @@ -82,3 +80,23 @@ dbusmenu_defaults_finalize (GObject *object) G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->finalize (object); return; } + +static DbusmenuDefaults * default_defaults = NULL; + +/** + * dbusmenu_defaults_ref_default: + * + * Get a reference to the default instance. If it doesn't exist this + * function will create it. + * + * Return value: (transfer full): A reference to the defaults + */ +DbusmenuDefaults * +dbusmenu_defaults_ref_default (void) +{ + if (default_defaults == NULL) { + default_defaults = DBUSMENU_DEFAULTS(g_object_new(DBUSMENU_TYPE_DEFAULTS, NULL)); + } + + return default_defaults; +} -- cgit v1.2.3 From a4a9e45e12ebfc45306f986953b04e2409f9cc7e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 16:13:44 -0600 Subject: Putting in stubs for our get/set functions --- libdbusmenu-glib/defaults.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/defaults.h | 11 +++++++++ 2 files changed, 68 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index a6dd4a2..ec70ce1 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -100,3 +100,60 @@ dbusmenu_defaults_ref_default (void) return default_defaults; } + +/** + * dbusmenu_defaults_default_set: + * @default: The #DbusmenuDefaults object to add to + * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT + * @property: Property name for the default + * @prop_type: (allow-none): Type of the property for runtime checking. To disable checking set to #NULL. + * @value: (allow-none): Default value for @property. #NULL if by default it is unset, but you want type checking from @prop_type. + * + * Sets up an entry in the defaults database for a given @property + * and menuitem type @type. @prop_type and @value can both be #NULL + * but both of them can not. + */ +void +dbusmenu_defaults_default_set (DbusmenuDefaults * defaults, const gchar * type, const gchar * property, const GVariantType * prop_type, GVariant * value) +{ + + return; +} + +/** + * dbusmenu_defaults_default_get: + * @defaults: The default database to use + * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT + * @property: Property name to lookup + * + * Gets an entry in the database for a give @property and @type. + * + * Return value: (transfer none): Returns a variant that does not + * have it's ref count increased. If you want to keep it, you should + * do that. + */ +GVariant * +dbusmenu_defaults_default_get (DbusmenuDefaults * defaults, const gchar * type, const gchar * property) +{ + + return NULL; +} + +/** + * dbusmenu_defaults_default_get_type: + * @defaults: The default database to use + * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT + * @property: Property name to lookup + * + * Gets the type for an entry in the database for a give @property and @type. + * + * Return value: (transfer none): Returns a type for the given + * @property value. + */ +GVariantType * +dbusmenu_defaults_default_get_type (DbusmenuDefaults * defaults, const gchar * type, const gchar * property) +{ + + return NULL; +} + diff --git a/libdbusmenu-glib/defaults.h b/libdbusmenu-glib/defaults.h index 842b58b..9668206 100644 --- a/libdbusmenu-glib/defaults.h +++ b/libdbusmenu-glib/defaults.h @@ -69,6 +69,17 @@ struct _DbusmenuDefaults { GType dbusmenu_defaults_get_type (void); DbusmenuDefaults * dbusmenu_defaults_ref_default (void); +void dbusmenu_defaults_default_set (DbusmenuDefaults * defaults, + const gchar * type, + const gchar * property, + const GVariantType * prop_type, + GVariant * value); +GVariant * dbusmenu_defaults_default_get (DbusmenuDefaults * defaults, + const gchar * type, + const gchar * property); +GVariantType * dbusmenu_defaults_default_get_type (DbusmenuDefaults * defaults, + const gchar * type, + const gchar * property); G_END_DECLS -- cgit v1.2.3 From 69951e51941d1122b58119f52b072aa9863fc3c2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:01:02 -0600 Subject: Setting the core defaults up in a handy table. --- libdbusmenu-glib/defaults.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index ec70ce1..c225612 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -30,7 +30,11 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#include + #include "defaults.h" +#include "menuitem.h" +#include "client.h" struct _DbusmenuDefaultsPrivate { GHashTable * types; @@ -62,6 +66,19 @@ static void dbusmenu_defaults_init (DbusmenuDefaults *self) { + /* Standard defaults */ + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_VISIBLE, G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(TRUE)); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_ENABLED, G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(TRUE)); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_LABEL, G_VARIANT_TYPE_STRING, g_variant_new_string(_("Label Empty"))); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_ICON_NAME, G_VARIANT_TYPE_STRING, NULL); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, G_VARIANT_TYPE_STRING, NULL); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, G_VARIANT_TYPE_INT32, NULL); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_SHORTCUT, G_VARIANT_TYPE_ARRAY, NULL); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, G_VARIANT_TYPE_STRING, NULL); + + /* Separator defaults */ + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_SEPARATOR, DBUSMENU_MENUITEM_PROP_VISIBLE, G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(TRUE)); + return; } @@ -103,7 +120,7 @@ dbusmenu_defaults_ref_default (void) /** * dbusmenu_defaults_default_set: - * @default: The #DbusmenuDefaults object to add to + * @defaults: The #DbusmenuDefaults object to add to * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT * @property: Property name for the default * @prop_type: (allow-none): Type of the property for runtime checking. To disable checking set to #NULL. -- cgit v1.2.3 From 6d298a977a906aa9029b8f82b19fae71562db5fe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:15:14 -0600 Subject: Create an entry structure and functions for creating and destroying it --- libdbusmenu-glib/defaults.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index c225612..3a98923 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -40,6 +40,12 @@ struct _DbusmenuDefaultsPrivate { GHashTable * types; }; +typedef struct _DefaultEntry DefaultEntry; +struct _DefaultEntry { + GVariantType * type; + GVariant * value; +}; + #define DBUSMENU_DEFAULTS_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_DEFAULTS_TYPE, DbusmenuDefaultsPrivate)) @@ -48,6 +54,9 @@ static void dbusmenu_defaults_init (DbusmenuDefaults *self); static void dbusmenu_defaults_dispose (GObject *object); static void dbusmenu_defaults_finalize (GObject *object); +static DefaultEntry * entry_create (GVariantType * type, GVariant * variant); +static void entry_destroy (gpointer entry); + G_DEFINE_TYPE (DbusmenuDefaults, dbusmenu_defaults, G_TYPE_OBJECT); static void @@ -98,6 +107,44 @@ dbusmenu_defaults_finalize (GObject *object) return; } +/* Create a new entry based on the info provided */ +static DefaultEntry * +entry_create (GVariantType * type, GVariant * variant) +{ + DefaultEntry * defentry = g_new0(DefaultEntry, 1); + + if (type != NULL) { + defentry->type = g_variant_type_copy(type); + } + + if (variant != NULL) { + defentry->value = variant; + g_variant_ref_sink(variant); + } + + return defentry; +} + +/* Destroy an entry */ +static void +entry_destroy (gpointer entry) +{ + DefaultEntry * defentry = (DefaultEntry *)entry; + + if (defentry->type != NULL) { + g_variant_type_free(defentry->type); + defentry->type = NULL; + } + + if (defentry->value != NULL) { + g_variant_unref(defentry->value); + defentry->value = NULL; + } + + g_free(defentry); + return; +} + static DbusmenuDefaults * default_defaults = NULL; /** -- cgit v1.2.3 From 6c544a4f41d713878667418cd14411e5fc6c1f3f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:18:58 -0600 Subject: Building our hash table and making sure it gets cleaned up --- libdbusmenu-glib/defaults.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index 3a98923..53ef09d 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -47,7 +47,7 @@ struct _DefaultEntry { }; #define DBUSMENU_DEFAULTS_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_DEFAULTS_TYPE, DbusmenuDefaultsPrivate)) +(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaultsPrivate)) static void dbusmenu_defaults_class_init (DbusmenuDefaultsClass *klass); static void dbusmenu_defaults_init (DbusmenuDefaults *self); @@ -74,6 +74,9 @@ dbusmenu_defaults_class_init (DbusmenuDefaultsClass *klass) static void dbusmenu_defaults_init (DbusmenuDefaults *self) { + self->priv = DBUSMENU_DEFAULTS_GET_PRIVATE(self); + + self->priv->types = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, entry_destroy); /* Standard defaults */ dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_VISIBLE, G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(TRUE)); @@ -94,6 +97,12 @@ dbusmenu_defaults_init (DbusmenuDefaults *self) static void dbusmenu_defaults_dispose (GObject *object) { + DbusmenuDefaults * self = DBUSMENU_DEFAULTS(object); + + if (self->priv->types != NULL) { + g_hash_table_destroy(self->priv->types); + self->priv->types = NULL; + } G_OBJECT_CLASS (dbusmenu_defaults_parent_class)->dispose (object); return; -- cgit v1.2.3 From c89e30d70bcd342837af4633f393a26c7fb3bdc9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:29:13 -0600 Subject: Create a basic setter function and fix our hashtables so they work with it. --- libdbusmenu-glib/defaults.c | 26 +++++++++++++++++++++++--- libdbusmenu-glib/defaults.h | 4 ++-- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index 53ef09d..9fde682 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -54,7 +54,7 @@ static void dbusmenu_defaults_init (DbusmenuDefaults *self); static void dbusmenu_defaults_dispose (GObject *object); static void dbusmenu_defaults_finalize (GObject *object); -static DefaultEntry * entry_create (GVariantType * type, GVariant * variant); +static DefaultEntry * entry_create (const GVariantType * type, GVariant * variant); static void entry_destroy (gpointer entry); G_DEFINE_TYPE (DbusmenuDefaults, dbusmenu_defaults, G_TYPE_OBJECT); @@ -76,7 +76,7 @@ dbusmenu_defaults_init (DbusmenuDefaults *self) { self->priv = DBUSMENU_DEFAULTS_GET_PRIVATE(self); - self->priv->types = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, entry_destroy); + self->priv->types = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_hash_table_destroy); /* Standard defaults */ dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_VISIBLE, G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(TRUE)); @@ -118,7 +118,7 @@ dbusmenu_defaults_finalize (GObject *object) /* Create a new entry based on the info provided */ static DefaultEntry * -entry_create (GVariantType * type, GVariant * variant) +entry_create (const GVariantType * type, GVariant * variant) { DefaultEntry * defentry = g_new0(DefaultEntry, 1); @@ -189,6 +189,26 @@ dbusmenu_defaults_ref_default (void) void dbusmenu_defaults_default_set (DbusmenuDefaults * defaults, const gchar * type, const gchar * property, const GVariantType * prop_type, GVariant * value) { + g_return_if_fail(DBUSMENU_IS_DEFAULTS(defaults)); + g_return_if_fail(property != NULL); + g_return_if_fail(prop_type != NULL || value != NULL); + + if (type == NULL) { + type = DBUSMENU_CLIENT_TYPES_DEFAULT; + } + + GHashTable * prop_table = (GHashTable *)g_hash_table_lookup(defaults->priv->types, type); + + /* We've never had a default for this type, so we need + to create a table for it. */ + if (prop_table == NULL) { + prop_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, entry_destroy); + + g_hash_table_insert(prop_table, g_strdup(property), entry_create(prop_type, value)); + g_hash_table_insert(defaults->priv->types, g_strdup(type), prop_table); + } else { + g_hash_table_replace(prop_table, g_strdup(property), entry_create(prop_type, value)); + } return; } diff --git a/libdbusmenu-glib/defaults.h b/libdbusmenu-glib/defaults.h index 9668206..ab377f7 100644 --- a/libdbusmenu-glib/defaults.h +++ b/libdbusmenu-glib/defaults.h @@ -37,8 +37,8 @@ G_BEGIN_DECLS #define DBUSMENU_TYPE_DEFAULTS (dbusmenu_defaults_get_type ()) #define DBUSMENU_DEFAULTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaults)) #define DBUSMENU_DEFAULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaultsClass)) -#define IS_DBUSMENU_DEFAULTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_DEFAULTS)) -#define IS_DBUSMENU_DEFAULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_DEFAULTS)) +#define DBUSMENU_IS_DEFAULTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_DEFAULTS)) +#define DBUSMENU_IS_DEFAULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_DEFAULTS)) #define DBUSMENU_DEFAULTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_DEFAULTS, DbusmenuDefaultsClass)) typedef struct _DbusmenuDefaults DbusmenuDefaults; -- cgit v1.2.3 From 543691a8c404735cc6f5bfbe24dc8bbe57908ff0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:32:53 -0600 Subject: Flesh out the getters as well --- libdbusmenu-glib/defaults.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index 9fde682..e8cdea0 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -228,8 +228,26 @@ dbusmenu_defaults_default_set (DbusmenuDefaults * defaults, const gchar * type, GVariant * dbusmenu_defaults_default_get (DbusmenuDefaults * defaults, const gchar * type, const gchar * property) { + g_return_val_if_fail(DBUSMENU_IS_DEFAULTS(defaults), NULL); + g_return_val_if_fail(property != NULL, NULL); - return NULL; + if (type == NULL) { + type = DBUSMENU_CLIENT_TYPES_DEFAULT; + } + + GHashTable * prop_table = (GHashTable *)g_hash_table_lookup(defaults->priv->types, type); + + if (prop_table == NULL) { + return NULL; + } + + DefaultEntry * entry = (DefaultEntry *)g_hash_table_lookup(prop_table, property); + + if (entry == NULL) { + return NULL; + } + + return entry->value; } /** @@ -246,7 +264,25 @@ dbusmenu_defaults_default_get (DbusmenuDefaults * defaults, const gchar * type, GVariantType * dbusmenu_defaults_default_get_type (DbusmenuDefaults * defaults, const gchar * type, const gchar * property) { + g_return_val_if_fail(DBUSMENU_IS_DEFAULTS(defaults), NULL); + g_return_val_if_fail(property != NULL, NULL); + + if (type == NULL) { + type = DBUSMENU_CLIENT_TYPES_DEFAULT; + } + + GHashTable * prop_table = (GHashTable *)g_hash_table_lookup(defaults->priv->types, type); + + if (prop_table == NULL) { + return NULL; + } + + DefaultEntry * entry = (DefaultEntry *)g_hash_table_lookup(prop_table, property); + + if (entry == NULL) { + return NULL; + } - return NULL; + return entry->type; } -- cgit v1.2.3 From 8dd5384336a88c076429c621f8080bad947a9d23 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:35:19 -0600 Subject: Finally getting our very own reference for the defaults --- libdbusmenu-glib/menuitem.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index c994130..b6c5712 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem.h" #include "menuitem-marshal.h" #include "menuitem-private.h" +#include "defaults.h" #ifdef MASSIVEDEBUGGING #define LABEL(x) dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(x), DBUSMENU_MENUITEM_PROP_LABEL) @@ -59,6 +60,7 @@ struct _DbusmenuMenuitemPrivate GHashTable * properties; gboolean root; gboolean realized; + DbusmenuDefaults * defaults; }; /* Signals */ @@ -312,6 +314,8 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->root = FALSE; priv->realized = FALSE; + + priv->defaults = dbusmenu_defaults_ref_default(); return; } @@ -328,6 +332,11 @@ dbusmenu_menuitem_dispose (GObject *object) g_list_free(priv->children); priv->children = NULL; + if (priv->defaults != NULL) { + g_object_unref(priv->defaults); + priv->defaults = NULL; + } + G_OBJECT_CLASS (dbusmenu_menuitem_parent_class)->dispose (object); return; } -- cgit v1.2.3 From c704e7e82e57f2ac6ca9e058459d600c0bbed6ab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 17:37:45 -0600 Subject: Making sure to have weak pointer support incase we do drop all the refs --- libdbusmenu-glib/defaults.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index e8cdea0..9031d20 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -169,6 +169,7 @@ dbusmenu_defaults_ref_default (void) { if (default_defaults == NULL) { default_defaults = DBUSMENU_DEFAULTS(g_object_new(DBUSMENU_TYPE_DEFAULTS, NULL)); + g_object_add_weak_pointer(G_OBJECT(default_defaults), (gpointer *)&default_defaults); } return default_defaults; -- cgit v1.2.3 From 494adf9835825c711fd9f05b44143d6331bcab63 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:06:41 -0600 Subject: When we're setting a value check to see if it's the same as the default and clear it if so. --- libdbusmenu-glib/menuitem.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index b6c5712..c744435 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -434,6 +434,14 @@ send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gp return; } +/* A helper function to get the type of the menuitem, this might + be a candidate for optimization in the future. */ +static const gchar * +menuitem_get_type (DbusmenuMenuitem * mi) +{ + return dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_TYPE); +} + /* Public interface */ /** @@ -1013,6 +1021,35 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + const gchar * type = menuitem_get_type(mi); + if (type != NULL) { + /* Check the defaults database to see if we have a default + for this property. */ + GVariant * default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); + if (default_value != NULL) { + /* If we have a default we might also have an expected type */ + GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); + + if (default_type != NULL) { + /* If we have an expected type we should check to see if + the value we've been given is of the same type and generate + a warning if it isn't */ + if (!g_variant_is_of_type(value, default_type)) { + g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); + } + } + + /* Now see if we're setting this to the same value as the + default. If we are then we just want to swallow this variant + and make the function behave like we're clearing it. */ + if (g_variant_equal(default_value, value)) { + g_variant_ref_sink(value); + g_variant_unref(value); + value = NULL; + } + } + } + gboolean replaced = FALSE; gpointer currentval = g_hash_table_lookup(priv->properties, property); -- cgit v1.2.3 From 507b6ec86e0e6c4eacd41863f8900a90c023f915 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:09:31 -0600 Subject: Allow for signaling the default value if it makes sense --- libdbusmenu-glib/menuitem.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index c744435..d25e80d 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1022,10 +1022,11 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); const gchar * type = menuitem_get_type(mi); + GVariant * default_value = NULL; if (type != NULL) { /* Check the defaults database to see if we have a default for this property. */ - GVariant * default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); + default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); if (default_value != NULL) { /* If we have a default we might also have an expected type */ GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); @@ -1073,7 +1074,15 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro table. But the fact that there was a value is the imporant part. */ if (currentval == NULL || replaced) { - g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE); + GVariant * signalval = value; + + if (signalval == NULL) { + /* Might also be NULL, but if it is we're definitely + clearing this thing. */ + signalval = default_value; + } + + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, signalval, TRUE); } return TRUE; -- cgit v1.2.3 From 32f2fccc8b40dc5ccea70acff83a5b6f0302ffea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:11:48 -0600 Subject: Always check the type even if we don't have a value. --- libdbusmenu-glib/menuitem.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d25e80d..a773755 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1024,22 +1024,21 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro const gchar * type = menuitem_get_type(mi); GVariant * default_value = NULL; if (type != NULL) { + /* Check the expected type to see if we want to have a warning */ + GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); + if (default_type != NULL) { + /* If we have an expected type we should check to see if + the value we've been given is of the same type and generate + a warning if it isn't */ + if (!g_variant_is_of_type(value, default_type)) { + g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); + } + } + /* Check the defaults database to see if we have a default for this property. */ default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); if (default_value != NULL) { - /* If we have a default we might also have an expected type */ - GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); - - if (default_type != NULL) { - /* If we have an expected type we should check to see if - the value we've been given is of the same type and generate - a warning if it isn't */ - if (!g_variant_is_of_type(value, default_type)) { - g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); - } - } - /* Now see if we're setting this to the same value as the default. If we are then we just want to swallow this variant and make the function behave like we're clearing it. */ -- cgit v1.2.3 From db5438c7f8721ca3b32df9be5b3cd980aebc6784 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:17:29 -0600 Subject: Always replace to ensure we don't leak references. --- libdbusmenu-glib/menuitem.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index a773755..2e3b8f0 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1054,13 +1054,18 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro gpointer currentval = g_hash_table_lookup(priv->properties, property); if (value != NULL) { - gchar * lprop = g_strdup(property); - g_variant_ref_sink(value); - + /* NOTE: We're only marking this as replaced if this is true + but we're actually replacing it no matter. This is so that + the variant passed in sticks around which the caller may + expect. They shouldn't, but it's low cost to remove bugs. */ if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) { - g_hash_table_replace(priv->properties, lprop, value); replaced = TRUE; } + + gchar * lprop = g_strdup(property); + g_variant_ref_sink(value); + + g_hash_table_replace(priv->properties, lprop, value); } else { if (currentval != NULL) { g_hash_table_remove(priv->properties, property); -- cgit v1.2.3 From f1fb82edb2ebcd07af0efbbf7ed98509ae297576 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:19:48 -0600 Subject: If we can't get the value from our database, let's check the defaults. --- libdbusmenu-glib/menuitem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 2e3b8f0..a3369af 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1133,7 +1133,13 @@ dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - return (GVariant *)g_hash_table_lookup(priv->properties, property); + GVariant * currentval = (GVariant *)g_hash_table_lookup(priv->properties, property); + + if (currentval == NULL) { + currentval = dbusmenu_defaults_default_get(priv->defaults, menuitem_get_type(mi), property); + } + + return currentval; } /** -- cgit v1.2.3 From 5192d305b96683f10567f961913e74bbe23f6e37 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:22:37 -0600 Subject: The defaults database can, and should, handle NULL types with fallbacks. --- libdbusmenu-glib/menuitem.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index a3369af..862cf63 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1022,31 +1022,29 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); const gchar * type = menuitem_get_type(mi); - GVariant * default_value = NULL; - if (type != NULL) { - /* Check the expected type to see if we want to have a warning */ - GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); - if (default_type != NULL) { - /* If we have an expected type we should check to see if - the value we've been given is of the same type and generate - a warning if it isn't */ - if (!g_variant_is_of_type(value, default_type)) { - g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); - } + + /* Check the expected type to see if we want to have a warning */ + GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); + if (default_type != NULL) { + /* If we have an expected type we should check to see if + the value we've been given is of the same type and generate + a warning if it isn't */ + if (!g_variant_is_of_type(value, default_type)) { + g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); } + } - /* Check the defaults database to see if we have a default - for this property. */ - default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); - if (default_value != NULL) { - /* Now see if we're setting this to the same value as the - default. If we are then we just want to swallow this variant - and make the function behave like we're clearing it. */ - if (g_variant_equal(default_value, value)) { - g_variant_ref_sink(value); - g_variant_unref(value); - value = NULL; - } + /* Check the defaults database to see if we have a default + for this property. */ + GVariant * default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); + if (default_value != NULL) { + /* Now see if we're setting this to the same value as the + default. If we are then we just want to swallow this variant + and make the function behave like we're clearing it. */ + if (g_variant_equal(default_value, value)) { + g_variant_ref_sink(value); + g_variant_unref(value); + value = NULL; } } -- cgit v1.2.3 From ac9229802235759397ce6fffc4d89f27be64ad3d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:27:13 -0600 Subject: Fleshing out the check for if a property is a default value. --- libdbusmenu-glib/menuitem.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 862cf63..bc2daf5 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1566,10 +1566,23 @@ dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp) /* Checks to see if the value of this property is unique or just the default value. */ -/* TODO: Implement this */ gboolean dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * property) { - /* No defaults system yet */ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + GVariant * currentval = (GVariant *)g_hash_table_lookup(priv->properties, property); + if (currentval != NULL) { + /* If we're storing it locally, then it shouldn't be a default */ + return FALSE; + } + + currentval = dbusmenu_defaults_default_get(priv->defaults, menuitem_get_type(mi), property); + if (currentval != NULL) { + return TRUE; + } + + g_warn_if_reached(); return FALSE; } -- cgit v1.2.3 From 75ecaddcbeb02eaa40d11bb8c3f858062a14471b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:41:54 -0600 Subject: Ensure that we check the local db for the type and don't go all recursive. --- libdbusmenu-glib/menuitem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index bc2daf5..ee18fab 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -439,7 +439,12 @@ send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gp static const gchar * menuitem_get_type (DbusmenuMenuitem * mi) { - return dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_TYPE); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + GVariant * currentval = (GVariant *)g_hash_table_lookup(priv->properties, DBUSMENU_MENUITEM_PROP_TYPE); + if (currentval != NULL) { + return g_variant_get_string(currentval, NULL); + } + return NULL; } /* Public interface */ -- cgit v1.2.3 From 47b42d7d4679cab52b6b9871fc15e2fb4d12297a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 21:51:35 -0600 Subject: Make sure to either ref or allocate --- libdbusmenu-glib/defaults.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index 9031d20..3ad5d76 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -170,6 +170,8 @@ dbusmenu_defaults_ref_default (void) if (default_defaults == NULL) { default_defaults = DBUSMENU_DEFAULTS(g_object_new(DBUSMENU_TYPE_DEFAULTS, NULL)); g_object_add_weak_pointer(G_OBJECT(default_defaults), (gpointer *)&default_defaults); + } else { + g_object_ref(default_defaults); } return default_defaults; -- cgit v1.2.3