From f753b6b03be3585bb9f96b276afffa0164a9a9e3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 4 Mar 2011 09:01:20 -0600 Subject: Use the 'basename' parameter --- libdbusmenu-glib/enum-types.c.in | 2 +- libdbusmenu-glib/enum-types.h.in | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in index 9395f5f..40f1759 100644 --- a/libdbusmenu-glib/enum-types.c.in +++ b/libdbusmenu-glib/enum-types.c.in @@ -31,7 +31,7 @@ License version 3 and version 2.1 along with this program. If not, see /*** END file-header ***/ /*** BEGIN file-production ***/ -#include "@filename@" +#include "@basename@" /*** END file-production ***/ /*** BEGIN value-header ***/ diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in index 488b615..5758438 100644 --- a/libdbusmenu-glib/enum-types.h.in +++ b/libdbusmenu-glib/enum-types.h.in @@ -44,13 +44,16 @@ G_END_DECLS /*** BEGIN file-production ***/ /* Enumerations from file: "@filename@" */ -#include "@filename@" +#include "@basename@" + /*** END file-production ***/ /*** BEGIN value-header ***/ + GType @enum_name@_get_type (void) G_GNUC_CONST; const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST; @EnumName@ @enum_name@_get_value_from_nick (const gchar * nick) G_GNUC_CONST; + /** DBUSMENU_TYPE_@ENUMSHORT@: -- cgit v1.2.3 From 639d982ed6fb70b09cd72e19a73d16a5e2f78db3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 7 Mar 2011 10:46:22 -0600 Subject: Switching to using the extended lookup and getting the key and value --- libdbusmenu-glib/menuitem.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index f7867e4..8534370 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1183,14 +1183,16 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro gboolean replaced = FALSE; gboolean remove = FALSE; - gpointer currentval = g_hash_table_lookup(priv->properties, property); + gchar * hash_key = NULL; + GVariant * hash_variant = NULL; + gboolean inhash = g_hash_table_lookup_extended(priv->properties, property, (gpointer *)&hash_key, (gpointer *)&hash_variant); if (value != NULL) { /* 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)) { + if (inhash || !g_variant_equal(hash_variant, value)) { replaced = TRUE; } @@ -1204,7 +1206,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro bad value */ g_hash_table_insert(priv->properties, lprop, value); } else { - if (currentval != NULL) { + if (inhash) { /* So the question you should be asking if you're paying attention is "Why not just do the remove here?" It's a good question with an interesting answer. Bascially it's the same reason as above, @@ -1220,7 +1222,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro becuse it has been unref'd when replaced in the hash table. But the fact that there was a value is the imporant part. */ - if (currentval == NULL || replaced) { + if (!inhash || replaced) { GVariant * signalval = value; if (signalval == NULL) { -- cgit v1.2.3 From b0af2cb938c23b980bd39ec3094d6d04e0996e25 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 7 Mar 2011 10:48:13 -0600 Subject: Steal earlier instead of later so that signal handlers don't find the value in the hashtable --- libdbusmenu-glib/menuitem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 8534370..950889b 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1215,6 +1215,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro it) after the signal emition */ remove = TRUE; replaced = TRUE; + g_hash_table_steal(priv->properties, property); } } @@ -1235,7 +1236,8 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro } if (remove) { - g_hash_table_remove(priv->properties, property); + g_free(hash_key); + g_variant_unref(hash_variant); } return TRUE; -- cgit v1.2.3 From d5e89f9a0144e0df6ba0cb45a97a1a598c96d8f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 7 Mar 2011 12:19:14 -0600 Subject: Putting in a protection and fixing the truth --- libdbusmenu-glib/menuitem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 950889b..2e5a345 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1180,19 +1180,23 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro } } - gboolean replaced = FALSE; gboolean remove = FALSE; gchar * hash_key = NULL; GVariant * hash_variant = NULL; gboolean inhash = g_hash_table_lookup_extended(priv->properties, property, (gpointer *)&hash_key, (gpointer *)&hash_variant); + if (inhash && hash_variant == NULL) { + g_warning("The property '%s' is in the hash with a NULL variant", property); + inhash = FALSE; + } + if (value != NULL) { /* 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 (inhash || !g_variant_equal(hash_variant, value)) { + if (!inhash || !g_variant_equal(hash_variant, value)) { replaced = TRUE; } -- cgit v1.2.3 From 7b868b0d9426cf060347d01da12a48b3b2bab82b Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 8 Mar 2011 11:55:34 -0500 Subject: wrap PropertiesChanged arguments in a variant --- 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 ca39ea3..a41e6ce 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -511,7 +511,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GVariantBuilder params; g_variant_builder_init(¶ms, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); - GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("TextDirection"), g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction))); + GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("TextDirection"), g_variant_new_variant(g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)))); g_variant_builder_add_value(¶ms, g_variant_new_array(NULL, &dict, 1)); g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); GVariant * vparams = g_variant_builder_end(¶ms); @@ -535,7 +535,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GVariantBuilder params; g_variant_builder_init(¶ms, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); - GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("Status"), g_variant_new_string(dbusmenu_status_get_nick(instatus))); + GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("Status"), g_variant_new_variant(g_variant_new_string(dbusmenu_status_get_nick(instatus)))); g_variant_builder_add_value(¶ms, g_variant_new_array(NULL, &dict, 1)); g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); GVariant * vparams = g_variant_builder_end(¶ms); @@ -1773,7 +1773,7 @@ dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths) g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); GVariant * items = NULL; if (priv->icon_dirs != NULL) { - GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("IconThemePath"), g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1)); + GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("IconThemePath"), g_variant_new_variant(g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1))); items = g_variant_new_array(NULL, &dict, 1); } else { items = g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0); -- cgit v1.2.3 From b50608f6000958965cf899ba6af1e2da52979051 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Mar 2011 14:26:21 -0600 Subject: Check to ensure that layout_props isn't NULL. Atleast we shouldn't crash. --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c95b161..61253e2 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1823,6 +1823,7 @@ static void update_layout (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + g_return_if_fail(priv->layout_props != NULL); if (priv->menuproxy == NULL) { return; -- cgit v1.2.3 From ec307704b44db4f65f3534f23cfdf517c883a9e1 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Thu, 10 Mar 2011 00:43:07 +0000 Subject: Fix various memory leaks --- libdbusmenu-glib/client.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 61253e2..5ca52f4 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1213,7 +1213,9 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian while (g_variant_iter_next(&properties, "s", &property)) { /* g_debug("Removing property '%s' on %d", property, id); */ dbusmenu_menuitem_property_remove(menuitem, property); + g_free(property); } + g_variant_unref(ritem); } GVariantIter items; @@ -1304,12 +1306,11 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin have_error = TRUE; } - GList * current_props = NULL; + GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); + GList * tmp = NULL; - for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); - current_props != NULL && have_error == FALSE; - current_props = g_list_next(current_props)) { - dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->data); + for (tmp = current_props; tmp != NULL && have_error == FALSE; tmp = g_list_next(tmp)) { + dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)tmp->data); } g_list_free(current_props); -- cgit v1.2.3 From a97646cd0857bc60433490542ec1b98daf9fe7a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Mar 2011 10:11:04 -0600 Subject: On initially getting the proxy we need to check the theme directories to boot strap. --- libdbusmenu-glib/client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c95b161..6a62f9e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1056,10 +1056,25 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) } priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL)); + g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_TEXT_DIRECTION); g_variant_unref(textdir); } + /* Get the icon theme directories if available */ + GVariant * icon_dirs = g_dbus_proxy_get_cached_property(priv->menuproxy, "IconThemePath"); + if (icon_dirs != NULL) { + if (priv->icon_dirs != NULL) { + g_strfreev(priv->icon_dirs); + priv->icon_dirs = NULL; + } + + priv->icon_dirs = g_variant_dup_strv(icon_dirs, NULL); + g_signal_emit(G_OBJECT(client), signals[ICON_THEME_DIRS], 0, priv->icon_dirs, TRUE); + + g_variant_unref(icon_dirs); + } + /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != 0) { g_bus_unwatch_name(priv->dbusproxy); -- cgit v1.2.3 From 4701338925eb99eff5c2dd7ef05815855aae5a87 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Mar 2011 10:13:58 -0600 Subject: Also check the status when we get the proxy, not part of this bug, but it'll come along soon enough. --- libdbusmenu-glib/client.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 6a62f9e..b9c50ee 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1061,6 +1061,20 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_variant_unref(textdir); } + /* Check the status if available */ + GVariant * status = g_dbus_proxy_get_cached_property(priv->menuproxy, "Status"); + if (textdir != NULL) { + GVariant * str = status; + if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { + str = g_variant_get_variant(str); + } + + priv->status = dbusmenu_status_get_value_from_nick(g_variant_get_string(str, NULL)); + g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS); + + g_variant_unref(status); + } + /* Get the icon theme directories if available */ GVariant * icon_dirs = g_dbus_proxy_get_cached_property(priv->menuproxy, "IconThemePath"); if (icon_dirs != NULL) { -- cgit v1.2.3