From 72650a318c8d65419fa53929e004ee48f98e6b09 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 10:30:47 -0600 Subject: Adding a property for icon theme path collection. --- libdbusmenu-glib/dbus-menu.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 3b42f7d..738a0b0 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -189,6 +189,15 @@ License version 3 and version 2.1 along with this program. If not, see + + + A list of directories that should be used for finding icons using + the icon naming spec. Idealy there should only be one for the icon + theme, but additional ones are often added by applications for + app specific icons. + + + -- cgit v1.2.3 From d5b20b1b8f51a56c05a20aa58e54d6d231f30729 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 12:10:20 -0600 Subject: Prototypes and stubs for the get/set icon paths --- libdbusmenu-glib/server.c | 15 +++++++++++++++ libdbusmenu-glib/server.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 91e7a25..259167b 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1685,3 +1685,18 @@ dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) return; } + +const GStrv +dbusmenu_server_get_icon_paths (DbusmenuServer * server) +{ + + return NULL; +} + +void +dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths) +{ + + + return; +} diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 54cf5fc..bed567f 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -119,6 +119,9 @@ void dbusmenu_server_set_text_direction (DbusmenuServer * DbusmenuStatus dbusmenu_server_get_status (DbusmenuServer * server); void dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status); +const GStrv dbusmenu_server_get_icon_paths (DbusmenuServer * server); +void dbusmenu_server_set_icon_paths (DbusmenuServer * server, + GStrv icon_paths); /** SECIONT:server -- cgit v1.2.3 From 3786fda6e30b90f71e55cb325a342a019a548007 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 12:22:53 -0600 Subject: Adding some documentation --- libdbusmenu-glib/server.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 259167b..8d55cea 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1686,6 +1686,16 @@ dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) return; } +/** + dbusmenu_server_get_icon_paths: + @server: The #DbusmenuServer to get the icon paths from + + Gets the stored and exported icon paths from the server. + + Return value: A NULL-terminated list of icon paths with + memory managed by the server. Duplicate if you want + to keep them. +*/ const GStrv dbusmenu_server_get_icon_paths (DbusmenuServer * server) { @@ -1693,6 +1703,13 @@ dbusmenu_server_get_icon_paths (DbusmenuServer * server) return NULL; } +/** + dbusmenu_server_set_icon_paths: + @server: The #DbusmenuServer to set the icon paths on + + Sets the icon paths for the server. This will replace previously + set icon theme paths. +*/ void dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths) { -- cgit v1.2.3 From aff9b26c5c82ce54126d9cecc0a66a3abb5bfcc7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 13:39:21 -0600 Subject: Adding a private variable for the string list --- libdbusmenu-glib/server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 8d55cea..6199a39 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -59,6 +59,7 @@ struct _DbusmenuServerPrivate DbusmenuTextDirection text_direction; DbusmenuStatus status; + GStrv icon_dirs; GArray * prop_array; guint property_idle; @@ -368,6 +369,7 @@ dbusmenu_server_init (DbusmenuServer *self) default_text_direction(self); priv->status = DBUSMENU_STATUS_NORMAL; + priv->icon_dirs = NULL; return; } @@ -425,6 +427,13 @@ dbusmenu_server_dispose (GObject *object) static void dbusmenu_server_finalize (GObject *object) { + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(object); + + if (priv->icon_dirs != NULL) { + g_strfreev(priv->icon_dirs); + priv->icon_dirs = NULL; + } + G_OBJECT_CLASS (dbusmenu_server_parent_class)->finalize (object); return; } -- cgit v1.2.3 From b6260e5ce88bda9aef711e1fdddc75cd807dd5f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 13:40:56 -0600 Subject: Fleshing out getting the dirs --- libdbusmenu-glib/server.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 6199a39..123472d 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1706,10 +1706,11 @@ dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) to keep them. */ const GStrv -dbusmenu_server_get_icon_paths (DbusmenuServer * server) +dbusmenu_server_get_icon_paths (DbusmenuServer * server) { - - return NULL; + g_return_val_if_fail(DBUSMENU_IS_SERVER(server), NULL); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + return priv->icon_dirs; } /** -- cgit v1.2.3 From a72bcc0edc0da201b2cf112e057ee2273d4dd6d8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 14:03:09 -0600 Subject: Fleshing out the function to set the icon dirs --- libdbusmenu-glib/server.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 123472d..d969a55 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -85,7 +85,8 @@ enum { PROP_ROOT_NODE, PROP_VERSION, PROP_TEXT_DIRECTION, - PROP_STATUS + PROP_STATUS, + PROP_ICON_THEME_DIRS }; /* Errors */ @@ -1723,7 +1724,41 @@ dbusmenu_server_get_icon_paths (DbusmenuServer * server) void dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths) { + g_return_if_fail(DBUSMENU_IS_SERVER(server)); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + if (priv->icon_dirs != NULL) { + g_strfreev(priv->icon_dirs); + priv->icon_dirs = NULL; + } + + if (icon_paths != NULL) { + priv->icon_dirs = g_strdupv(icon_paths); + } + if (priv->bus != NULL && priv->dbusobject != NULL) { + GVariantBuilder params; + g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); + 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("icon-theme-path"), 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); + } + g_variant_builder_add_value(¶ms, items); + g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); + GVariant * vparams = g_variant_builder_end(¶ms); + + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + vparams, + NULL); + } return; } -- cgit v1.2.3 From 08409e83ad0cc9beeb27f3f4dce9b98a43138576 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 14:16:45 -0600 Subject: Handle the property being grabbed over dbus --- libdbusmenu-glib/server.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index d969a55..22aec70 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -754,6 +754,16 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); } else if (g_strcmp0(property, "text-direction") == 0) { return g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)); + } else if (g_strcmp0(property, "icon-theme-path") == 0) { + GVariant * dirs = NULL; + + if (priv->icon_dirs != NULL) { + dirs = g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1); + } else { + dirs = g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0); + } + + return dirs; } else { g_warning("Unknown property '%s'", property); } -- cgit v1.2.3 From 86bd1a4d6b7f9eb47357dae9569d150e5be4b338 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 21:30:16 -0600 Subject: Making sure to grab the variant and dispose of it in handle_event. --- libdbusmenu-glib/menuitem.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 5202aa1..34147a3 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1670,11 +1670,22 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVari #endif DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); + /* We need to keep a ref to the variant because the signal + handler will drop the floating ref and then we'll be up + a creek if we don't have our own later. */ + if (variant != NULL) { + g_variant_ref_sink(variant); + } + gboolean handled = FALSE; g_signal_emit(G_OBJECT(mi), signals[EVENT], g_quark_from_string(name), name, variant, timestamp, &handled); if (!handled && class->handle_event != NULL) { - return class->handle_event(mi, name, variant, timestamp); + class->handle_event(mi, name, variant, timestamp); + } + + if (variant != NULL) { + g_variant_unref(variant); } return; -- cgit v1.2.3 From 4775fc7ebe2c4c536cfe71b9f1087474c7567d7a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 25 Feb 2011 08:47:56 -0600 Subject: Use the library i18n instead of the standard one for apps. --- libdbusmenu-glib/defaults.c | 2 +- libdbusmenu-glib/server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index c05ef38..9eaf9e5 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -30,7 +30,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif -#include +#include #include "defaults.h" #include "menuitem.h" diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 056d6cb..3fe2422 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -30,7 +30,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif -#include +#include #include #include "menuitem-private.h" -- cgit v1.2.3 From f143a8c10adc126aa89a01f2b8f9fdb156fa0a44 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 25 Feb 2011 09:01:55 -0600 Subject: Switching so that the GIR file is built from our exported H files and objects. --- libdbusmenu-glib/Makefile.am | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 8b523aa..a04e286 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -17,12 +17,16 @@ lib_LTLIBRARIES = \ libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-glib/ -libdbusmenu_glibinclude_HEADERS = \ - dbusmenu-glib.h \ + +EXPORTED_OBJECTS = \ menuitem.h \ menuitem-proxy.h \ server.h \ - client.h \ + client.h + +libdbusmenu_glibinclude_HEADERS = \ + $(EXPORTED_OBJECTS) \ + dbusmenu-glib.h \ types.h libdbusmenu_glib_la_SOURCES = \ @@ -153,7 +157,9 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) if HAVE_INTROSPECTION -introspection_sources = $(libdbusmenu_glibinclude_HEADERS) $(libdbusmenu_glib_la_SOURCES) +introspection_sources = \ + $(libdbusmenu_glibinclude_HEADERS) \ + $(EXPORTED_OBJECTS:.h=.c) Dbusmenu-0.4.gir: libdbusmenu-glib.la Dbusmenu_0_4_gir_INCLUDES = \ -- cgit v1.2.3 From 6e69c09ed89fea101a214a257aaabdb5cc5abf5f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 25 Feb 2011 09:04:39 -0600 Subject: Add enum-types to the exported headers so that language bindings can use them. --- libdbusmenu-glib/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index a04e286..5b04415 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -19,6 +19,7 @@ libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-glib/ EXPORTED_OBJECTS = \ + enum-types.h \ menuitem.h \ menuitem-proxy.h \ server.h \ -- cgit v1.2.3 From 356ee2d0385f8fd22ec60d84620c0eb2df018384 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 28 Feb 2011 10:57:36 +0100 Subject: Doc fixes: - Use "@a foo" for arguments, not "@foo" - Rename "recurse" (which sounds boolean) to "recursionDepth" - Removed dbusmenu-qt specific annotations --- libdbusmenu-glib/dbus-menu.xml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index c0831e5..ffeca1e 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -177,21 +177,24 @@ License version 3 and version 2.1 along with this program. If not, see 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. + of the item that is specified in @a parentId. It will return all of the + properties or specific ones depending of the value in @a propertyNames. 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 - less than one then the second array will have zero entries. + as the original 'a(ia{sv}av)'. Its content depends on the value + of @a recursionDepth. The ID of the parent node for the layout. For grabbing the layout from the root node use zero. - + - The amount of levels of recursion to use. -1, as value would - deliver all the items under the @parentId. + The amount of levels of recursion to use. This affects the + content of the second variant array. + - -1: deliver all the items under the @a parentId. + - 0: no recursion, the array will be empty. + - n: array will contains items up to 'n' level depth. @@ -206,13 +209,11 @@ License version 3 and version 2.1 along with this program. If not, see with layoutUpdated signals. - The layout as an XML string of IDs. + The layout, as a recursive structure. - - Returns the list of items which are children of @a parentId. @@ -309,7 +310,7 @@ License version 3 and version 2.1 along with this program. If not, see properties. - + -- cgit v1.2.3 From ac984fac079ac48c7687aea3dce5808ace890b3f Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Mon, 28 Feb 2011 09:56:59 -0500 Subject: disconnect some more signals when menuitem dies --- libdbusmenu-gtk/parser.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 97f7979..8045b7f 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -129,6 +129,12 @@ parse_data_free (gpointer data) if (pdata != NULL && pdata->widget != NULL) { g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, 0, 0, NULL, G_CALLBACK(widget_notify_cb), NULL); + g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, G_CALLBACK(accel_changed), NULL); + g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, G_CALLBACK(checkbox_toggled), NULL); + g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, G_CALLBACK(menuitem_notify_cb), NULL); g_object_remove_weak_pointer(G_OBJECT(pdata->widget), (gpointer*)&pdata->widget); } -- cgit v1.2.3 From f9bc2ad66bbd631b17d264cb1baddf600b67ed7c Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 28 Feb 2011 17:20:24 +0000 Subject: Check the return value of gdk_keyval_name, as passing NULL pointers to g_variant_builder_add can cause bad things to happen. Might fix LP: #720895 --- libdbusmenu-gtk/menuitem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 508b43f..fd8246c 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -194,6 +194,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, } const gchar * keyname = gdk_keyval_name(key); + g_return_val_if_fail(keyname != NULL, FALSE); g_variant_builder_add(&builder, "s", keyname); GVariant * inside = g_variant_builder_end(&builder); -- cgit v1.2.3 From b8c5def4dd43b7061a65ba87f65b4b578a9d5c35 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 28 Feb 2011 18:29:17 +0000 Subject: Ensure we disconnect theme_changed_cb if the DbusmenuMenuitem disappears, but the corresponding GtkMenuItem stays alive. This shouldn't really be a problem, as dbusmenu_item_freed *should* do enough cleaning up to ensure that theme_changed_cb is inert if it fires later on. Just do this to be safe though --- libdbusmenu-gtk/parser.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 97f7979..30c802f 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -149,6 +149,14 @@ parse_data_free (gpointer data) return; } +static void +widget_freed (gpointer data, GObject * obj) +{ + g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), obj); + + return; +} + /* Called when the dbusmenu item that we're keeping around is finalized */ static void @@ -157,18 +165,12 @@ dbusmenu_item_freed (gpointer data, GObject * obj) ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(obj), PARSER_DATA); if (pdata != NULL && pdata->widget != NULL) { + g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), pdata->widget); g_object_steal_data(G_OBJECT(pdata->widget), CACHED_MENUITEM); + g_object_weak_unref(G_OBJECT(pdata->widget), widget_freed, NULL); } } -static void -widget_freed (gpointer data, GObject * obj) -{ - g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), obj); - - return; -} - /* Gets the positon of the child with its' parent if it has one. Returns -1 if the position is unable to be calculated. */ static gint -- cgit v1.2.3 From 02582ed5c9b2504f7ac4e2c907970f1b2ab26e2b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Feb 2011 12:37:31 -0600 Subject: These should be tuples, and now they are! --- libdbusmenu-glib/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 056d6cb..6b65638 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -499,7 +499,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) /* If the value has changed we need to signal that on DBus */ if (priv->text_direction != olddir && priv->bus != NULL && priv->dbusobject != NULL) { GVariantBuilder params; - g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); + 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("text-direction"), 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)); @@ -523,7 +523,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) /* If the value has changed we need to signal that on DBus */ if (priv->status != instatus && priv->bus != NULL && priv->dbusobject != NULL) { GVariantBuilder params; - g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); + 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))); g_variant_builder_add_value(¶ms, g_variant_new_array(NULL, &dict, 1)); -- cgit v1.2.3 From 6fd3cb9d03b1418aaf550e4069f18e0dca8c7054 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 28 Feb 2011 22:47:04 +0000 Subject: Fix LP: #723873 - when a menuitems property is restored to a default value, the new state is not updated correctly on the listening client. Make dbusmenu_menuitem_property_remove call dbusmenu_menuitem_property_set_variant with a NULL value rather than manipulating the properties directly. When removing a property that has a default value now, it will signal PROPERTY_CHANGED with the default value, which means that changing a property from non-default to default over the wire (which really just deletes the property) now works correctly. This is also now more aligned with how dbusmenu_menuitem_property_get* works, which will return the default value for a property after removing the property from the menuitem --- libdbusmenu-glib/menuitem.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 34147a3..61e59c3 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1150,9 +1150,9 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); GVariant * default_value = NULL; - if (value != NULL) { - const gchar * type = menuitem_get_type(mi); + const gchar * type = menuitem_get_type(mi); + if (value != 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) { @@ -1163,22 +1163,23 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro 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. */ + default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); + if (default_value != NULL && 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; } } + gboolean replaced = FALSE; gpointer currentval = g_hash_table_lookup(priv->properties, property); @@ -1371,9 +1372,7 @@ dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); g_return_if_fail(property != NULL); - DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - - g_hash_table_remove(priv->properties, property); + dbusmenu_menuitem_property_set_variant(mi, property, NULL); return; } -- cgit v1.2.3 From b678e3199d416efe0dc55d7f46c4124b673a2ae6 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Tue, 1 Mar 2011 11:15:19 +0000 Subject: The last commit causes the warning in dbusmenu_menuitem_property_is_default to be thrown when removing a property that has no default value. This warning seems bogus though, as any property that is not in the menuitems local property list is a default value (as that is what dbusmenu_menuitem_property_get* will return). Simplify this function to work like this and drop the warning --- libdbusmenu-glib/menuitem.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 61e59c3..855f4ee 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1752,13 +1752,8 @@ dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * prop 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; + /* If we haven't stored it locally, then it's the default */ + return TRUE; } /* Check to see if this menu item has been sent into the bus yet or -- cgit v1.2.3 From d53aa22ffd52ca5d78de74faf7b52832a2ac0663 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Tue, 1 Mar 2011 14:45:06 +0000 Subject: Ensure we hook on to child-added signals from sub GtkMenuShell's. This broke in r220 in order to stop adding weak pointers on the root shell more than once. Now, we connect the signals when we create the DbusmenuMenuitem --- libdbusmenu-gtk/parser.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 97f7979..74da3cd 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -450,6 +450,17 @@ construct_dbusmenu_for_widget (GtkWidget * widget) } } + GtkWidget *submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); + if (submenu) + { + pdata->shell = submenu; + g_signal_connect (G_OBJECT (submenu), + "child-added", + G_CALLBACK (child_added_cb), + thisitem); + g_object_add_weak_pointer(G_OBJECT(submenu), (gpointer*)&pdata->shell); + } + if (!g_object_get_data (G_OBJECT (widget), "gtk-empty-menu-item") && !GTK_IS_TEAROFF_MENU_ITEM (widget)) { visible = gtk_widget_get_visible (widget); -- cgit v1.2.3 From e319dcd8d8b2436b1f3bd5f8749b93c08f176251 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Tue, 1 Mar 2011 15:16:30 +0000 Subject: Oops, fix a silly typo --- libdbusmenu-gtk/parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 74da3cd..e705dc7 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -457,7 +457,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget) g_signal_connect (G_OBJECT (submenu), "child-added", G_CALLBACK (child_added_cb), - thisitem); + mi); g_object_add_weak_pointer(G_OBJECT(submenu), (gpointer*)&pdata->shell); } -- cgit v1.2.3 From 175bbbfbe11060d9029554732145f465062c792c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Mar 2011 10:47:31 -0600 Subject: Actually looking up the parent menu item --- libdbusmenu-glib/server.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 056d6cb..e268d1a 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1180,7 +1180,11 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio GVariant * items = NULL; if (priv->root != NULL) { - items = dbusmenu_menuitem_build_variant(priv->root, props, recurse); + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, parent); + + if (mi != NULL) { + items = dbusmenu_menuitem_build_variant(mi, props, recurse); + } } /* What happens if we don't have anything? */ -- cgit v1.2.3 From e45f9a41dd7104152d462870d6ac8feb0f64c0b5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Mar 2011 11:45:50 -0600 Subject: Move keyname check before builder is init'd --- libdbusmenu-gtk/menuitem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index fd8246c..370dbf2 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -177,6 +177,9 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); g_return_val_if_fail(gtk_accelerator_valid(key, modifier), FALSE); + const gchar * keyname = gdk_keyval_name(key); + g_return_val_if_fail(keyname != NULL, FALSE); + GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); @@ -193,8 +196,6 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, g_variant_builder_add(&builder, "s", DBUSMENU_MENUITEM_SHORTCUT_SUPER); } - const gchar * keyname = gdk_keyval_name(key); - g_return_val_if_fail(keyname != NULL, FALSE); g_variant_builder_add(&builder, "s", keyname); GVariant * inside = g_variant_builder_end(&builder); -- cgit v1.2.3 From 7382073359ea7a103f53b05167214b0f10fd516c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Mar 2011 21:01:59 -0600 Subject: Putting a protection in for bad key values. --- libdbusmenu-glib/menuitem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 855f4ee..399b6f5 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1146,6 +1146,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); g_return_val_if_fail(property != NULL, FALSE); + g_return_val_if_fail(g_utf8_validate(property, -1, NULL), FALSE); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); GVariant * default_value = NULL; -- cgit v1.2.3 From 47b5514af1101a64fcf220056c7e4a81d89aeeb9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Mar 2011 21:12:03 -0600 Subject: Delaying the removal from the hashtable. --- libdbusmenu-glib/menuitem.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 399b6f5..f7867e4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1182,6 +1182,7 @@ 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); if (value != NULL) { @@ -1196,10 +1197,21 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro gchar * lprop = g_strdup(property); g_variant_ref_sink(value); - g_hash_table_replace(priv->properties, lprop, value); + /* Really important that this is _insert as that means the value + that we just created in the _strdup is free'd and not the one + currently in the hashtable. That could be the same as the one + being passed in and then the signal emit would be done with a + bad value */ + g_hash_table_insert(priv->properties, lprop, value); } else { if (currentval != NULL) { - g_hash_table_remove(priv->properties, property); + /* 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, + in a couple cases the passed in properties is the value in the hash + table so we can avoid strdup'ing it by removing it (and thus free'ing + it) after the signal emition */ + remove = TRUE; replaced = TRUE; } } @@ -1220,6 +1232,10 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, signalval, TRUE); } + if (remove) { + g_hash_table_remove(priv->properties, property); + } + return TRUE; } -- cgit v1.2.3 From 0e6db378e81e24f2ee2ff4498ff40dc60d1915bc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Mar 2011 21:19:43 -0600 Subject: Don't tell us everytime, we know you're good, you don't have to brag. --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d368a0e..e1f20d1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1168,7 +1168,7 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian gchar * property; while (g_variant_iter_next(&properties, "s", &property)) { - g_debug("Removing property '%s' on %d", property, id); + /* g_debug("Removing property '%s' on %d", property, id); */ dbusmenu_menuitem_property_remove(menuitem, property); } } -- cgit v1.2.3 From 33b4e34124c38f8159ea4af25f2b3622b3cc392e Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Wed, 2 Mar 2011 12:07:07 +0100 Subject: Rename dbus properties to follow dbus naming conventions - version => Version - text-direction => TextDirection - status => Status --- libdbusmenu-glib/client.c | 10 +++++----- libdbusmenu-glib/dbus-menu.xml | 6 +++--- libdbusmenu-glib/server.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d368a0e..8424d6f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1026,7 +1026,7 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) } /* Check the text direction if available */ - GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "text-direction"); + GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "TextDirection"); if (textdir != NULL) { GVariant * str = textdir; if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { @@ -1069,10 +1069,10 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva gchar * invalid; gint i = 0; for (invalid = invalidated[i]; invalid != NULL; invalid = invalidated[++i]) { - if (g_strcmp0(invalid, "text-direction") == 0) { + if (g_strcmp0(invalid, "TextDirection") == 0) { priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; } - if (g_strcmp0(invalid, "status") == 0) { + if (g_strcmp0(invalid, "Status") == 0) { priv->status = DBUSMENU_STATUS_NORMAL; } } @@ -1082,7 +1082,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva gchar * key; GVariant * value; g_variant_iter_init(&iters, properties); while (g_variant_iter_next(&iters, "{sv}", &key, &value)) { - if (g_strcmp0(key, "text-direction") == 0) { + if (g_strcmp0(key, "TextDirection") == 0) { GVariant * str = value; if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { str = g_variant_get_variant(str); @@ -1090,7 +1090,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL)); } - if (g_strcmp0(key, "status") == 0) { + if (g_strcmp0(key, "Status") == 0) { GVariant * str = value; if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { str = g_variant_get_variant(str); diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 2352712..b61b5ec 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -164,14 +164,14 @@ License version 3 and version 2.1 along with this program. If not, see ]]> - + Provides the version of the DBusmenu API that this API is implementing. - + Represents the way the text direction of the application. This allows the server to handle mismatches intelligently. For left- @@ -179,7 +179,7 @@ License version 3 and version 2.1 along with this program. If not, see - + Tells if the menus are in a normal state or they believe that they could use some attention. Cases for showing them would be if help diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7c943b2..ebd9193 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -501,7 +501,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GVariantBuilder params; g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); - GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("text-direction"), 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_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); @@ -525,7 +525,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GVariantBuilder params; g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); 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_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); @@ -740,11 +740,11 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * g_return_val_if_fail(g_strcmp0(interface, DBUSMENU_INTERFACE) == 0, NULL); g_return_val_if_fail(g_strcmp0(path, priv->dbusobject) == 0, NULL); - if (g_strcmp0(property, "version") == 0) { + if (g_strcmp0(property, "Version") == 0) { return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); - } else if (g_strcmp0(property, "text-direction") == 0) { + } else if (g_strcmp0(property, "TextDirection") == 0) { return g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)); - } else if (g_strcmp0(property, "status") == 0) { + } else if (g_strcmp0(property, "Status") == 0) { return g_variant_new_string(dbusmenu_status_get_nick(priv->status)); } else { g_warning("Unknown property '%s'", property); -- cgit v1.2.3 From ecd64358f931dc26bd806f72f774cac54e3bfad7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Mar 2011 10:04:25 -0600 Subject: Changing the destroy notification function to be a GDestroyNotify for GIR purposes --- libdbusmenu-glib/client.c | 10 +++++----- libdbusmenu-glib/client.h | 14 +------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 83ca056..8415b95 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -129,7 +129,7 @@ typedef struct _type_handler_t type_handler_t; struct _type_handler_t { DbusmenuClient * client; DbusmenuClientTypeHandler cb; - DbusmenuClientTypeDestroyHandler destroy_cb; + GDestroyNotify destroy_cb; gpointer user_data; gchar * type; }; @@ -1881,7 +1881,7 @@ type_handler_destroy (gpointer user_data) { type_handler_t * th = (type_handler_t *)user_data; if (th->destroy_cb != NULL) { - th->destroy_cb(th->client, th->type, th->user_data); + th->destroy_cb(th->user_data); } g_free(th->type); g_free(th); @@ -1893,7 +1893,7 @@ type_handler_destroy (gpointer user_data) * @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 + * @newfunc: (scope notified): The function that will be executed with those new * items when they come in. * * This function connects into the type handling of the #DbusmenuClient. @@ -1920,7 +1920,7 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D * @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 + * @newfunc: (scope notified): 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 @@ -1941,7 +1941,7 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D * 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) +dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, GDestroyNotify destroy_func) { g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), FALSE); g_return_val_if_fail(type != NULL, FALSE); diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 28d4dd3..1deed56 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -198,18 +198,6 @@ struct _DbusmenuClient { */ typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -/** - DbusmenuClientTypeDestroyHandler: - @client: A pointer to the #DbusmenuClient - @type: The type that this handler was registered with - @user_data: The data you gave us - - This handler is called when the type becomes unregistered by the - client. This is usally caused by the #DbusmenuClient being destroyed - and should free memory or unref objects in @user_data. -*/ -typedef void (*DbusmenuClientTypeDestroyHandler) (DbusmenuClient * client, const gchar * type, gpointer user_data); - GType dbusmenu_client_get_type (void); DbusmenuClient * dbusmenu_client_new (const gchar * name, const gchar * object); @@ -221,7 +209,7 @@ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * cli const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, - DbusmenuClientTypeDestroyHandler destroy_func); + GDestroyNotify destroy_func); DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client); DbusmenuStatus dbusmenu_client_get_status (DbusmenuClient * client); -- cgit v1.2.3 From 6fb7eb541f20583ab5427d6fd57bd7ecc1280f05 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Mar 2011 10:05:54 -0600 Subject: Fix the type_destroy_handler to be a GDestroyNotify function --- libdbusmenu-gtk/serializablemenuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 29f83a8..b560fe3 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -215,7 +215,7 @@ type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCli /* Destruction is inevitable */ static void -type_destroy_handler (DbusmenuClient * client, const gchar * type, gpointer user_data) +type_destroy_handler (gpointer user_data) { g_return_if_fail(user_data != NULL); type_handler_t * th = (type_handler_t *)user_data; @@ -255,7 +255,7 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, th->class = class; th->type = item_type; if (!dbusmenu_client_add_type_handler_full(client, class->get_type_string(), type_handler, th, type_destroy_handler)) { - type_destroy_handler(client, class->get_type_string(), th); + type_destroy_handler(th); } /* Register defaults */ -- cgit v1.2.3 From 45962d68b2e1dcac1443f9e56b6a597cdd2816c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Mar 2011 10:36:59 -0600 Subject: Dropping the destroy handler from the docs --- docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt b/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt index b1e2d8c..2a8aa90 100644 --- a/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt +++ b/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt @@ -17,7 +17,6 @@ DBUSMENU_CLIENT_TYPES_IMAGE DbusmenuClient DbusmenuClientClass DbusmenuClientTypeHandler -DbusmenuClientTypeDestroyHandler dbusmenu_client_new dbusmenu_client_get_root dbusmenu_client_get_status -- cgit v1.2.3 From d693a90a23e498b50052040f90d761d0b57c5914 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Mar 2011 22:41:48 -0600 Subject: Changing property name to match DBus recommendations --- libdbusmenu-glib/dbus-menu.xml | 2 +- libdbusmenu-glib/server.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 956844e..efb55d4 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -189,7 +189,7 @@ License version 3 and version 2.1 along with this program. If not, see - + A list of directories that should be used for finding icons using the icon naming spec. Idealy there should only be one for the icon diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 14c0c53..7421747 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -754,7 +754,7 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); } else if (g_strcmp0(property, "TextDirection") == 0) { return g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)); - } else if (g_strcmp0(property, "icon-theme-path") == 0) { + } else if (g_strcmp0(property, "IconThemePath") == 0) { GVariant * dirs = NULL; if (priv->icon_dirs != NULL) { @@ -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("icon-theme-path"), 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_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 653e6aaf8dfbc91f728cd8766991a50c2fc6f275 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Mar 2011 22:47:54 -0600 Subject: Adding the private variable for icon directories --- libdbusmenu-glib/client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 83ca056..a91e9f6 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -98,6 +98,7 @@ struct _DbusmenuClientPrivate DbusmenuTextDirection text_direction; DbusmenuStatus status; + GStrv icon_dirs; }; typedef struct _newItemPropData newItemPropData; @@ -358,6 +359,7 @@ dbusmenu_client_init (DbusmenuClient *self) priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; priv->status = DBUSMENU_STATUS_NORMAL; + priv->icon_dirs = NULL; return; } @@ -466,6 +468,11 @@ dbusmenu_client_finalize (GObject *object) g_hash_table_destroy(priv->type_handlers); } + if (priv->icon_dirs != NULL) { + g_strfreev(priv->icon_dirs); + priv->icon_dirs = NULL; + } + G_OBJECT_CLASS (dbusmenu_client_parent_class)->finalize (object); return; } -- cgit v1.2.3 From 75eb455e972b3e04b2fc8b89ead2815dff070fa5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Mar 2011 22:53:09 -0600 Subject: Handle getting the property and/or getting an update to it. --- libdbusmenu-glib/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a91e9f6..9954683 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1071,6 +1071,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); DbusmenuTextDirection olddir = priv->text_direction; DbusmenuStatus oldstatus = priv->status; + gboolean dirs_changed = FALSE; /* Invalidate first */ gchar * invalid; @@ -1082,6 +1083,13 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva if (g_strcmp0(invalid, "Status") == 0) { priv->status = DBUSMENU_STATUS_NORMAL; } + if (g_strcmp0(invalid, "IconThemePath") == 0) { + if (priv->icon_dirs != NULL) { + dirs_changed = TRUE; + g_strfreev(priv->icon_dirs); + priv->icon_dirs = NULL; + } + } } /* Check updates */ @@ -1105,6 +1113,15 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva priv->status = dbusmenu_status_get_value_from_nick(g_variant_get_string(str, NULL)); } + if (g_strcmp0(key, "IconThemePath") == 0) { + if (priv->icon_dirs != NULL) { + g_strfreev(priv->icon_dirs); + priv->icon_dirs = NULL; + } + + priv->icon_dirs = g_variant_dup_strv(value, NULL); + dirs_changed = TRUE; + } g_variant_unref(value); g_free(key); @@ -1118,6 +1135,10 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS); } + if (dirs_changed) { + // TODO: We need to tell someone! + } + return; } -- cgit v1.2.3 From 9dd7d767dfc3388d549e2b2ed6004618dcf84270 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 10:31:22 -0600 Subject: Adding a signal for theme directories changing. --- libdbusmenu-glib/client-marshal.list | 1 + libdbusmenu-glib/client.c | 15 +++++++++++++++ libdbusmenu-glib/client.h | 10 +++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list index 96f9302..980c5c3 100644 --- a/libdbusmenu-glib/client-marshal.list +++ b/libdbusmenu-glib/client-marshal.list @@ -1,3 +1,4 @@ VOID: OBJECT, UINT VOID: OBJECT, STRING, VARIANT, UINT, POINTER VOID: ENUM +VOID: POINTER diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 9954683..30fe1ba 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -62,6 +62,7 @@ enum { NEW_MENUITEM, ITEM_ACTIVATE, EVENT_RESULT, + ICON_THEME_DIRS, LAST_SIGNAL }; @@ -273,6 +274,20 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, NULL, _dbusmenu_client_marshal_VOID__OBJECT_STRING_VARIANT_UINT_POINTER, G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT, G_TYPE_POINTER); + /** + DbusmenuClient::icon-theme-dirs-changed: + @arg0: The #DbusmenuClient object + @arg1: A #GStrv of theme directories + + Signaled when the theme directories are changed by the server. + */ + signals[ICON_THEME_DIRS] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DbusmenuClientClass, icon_theme_dirs), + NULL, NULL, + _dbusmenu_client_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); g_object_class_install_property (object_class, PROP_DBUSOBJECT, g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_OBJECT, "DBus Object we represent", diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 28d4dd3..f69270f 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -75,11 +75,11 @@ G_BEGIN_DECLS */ #define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT "event-result" /** - * DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED: + * DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED: * - * String to attach to signal #DbusmenuClient::text-direction-changed + * String to attach to signal #DbusmenuClient::icon-theme-dirs-changed */ -#define DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED "text-direction-changed" +#define DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED "icon-theme-dirs-changed" /** * DBUSMENU_CLIENT_PROP_DBUS_NAME: @@ -139,12 +139,12 @@ typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; @new_menuitem: Slot for #DbusmenuClient::new-menuitem. @item_activate: Slot for #DbusmenuClient::item-activate. @event_result: Slot for #DbusmenuClient::event-error. + @icon_theme_dirs: Slot for #DbusmenuClient::icon-theme-dirs-changed. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @reserved3: Reserved for future use. @reserved4: Reserved for future use. @reserved5: Reserved for future use. - @reserved6: Reserved for future use. A simple class that takes all of the information from a #DbusmenuServer over DBus and makes the same set of @@ -159,6 +159,7 @@ struct _DbusmenuClientClass { void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); void (*event_result) (DbusmenuMenuitem * item, gchar * event, GVariant * data, guint timestamp, GError * error); + void (*icon_theme_dirs) (DbusmenuMenuitem * item, gpointer theme_dirs, GError * error); /*< Private >*/ void (*reserved1) (void); @@ -166,7 +167,6 @@ struct _DbusmenuClientClass { void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); - void (*reserved6) (void); }; /** -- cgit v1.2.3 From c975ec882ef2842aec03e799c5fc807d8dc6c3b4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 10:34:54 -0600 Subject: Emit the signal when needed --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 30fe1ba..26c7942 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1151,7 +1151,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva } if (dirs_changed) { - // TODO: We need to tell someone! + g_signal_emit(G_OBJECT(user_data), signals[ICON_THEME_DIRS], 0, priv->icon_dirs, TRUE); } return; -- cgit v1.2.3 From baacc6da45b252e8c510a6e69fd7332f51dd961e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 10:37:07 -0600 Subject: Changing comment so it can get some GIR lovin' --- libdbusmenu-glib/server.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7421747..810fc05 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1728,15 +1728,15 @@ dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) } /** - dbusmenu_server_get_icon_paths: - @server: The #DbusmenuServer to get the icon paths from - - Gets the stored and exported icon paths from the server. - - Return value: A NULL-terminated list of icon paths with - memory managed by the server. Duplicate if you want - to keep them. -*/ + * dbusmenu_server_get_icon_paths: + * @server: The #DbusmenuServer to get the icon paths from + * + * Gets the stored and exported icon paths from the server. + * + * Return value: (transfer none): A NULL-terminated list of icon paths with + * memory managed by the server. Duplicate if you want + * to keep them. + */ const GStrv dbusmenu_server_get_icon_paths (DbusmenuServer * server) { -- cgit v1.2.3 From 10a95caedd896115b4d479c0328d575ce20e32d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 10:43:26 -0600 Subject: Add a 'get' function for the icon theme directories. --- libdbusmenu-glib/client.c | 17 +++++++++++++++++ libdbusmenu-glib/client.h | 1 + 2 files changed, 18 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 26c7942..f041730 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -2055,4 +2055,21 @@ dbusmenu_client_get_status (DbusmenuClient * client) return priv->status; } +/** + * dbusmenu_client_get_icon_paths: + * @client: The #DbusmenuClient to get the icon paths from + * + * Gets the stored and exported icon paths from the client. + * + * Return value: (transfer none): A NULL-terminated list of icon paths with + * memory managed by the client. Duplicate if you want + * to keep them. + */ +const GStrv +dbusmenu_client_get_icon_paths (DbusmenuClient * client) +{ + g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), NULL); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + return priv->icon_dirs; +} diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index f69270f..93f4280 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -224,6 +224,7 @@ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * cli DbusmenuClientTypeDestroyHandler destroy_func); DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client); DbusmenuStatus dbusmenu_client_get_status (DbusmenuClient * client); +const GStrv dbusmenu_client_get_icon_paths (DbusmenuClient * client); /** SECTION:client -- cgit v1.2.3 From a5f4f2898eec5e8dda5ec302c57ab9610ac9d1f3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 10:59:21 -0600 Subject: Should be a tuple --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 810fc05..fa517f5 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1769,7 +1769,7 @@ dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths) if (priv->bus != NULL && priv->dbusobject != NULL) { GVariantBuilder params; - g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); + g_variant_builder_init(¶ms, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); GVariant * items = NULL; if (priv->icon_dirs != NULL) { -- cgit v1.2.3 From 1e1969a77b03f79504305ecfc6098249b52862c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 11:00:53 -0600 Subject: Fixing the sections to match our new funcs --- docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt b/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt index b1e2d8c..4ee1401 100644 --- a/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt +++ b/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt @@ -6,7 +6,7 @@ DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE -DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED +DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED DBUSMENU_CLIENT_PROP_DBUS_NAME DBUSMENU_CLIENT_PROP_DBUS_OBJECT DBUSMENU_CLIENT_PROP_STATUS @@ -19,6 +19,7 @@ DbusmenuClientClass DbusmenuClientTypeHandler DbusmenuClientTypeDestroyHandler dbusmenu_client_new +dbusmenu_client_get_icon_paths dbusmenu_client_get_root dbusmenu_client_get_status dbusmenu_client_get_text_direction @@ -152,6 +153,8 @@ DBUSMENU_SERVER_GET_CLASS DbusmenuServerPrivate dbusmenu_server_get_type +dbusmenu_server_get_icon_paths +dbusmenu_server_set_icon_paths
-- cgit v1.2.3 From 5debce23eeb45e440a2e3be9f67c6eb2e2a78e31 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Mar 2011 13:24:44 -0600 Subject: 0.3.100 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 195422b..98f7cc7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.99, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.100, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.99, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.100, [-Wno-portability]) AM_MAINTAINER_MODE @@ -134,7 +134,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=7 +LIBDBUSMENU_REVISION=8 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3