From a252fa4375ce61f691d317ee644573d983a42df9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Jun 2010 16:23:31 -0500 Subject: The shortcut strings defined. --- libdbusmenu-glib/menuitem.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index b04bba8..77997ba 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -58,6 +58,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" #define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" #define DBUSMENU_MENUITEM_PROP_TOGGLE_STATE "toggle-state" +#define DBUSMENU_MENUITEM_PROP_SHORTCUT "shortcut" #define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" #define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" @@ -68,6 +69,12 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_ICON_NAME_BLANK "blank-icon" +#define DBUSMENU_MENUITEM_SHORTCUT_CONTROL "Control" +#define DBUSMENU_MENUITEM_SHORTCUT_ALT "Alt" +#define DBUSMENU_MENUITEM_SHORTCUT_SHIFT "Shift" +#define DBUSMENU_MENUITEM_SHORTCUT_SUPER "Super" + + /** * DbusmenuMenuitem: * -- cgit v1.2.3 From 8ec651ef62779668b4919e94a32cd6c7868b7609 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Jun 2010 17:36:57 -0500 Subject: Dummy functions to get and set the shortcut --- libdbusmenu-gtk/menuitem.c | 34 ++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/menuitem.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 23ff311..8b026e6 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -128,3 +128,37 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * return icon; } +/** + dbusmenu_menuitem_property_set_shortcut: + @menuitem: The #DbusmenuMenuitem to set the shortcut on + @shortcut: String describing the shortcut + + This function takes a GTK shortcut string as defined in + #gtk_accellerator_parse and turns that into the information + required to send it over DBusmenu. + + Return value: Whether it was successful at setting the property. +*/ +gboolean +dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut) +{ + + return FALSE; +} + +/** + dbusmenu_menuitem_property_get_shortcut: + @menuitem: The #DbusmenuMenuitem to get the shortcut off + + This function gets a GTK shortcut string as defined in + #gtk_accellerator_parse from the data that is transferred + over DBusmenu. + + Return value: Either the string or #NULL if there is none. +*/ +gchar * +dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem) +{ + + return NULL; +} diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h index ff458de..aacab42 100644 --- a/libdbusmenu-gtk/menuitem.h +++ b/libdbusmenu-gtk/menuitem.h @@ -36,4 +36,7 @@ License version 3 and version 2.1 along with this program. If not, see gboolean dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * property, const GdkPixbuf * data); GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * property); +gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut); +gchar * dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem); + #endif -- cgit v1.2.3 From 9c4988079766e6c5398852b8b7f78188b6aee369 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Jun 2010 16:52:24 -0500 Subject: Fleshing out building the shortcut array. --- libdbusmenu-gtk/menuitem.c | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 8b026e6..1ae4817 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -27,6 +27,8 @@ License version 3 and version 2.1 along with this program. If not, see */ #include "menuitem.h" +#include +#include /** dbusmenu_menuitem_property_set_image: @@ -134,7 +136,7 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * @shortcut: String describing the shortcut This function takes a GTK shortcut string as defined in - #gtk_accellerator_parse and turns that into the information + #gtk_accelerator_parse and turns that into the information required to send it over DBusmenu. Return value: Whether it was successful at setting the property. @@ -142,8 +144,47 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut) { + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); + g_return_val_if_fail(shortcut != NULL, FALSE); + + guint key = 0; + GdkModifierType modifier = 0; + + gtk_accelerator_parse(shortcut, &key, &modifier); - return FALSE; + if (key == 0) { + g_warning("Unable to parse shortcut string '%s'", shortcut); + return FALSE; + } + + GPtrArray * array = g_ptr_array_new(); + + if (modifier & GDK_CONTROL_MASK) { + g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_CONTROL)); + } + if (modifier & GDK_MOD1_MASK) { + g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_ALT)); + } + if (modifier & GDK_SHIFT_MASK) { + g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_SHIFT)); + } + if (modifier & GDK_SUPER_MASK) { + g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_SUPER)); + } + + gint len = g_utf8_strlen(shortcut, -1); + g_ptr_array_add(array, g_strdup(shortcut + len - 1)); + + GPtrArray * wrapper = g_ptr_array_new(); + g_ptr_array_add(wrapper, array); + + GValue value = {0}; + g_value_init(&value, G_TYPE_BOXED); + g_value_set_boxed(&value, wrapper); + + dbusmenu_menuitem_property_set_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, &value); + + return TRUE; } /** @@ -151,7 +192,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha @menuitem: The #DbusmenuMenuitem to get the shortcut off This function gets a GTK shortcut string as defined in - #gtk_accellerator_parse from the data that is transferred + #gtk_accelerator_parse from the data that is transferred over DBusmenu. Return value: Either the string or #NULL if there is none. @@ -159,6 +200,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha gchar * dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem) { + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); return NULL; } -- cgit v1.2.3 From 2c464b6b4c16d4dc32090706ecfc7c198d68c84e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Jun 2010 20:39:21 -0500 Subject: Switching things around to expose the key and modifier more as it's more useful. --- libdbusmenu-gtk/menuitem.c | 30 ++++++++++++++++++------------ libdbusmenu-gtk/menuitem.h | 6 ++++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 1ae4817..0f09483 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -142,7 +142,7 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * Return value: Whether it was successful at setting the property. */ gboolean -dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut) +dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); g_return_val_if_fail(shortcut != NULL, FALSE); @@ -157,6 +157,14 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha return FALSE; } + return dbusmenu_menuitem_property_set_shortcut(menuitem, key, modifier); +} + +gboolean +dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); + GPtrArray * array = g_ptr_array_new(); if (modifier & GDK_CONTROL_MASK) { @@ -172,8 +180,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_SUPER)); } - gint len = g_utf8_strlen(shortcut, -1); - g_ptr_array_add(array, g_strdup(shortcut + len - 1)); + g_ptr_array_add(array, g_strdup(gdk_keyval_name(key))); GPtrArray * wrapper = g_ptr_array_new(); g_ptr_array_add(wrapper, array); @@ -190,17 +197,16 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha /** dbusmenu_menuitem_property_get_shortcut: @menuitem: The #DbusmenuMenuitem to get the shortcut off + @key: Location to put the key value + @modifier: Location to put the modifier mask - This function gets a GTK shortcut string as defined in - #gtk_accelerator_parse from the data that is transferred - over DBusmenu. - - Return value: Either the string or #NULL if there is none. + This function gets a GTK shortcut as a key and a mask + for use to set the accelerators. */ -gchar * -dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem) +void +dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifier) { - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); + g_return_if_fail(DBUSMENU_IS_MENUITEM(menuitem)); - return NULL; + return; } diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h index aacab42..ba01549 100644 --- a/libdbusmenu-gtk/menuitem.h +++ b/libdbusmenu-gtk/menuitem.h @@ -32,11 +32,13 @@ License version 3 and version 2.1 along with this program. If not, see #include #include #include +#include gboolean dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * property, const GdkPixbuf * data); GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * property); -gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut); -gchar * dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem); +gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier); +gboolean dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut); +void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifiers); #endif -- cgit v1.2.3 From 47d48f8c3eb464e27f9632f51ce574fc9358143b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Jun 2010 15:17:26 -0500 Subject: Trying a dummy sgml file --- docs/libdbusmenu-glib/reference/Makefile.am | 2 +- docs/libdbusmenu-glib/reference/tmpl/dummy.sgml | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 docs/libdbusmenu-glib/reference/tmpl/dummy.sgml diff --git a/docs/libdbusmenu-glib/reference/Makefile.am b/docs/libdbusmenu-glib/reference/Makefile.am index e8a3610..8119537 100644 --- a/docs/libdbusmenu-glib/reference/Makefile.am +++ b/docs/libdbusmenu-glib/reference/Makefile.am @@ -80,7 +80,7 @@ include $(top_srcdir)/gtk-doc.local.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in -EXTRA_DIST += version.xml.in +EXTRA_DIST += version.xml.in tmpl/dummy.sgml # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types diff --git a/docs/libdbusmenu-glib/reference/tmpl/dummy.sgml b/docs/libdbusmenu-glib/reference/tmpl/dummy.sgml new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From d6970de44f5ce5e6572761bc68d4252061794c9d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Jun 2010 15:20:24 -0500 Subject: Apparently you can't use EXTRA_DIST like this with gtk-doc. Why be normal? --- docs/libdbusmenu-glib/reference/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/libdbusmenu-glib/reference/Makefile.am b/docs/libdbusmenu-glib/reference/Makefile.am index 8119537..e8a3610 100644 --- a/docs/libdbusmenu-glib/reference/Makefile.am +++ b/docs/libdbusmenu-glib/reference/Makefile.am @@ -80,7 +80,7 @@ include $(top_srcdir)/gtk-doc.local.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in -EXTRA_DIST += version.xml.in tmpl/dummy.sgml +EXTRA_DIST += version.xml.in # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types -- cgit v1.2.3 From 327143819733e9104a6f9b6ee043289d09a5fae5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Jun 2010 20:19:34 -0500 Subject: Adding a dummy sgml file. --- docs/libdbusmenu-gtk/reference/tmpl/dummy.sgml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/libdbusmenu-gtk/reference/tmpl/dummy.sgml diff --git a/docs/libdbusmenu-gtk/reference/tmpl/dummy.sgml b/docs/libdbusmenu-gtk/reference/tmpl/dummy.sgml new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From 4fbdf12b5671ebcc68ce2d41018cd2a567298be8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Jun 2010 21:11:45 -0500 Subject: Adding an extra callback to catch a race condition --- libdbusmenu-glib/client.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c0d3b7a..fa233a4 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -30,6 +30,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#include + #include #include @@ -397,6 +399,25 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c return build_proxies(client); } +/* This is the response to see if the name has an owner. If + it does, then we should build the proxies here. Race condition + check. */ +static void +name_owner_check (DBusGProxy *proxy, gboolean has_owner, GError *error, gpointer userdata) +{ + if (error != NULL) { + return; + } + + if (!has_owner) { + return; + } + + DbusmenuClient * client = DBUSMENU_CLIENT(userdata); + build_proxies(client); + return; +} + /* This function builds the DBus proxy which will look out for the service coming up. */ static void @@ -426,6 +447,13 @@ build_dbus_proxy (DbusmenuClient * client) dbus_g_proxy_connect_signal(priv->dbusproxy, "NameOwnerChanged", G_CALLBACK(dbus_owner_change), client, NULL); + /* Now let's check to make sure we're not in some race + condition case. */ + org_freedesktop_DBus_name_has_owner_async(priv->dbusproxy, + priv->dbus_name, + name_owner_check, + client); + return; } -- cgit v1.2.3 From 77958c0a4c45138e5f731e6f11cdee5a8bc3f8a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 10:58:21 -0500 Subject: Adding in a prototype for stealing the shortcut off of a menuitem. --- libdbusmenu-gtk/menuitem.c | 7 +++++++ libdbusmenu-gtk/menuitem.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 0f09483..74cb635 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -194,6 +194,13 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, return TRUE; } +gboolean +dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi) +{ + + return FALSE; +} + /** dbusmenu_menuitem_property_get_shortcut: @menuitem: The #DbusmenuMenuitem to get the shortcut off diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h index ba01549..6960f76 100644 --- a/libdbusmenu-gtk/menuitem.h +++ b/libdbusmenu-gtk/menuitem.h @@ -33,12 +33,14 @@ License version 3 and version 2.1 along with this program. If not, see #include #include #include +#include gboolean dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * property, const GdkPixbuf * data); GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * property); gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier); gboolean dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut); +gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi); void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifiers); #endif -- cgit v1.2.3 From 50dcdae3889fef7da43c6618b35b70847ba59d72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 11:05:34 -0500 Subject: Comment fixes --- libdbusmenu-gtk/menuitem.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 74cb635..6f5c6b3 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -131,7 +131,7 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * } /** - dbusmenu_menuitem_property_set_shortcut: + dbusmenu_menuitem_property_set_shortcut_string: @menuitem: The #DbusmenuMenuitem to set the shortcut on @shortcut: String describing the shortcut @@ -160,6 +160,17 @@ dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, con return dbusmenu_menuitem_property_set_shortcut(menuitem, key, modifier); } +/** + dbusmenu_menuitem_property_set_shortcut: + @menuitem: The #DbusmenuMenuitem to set the shortcut on + @key: The keycode of the key to send + @modifier: A bitmask of modifiers used to activate the item + + Takes the modifer described by @key and @modifier and places that into + the format sending across Dbus for shortcuts. + + Return value: Whether it was successful at setting the property. +*/ gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier) { @@ -194,6 +205,17 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, return TRUE; } +/** + dbusmenu_menuitem_property_set_shortcut_menuitem: + @menuitem: The #DbusmenuMenuitem to set the shortcut on + @gmi: A menu item to steal the shortcut off of + + Takes the shortcut that is installed on a menu item and calls + #dbusmenu_menuitem_property_set_shortcut with it. It also sets + up listeners to watch it change. + + Return value: Whether it was successful at setting the property. +*/ gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi) { -- cgit v1.2.3 From 7fc24062ed7fea97fec2a3cd873dcc68edc9c488 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 12:12:35 -0500 Subject: Fleshing out getting the accelerator from the menuitem. --- libdbusmenu-gtk/menuitem.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 6f5c6b3..dfd83b0 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -205,6 +205,14 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, return TRUE; } +/* Look at the closures in an accel group and find + the one that matches the one we've been passed */ +static gboolean +find_closure (GtkAccelKey * key, GClosure * closure, gpointer user_data) +{ + return closure == user_data; +} + /** dbusmenu_menuitem_property_set_shortcut_menuitem: @menuitem: The #DbusmenuMenuitem to set the shortcut on @@ -219,8 +227,32 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi) { + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); + g_return_val_if_fail(GTK_IS_MENU_ITEM(gmi), FALSE); + + GClosure * closure = NULL; + GList * clist; + + clist = gtk_widget_list_accel_closures(GTK_WIDGET(gmi)); + if (clist == NULL) { + g_warning("Menuitem does not have any closures."); + return FALSE; + } + + closure = (GClosure *)clist->data; + g_list_free(clist); + + GtkAccelGroup * group = gtk_accel_group_from_accel_closure(closure); + + /* Seriously, if this returns NULL something is seriously + wrong in GTK. */ + g_return_val_if_fail(group != NULL, FALSE); + + GtkAccelKey * key = gtk_accel_group_find(group, find_closure, closure); + /* Again, not much we can do except complain loudly. */ + g_return_val_if_fail(key != NULL, FALSE); - return FALSE; + return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } /** -- cgit v1.2.3 From b0099f8f5ce53544a225033274ffd692e9edf4e6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 12:44:03 -0500 Subject: Checking the validity of the key combo. --- libdbusmenu-gtk/menuitem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index dfd83b0..ea1b77f 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -175,6 +175,7 @@ gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); + g_return_val_if_fail(gtk_accelerator_valid(key, modifier), FALSE); GPtrArray * array = g_ptr_array_new(); -- cgit v1.2.3 From b29f86be192fda821b7245b6159fa1aefc623a40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 13:10:18 -0500 Subject: Adding in a new gtester test suite. --- .bzrignore | 3 +++ tests/Makefile.am | 32 ++++++++++++++++++++++- tests/test-gtk-objects.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 tests/test-gtk-objects.c diff --git a/.bzrignore b/.bzrignore index 37f2bb8..02b481f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -71,3 +71,6 @@ libdbusmenu-gtk/DbusmenuGtk-0.2.gir libdbusmenu-gtk/DbusmenuGtk-0.2.tmp.gir libdbusmenu-gtk/DbusmenuGtk-0.2.typelib libdbusmenu-gtk/DbusmenuGtk-0.2.vapi +tests/test-gtk-objects +tests/test-gtk-objects-test +tests/test-gtk-objects.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index cfa1399..6482d09 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,7 @@ TESTS = \ test-glib-properties \ test-glib-proxy \ test-glib-simple-items \ + test-gtk-objects-test \ test-gtk-label \ test-gtk-reorder @@ -20,6 +21,7 @@ check_PROGRAMS = \ test-glib-proxy-client \ test-glib-proxy-server \ test-glib-proxy-proxy \ + test-gtk-objects \ test-gtk-label-client \ test-gtk-label-server \ test-glib-simple-items \ @@ -196,6 +198,33 @@ test_glib_simple_items_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +###################### +# Test GTK Object +###################### + +GTK_OBJECT_XML_REPORT = test-gtk-objects.xml + +test-gtk-objects-test: test-gtk-objects Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task gtester --parameter --verbose --parameter -k --parameter -o --parameter $(GTK_OBJECT_XML_REPORT) --parameter ./test-gtk-objects >> $@ + @chmod +x $@ + +test_gtk_objects_SOURCES = \ + test-gtk-objects.c + +test_gtk_objects_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) \ + $(DBUSMENUGTK_CFLAGS) \ + -Wall -Werror + +test_gtk_objects_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGLIB_LIBS) \ + $(DBUSMENUGTK_LIBS) + ######################### # Test GTK Label ######################### @@ -322,5 +351,6 @@ distclean-local: DISTCLEANFILES = \ $(TESTS) \ - $(OBJECT_XML_REPORT) + $(OBJECT_XML_REPORT) \ + $(GTK_OBJECT_XML_REPORT) diff --git a/tests/test-gtk-objects.c b/tests/test-gtk-objects.c new file mode 100644 index 0000000..561f91e --- /dev/null +++ b/tests/test-gtk-objects.c @@ -0,0 +1,67 @@ +/* +Testing for the various objects just by themselves. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +/* Building the basic menu item, make sure we didn't break + any core GObject stuff */ +static void +test_object_menuitem (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + g_assert(G_IS_OBJECT(item)); + g_assert(DBUSMENU_IS_MENUITEM(item)); + + /* Set up a check to make sure it gets destroyed on unref */ + g_object_add_weak_pointer(G_OBJECT(item), (gpointer *)&item); + g_object_unref(item); + + /* Did it go away? */ + g_assert(item == NULL); + + return; +} + +/* Build the test suite */ +static void +test_gtk_objects_suite (void) +{ + g_test_add_func ("/dbusmenu/gtk/objects/menuitem/base", test_object_menuitem); + return; +} + +gint +main (gint argc, gchar * argv[]) +{ + gtk_init(&argc, &argv); + + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + test_gtk_objects_suite(); + + return g_test_run (); +} -- cgit v1.2.3 From c78d1b4b827e13ee4e498516e14a56571e8a8b5f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 13:29:49 -0500 Subject: Adding a test image --- tests/test-gtk-objects.jpg | Bin 0 -> 14376 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/test-gtk-objects.jpg diff --git a/tests/test-gtk-objects.jpg b/tests/test-gtk-objects.jpg new file mode 100644 index 0000000..478704e Binary files /dev/null and b/tests/test-gtk-objects.jpg differ -- cgit v1.2.3 From ecf64a2f000ee9666a263afe23075d36bf2efe9a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 13:54:12 -0500 Subject: Adding in a test for the pixbuf property --- tests/Makefile.am | 1 + tests/test-gtk-objects.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6482d09..b21c346 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -217,6 +217,7 @@ test_gtk_objects_CFLAGS = \ -I $(srcdir)/.. \ $(DBUSMENUGLIB_CFLAGS) \ $(DBUSMENUGTK_CFLAGS) \ + -DSRCDIR="\"$(srcdir)\"" \ -Wall -Werror test_gtk_objects_LDADD = \ diff --git a/tests/test-gtk-objects.c b/tests/test-gtk-objects.c index 561f91e..c9f9c4c 100644 --- a/tests/test-gtk-objects.c +++ b/tests/test-gtk-objects.c @@ -22,6 +22,8 @@ with this program. If not, see . #include #include +#define TEST_IMAGE SRCDIR "/" "test-gtk-objects.jpg" + /* Building the basic menu item, make sure we didn't break any core GObject stuff */ static void @@ -45,11 +47,49 @@ test_object_menuitem (void) return; } +/* Setting and getting a pixbuf */ +static void +test_object_prop_pixbuf (void) +{ + const gchar * prop_name = "image-test"; + + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + g_assert(G_IS_OBJECT(item)); + g_assert(DBUSMENU_IS_MENUITEM(item)); + + /* Load our image */ + GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(TEST_IMAGE, NULL); + g_assert(pixbuf != NULL); + + /* Set the property */ + gboolean success = dbusmenu_menuitem_property_set_image(item, prop_name, pixbuf); + g_assert(success); + g_object_unref(pixbuf); + + /* Check to see if it's set */ + const GValue * val = dbusmenu_menuitem_property_get_value(item, prop_name); + g_assert(val != NULL); + + /* Get the pixbuf back! */ + GdkPixbuf * newpixbuf = dbusmenu_menuitem_property_get_image(item, prop_name); + g_assert(newpixbuf != NULL); + g_object_unref(newpixbuf); + + g_object_unref(item); + + return; +} + /* Build the test suite */ static void test_gtk_objects_suite (void) { g_test_add_func ("/dbusmenu/gtk/objects/menuitem/base", test_object_menuitem); + g_test_add_func ("/dbusmenu/gtk/objects/menuitem/prop_pixbuf", test_object_prop_pixbuf); return; } -- cgit v1.2.3 From 13fd7c6e7182b3142c6951098dcd2172c9ddf4ca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 14:09:09 -0500 Subject: Add a test to set the shortcut on a menuitem --- tests/test-gtk-objects.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test-gtk-objects.c b/tests/test-gtk-objects.c index c9f9c4c..92f2469 100644 --- a/tests/test-gtk-objects.c +++ b/tests/test-gtk-objects.c @@ -21,6 +21,7 @@ with this program. If not, see . #include #include +#include #define TEST_IMAGE SRCDIR "/" "test-gtk-objects.jpg" @@ -84,12 +85,41 @@ test_object_prop_pixbuf (void) return; } +/* Setting and getting a shortcut */ +static void +test_object_prop_shortcut (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + g_assert(G_IS_OBJECT(item)); + g_assert(DBUSMENU_IS_MENUITEM(item)); + + guint key = GDK_c; + GdkModifierType modifier = GDK_CONTROL_MASK; + + /* Set a shortcut */ + gboolean success = dbusmenu_menuitem_property_set_shortcut(item, key, modifier); + g_assert(success); + + /* Check for value */ + const GValue * val = dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SHORTCUT); + g_assert(val != NULL); + + g_object_unref(item); + + return; +} + /* Build the test suite */ static void test_gtk_objects_suite (void) { g_test_add_func ("/dbusmenu/gtk/objects/menuitem/base", test_object_menuitem); g_test_add_func ("/dbusmenu/gtk/objects/menuitem/prop_pixbuf", test_object_prop_pixbuf); + g_test_add_func ("/dbusmenu/gtk/objects/menuitem/prop_shortcut", test_object_prop_shortcut); return; } -- cgit v1.2.3 From 01b4ed50a28d5e340462b5371802006260519a11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 14:20:34 -0500 Subject: Putting more sensible names in the gtester output --- tests/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index b21c346..d608860 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -86,7 +86,7 @@ OBJECT_XML_REPORT = test-glib-objects.xml test-glib-objects-test: test-glib-objects Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) --task gtester --parameter --verbose --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@ + @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@ @chmod +x $@ test_glib_objects_SOURCES = \ @@ -207,7 +207,7 @@ GTK_OBJECT_XML_REPORT = test-gtk-objects.xml test-gtk-objects-test: test-gtk-objects Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) --task gtester --parameter --verbose --parameter -k --parameter -o --parameter $(GTK_OBJECT_XML_REPORT) --parameter ./test-gtk-objects >> $@ + @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(GTK_OBJECT_XML_REPORT) --parameter ./test-gtk-objects >> $@ @chmod +x $@ test_gtk_objects_SOURCES = \ -- cgit v1.2.3 From 4ead60b99de627e29d0aae213c622ba10ef72069 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 14:20:52 -0500 Subject: initing the value array properly --- libdbusmenu-gtk/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index ea1b77f..a4818ca 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -198,7 +198,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, g_ptr_array_add(wrapper, array); GValue value = {0}; - g_value_init(&value, G_TYPE_BOXED); + g_value_init(&value, G_TYPE_PTR_ARRAY); g_value_set_boxed(&value, wrapper); dbusmenu_menuitem_property_set_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, &value); -- cgit v1.2.3 From 16b5a01c2cb8c4d8ce6216f984c4a06f6aa14c3a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 14:50:16 -0500 Subject: Fleshing out getting the shortcut --- libdbusmenu-gtk/menuitem.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index a4818ca..f56e9e5 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -268,7 +268,58 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifier) { + *key = 0; + *modifier = 0; + g_return_if_fail(DBUSMENU_IS_MENUITEM(menuitem)); + const GValue * wrapper = dbusmenu_menuitem_property_get_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT); + if (wrapper == NULL) { + return; + } + + g_return_if_fail(G_VALUE_HOLDS_BOXED(wrapper)); + + GPtrArray * wrapperarray = (GPtrArray *)g_value_get_boxed(wrapper); + if (wrapperarray->len == 0) { + return; + } + + if (wrapperarray->len != 1) { + g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); + } + + GPtrArray * entryarray = g_ptr_array_index(wrapperarray, 0); + if (entryarray->len == 0) { + /* Seems a little odd, but really, we're saying that it isn't a + shortcut, so I'm comfortable with exiting silently. */ + return; + } + + /* Parse through modifiers */ + int i; + for (i = 0; i < entryarray->len - 1; i++) { + if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + *modifier |= GDK_CONTROL_MASK; + continue; + } + if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + *modifier |= GDK_MOD1_MASK; + continue; + } + if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + *modifier |= GDK_SHIFT_MASK; + continue; + } + if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + *modifier |= GDK_SUPER_MASK; + continue; + } + } + + GdkModifierType tempmod; + + gtk_accelerator_parse(g_ptr_array_index(entryarray, entryarray->len - 1), key, &tempmod); + return; } -- cgit v1.2.3 From ac0a5299c1fe73acb30f34939dfcd6af57c12231 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 14:52:26 -0500 Subject: Testing we can get the modifier back out. --- tests/test-gtk-objects.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test-gtk-objects.c b/tests/test-gtk-objects.c index 92f2469..726f404 100644 --- a/tests/test-gtk-objects.c +++ b/tests/test-gtk-objects.c @@ -108,6 +108,14 @@ test_object_prop_shortcut (void) const GValue * val = dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SHORTCUT); g_assert(val != NULL); + /* Check to see if we love it */ + guint newkey = 0; + GdkModifierType newmodifier = 0; + dbusmenu_menuitem_property_get_shortcut(item, &newkey, &newmodifier); + + g_assert(key == newkey); + g_assert(newmodifier == modifier); + g_object_unref(item); return; -- cgit v1.2.3 From 53e80ec1652a9519a7e546d7055527eb7b5ad2aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 15:00:57 -0500 Subject: Sending the test image along with the other data. --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index d608860..00297bd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -324,6 +324,7 @@ EXTRA_DIST = \ $(examples_DATA) \ run-xvfb.sh \ $(json_DATA) \ + test-gtk-objects.jpg \ dbusmenu-gtk/dbusMenuTest \ dbusmenu-gtk/mago_tests/dbusmenu.xml \ dbusmenu-gtk/mago_tests/dbusmenu.py \ -- cgit v1.2.3 From 2525166d72f421e045b21910aa7df2523135d1c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 15:23:05 -0500 Subject: Switching to an accel label --- libdbusmenu-gtk/genericmenuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 8f40d93..1000c68 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -191,7 +191,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label) update the one that we already have. */ if (labelw == NULL) { /* Build it */ - labelw = GTK_LABEL(gtk_label_new(label)); + labelw = GTK_LABEL(gtk_accel_label_new(label)); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5); gtk_widget_show(GTK_WIDGET(labelw)); -- cgit v1.2.3 From b2be41cd5085e821f5557303592c11a064eef104 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 16:10:54 -0500 Subject: Add two functions for setting and getting the accelerator group. --- libdbusmenu-gtk/client.c | 34 ++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/client.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 3bd0af6..64f6a6d 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -99,6 +99,40 @@ dbusmenu_gtkclient_finalize (GObject *object) return; } +/** + dbusmenu_gtkclient_set_accel_group: + @client: To set the group on + @agroup: The new acceleration group + + Sets the acceleration group for the menu items with accelerators + on this client. +*/ +void +dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * agroup) +{ + g_return_if_fail(DBUSMENU_IS_GTKCLIENT(client)); + g_return_if_fail(GTK_IS_ACCEL_GROUP(agroup)); + + return; +} + +/** + dbusmenu_gtkclient_get_accel_group: + @client: Client to query for an accelerator group + + Gets the accel group for this client. + + Return value: Either a valid group or #NULL on error or + none set. +*/ +GtkAccelGroup * +dbusmenu_gtkclient_get_accel_group (DbusmenuGtkClient * client) +{ + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), NULL); + + return NULL; +} + /* Internal Functions */ static const gchar * data_menuitem = "dbusmenugtk-data-gtkmenuitem"; diff --git a/libdbusmenu-gtk/client.h b/libdbusmenu-gtk/client.h index 7672bf7..a7c96ee 100644 --- a/libdbusmenu-gtk/client.h +++ b/libdbusmenu-gtk/client.h @@ -79,6 +79,9 @@ DbusmenuGtkClient * dbusmenu_gtkclient_new (gchar * dbus_name, gchar * dbus_obje GtkMenuItem * dbusmenu_gtkclient_menuitem_get (DbusmenuGtkClient * client, DbusmenuMenuitem * item); GtkMenu * dbusmenu_gtkclient_menuitem_get_submenu (DbusmenuGtkClient * client, DbusmenuMenuitem * item); +void dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * agroup); +GtkAccelGroup * dbusmenu_gtkclient_get_accel_group (DbusmenuGtkClient * client); + void dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * item, GtkMenuItem * gmi, DbusmenuMenuitem * parent); /** -- cgit v1.2.3 From b426c6e47fbfa4c701a264c765a47b7fba820e8c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 16:15:30 -0500 Subject: Adding a private area on to the client. --- libdbusmenu-gtk/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 64f6a6d..09e7b4e 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -36,6 +36,15 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem.h" #include "genericmenuitem.h" +/* Private */ +typedef struct _DbusmenuGtkClientPrivate DbusmenuGtkClientPrivate; +struct _DbusmenuGtkClientPrivate { + GtkAccelGroup * agroup; +}; + +#define DBUSMENU_GTKCLIENT_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_GTKCLIENT_TYPE, DbusmenuGtkClientPrivate)) + /* Prototypes */ static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass); static void dbusmenu_gtkclient_init (DbusmenuGtkClient *self); @@ -62,6 +71,8 @@ dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + g_type_class_add_private (klass, sizeof (DbusmenuGtkClientPrivate)); + object_class->dispose = dbusmenu_gtkclient_dispose; object_class->finalize = dbusmenu_gtkclient_finalize; @@ -73,6 +84,10 @@ dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass) static void dbusmenu_gtkclient_init (DbusmenuGtkClient *self) { + DbusmenuGtkClientPrivate * priv = DBUSMENU_GTKCLIENT_GET_PRIVATE(self); + + priv->agroup = NULL; + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_DEFAULT, new_item_normal); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_SEPARATOR, new_item_seperator); @@ -85,6 +100,12 @@ dbusmenu_gtkclient_init (DbusmenuGtkClient *self) static void dbusmenu_gtkclient_dispose (GObject *object) { + DbusmenuGtkClientPrivate * priv = DBUSMENU_GTKCLIENT_GET_PRIVATE(object); + + if (priv->agroup != NULL) { + g_object_unref(priv->agroup); + priv->agroup = NULL; + } G_OBJECT_CLASS (dbusmenu_gtkclient_parent_class)->dispose (object); return; -- cgit v1.2.3 From a27e07f2173dea07625df51466563b1caeddb385 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 17:04:37 -0500 Subject: Fleshing out setting and getting the accel group --- libdbusmenu-gtk/client.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 09e7b4e..ca0b668 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -120,6 +120,48 @@ dbusmenu_gtkclient_finalize (GObject *object) return; } +static void +swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { + gpointer * array = (gpointer *)userdata; + DbusmenuGtkClient * client = (DbusmenuGtkClient *)array[0]; + GtkAccelGroup * old_agroup = (GtkAccelGroup *)array[1]; + GtkAccelGroup * new_agroup = (GtkAccelGroup *)array[2]; + + /* If we don't have a shortcut we don't care */ + if (!dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { + return; + } + + guint key = 0; + GdkModifierType modifiers = 0; + + dbusmenu_menuitem_property_get_shortcut(mi, &key, &modifiers); + + if (key == 0) { + return; + } + + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(client, mi); + if (gmi == NULL) { + return; + } + + if (old_agroup != NULL) { + gtk_widget_remove_accelerator(GTK_WIDGET(gmi), old_agroup, key, modifiers); + } + + if (new_agroup != NULL) { + gtk_widget_add_accelerator(GTK_WIDGET(gmi), + "activate", + new_agroup, + key, + modifiers, + GTK_ACCEL_VISIBLE); + } + + return; +} + /** dbusmenu_gtkclient_set_accel_group: @client: To set the group on @@ -134,6 +176,23 @@ dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * g_return_if_fail(DBUSMENU_IS_GTKCLIENT(client)); g_return_if_fail(GTK_IS_ACCEL_GROUP(agroup)); + DbusmenuGtkClientPrivate * priv = DBUSMENU_GTKCLIENT_GET_PRIVATE(client); + + DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(client)); + if (root != NULL) { + gpointer data[3]; + data[0] = client; + data[1] = priv->agroup; + data[2] = agroup; + + dbusmenu_menuitem_foreach(root, swap_agroup, data); + } + + if (priv->agroup != NULL) { + g_object_unref(priv->agroup); + priv->agroup = NULL; + } + return; } @@ -151,7 +210,9 @@ dbusmenu_gtkclient_get_accel_group (DbusmenuGtkClient * client) { g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), NULL); - return NULL; + DbusmenuGtkClientPrivate * priv = DBUSMENU_GTKCLIENT_GET_PRIVATE(client); + + return priv->agroup; } /* Internal Functions */ -- cgit v1.2.3 From be82ae8c060f84b28d4e4c6fb0c4b11062112984 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 17:09:02 -0500 Subject: Restructuring to use a structure to get cleaner type checking. --- libdbusmenu-gtk/client.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index ca0b668..f5d683c 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -120,12 +120,19 @@ dbusmenu_gtkclient_finalize (GObject *object) return; } +/* Structure for passing data to swap_agroup */ +typedef struct _swap_agroup_t swap_agroup_t; +struct _swap_agroup_t { + DbusmenuGtkClient * client; + GtkAccelGroup * old_agroup; + GtkAccelGroup * new_agroup; +}; + +/* Looks at the old version of the accelerator group and + the new one and makes the state proper. */ static void swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { - gpointer * array = (gpointer *)userdata; - DbusmenuGtkClient * client = (DbusmenuGtkClient *)array[0]; - GtkAccelGroup * old_agroup = (GtkAccelGroup *)array[1]; - GtkAccelGroup * new_agroup = (GtkAccelGroup *)array[2]; + swap_agroup_t * data = (swap_agroup_t *)userdata; /* If we don't have a shortcut we don't care */ if (!dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { @@ -141,19 +148,19 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { return; } - GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(client, mi); + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(data->client, mi); if (gmi == NULL) { return; } - if (old_agroup != NULL) { - gtk_widget_remove_accelerator(GTK_WIDGET(gmi), old_agroup, key, modifiers); + if (data->old_agroup != NULL) { + gtk_widget_remove_accelerator(GTK_WIDGET(gmi), data->old_agroup, key, modifiers); } - if (new_agroup != NULL) { + if (data->new_agroup != NULL) { gtk_widget_add_accelerator(GTK_WIDGET(gmi), "activate", - new_agroup, + data->new_agroup, key, modifiers, GTK_ACCEL_VISIBLE); @@ -180,12 +187,12 @@ dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(client)); if (root != NULL) { - gpointer data[3]; - data[0] = client; - data[1] = priv->agroup; - data[2] = agroup; + swap_agroup_t data; + data.client = client; + data.old_agroup = priv->agroup; + data.new_agroup = agroup; - dbusmenu_menuitem_foreach(root, swap_agroup, data); + dbusmenu_menuitem_foreach(root, swap_agroup, &data); } if (priv->agroup != NULL) { @@ -193,6 +200,8 @@ dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * priv->agroup = NULL; } + priv->agroup = agroup; + return; } -- cgit v1.2.3 From 1338ccff53e35cafae1500eb5414514c57af15bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 19:59:13 -0500 Subject: Adding a function to refresh the shortcut of a menuitem. --- libdbusmenu-gtk/client.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index f5d683c..625c4ba 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -169,6 +169,24 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { return; } +/* Refresh the shortcut for an entry */ +static void +refresh_shortcut (DbusmenuGtkClient * client, DbusmenuMenuitem * mi) +{ + g_return_if_fail(DBUSMENU_IS_GTKCLIENT(client)); + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + + DbusmenuGtkClientPrivate * priv = DBUSMENU_GTKCLIENT_GET_PRIVATE(client); + + swap_agroup_t data; + data.client = client; + data.old_agroup = priv->agroup; + data.new_agroup = priv->agroup; + + return swap_agroup(mi, &data); +} + + /** dbusmenu_gtkclient_set_accel_group: @client: To set the group on -- cgit v1.2.3 From 85d700350d533fc1989aa7cb6cfe9e973b4db552 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 20:05:19 -0500 Subject: Connecting up the refresh cycles to property changes and creation. --- libdbusmenu-gtk/client.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 625c4ba..ab7f16c 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -368,6 +368,17 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkMen return; } +/* Special handler for the shortcut changing as we need to have the + client for that one to get the accel group. */ +static void +menu_shortcut_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, DbusmenuGtkClient * client) +{ + if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { + refresh_shortcut(client, mi); + } + return; +} + /* Call back that happens when the DbusmenuMenuitem is destroyed. We're making sure to clean up everything else down the pipe. */ @@ -434,6 +445,7 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* DbusmenuMenuitem signals */ g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_shortcut_change_cb), client); g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(delete_child), client); g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(move_child), client); @@ -448,6 +460,7 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * process_sensitive(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_ENABLED)); process_toggle_type(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)); process_toggle_state(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)); + refresh_shortcut(client, item); /* Oh, we're a child, let's deal with that */ if (parent != NULL) { -- cgit v1.2.3 From d1cf581703855139e5759ed2fd7b3c49157061ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 21:04:19 -0500 Subject: Building a shortcut test --- .bzrignore | 3 ++ tests/Makefile.am | 43 +++++++++++++++++ tests/test-gtk-shortcut-client.c | 75 ++++++++++++++++++++++++++++++ tests/test-gtk-shortcut-server.c | 99 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 tests/test-gtk-shortcut-client.c create mode 100644 tests/test-gtk-shortcut-server.c diff --git a/.bzrignore b/.bzrignore index 02b481f..0f5b495 100644 --- a/.bzrignore +++ b/.bzrignore @@ -74,3 +74,6 @@ libdbusmenu-gtk/DbusmenuGtk-0.2.vapi tests/test-gtk-objects tests/test-gtk-objects-test tests/test-gtk-objects.xml +tests/test-gtk-shortcut +tests/test-gtk-shortcut-client +tests/test-gtk-shortcut-server diff --git a/tests/Makefile.am b/tests/Makefile.am index 00297bd..356146f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,6 +9,7 @@ TESTS = \ test-glib-simple-items \ test-gtk-objects-test \ test-gtk-label \ + test-gtk-shortcut \ test-gtk-reorder check_PROGRAMS = \ @@ -24,6 +25,8 @@ check_PROGRAMS = \ test-gtk-objects \ test-gtk-label-client \ test-gtk-label-server \ + test-gtk-shortcut-client \ + test-gtk-shortcut-server \ test-glib-simple-items \ test-gtk-reorder-server @@ -266,6 +269,46 @@ test_gtk_label_client_LDADD = \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) +######################### +# Test GTK Shortcut +######################### + +test-gtk-shortcut: test-gtk-shortcut-client test-gtk-shortcut-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + +test_gtk_shortcut_server_SOURCES = \ + test-gtk-shortcut-server.c + +test_gtk_shortcut_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_shortcut_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) + +test_gtk_shortcut_client_SOURCES = \ + test-gtk-shortcut-client.c + +test_gtk_shortcut_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_shortcut_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) + ######################### # Test GTK Reorder ######################### diff --git a/tests/test-gtk-shortcut-client.c b/tests/test-gtk-shortcut-client.c new file mode 100644 index 0000000..26e1531 --- /dev/null +++ b/tests/test-gtk-shortcut-client.c @@ -0,0 +1,75 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include +#include + +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; +static guint death_timer = 0; + +static gboolean +timer_func (gpointer data) +{ + passed = TRUE; + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char ** argv) +{ + gtk_init(&argc, &argv); + + g_debug("Building Window"); + GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget * menubar = gtk_menu_bar_new(); + GtkWidget * menuitem = gtk_menu_item_new_with_label("Test"); + + DbusmenuGtkMenu * dmenu = dbusmenu_gtkmenu_new ("glib.label.test", "/org/test"); + DbusmenuGtkClient * dclient = dbusmenu_gtkmenu_get_client(dmenu); + + GtkAccelGroup * agroup = gtk_accel_group_new(); + dbusmenu_gtkclient_set_accel_group(dclient, agroup); + + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(dmenu)); + gtk_widget_show(menuitem); + gtk_menu_bar_append(menubar, menuitem); + gtk_widget_show(menubar); + gtk_container_add(GTK_CONTAINER(window), menubar); + gtk_window_set_title(GTK_WINDOW(window), "libdbusmenu-gtk test"); + gtk_widget_show(window); + + death_timer = g_timeout_add_seconds(10, timer_func, window); + + g_debug("Entering Mainloop"); + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 1; + } +} diff --git a/tests/test-gtk-shortcut-server.c b/tests/test-gtk-shortcut-server.c new file mode 100644 index 0000000..428f558 --- /dev/null +++ b/tests/test-gtk-shortcut-server.c @@ -0,0 +1,99 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +GMainLoop * mainloop = NULL; +DbusmenuServer * server = NULL; + +gboolean +timer_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + return FALSE; +} + +void +build_menu (void) +{ + DbusmenuMenuitem * item; + + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + + item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Control-C"); + dbusmenu_menuitem_property_set_shortcut(item, GDK_c, GDK_CONTROL_MASK); + dbusmenu_menuitem_child_append(root, item); + g_object_unref(item); + + + dbusmenu_server_set_root(server, root); + g_object_unref(root); + + return; +} + +int +main (int argc, char ** argv) +{ + GError * error = NULL; + + g_type_init(); + + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + + server = dbusmenu_server_new("/org/test"); + build_menu(); + + g_timeout_add_seconds(10, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} + -- cgit v1.2.3 From a7940079b8a074529ea504efe3e9a033197ea057 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 21:24:29 -0500 Subject: Switching to a value array from a ptrarray --- libdbusmenu-gtk/menuitem.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index f56e9e5..9a374b0 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -160,6 +160,17 @@ dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, con return dbusmenu_menuitem_property_set_shortcut(menuitem, key, modifier); } +/* Append strings to an g_value_array */ +static void +_g_value_array_append_string (GValueArray * array, const gchar * string) +{ + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, string); + g_value_array_append(array, &value); + return; +} + /** dbusmenu_menuitem_property_set_shortcut: @menuitem: The #DbusmenuMenuitem to set the shortcut on @@ -177,28 +188,31 @@ 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); - GPtrArray * array = g_ptr_array_new(); + GValueArray * array = g_value_array_new(4); /* Four seems like the max we'd need, plus it's still small */ if (modifier & GDK_CONTROL_MASK) { - g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_CONTROL)); + _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_CONTROL); } if (modifier & GDK_MOD1_MASK) { - g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_ALT)); + _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_ALT); } if (modifier & GDK_SHIFT_MASK) { - g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_SHIFT)); + _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_SHIFT); } if (modifier & GDK_SUPER_MASK) { - g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_SUPER)); + _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_SUPER); } - g_ptr_array_add(array, g_strdup(gdk_keyval_name(key))); + _g_value_array_append_string(array, gdk_keyval_name(key)); - GPtrArray * wrapper = g_ptr_array_new(); - g_ptr_array_add(wrapper, array); + GValueArray * wrapper = g_value_array_new(1); + GValue wrap_val = {0}; + g_value_init(&wrap_val, G_TYPE_VALUE_ARRAY); + g_value_set_boxed(&wrap_val, array); + g_value_array_append(wrapper, &wrap_val); GValue value = {0}; - g_value_init(&value, G_TYPE_PTR_ARRAY); + g_value_init(&value, G_TYPE_VALUE_ARRAY); g_value_set_boxed(&value, wrapper); dbusmenu_menuitem_property_set_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, &value); -- cgit v1.2.3 From b31f6418f37bc35dc59162d5878eacb5002e3402 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 22:01:56 -0500 Subject: Block the case where the label is being init'd to NULL --- libdbusmenu-gtk/genericmenuitem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 1000c68..7239864 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -158,6 +158,8 @@ get_hpadding (GtkWidget * widget) static void set_label (GtkMenuItem * menu_item, const gchar * label) { + if (label == NULL) return; + GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); GtkLabel * labelw = NULL; gboolean suppress_update = FALSE; -- cgit v1.2.3 From 2a1ad77c4b91f35b69e42a79b48b2f0cc0f01bfb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 23:48:51 -0500 Subject: Switching get over to a GValueArray too! --- libdbusmenu-gtk/menuitem.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 9a374b0..a448f88 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -292,19 +292,18 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke return; } - g_return_if_fail(G_VALUE_HOLDS_BOXED(wrapper)); - - GPtrArray * wrapperarray = (GPtrArray *)g_value_get_boxed(wrapper); - if (wrapperarray->len == 0) { + GValueArray * wrapperarray = (GValueArray *)g_value_get_boxed(wrapper); + if (wrapperarray->n_values == 0) { return; } - if (wrapperarray->len != 1) { + if (wrapperarray->n_values != 1) { g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); } - GPtrArray * entryarray = g_ptr_array_index(wrapperarray, 0); - if (entryarray->len == 0) { + GValue * ventryarray = g_value_array_get_nth(wrapperarray, 0); + GValueArray * entryarray = (GValueArray *)g_value_get_boxed(ventryarray); + if (entryarray->n_values == 0) { /* Seems a little odd, but really, we're saying that it isn't a shortcut, so I'm comfortable with exiting silently. */ return; @@ -312,20 +311,20 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke /* Parse through modifiers */ int i; - for (i = 0; i < entryarray->len - 1; i++) { - if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + for (i = 0; i < entryarray->n_values - 1; i++) { + if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { *modifier |= GDK_CONTROL_MASK; continue; } - if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { *modifier |= GDK_MOD1_MASK; continue; } - if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { *modifier |= GDK_SHIFT_MASK; continue; } - if (g_strcmp0(g_ptr_array_index(entryarray, i), DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { *modifier |= GDK_SUPER_MASK; continue; } @@ -333,7 +332,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke GdkModifierType tempmod; - gtk_accelerator_parse(g_ptr_array_index(entryarray, entryarray->len - 1), key, &tempmod); + gtk_accelerator_parse(g_value_get_string(g_value_array_get_nth(entryarray, entryarray->n_values - 1)), key, &tempmod); return; } -- cgit v1.2.3 From 02a8c4e2b1eff14575d1cb78fb35b483f1e35ad7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 23:57:38 -0500 Subject: More robust comparison --- tests/run-xvfb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-xvfb.sh b/tests/run-xvfb.sh index 3622dbf..3aa05c1 100644 --- a/tests/run-xvfb.sh +++ b/tests/run-xvfb.sh @@ -1,4 +1,4 @@ -if [ "$DISPLAY" == "" ]; then +if [ "x$DISPLAY" == "x" ]; then Xvfb -ac -noreset -screen 0 800x600x16 -help 2>/dev/null 1>&2 XID=`for id in 101 102 103 104 105 106 107 197 199 211 223 227 293 307 308 309 310 311 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 4703 4721 4723 4729 4733 4751 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 ; do test -e /tmp/.X$id-lock || { echo $id; exit 0; }; done; exit 1` { Xvfb -ac -noreset -screen 0 800x600x16 :$XID -screen 0 800x600x16 -nolisten tcp -auth /dev/null >/dev/null 2>&1 & trap "kill -15 $! " 0 HUP INT QUIT TRAP USR1 PIPE TERM ; } || { echo "Gtk+Tests:ERROR: Failed to start Xvfb environment for X11 target tests."; exit 1; } -- cgit v1.2.3 From 97513daeb03ba302613de3ebbfcf356bc75fa611 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Jun 2010 13:49:05 -0500 Subject: Switch to using the accel map with paths --- libdbusmenu-gtk/client.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index ab7f16c..a9c6657 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -153,17 +153,20 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { return; } - if (data->old_agroup != NULL) { - gtk_widget_remove_accelerator(GTK_WIDGET(gmi), data->old_agroup, key, modifiers); + const gchar * accel_path = gtk_menu_item_get_accel_path(gmi); + + if (accel_path != NULL) { + gtk_accel_map_change_entry(accel_path, key, modifiers, TRUE /* replace */); + } else { + gchar * accel_path = g_strdup_printf("/Generated/%d", dbusmenu_menuitem_get_id(mi)); + gtk_accel_map_add_entry(accel_path, key, modifiers); + gtk_menu_item_set_accel_path(gmi, accel_path); + g_free(accel_path); } - if (data->new_agroup != NULL) { - gtk_widget_add_accelerator(GTK_WIDGET(gmi), - "activate", - data->new_agroup, - key, - modifiers, - GTK_ACCEL_VISIBLE); + GtkMenu * submenu = dbusmenu_gtkclient_menuitem_get_submenu(data->client, mi); + if (submenu != NULL) { + gtk_menu_set_accel_group(submenu, data->new_agroup); } return; -- cgit v1.2.3 From d0bbb5a0985adccf54cf857d4b0f17a8ba803cd2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Jun 2010 13:50:52 -0500 Subject: Setting the accel widget for the accel label. --- libdbusmenu-gtk/genericmenuitem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 7239864..30b072f 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -196,6 +196,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label) labelw = GTK_LABEL(gtk_accel_label_new(label)); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5); + gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item)); gtk_widget_show(GTK_WIDGET(labelw)); /* Check to see if it needs to be in the bin for this -- cgit v1.2.3 From 81f4b7c5e21a23e97bdd267567b40cdbe0d528b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Jun 2010 14:10:22 -0500 Subject: Making the path more unique and using the lower level path set function. --- libdbusmenu-gtk/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index a9c6657..c7d1140 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -158,9 +158,9 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { if (accel_path != NULL) { gtk_accel_map_change_entry(accel_path, key, modifiers, TRUE /* replace */); } else { - gchar * accel_path = g_strdup_printf("/Generated/%d", dbusmenu_menuitem_get_id(mi)); + gchar * accel_path = g_strdup_printf("/Generated/%X/%d", GPOINTER_TO_UINT(data->client), dbusmenu_menuitem_get_id(mi)); gtk_accel_map_add_entry(accel_path, key, modifiers); - gtk_menu_item_set_accel_path(gmi, accel_path); + gtk_widget_set_accel_path(GTK_WIDGET(gmi), accel_path, data->new_agroup); g_free(accel_path); } -- cgit v1.2.3 From fca6f989e2c563ac071322a0f664bdebdcfdf79e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Jun 2010 14:21:44 -0500 Subject: Making sure the accel group gets added to the window --- tests/test-gtk-shortcut-client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-gtk-shortcut-client.c b/tests/test-gtk-shortcut-client.c index 26e1531..003885c 100644 --- a/tests/test-gtk-shortcut-client.c +++ b/tests/test-gtk-shortcut-client.c @@ -57,6 +57,7 @@ main (int argc, char ** argv) gtk_widget_show(menubar); gtk_container_add(GTK_CONTAINER(window), menubar); gtk_window_set_title(GTK_WINDOW(window), "libdbusmenu-gtk test"); + gtk_window_add_accel_group(GTK_WINDOW(window), agroup); gtk_widget_show(window); death_timer = g_timeout_add_seconds(10, timer_func, window); -- cgit v1.2.3 From 607356d413f548b067020bcabed0aa78337066ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Jun 2010 14:42:35 -0500 Subject: Switching to control L just in case --- tests/test-gtk-shortcut-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-gtk-shortcut-server.c b/tests/test-gtk-shortcut-server.c index 428f558..3b703a1 100644 --- a/tests/test-gtk-shortcut-server.c +++ b/tests/test-gtk-shortcut-server.c @@ -49,8 +49,8 @@ build_menu (void) DbusmenuMenuitem * root = dbusmenu_menuitem_new(); item = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Control-C"); - dbusmenu_menuitem_property_set_shortcut(item, GDK_c, GDK_CONTROL_MASK); + dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Control-L"); + dbusmenu_menuitem_property_set_shortcut(item, GDK_l, GDK_CONTROL_MASK); dbusmenu_menuitem_child_append(root, item); g_object_unref(item); -- cgit v1.2.3 From 71817a1eed1c49d358d7cb1c093321ddc91fb258 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Jun 2010 14:47:29 -0500 Subject: Adding a debug message --- libdbusmenu-gtk/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index c7d1140..d45360a 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -143,6 +143,8 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { GdkModifierType modifiers = 0; dbusmenu_menuitem_property_get_shortcut(mi, &key, &modifiers); + + g_debug("Setting shortcut on '%s': %d %X", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL), key, modifiers); if (key == 0) { return; -- cgit v1.2.3 From 16851654b11b15fe43ffb97ce8b4f26a7e2601c6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Jun 2010 14:58:28 -0500 Subject: Wrong name for the property --- libdbusmenu-glib/menuitem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 39d257e..0d79ebb 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -58,7 +58,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" #define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" #define DBUSMENU_MENUITEM_PROP_TOGGLE_STATE "toggle-state" -#define DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY "child-display" +#define DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY "children-display" #define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" #define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" -- cgit v1.2.3 From ce0a5c849081e8d6f54a28f771dce0136a4e4b93 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Sat, 19 Jun 2010 09:32:56 -0400 Subject: support gtk3 version of libdbusmenu-gtk --- configure.ac | 10 ++++++++ libdbusmenu-gtk/Makefile.am | 47 ++++++++++++++++++++++++++++++++----- libdbusmenu-gtk/dbusmenu-gtk3.pc.in | 14 +++++++++++ libdbusmenu-gtk/menu.c | 4 ++-- 4 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 libdbusmenu-gtk/dbusmenu-gtk3.pc.in diff --git a/configure.ac b/configure.ac index 938fe84..ff8dc78 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,7 @@ AC_SUBST(DBUSMENUGLIB_LIBS) ########################### GTK_REQUIRED_VERSION=2.16 +GTK3_REQUIRED_VERSION=2.90 PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION @@ -57,6 +58,14 @@ PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) +PKG_CHECK_MODULES(DBUSMENUGTK3, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) + +AC_SUBST(DBUSMENUGTK3_CFLAGS) +AC_SUBST(DBUSMENUGTK3_LIBS) + ########################### # Dependencies - Testing ########################### @@ -123,6 +132,7 @@ libdbusmenu-glib/Makefile libdbusmenu-glib/dbusmenu-glib.pc libdbusmenu-gtk/Makefile libdbusmenu-gtk/dbusmenu-gtk.pc +libdbusmenu-gtk/dbusmenu-gtk3.pc tools/Makefile tools/testapp/Makefile tests/Makefile diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 2be63b7..4f38b63 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -2,17 +2,21 @@ CLEANFILES = EXTRA_DIST = \ - dbusmenu-gtk.pc.in + dbusmenu-gtk.pc.in \ + dbusmenu-gtk3.pc.in lib_LTLIBRARIES = \ - libdbusmenu-gtk.la + libdbusmenu-gtk.la \ + libdbusmenu-gtk3.la libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/ +libdbusmenu_gtk3includedir=$(includedir)/libdbusmenu3-0.1/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ client.h \ menu.h \ menuitem.h +libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) libdbusmenu_gtk_la_SOURCES = \ client.h \ @@ -23,20 +27,27 @@ libdbusmenu_gtk_la_SOURCES = \ menu.c \ menuitem.h \ menuitem.c +libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) libdbusmenu_gtk_la_LDFLAGS = \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ -no-undefined \ -export-symbols-regex "^[^_].*" +libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) libdbusmenu_gtk_la_CFLAGS = \ $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" +libdbusmenu_gtk3_la_CFLAGS = \ + $(DBUSMENUGTK3_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" libdbusmenu_gtk_la_LIBADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGTK_LIBS) +libdbusmenu_gtk3_la_LIBADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGTK3_LIBS) -pkgconfig_DATA = dbusmenu-gtk.pc +pkgconfig_DATA = dbusmenu-gtk.pc dbusmenu-gtk3.pc pkgconfigdir = $(libdir)/pkgconfig ######################### @@ -64,7 +75,16 @@ DbusmenuGtk_0_2_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk.la DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir +DbusmenuGtk3-0.2.gir: libdbusmenu-gtk3.la +DbusmenuGtk3_0_2_gir_INCLUDES = \ + GObject-2.0 \ + Gtk-3.0 \ + Dbusmenu-Glib-0.2 +DbusmenuGtk3_0_2_gir_CFLAGS = $(DBUSMENUGTK3_CFLAGS) -I$(top_srcdir) +DbusmenuGtk3_0_2_gir_LIBS = libdbusmenu-gtk3.la +DbusmenuGtk3_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) + +INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir DbusmenuGtk3-0.2.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -83,7 +103,7 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = DbusmenuGtk-0.2.vapi +vapi_DATA = DbusmenuGtk-0.2.vapi DbusmenuGtk3-0.2.vapi DbusmenuGtk-0.2.vapi: DbusmenuGtk-0.2.tmp.gir Makefile.am $(VALA_API_GEN) --library=DbusmenuGtk-0.2 \ @@ -94,13 +114,28 @@ DbusmenuGtk-0.2.vapi: DbusmenuGtk-0.2.tmp.gir Makefile.am --vapidir=$(top_builddir)/libdbusmenu-glib \ $< +DbusmenuGtk3-0.2.vapi: DbusmenuGtk3-0.2.tmp.gir Makefile.am + $(VALA_API_GEN) --library=DbusmenuGtk3-0.2 \ + --pkg gdk-pixbuf-3.0 \ + --pkg gtk+-3.0 \ + --pkg atk \ + --pkg Dbusmenu-Glib-0.2 \ + --vapidir=$(top_builddir)/libdbusmenu-glib \ + $< + DbusmenuGtk-0.2.tmp.gir: DbusmenuGtk-0.2.gir $(SED) \ -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ $< > $@ -CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.2.tmp.gir +DbusmenuGtk3-0.2.tmp.gir: DbusmenuGtk3-0.2.gir + $(SED) \ + -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ + -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ + $< > $@ + +CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.2.tmp.gir DbusmenuGtk3-0.2.tmp.gir endif diff --git a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in new file mode 100644 index 0000000..e2c4cc3 --- /dev/null +++ b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libdbusmenu-3.1 +Requires: dbus-glib-1 dbusmenu-glib +Libs: -L${libdir} -ldbusmenu-gtk3 + +Name: libdbusmenu-gtk3 +Description: libdbusmenu-gtk3. +Version: @VERSION@ + diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 4fa546b..3e6f2dd 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -237,7 +237,7 @@ root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint posit GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child); if (mi != NULL) { GtkWidget * item = GTK_WIDGET(mi); - gtk_menu_insert(GTK_MENU(menu), item, dbusmenu_menuitem_get_position_realized(child, root)); + gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, dbusmenu_menuitem_get_position_realized(child, root)); #ifdef MASSIVEDEBUGGING menu_pos_t menu_pos; menu_pos.mi = mi; @@ -299,7 +299,7 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata) GtkWidget * child_widget = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)); if (child_widget != NULL) { - gtk_menu_append(menu, child_widget); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), child_widget); gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position_realized(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client)))); } else { g_warning("Child is realized, but doesn't have a GTK Widget!"); -- cgit v1.2.3 From cfdd33a19758224cb835efa705a410d3d4d0db91 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Mon, 21 Jun 2010 14:37:18 -0500 Subject: Add the accelerators. --- libdbusmenu-gtk/client.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index d45360a..91bc816 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -130,13 +130,13 @@ struct _swap_agroup_t { /* Looks at the old version of the accelerator group and the new one and makes the state proper. */ -static void -swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { - swap_agroup_t * data = (swap_agroup_t *)userdata; +static gboolean +do_swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { + swap_agroup_t * data = (swap_agroup_t *)userdata; /* If we don't have a shortcut we don't care */ if (!dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { - return; + return FALSE; } guint key = 0; @@ -145,14 +145,14 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { dbusmenu_menuitem_property_get_shortcut(mi, &key, &modifiers); g_debug("Setting shortcut on '%s': %d %X", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL), key, modifiers); - + if (key == 0) { - return; + return FALSE; } GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(data->client, mi); if (gmi == NULL) { - return; + return FALSE; } const gchar * accel_path = gtk_menu_item_get_accel_path(gmi); @@ -161,6 +161,7 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { gtk_accel_map_change_entry(accel_path, key, modifiers, TRUE /* replace */); } else { gchar * accel_path = g_strdup_printf("/Generated/%X/%d", GPOINTER_TO_UINT(data->client), dbusmenu_menuitem_get_id(mi)); + gtk_accel_map_add_entry(accel_path, key, modifiers); gtk_widget_set_accel_path(GTK_WIDGET(gmi), accel_path, data->new_agroup); g_free(accel_path); @@ -171,7 +172,14 @@ swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { gtk_menu_set_accel_group(submenu, data->new_agroup); } - return; + return TRUE; +} + +static void +swap_agroup (DbusmenuMenuitem *mi, gpointer userdata) { + do_swap_agroup (mi, userdata); + + return; /* See what I did here, Ted? :) */ } /* Refresh the shortcut for an entry */ @@ -188,7 +196,17 @@ refresh_shortcut (DbusmenuGtkClient * client, DbusmenuMenuitem * mi) data.old_agroup = priv->agroup; data.new_agroup = priv->agroup; - return swap_agroup(mi, &data); + if (do_swap_agroup(mi, &data)) { + guint key; + GdkModifierType mod; + GtkMenuItem *gmi = dbusmenu_gtkclient_menuitem_get (client, mi); + + dbusmenu_menuitem_property_get_shortcut (mi, &key, &mod); + + gtk_widget_add_accelerator (GTK_WIDGET (gmi), "activate", priv->agroup, key, mod, GTK_ACCEL_VISIBLE); + } + + return; } -- cgit v1.2.3 From 778a2283832108d035a7779bef1af3170abd5135 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Tue, 22 Jun 2010 10:37:15 -0500 Subject: Pass args gnome-autogen.sh --- autogen.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index 93174f5..61260e2 100755 --- a/autogen.sh +++ b/autogen.sh @@ -9,5 +9,4 @@ which gnome-autogen.sh || { USE_GNOME2_MACROS=1 \ USE_COMMON_DOC_BUILD=yes \ -gnome-autogen.sh --enable-gtk-doc - +gnome-autogen.sh --enable-gtk-doc $@ -- cgit v1.2.3 From 2872698e6eb9bfab4d56f5d98fd8f9494738a398 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Tue, 22 Jun 2010 11:03:42 -0500 Subject: Fix setting shortcuts from GtkMenuItem --- libdbusmenu-gtk/menuitem.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index a448f88..57cd258 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -246,19 +246,20 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c g_return_val_if_fail(GTK_IS_MENU_ITEM(gmi), FALSE); GClosure * closure = NULL; - GList * clist; + GtkWidget *label = GTK_BIN (gmi)->child; - clist = gtk_widget_list_accel_closures(GTK_WIDGET(gmi)); - if (clist == NULL) { - g_warning("Menuitem does not have any closures."); - return FALSE; - } + if (GTK_IS_ACCEL_LABEL (label)) + { + g_object_get (label, + "accel-closure", &closure, + NULL); + } - closure = (GClosure *)clist->data; - g_list_free(clist); + if (closure == NULL) + return FALSE; GtkAccelGroup * group = gtk_accel_group_from_accel_closure(closure); - + /* Seriously, if this returns NULL something is seriously wrong in GTK. */ g_return_val_if_fail(group != NULL, FALSE); @@ -267,6 +268,9 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c /* Again, not much we can do except complain loudly. */ g_return_val_if_fail(key != NULL, FALSE); + if (!gtk_accelerator_valid (key->accel_key, key->accel_mods)) + return FALSE; + return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } -- cgit v1.2.3 From 49ce6868ccba0928a401e15fe11689ebab711471 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 14:07:28 -0500 Subject: Putting in several GValue checks to ensure we're getting what we thing we're getting. --- libdbusmenu-gtk/menuitem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 57cd258..a250431 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -295,6 +295,9 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (wrapper == NULL) { return; } + if (!G_VALUE_HOLDS_BOXED(wrapper)) { + return; + } GValueArray * wrapperarray = (GValueArray *)g_value_get_boxed(wrapper); if (wrapperarray->n_values == 0) { @@ -306,6 +309,10 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } GValue * ventryarray = g_value_array_get_nth(wrapperarray, 0); + if (!G_VALUE_HOLDS_BOXED(ventryarray)) { + return; + } + GValueArray * entryarray = (GValueArray *)g_value_get_boxed(ventryarray); if (entryarray->n_values == 0) { /* Seems a little odd, but really, we're saying that it isn't a @@ -316,6 +323,10 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke /* Parse through modifiers */ int i; for (i = 0; i < entryarray->n_values - 1; i++) { + if (!G_VALUE_HOLDS_STRING(g_value_array_get_nth(entryarray, i))) { + continue; + } + if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { *modifier |= GDK_CONTROL_MASK; continue; -- cgit v1.2.3 From d9922623de540c7d670c67a96a83722dd6674f31 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 14:15:14 -0500 Subject: Refactoring to make things more clear --- libdbusmenu-gtk/menuitem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index a250431..a201558 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -323,23 +323,25 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke /* Parse through modifiers */ int i; for (i = 0; i < entryarray->n_values - 1; i++) { - if (!G_VALUE_HOLDS_STRING(g_value_array_get_nth(entryarray, i))) { + GValue * value = g_value_array_get_nth(entryarray, i); + + if (!G_VALUE_HOLDS_STRING(value)) { continue; } - if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { *modifier |= GDK_CONTROL_MASK; continue; } - if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { *modifier |= GDK_MOD1_MASK; continue; } - if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { *modifier |= GDK_SHIFT_MASK; continue; } - if (g_strcmp0(g_value_get_string(g_value_array_get_nth(entryarray, i)), DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { *modifier |= GDK_SUPER_MASK; continue; } -- cgit v1.2.3 From a3e3bf18795873dcb8cafbaac758dc93448f49bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 14:19:40 -0500 Subject: Checking the final value as well. --- libdbusmenu-gtk/menuitem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index a201558..e1e1e30 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -349,7 +349,13 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke GdkModifierType tempmod; - gtk_accelerator_parse(g_value_get_string(g_value_array_get_nth(entryarray, entryarray->n_values - 1)), key, &tempmod); + GValue * accelval = g_value_array_get_nth(entryarray, entryarray->n_values - 1); + if (!G_VALUE_HOLDS_STRING(accelval)) { + *modifier = 0; + return; + } + + gtk_accelerator_parse(g_value_get_string(accelval), key, &tempmod); return; } -- cgit v1.2.3 From 2412ce9b02272a0928157b91a15d67b8f1b805a5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 14:37:24 -0500 Subject: Not checking just for boxed, looking inside a bit. --- libdbusmenu-gtk/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index e1e1e30..0eb0758 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -295,7 +295,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (wrapper == NULL) { return; } - if (!G_VALUE_HOLDS_BOXED(wrapper)) { + if (!G_VALUE_HOLDS(wrapper, G_TYPE_VALUE_ARRAY)) { return; } @@ -309,7 +309,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } GValue * ventryarray = g_value_array_get_nth(wrapperarray, 0); - if (!G_VALUE_HOLDS_BOXED(ventryarray)) { + if (!G_VALUE_HOLDS(ventryarray, G_TYPE_VALUE_ARRAY)) { return; } -- cgit v1.2.3 From 5c0f9d84925fc1221f20b8356810c015dbad962c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 14:45:03 -0500 Subject: A couple of warning messages. --- libdbusmenu-gtk/menuitem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 0eb0758..a7aa9d2 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -296,6 +296,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke return; } if (!G_VALUE_HOLDS(wrapper, G_TYPE_VALUE_ARRAY)) { + g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } @@ -310,6 +311,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke GValue * ventryarray = g_value_array_get_nth(wrapperarray, 0); if (!G_VALUE_HOLDS(ventryarray, G_TYPE_VALUE_ARRAY)) { + g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(ventryarray)); return; } -- cgit v1.2.3 From 2a90535dae3ef2d97ff02c2c6325615de0f6ca09 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 16:29:08 -0500 Subject: Cleaning up usage of get_shortcut to only print/set if it sets a key --- libdbusmenu-gtk/client.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 91bc816..c73c90f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -144,12 +144,12 @@ do_swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { dbusmenu_menuitem_property_get_shortcut(mi, &key, &modifiers); - g_debug("Setting shortcut on '%s': %d %X", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL), key, modifiers); - if (key == 0) { return FALSE; } + g_debug("Setting shortcut on '%s': %d %X", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL), key, modifiers); + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(data->client, mi); if (gmi == NULL) { return FALSE; @@ -197,16 +197,18 @@ refresh_shortcut (DbusmenuGtkClient * client, DbusmenuMenuitem * mi) data.new_agroup = priv->agroup; if (do_swap_agroup(mi, &data)) { - guint key; - GdkModifierType mod; - GtkMenuItem *gmi = dbusmenu_gtkclient_menuitem_get (client, mi); + guint key = 0; + GdkModifierType mod = 0; + GtkMenuItem *gmi = dbusmenu_gtkclient_menuitem_get (client, mi); - dbusmenu_menuitem_property_get_shortcut (mi, &key, &mod); + dbusmenu_menuitem_property_get_shortcut (mi, &key, &mod); - gtk_widget_add_accelerator (GTK_WIDGET (gmi), "activate", priv->agroup, key, mod, GTK_ACCEL_VISIBLE); - } + if (key != 0) { + gtk_widget_add_accelerator (GTK_WIDGET (gmi), "activate", priv->agroup, key, mod, GTK_ACCEL_VISIBLE); + } + } - return; + return; } -- cgit v1.2.3 From 0ace7ce970cdffdca66ab7d19c152269f358b730 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 16:37:10 -0500 Subject: Switching around the get function to be GPtrArray-GStrV --- libdbusmenu-gtk/menuitem.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index a7aa9d2..5d41934 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -295,28 +295,28 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (wrapper == NULL) { return; } - if (!G_VALUE_HOLDS(wrapper, G_TYPE_VALUE_ARRAY)) { + if (!G_VALUE_HOLDS(wrapper, G_TYPE_PTR_ARRAY)) { g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } - GValueArray * wrapperarray = (GValueArray *)g_value_get_boxed(wrapper); - if (wrapperarray->n_values == 0) { + GPtrArray * wrapperarray = (GPtrArray *)g_value_get_boxed(wrapper); + if (wrapperarray->len == 0) { return; } - if (wrapperarray->n_values != 1) { + if (wrapperarray->len != 1) { g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); } - GValue * ventryarray = g_value_array_get_nth(wrapperarray, 0); - if (!G_VALUE_HOLDS(ventryarray, G_TYPE_VALUE_ARRAY)) { + GValue * ventryarray = g_ptr_array_index(wrapperarray, 0); + if (!G_VALUE_HOLDS(ventryarray, G_TYPE_STRV)) { g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(ventryarray)); return; } - GValueArray * entryarray = (GValueArray *)g_value_get_boxed(ventryarray); - if (entryarray->n_values == 0) { + gchar ** entryarray = (gchar **)g_value_get_boxed(ventryarray); + if (entryarray == NULL || entryarray[0] == NULL) { /* Seems a little odd, but really, we're saying that it isn't a shortcut, so I'm comfortable with exiting silently. */ return; @@ -324,40 +324,31 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke /* Parse through modifiers */ int i; - for (i = 0; i < entryarray->n_values - 1; i++) { - GValue * value = g_value_array_get_nth(entryarray, i); + for (i = 0; entryarray[i + 1] != NULL; i++) { + gchar * value = entryarray[i]; - if (!G_VALUE_HOLDS_STRING(value)) { - continue; - } - - if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { *modifier |= GDK_CONTROL_MASK; continue; } - if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { *modifier |= GDK_MOD1_MASK; continue; } - if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { *modifier |= GDK_SHIFT_MASK; continue; } - if (g_strcmp0(g_value_get_string(value), DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { *modifier |= GDK_SUPER_MASK; continue; } } GdkModifierType tempmod; - - GValue * accelval = g_value_array_get_nth(entryarray, entryarray->n_values - 1); - if (!G_VALUE_HOLDS_STRING(accelval)) { - *modifier = 0; - return; - } - - gtk_accelerator_parse(g_value_get_string(accelval), key, &tempmod); + gchar * accelval = entryarray[i]; + gtk_accelerator_parse(accelval, key, &tempmod); return; } + -- cgit v1.2.3 From c94eb1cfe25551c528409fdcb9d56446a915ed0f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Jun 2010 16:50:42 -0500 Subject: Lowering our protection a little, but hopefully this'll make it happy. --- libdbusmenu-gtk/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 5d41934..44e78e1 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -295,7 +295,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (wrapper == NULL) { return; } - if (!G_VALUE_HOLDS(wrapper, G_TYPE_PTR_ARRAY)) { + if (!G_VALUE_HOLDS(wrapper, G_TYPE_BOXED)) { g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } @@ -310,7 +310,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } GValue * ventryarray = g_ptr_array_index(wrapperarray, 0); - if (!G_VALUE_HOLDS(ventryarray, G_TYPE_STRV)) { + if (!G_VALUE_HOLDS(ventryarray, G_TYPE_BOXED)) { g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(ventryarray)); return; } -- cgit v1.2.3 From f071a21b449e8ac1d34b593dc788929e175d987f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 09:07:27 -0500 Subject: Building us some custom types. --- libdbusmenu-gtk/menuitem.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 44e78e1..532f478 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -29,6 +29,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem.h" #include #include +#include /** dbusmenu_menuitem_property_set_image: @@ -274,6 +275,27 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } +static const gchar * wrapper_type_name = "wrapper-type"; +static const gchar * string_array_type_name = "string-array-type"; + +static GType wrapper_type = 0; +static GType string_array_type = 0; + +/* Works with dbus to get types for the collections that we're using. + Should be pretty quick if we've done this once already. */ +static void +setup_collections (void) { + if (string_array_type == 0) { + dbus_g_type_get_collection(string_array_type_name, G_TYPE_STRING); + } + + if (wrapper_type == 0) { + dbus_g_type_get_collection(wrapper_type_name, string_array_type); + } + + return; +} + /** dbusmenu_menuitem_property_get_shortcut: @menuitem: The #DbusmenuMenuitem to get the shortcut off @@ -290,6 +312,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke *modifier = 0; g_return_if_fail(DBUSMENU_IS_MENUITEM(menuitem)); + setup_collections(); const GValue * wrapper = dbusmenu_menuitem_property_get_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT); if (wrapper == NULL) { -- cgit v1.2.3 From 63fc1985fdf9ef74830ec27d7ad8c1bb03c54f0c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 09:10:10 -0500 Subject: Using our complex types to start looking at things. --- libdbusmenu-gtk/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 532f478..9154592 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -318,7 +318,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (wrapper == NULL) { return; } - if (!G_VALUE_HOLDS(wrapper, G_TYPE_BOXED)) { + if (!G_VALUE_HOLDS(wrapper, wrapper_type)) { g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } @@ -333,7 +333,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } GValue * ventryarray = g_ptr_array_index(wrapperarray, 0); - if (!G_VALUE_HOLDS(ventryarray, G_TYPE_BOXED)) { + if (!G_VALUE_HOLDS(ventryarray, string_array_type)) { g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(ventryarray)); return; } -- cgit v1.2.3 From 51815a2cd05dd18d649113f2fc76247d7fdf00d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 09:36:57 -0500 Subject: Eh, that's not a rat hole that I want to go down. Realized I'd have to build the types with their vtables to go that way. We'll try using the others. --- libdbusmenu-gtk/menuitem.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 9154592..8874ebe 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -275,27 +275,6 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } -static const gchar * wrapper_type_name = "wrapper-type"; -static const gchar * string_array_type_name = "string-array-type"; - -static GType wrapper_type = 0; -static GType string_array_type = 0; - -/* Works with dbus to get types for the collections that we're using. - Should be pretty quick if we've done this once already. */ -static void -setup_collections (void) { - if (string_array_type == 0) { - dbus_g_type_get_collection(string_array_type_name, G_TYPE_STRING); - } - - if (wrapper_type == 0) { - dbus_g_type_get_collection(wrapper_type_name, string_array_type); - } - - return; -} - /** dbusmenu_menuitem_property_get_shortcut: @menuitem: The #DbusmenuMenuitem to get the shortcut off @@ -312,13 +291,12 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke *modifier = 0; g_return_if_fail(DBUSMENU_IS_MENUITEM(menuitem)); - setup_collections(); const GValue * wrapper = dbusmenu_menuitem_property_get_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT); if (wrapper == NULL) { return; } - if (!G_VALUE_HOLDS(wrapper, wrapper_type)) { + if (!G_VALUE_HOLDS(wrapper, G_TYPE_BOXED)) { g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } @@ -333,7 +311,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } GValue * ventryarray = g_ptr_array_index(wrapperarray, 0); - if (!G_VALUE_HOLDS(ventryarray, string_array_type)) { + if (!G_VALUE_HOLDS(ventryarray, G_TYPE_BOXED)) { g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(ventryarray)); return; } -- cgit v1.2.3 From 4c05e67b833cdd4467eab0a740367536ebfb2c33 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 10:17:44 -0500 Subject: Reworking to use collection iterators. --- libdbusmenu-gtk/menuitem.c | 117 ++++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 48 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 8874ebe..fa94c1e 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -275,6 +275,69 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } +typedef struct _iter_data_t iter_data_t; +struct _iter_data_t { + guint * key; + GdkModifierType * modifier; + const gchar * last_string; +}; + +static void +_string_iterator (const GValue * value, gpointer user_data) +{ + iter_data_t * iter_data = (iter_data_t *)user_data; + + if (!G_VALUE_HOLDS_STRING(value)) { + return; + } + + const gchar * string = g_value_get_string(value); + iter_data->last_string = string; + + if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + *iter_data->modifier |= GDK_CONTROL_MASK; + return; + } + if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + *iter_data->modifier |= GDK_MOD1_MASK; + return; + } + if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + *iter_data->modifier |= GDK_SHIFT_MASK; + return; + } + if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + *iter_data->modifier |= GDK_SUPER_MASK; + return; + } + + return; +} + +static void +_wrapper_iterator (const GValue * value, gpointer user_data) +{ + iter_data_t * iter_data = (iter_data_t *)user_data; + + if (*iter_data->key != 0) { + g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); + return; + } + + if (!dbus_g_type_is_collection(G_VALUE_TYPE(value))) { + g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(value)); + } + + dbus_g_type_collection_value_iterate(value, _string_iterator, iter_data); + + if (iter_data->last_string != NULL) { + GdkModifierType tempmod; + gtk_accelerator_parse(iter_data->last_string, iter_data->key, &tempmod); + } + + return; +} + /** dbusmenu_menuitem_property_get_shortcut: @menuitem: The #DbusmenuMenuitem to get the shortcut off @@ -296,59 +359,17 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (wrapper == NULL) { return; } - if (!G_VALUE_HOLDS(wrapper, G_TYPE_BOXED)) { + if (!dbus_g_type_is_collection(G_VALUE_TYPE(wrapper))) { g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } - GPtrArray * wrapperarray = (GPtrArray *)g_value_get_boxed(wrapper); - if (wrapperarray->len == 0) { - return; - } - - if (wrapperarray->len != 1) { - g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); - } - - GValue * ventryarray = g_ptr_array_index(wrapperarray, 0); - if (!G_VALUE_HOLDS(ventryarray, G_TYPE_BOXED)) { - g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(ventryarray)); - return; - } - - gchar ** entryarray = (gchar **)g_value_get_boxed(ventryarray); - if (entryarray == NULL || entryarray[0] == NULL) { - /* Seems a little odd, but really, we're saying that it isn't a - shortcut, so I'm comfortable with exiting silently. */ - return; - } - - /* Parse through modifiers */ - int i; - for (i = 0; entryarray[i + 1] != NULL; i++) { - gchar * value = entryarray[i]; - - if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { - *modifier |= GDK_CONTROL_MASK; - continue; - } - if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { - *modifier |= GDK_MOD1_MASK; - continue; - } - if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { - *modifier |= GDK_SHIFT_MASK; - continue; - } - if (g_strcmp0(value, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { - *modifier |= GDK_SUPER_MASK; - continue; - } - } + iter_data_t iter_data; + iter_data.key = key; + iter_data.modifier = modifier; + iter_data.last_string = NULL; - GdkModifierType tempmod; - gchar * accelval = entryarray[i]; - gtk_accelerator_parse(accelval, key, &tempmod); + dbus_g_type_collection_value_iterate(wrapper, _wrapper_iterator, &iter_data); return; } -- cgit v1.2.3 From 0591156dc8defd6a816634448d3ab9aa68f92882 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 10:48:43 -0500 Subject: Apparently not a collection internally. --- libdbusmenu-gtk/menuitem.c | 66 +++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index fa94c1e..56dd192 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -279,60 +279,55 @@ typedef struct _iter_data_t iter_data_t; struct _iter_data_t { guint * key; GdkModifierType * modifier; - const gchar * last_string; }; static void -_string_iterator (const GValue * value, gpointer user_data) +_wrapper_iterator (const GValue * value, gpointer user_data) { iter_data_t * iter_data = (iter_data_t *)user_data; - if (!G_VALUE_HOLDS_STRING(value)) { + if (*iter_data->key != 0) { + g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); return; } - const gchar * string = g_value_get_string(value); - iter_data->last_string = string; - - if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { - *iter_data->modifier |= GDK_CONTROL_MASK; - return; - } - if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { - *iter_data->modifier |= GDK_MOD1_MASK; - return; - } - if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { - *iter_data->modifier |= GDK_SHIFT_MASK; + if (!G_VALUE_HOLDS(value, G_TYPE_STRV)) { + g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(value)); return; } - if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { - *iter_data->modifier |= GDK_SUPER_MASK; + + gchar ** stringarray = (gchar **)g_value_get_boxed(value); + if (stringarray == NULL) { return; } - return; -} + const gchar * last_string = NULL; + int i; -static void -_wrapper_iterator (const GValue * value, gpointer user_data) -{ - iter_data_t * iter_data = (iter_data_t *)user_data; - - if (*iter_data->key != 0) { - g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); - return; - } + for (i = 0; stringarray[i] != NULL; i++) { + last_string = stringarray[i]; - if (!dbus_g_type_is_collection(G_VALUE_TYPE(value))) { - g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(value)); + if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + *iter_data->modifier |= GDK_CONTROL_MASK; + continue; + } + if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + *iter_data->modifier |= GDK_MOD1_MASK; + continue; + } + if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + *iter_data->modifier |= GDK_SHIFT_MASK; + continue; + } + if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + *iter_data->modifier |= GDK_SUPER_MASK; + continue; + } } - dbus_g_type_collection_value_iterate(value, _string_iterator, iter_data); - - if (iter_data->last_string != NULL) { + if (last_string != NULL) { GdkModifierType tempmod; - gtk_accelerator_parse(iter_data->last_string, iter_data->key, &tempmod); + gtk_accelerator_parse(last_string, iter_data->key, &tempmod); } return; @@ -367,7 +362,6 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke iter_data_t iter_data; iter_data.key = key; iter_data.modifier = modifier; - iter_data.last_string = NULL; dbus_g_type_collection_value_iterate(wrapper, _wrapper_iterator, &iter_data); -- cgit v1.2.3 From 5bed312e9e03a4fd0f3ef189205bd3eb3f1a43bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 11:15:12 -0500 Subject: Adding comments --- libdbusmenu-gtk/menuitem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 56dd192..adc01f3 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -275,12 +275,16 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } +/* A set of typed data for the interator */ typedef struct _iter_data_t iter_data_t; struct _iter_data_t { guint * key; GdkModifierType * modifier; }; +/* Goes through the wrapper items. In reality we only support one + so it checks to see if a key is set first. But, we could possibly, + support more in the future. */ static void _wrapper_iterator (const GValue * value, gpointer user_data) { -- cgit v1.2.3 From 9c28ec10b2481d4374dd83310d9a894dca01d5c1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 14:32:47 -0500 Subject: Start building structures more like the KDE ones. --- libdbusmenu-gtk/menuitem.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index adc01f3..811ff1f 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -161,17 +161,6 @@ dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, con return dbusmenu_menuitem_property_set_shortcut(menuitem, key, modifier); } -/* Append strings to an g_value_array */ -static void -_g_value_array_append_string (GValueArray * array, const gchar * string) -{ - GValue value = {0}; - g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, string); - g_value_array_append(array, &value); - return; -} - /** dbusmenu_menuitem_property_set_shortcut: @menuitem: The #DbusmenuMenuitem to set the shortcut on @@ -189,31 +178,37 @@ 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); - GValueArray * array = g_value_array_new(4); /* Four seems like the max we'd need, plus it's still small */ + GArray * array = g_array_sized_new(TRUE, TRUE, sizeof(gchar *), 4); /* Four seems like the max we'd need, plus it's still small */ + + const gchar * control_val = DBUSMENU_MENUITEM_SHORTCUT_CONTROL; + const gchar * alt_val = DBUSMENU_MENUITEM_SHORTCUT_ALT; + const gchar * shift_val = DBUSMENU_MENUITEM_SHORTCUT_SHIFT; + const gchar * super_val = DBUSMENU_MENUITEM_SHORTCUT_SUPER; if (modifier & GDK_CONTROL_MASK) { - _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_CONTROL); + g_array_append_val(array, control_val); } if (modifier & GDK_MOD1_MASK) { - _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_ALT); + g_array_append_val(array, alt_val); } if (modifier & GDK_SHIFT_MASK) { - _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_SHIFT); + g_array_append_val(array, shift_val); } if (modifier & GDK_SUPER_MASK) { - _g_value_array_append_string(array, DBUSMENU_MENUITEM_SHORTCUT_SUPER); + g_array_append_val(array, super_val); } - _g_value_array_append_string(array, gdk_keyval_name(key)); + const gchar * keyname = gdk_keyval_name(key); + g_array_append_val(array, keyname); - GValueArray * wrapper = g_value_array_new(1); + GPtrArray * wrapper = g_ptr_array_new(); GValue wrap_val = {0}; - g_value_init(&wrap_val, G_TYPE_VALUE_ARRAY); - g_value_set_boxed(&wrap_val, array); - g_value_array_append(wrapper, &wrap_val); + g_value_init(&wrap_val, G_TYPE_STRV); + g_value_set_boxed(&wrap_val, array->data); + g_ptr_array_add(wrapper, &wrap_val); GValue value = {0}; - g_value_init(&value, G_TYPE_VALUE_ARRAY); + g_value_init(&value, G_TYPE_PTR_ARRAY); g_value_set_boxed(&value, wrapper); dbusmenu_menuitem_property_set_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, &value); -- cgit v1.2.3 From df4949bb3ea62b531bf2a38cc2f37a1f9ead4991 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 14:41:30 -0500 Subject: The joy of specialized collections. --- libdbusmenu-gtk/menuitem.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 811ff1f..3a0f117 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -201,15 +201,22 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, const gchar * keyname = gdk_keyval_name(key); g_array_append_val(array, keyname); - GPtrArray * wrapper = g_ptr_array_new(); - GValue wrap_val = {0}; - g_value_init(&wrap_val, G_TYPE_STRV); - g_value_set_boxed(&wrap_val, array->data); - g_ptr_array_add(wrapper, &wrap_val); - - GValue value = {0}; - g_value_init(&value, G_TYPE_PTR_ARRAY); - g_value_set_boxed(&value, wrapper); + GType type = dbus_g_type_get_collection("GPtrArray", G_TYPE_STRV); + GPtrArray * wrapper = (GPtrArray *)dbus_g_type_specialized_construct(type); + + GValue value = {0,}; + g_value_init(&value, type); + g_value_take_boxed(&value, wrapper); + + DBusGTypeSpecializedAppendContext ctx; + dbus_g_type_specialized_init_append(&value, &ctx); + + GValue strval = {0,}; + g_value_init(&strval, G_TYPE_STRV); + g_value_take_boxed(&strval, array->data); + + dbus_g_type_specialized_collection_append(&ctx, &strval); + dbus_g_type_specialized_collection_end_append(&ctx); dbusmenu_menuitem_property_set_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, &value); -- cgit v1.2.3 From 85a801e7f19b862fd21c0286899d3b87bebcac83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Jun 2010 14:50:26 -0500 Subject: Freeing the array wrapper --- libdbusmenu-gtk/menuitem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 3a0f117..9924546 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -214,6 +214,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GValue strval = {0,}; g_value_init(&strval, G_TYPE_STRV); g_value_take_boxed(&strval, array->data); + g_array_free(array, FALSE); dbus_g_type_specialized_collection_append(&ctx, &strval); dbus_g_type_specialized_collection_end_append(&ctx); -- cgit v1.2.3 From da2663f744d60ab4ffcc0a798448a48266532d3d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Jun 2010 09:20:25 -0500 Subject: 0.3.3 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 938fe84..80c4b8b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.2, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.3, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.2, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.3, [-Wno-portability]) AM_MAINTAINER_MODE @@ -85,7 +85,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=7 +LIBDBUSMENU_REVISION=8 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 62b0fccd725b4e3c7b01e39258fd64dfa1d6064d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 10:54:48 -0500 Subject: Changing from using a transform to getting the contents --- tools/dbusmenu-dumper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 55d631e..68a21d9 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -36,11 +36,10 @@ print_menuitem (DbusmenuMenuitem * item, int depth) GList * properties = dbusmenu_menuitem_properties_list(item); GList * property; for (property = properties; property != NULL; property = g_list_next(property)) { - GValue value = {0}; - g_value_init(&value, G_TYPE_STRING); - g_value_transform(dbusmenu_menuitem_property_get_value(item, (gchar *)property->data), &value); - g_print(",\n%s\"%s\": \"%s\"", space, (gchar *)property->data, g_value_get_string(&value)); - g_value_unset(&value); + const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); + gchar * str = g_strdup_value_contents(value); + g_print(",\n%s\"%s\": %s", space, (gchar *)property->data, str); + g_free(str); } g_list_free(properties); -- cgit v1.2.3 From e7ef77f7498d95f1f752aaca73f2dfdd935a0f44 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:07:31 -0500 Subject: Splitting out the collection printing. --- tools/dbusmenu-dumper.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 68a21d9..38284b1 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -25,8 +25,16 @@ with this program. If not, see . #include #include +#include + static GMainLoop * mainloop = NULL; +static gchar * +collection_dumper (const GValue * value) +{ + return g_strdup(""); +} + static void print_menuitem (DbusmenuMenuitem * item, int depth) { @@ -37,7 +45,12 @@ print_menuitem (DbusmenuMenuitem * item, int depth) GList * property; for (property = properties; property != NULL; property = g_list_next(property)) { const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); - gchar * str = g_strdup_value_contents(value); + gchar * str = NULL; + if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { + str = collection_dumper(value); + } else { + str = g_strdup_value_contents(value); + } g_print(",\n%s\"%s\": %s", space, (gchar *)property->data, str); g_free(str); } -- cgit v1.2.3 From b13fe82d9d489e0c77cd4e8a9e09fce934d40865 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:14:28 -0500 Subject: Giving the depth as well so this can look nice. --- tools/dbusmenu-dumper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 38284b1..5790828 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -30,7 +30,7 @@ with this program. If not, see . static GMainLoop * mainloop = NULL; static gchar * -collection_dumper (const GValue * value) +collection_dumper (const GValue * value, int depth) { return g_strdup(""); } @@ -47,7 +47,7 @@ print_menuitem (DbusmenuMenuitem * item, int depth) const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); gchar * str = NULL; if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { - str = collection_dumper(value); + str = collection_dumper(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2); } else { str = g_strdup_value_contents(value); } -- cgit v1.2.3 From 84e7a884a2f3c6bd480060235478beb50a38841e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:22:07 -0500 Subject: Printing more like we'd want a collection to print. --- tools/dbusmenu-dumper.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 5790828..1bf6e43 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -32,7 +32,19 @@ static GMainLoop * mainloop = NULL; static gchar * collection_dumper (const GValue * value, int depth) { - return g_strdup(""); + gchar * space = g_strnfill(depth, ' '); + GPtrArray * array = g_ptr_array_new_with_free_func(g_free); + + g_ptr_array_add(array, g_strdup("[\n")); + g_ptr_array_add(array, g_strdup_printf("%s\n", space)); + g_ptr_array_add(array, g_strdup_printf("%s]", space)); + + g_free(space); + + gchar * retstr = g_strjoinv(NULL, (gchar **)array->pdata); + g_ptr_array_free(array, TRUE); + + return retstr; } static void @@ -47,7 +59,7 @@ print_menuitem (DbusmenuMenuitem * item, int depth) const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); gchar * str = NULL; if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { - str = collection_dumper(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2); + str = collection_dumper(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2 /*quotes*/ + 2 /*: */); } else { str = g_strdup_value_contents(value); } -- cgit v1.2.3 From a359a31ffc36630c385ac9ebdf06b6f20e8401f6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:36:35 -0500 Subject: Now iterating through the collection and printing those entries out. --- tools/dbusmenu-dumper.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 1bf6e43..724ee25 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -29,15 +29,50 @@ with this program. If not, see . static GMainLoop * mainloop = NULL; +typedef struct _collection_iterator_t collection_iterator_t; +struct _collection_iterator_t { + gchar * space; + GPtrArray * array; + gboolean first; +}; + +static void +collection_iterate (const GValue * value, gpointer user_data) +{ + collection_iterator_t * iter = (collection_iterator_t *)user_data; + + gchar * str = g_strdup_value_contents(value); + gchar * retval = NULL; + + if (iter->first) { + iter->first = FALSE; + retval = g_strdup_printf("\n%s%s", iter->space, str); + } else { + retval = g_strdup_printf(",\n%s%s", iter->space, str); + } + + g_ptr_array_add(iter->array, retval); + g_free(str); + + return; +} + static gchar * collection_dumper (const GValue * value, int depth) { gchar * space = g_strnfill(depth, ' '); GPtrArray * array = g_ptr_array_new_with_free_func(g_free); - g_ptr_array_add(array, g_strdup("[\n")); - g_ptr_array_add(array, g_strdup_printf("%s\n", space)); - g_ptr_array_add(array, g_strdup_printf("%s]", space)); + g_ptr_array_add(array, g_strdup("[")); + + collection_iterator_t iter; + iter.space = space; + iter.array = array; + iter.first = TRUE; + + dbus_g_type_collection_value_iterate(value, collection_iterate, &iter); + + g_ptr_array_add(array, g_strdup_printf("\n%s]", space)); g_free(space); -- cgit v1.2.3 From 84437fefcfda6157063210bbd9677298d62899b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:45:56 -0500 Subject: Handling the printing of strv's as well. --- tools/dbusmenu-dumper.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 724ee25..4ce1374 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -29,6 +29,17 @@ with this program. If not, see . static GMainLoop * mainloop = NULL; +static gchar * +strv_dumper(const GValue * value) +{ + gchar ** strv = (gchar **)g_value_get_boxed(value); + + gchar * joined = g_strjoinv("\", \"", strv); + gchar * retval = g_strdup_printf("[\"%s\"]", joined); + g_free(joined); + return retval; +} + typedef struct _collection_iterator_t collection_iterator_t; struct _collection_iterator_t { gchar * space; @@ -41,7 +52,13 @@ collection_iterate (const GValue * value, gpointer user_data) { collection_iterator_t * iter = (collection_iterator_t *)user_data; - gchar * str = g_strdup_value_contents(value); + gchar * str; + if (G_VALUE_TYPE(value) == G_TYPE_STRV) { + str = strv_dumper(value); + } else { + str = g_strdup_value_contents(value); + } + gchar * retval = NULL; if (iter->first) { -- cgit v1.2.3 From 057503a47f2dff7ea4863ffc1df939556cc1753f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:51:19 -0500 Subject: Abstracting out the choosing of how to dump the value. --- tools/dbusmenu-dumper.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 4ce1374..6af344d 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -29,6 +29,8 @@ with this program. If not, see . static GMainLoop * mainloop = NULL; +static gchar * value2string (const GValue * value, int depth); + static gchar * strv_dumper(const GValue * value) { @@ -45,6 +47,7 @@ struct _collection_iterator_t { gchar * space; GPtrArray * array; gboolean first; + int depth; }; static void @@ -52,13 +55,7 @@ collection_iterate (const GValue * value, gpointer user_data) { collection_iterator_t * iter = (collection_iterator_t *)user_data; - gchar * str; - if (G_VALUE_TYPE(value) == G_TYPE_STRV) { - str = strv_dumper(value); - } else { - str = g_strdup_value_contents(value); - } - + gchar * str = value2string(value, iter->depth); gchar * retval = NULL; if (iter->first) { @@ -86,6 +83,7 @@ collection_dumper (const GValue * value, int depth) iter.space = space; iter.array = array; iter.first = TRUE; + iter.depth = depth + 2; dbus_g_type_collection_value_iterate(value, collection_iterate, &iter); @@ -99,6 +97,22 @@ collection_dumper (const GValue * value, int depth) return retstr; } +static gchar * +value2string (const GValue * value, int depth) +{ + gchar * str = NULL; + + if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { + str = collection_dumper(value, depth); + } else if (G_VALUE_TYPE(value) == G_TYPE_STRV) { + str = strv_dumper(value); + } else { + str = g_strdup_value_contents(value); + } + + return str; +} + static void print_menuitem (DbusmenuMenuitem * item, int depth) { @@ -109,12 +123,7 @@ print_menuitem (DbusmenuMenuitem * item, int depth) GList * property; for (property = properties; property != NULL; property = g_list_next(property)) { const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); - gchar * str = NULL; - if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { - str = collection_dumper(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2 /*quotes*/ + 2 /*: */); - } else { - str = g_strdup_value_contents(value); - } + gchar * str = value2string(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2 /*quotes*/ + 2 /*: */); g_print(",\n%s\"%s\": %s", space, (gchar *)property->data, str); g_free(str); } -- cgit v1.2.3 From aea8d2664195b8d5b6b77817a70c5955f9f32a8c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:55:22 -0500 Subject: Optimizing the one item in the collection case (common for shortcuts) --- tools/dbusmenu-dumper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 6af344d..f0f4ba0 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -90,8 +90,14 @@ collection_dumper (const GValue * value, int depth) g_ptr_array_add(array, g_strdup_printf("\n%s]", space)); g_free(space); - - gchar * retstr = g_strjoinv(NULL, (gchar **)array->pdata); + + gchar * retstr = NULL; + if (array->len == 3) { + retstr = g_strdup_printf("[%s]", ((gchar *)array->pdata[1]) + depth + 1/*for newline*/); + } else { + retstr = g_strjoinv(NULL, (gchar **)array->pdata); + } + g_ptr_array_free(array, TRUE); return retstr; -- cgit v1.2.3 From a2d820e83b57e71a0b1305b52b1aff8162d6930d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 12:55:51 -0500 Subject: Adding an explicit null check. --- tools/dbusmenu-dumper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index f0f4ba0..f2e2bec 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -108,6 +108,10 @@ value2string (const GValue * value, int depth) { gchar * str = NULL; + if (value == NULL) { + return g_strdup("(null)"); + } + if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { str = collection_dumper(value, depth); } else if (G_VALUE_TYPE(value) == G_TYPE_STRV) { -- cgit v1.2.3 From 778e00d98087fc00329b1ddd28dd46df4f297d8f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 12:58:36 -0500 Subject: Ignoring the gtk-doc build files. --- .bzrignore | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/.bzrignore b/.bzrignore index c5aa635..986e540 100644 --- a/.bzrignore +++ b/.bzrignore @@ -80,3 +80,105 @@ tests/test-gtk-shortcut-server tests/test-glib-submenu tests/test-glib-submenu-client tests/test-glib-submenu-server +docs/libdbusmenu-glib/reference/html-build.stamp +docs/libdbusmenu-glib/reference/html.stamp +docs/libdbusmenu-glib/reference/libdbusmenu-glib-decl-list.txt +docs/libdbusmenu-glib/reference/libdbusmenu-glib-decl-list.txt.bak +docs/libdbusmenu-glib/reference/libdbusmenu-glib-decl.txt +docs/libdbusmenu-glib/reference/libdbusmenu-glib-decl.txt.bak +docs/libdbusmenu-glib/reference/libdbusmenu-glib-overrides.txt +docs/libdbusmenu-glib/reference/libdbusmenu-glib-undeclared.txt +docs/libdbusmenu-glib/reference/libdbusmenu-glib-undocumented.txt +docs/libdbusmenu-glib/reference/libdbusmenu-glib-unused.txt +docs/libdbusmenu-glib/reference/libdbusmenu-glib.args +docs/libdbusmenu-glib/reference/libdbusmenu-glib.hierarchy +docs/libdbusmenu-glib/reference/libdbusmenu-glib.interfaces +docs/libdbusmenu-glib/reference/libdbusmenu-glib.prerequisites +docs/libdbusmenu-glib/reference/libdbusmenu-glib.signals +docs/libdbusmenu-glib/reference/scan-build.stamp +docs/libdbusmenu-glib/reference/sgml-build.stamp +docs/libdbusmenu-glib/reference/sgml.stamp +docs/libdbusmenu-glib/reference/tmpl-build.stamp +docs/libdbusmenu-glib/reference/tmpl.stamp +docs/libdbusmenu-glib/reference/version.xml +docs/libdbusmenu-glib/reference/xml +docs/libdbusmenu-glib/reference/html/annotation-glossary.html +docs/libdbusmenu-glib/reference/html/api-index-full.html +docs/libdbusmenu-glib/reference/html/ch01.html +docs/libdbusmenu-glib/reference/html/home.png +docs/libdbusmenu-glib/reference/html/index.html +docs/libdbusmenu-glib/reference/html/index.sgml +docs/libdbusmenu-glib/reference/html/left.png +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib-DbusmenuClient.html +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib-DbusmenuClientMenuitem.html +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib-DbusmenuMenuitem.html +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib-DbusmenuMenuitemProxy.html +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib-DbusmenuServer.html +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib.devhelp +docs/libdbusmenu-glib/reference/html/libdbusmenu-glib.devhelp2 +docs/libdbusmenu-glib/reference/html/object-tree.html +docs/libdbusmenu-glib/reference/html/right.png +docs/libdbusmenu-glib/reference/html/style.css +docs/libdbusmenu-glib/reference/html/up.png +docs/libdbusmenu-glib/reference/tmpl/client-menuitem.sgml +docs/libdbusmenu-glib/reference/tmpl/client-menuitem.sgml.bak +docs/libdbusmenu-glib/reference/tmpl/client.sgml +docs/libdbusmenu-glib/reference/tmpl/client.sgml.bak +docs/libdbusmenu-glib/reference/tmpl/libdbusmenu-glib-unused.sgml +docs/libdbusmenu-glib/reference/tmpl/menuitem-proxy.sgml +docs/libdbusmenu-glib/reference/tmpl/menuitem-proxy.sgml.bak +docs/libdbusmenu-glib/reference/tmpl/menuitem.sgml +docs/libdbusmenu-glib/reference/tmpl/menuitem.sgml.bak +docs/libdbusmenu-glib/reference/tmpl/server.sgml +docs/libdbusmenu-glib/reference/tmpl/server.sgml.bak +docs/libdbusmenu-gtk/reference/html-build.stamp +docs/libdbusmenu-gtk/reference/html.stamp +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-decl-list.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-decl-list.txt.bak +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-decl.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-decl.txt.bak +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-overrides.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-sections.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-undeclared.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-undocumented.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-unused.txt +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk.args +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk.hierarchy +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk.interfaces +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk.prerequisites +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk.signals +docs/libdbusmenu-gtk/reference/libdbusmenu-gtk.types +docs/libdbusmenu-gtk/reference/scan-build.stamp +docs/libdbusmenu-gtk/reference/sgml-build.stamp +docs/libdbusmenu-gtk/reference/sgml.stamp +docs/libdbusmenu-gtk/reference/tmpl-build.stamp +docs/libdbusmenu-gtk/reference/tmpl.stamp +docs/libdbusmenu-gtk/reference/version.xml +docs/libdbusmenu-gtk/reference/xml +docs/libdbusmenu-gtk/reference/html/Genericmenuitem.html +docs/libdbusmenu-gtk/reference/html/api-index-full.html +docs/libdbusmenu-gtk/reference/html/ch01.html +docs/libdbusmenu-gtk/reference/html/home.png +docs/libdbusmenu-gtk/reference/html/index.html +docs/libdbusmenu-gtk/reference/html/index.sgml +docs/libdbusmenu-gtk/reference/html/left.png +docs/libdbusmenu-gtk/reference/html/libdbusmenu-gtk-DbusmenuGtkClient.html +docs/libdbusmenu-gtk/reference/html/libdbusmenu-gtk-DbusmenuGtkMenu.html +docs/libdbusmenu-gtk/reference/html/libdbusmenu-gtk-menuitem.html +docs/libdbusmenu-gtk/reference/html/libdbusmenu-gtk.devhelp +docs/libdbusmenu-gtk/reference/html/libdbusmenu-gtk.devhelp2 +docs/libdbusmenu-gtk/reference/html/object-tree.html +docs/libdbusmenu-gtk/reference/html/right.png +docs/libdbusmenu-gtk/reference/html/style.css +docs/libdbusmenu-gtk/reference/html/up.png +docs/libdbusmenu-gtk/reference/tmpl/client.sgml +docs/libdbusmenu-gtk/reference/tmpl/client.sgml.bak +docs/libdbusmenu-gtk/reference/tmpl/genericmenuitem.sgml +docs/libdbusmenu-gtk/reference/tmpl/genericmenuitem.sgml.bak +docs/libdbusmenu-gtk/reference/tmpl/libdbusmenu-gtk-unused.sgml +docs/libdbusmenu-gtk/reference/tmpl/menu.sgml +docs/libdbusmenu-gtk/reference/tmpl/menu.sgml.bak +docs/libdbusmenu-gtk/reference/tmpl/menuitem.sgml +docs/libdbusmenu-gtk/reference/tmpl/menuitem.sgml.bak +gtk-doc.make +m4/gtk-doc.m4 -- cgit v1.2.3 From 1fa54c12337433455d7e9a65779b28d927050896 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 13:44:43 -0500 Subject: Adding a new testing lib. --- .bzrignore | 3 +++ configure.ac | 1 + tests/Makefile.am | 34 ++++++++++++++++++++++++++++++++++ tests/dbusmenu-jsonloader.pc.in | 14 ++++++++++++++ tests/json-loader.c | 4 ++++ tests/json-loader.h | 3 +++ 6 files changed, 59 insertions(+) create mode 100644 tests/dbusmenu-jsonloader.pc.in create mode 100644 tests/json-loader.c create mode 100644 tests/json-loader.h diff --git a/.bzrignore b/.bzrignore index 986e540..1079d9f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -182,3 +182,6 @@ docs/libdbusmenu-gtk/reference/tmpl/menuitem.sgml docs/libdbusmenu-gtk/reference/tmpl/menuitem.sgml.bak gtk-doc.make m4/gtk-doc.m4 +tests/dbusmenu-jsonloader.pc +tests/libdbusmenu-jsonloader.la +tests/libdbusmenu_jsonloader_la-json-loader.lo diff --git a/configure.ac b/configure.ac index 80c4b8b..fdc76fb 100644 --- a/configure.ac +++ b/configure.ac @@ -126,6 +126,7 @@ libdbusmenu-gtk/dbusmenu-gtk.pc tools/Makefile tools/testapp/Makefile tests/Makefile +tests/dbusmenu-jsonloader.pc docs/Makefile docs/libdbusmenu-glib/Makefile docs/libdbusmenu-glib/reference/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index 66f286b..18ca628 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -35,6 +35,40 @@ check_PROGRAMS = \ XVFB_RUN=". $(srcdir)/run-xvfb.sh" +###################### +# JSON Loader lib +###################### + +lib_LTLIBRARIES = libdbusmenu-jsonloader.la + +libdbusmenu_jsonloaderincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-jsonloader/ + +libdbusmenu_jsonloaderinclude_HEADERS = \ + json-loader.h + +libdbusmenu_jsonloader_la_SOURCES = \ + json-loader.h \ + json-loader.c + +libdbusmenu_jsonloader_la_LDFLAGS = \ + -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ + -no-undefined \ + -export-symbols-regex "^[^_].*" + +libdbusmenu_jsonloader_la_CFLAGS = \ + $(DBUSMENUGLIB_CFLAGS) \ + -I $(srcdir)/.. \ + -Wall \ + -Werror \ + -DG_DISABLE_DEPRECATED \ + -DG_LOG_DOMAIN="\"LIBDBUSMENU-JSONLOADER\"" + +libdbusmenu_jsonloader_la_LIBADD = \ + $(DBUSMENUGLIB_LIBS) + +pkgconfig_DATA = dbusmenu-jsonloader.pc +pkgconfigdir = $(libdir)/pkgconfig + ###################### # Test GLib server ###################### diff --git a/tests/dbusmenu-jsonloader.pc.in b/tests/dbusmenu-jsonloader.pc.in new file mode 100644 index 0000000..6c48f7e --- /dev/null +++ b/tests/dbusmenu-jsonloader.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libdbusmenu-0.1 +Requires: dbus-glib-1 +Libs: -L${libdir} -ldbusmenu-jsonloader + +Name: libdbusmenu-jsonloader +Description: A small library to load JSON descriptions of menus. Mostly for testing. +Version: @VERSION@ + diff --git a/tests/json-loader.c b/tests/json-loader.c new file mode 100644 index 0000000..c2483b6 --- /dev/null +++ b/tests/json-loader.c @@ -0,0 +1,4 @@ + +#include "json-loader.h" + +const gchar * myval = "FIVE"; diff --git a/tests/json-loader.h b/tests/json-loader.h new file mode 100644 index 0000000..b776c15 --- /dev/null +++ b/tests/json-loader.h @@ -0,0 +1,3 @@ + +#include + -- cgit v1.2.3 From 71e4cc90f10559cc675d696c773ed2825a2cbb8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 15:55:53 -0500 Subject: Moving the JSON parsing code into the library. --- tests/Makefile.am | 2 + tests/json-loader.c | 87 ++++++++++++++++++++++++++++++++++++++++++- tests/json-loader.h | 8 ++++ tests/test-gtk-label-server.c | 71 +---------------------------------- 4 files changed, 98 insertions(+), 70 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 18ca628..d9468bb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -57,6 +57,7 @@ libdbusmenu_jsonloader_la_LDFLAGS = \ libdbusmenu_jsonloader_la_CFLAGS = \ $(DBUSMENUGLIB_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ -I $(srcdir)/.. \ -Wall \ -Werror \ @@ -320,6 +321,7 @@ test_gtk_label_server_CFLAGS = \ test_gtk_label_server_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + libdbusmenu-jsonloader.la \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) diff --git a/tests/json-loader.c b/tests/json-loader.c index c2483b6..7cfc7d9 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -1,4 +1,89 @@ #include "json-loader.h" -const gchar * myval = "FIVE"; +static void +set_props (DbusmenuMenuitem * mi, JsonObject * node) +{ + if (node == NULL) return; + + GList * members = NULL; + for (members = json_object_get_members(node); members != NULL; members = g_list_next(members)) { + const gchar * member = members->data; + + if (!g_strcmp0(member, "id")) { continue; } + if (!g_strcmp0(member, "submenu")) { continue; } + + JsonNode * lnode = json_object_get_member(node, member); + if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } + + GValue value = {0}; + json_node_get_value(lnode, &value); + dbusmenu_menuitem_property_set_value(mi, member, &value); + g_value_unset(&value); + } + + return; +} + +DbusmenuMenuitem * +dbusmenu_json_build_from_node (const JsonNode * cnode) +{ + JsonNode * node = (JsonNode *)cnode; /* To match the jsonglib API :( */ + + if (node == NULL) return NULL; + if (JSON_NODE_TYPE(node) != JSON_NODE_OBJECT) return NULL; + + JsonObject * layout = json_node_get_object(node); + + DbusmenuMenuitem * local = NULL; + if (json_object_has_member(layout, "id")) { + JsonNode * node = json_object_get_member(layout, "id"); + g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE, NULL); + local = dbusmenu_menuitem_new_with_id(json_node_get_int(node)); + } else { + local = dbusmenu_menuitem_new(); + } + + set_props(local, layout); + + if (json_object_has_member(layout, "submenu")) { + JsonNode * node = json_object_get_member(layout, "submenu"); + g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_ARRAY, local); + JsonArray * array = json_node_get_array(node); + guint count; + for (count = 0; count < json_array_get_length(array); count++) { + DbusmenuMenuitem * child = dbusmenu_json_build_from_node(json_array_get_element(array, count)); + if (child != NULL) { + dbusmenu_menuitem_child_append(local, child); + } + } + } + + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ + return local; +} + +DbusmenuMenuitem * +dbusmenu_json_build_from_file (const gchar * filename) +{ + JsonParser * parser = json_parser_new(); + + GError * error = NULL; + if (!json_parser_load_from_file(parser, filename, &error)) { + g_warning("Failed parsing file %s because: %s", filename, error->message); + g_error_free(error); + return NULL; + } + + JsonNode * root_node = json_parser_get_root(parser); + if (JSON_NODE_TYPE(root_node) != JSON_NODE_OBJECT) { + g_warning("Root node is not an object, fail. It's an: %s", json_node_type_name(root_node)); + return NULL; + } + + DbusmenuMenuitem * mi = dbusmenu_json_build_from_node(root_node); + + g_object_unref(parser); + + return mi; +} diff --git a/tests/json-loader.h b/tests/json-loader.h index b776c15..67e1c8b 100644 --- a/tests/json-loader.h +++ b/tests/json-loader.h @@ -1,3 +1,11 @@ +#ifndef __DBUSMENU_JSON_LOADER_H__ +#define __DBUSMENU_JSON_LOADER_H__ + #include +#include + +DbusmenuMenuitem * dbusmenu_json_build_from_node (const JsonNode * node); +DbusmenuMenuitem * dbusmenu_json_build_from_file (const gchar * filename); +#endif /* __DBUSMENU_JSON_LOADER_H__ */ diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 32d7a43..32572fc 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -30,74 +30,7 @@ with this program. If not, see . #include #include - -static void -menuitem_click(DbusmenuMenuitem * mi, guint32 time, gpointer user_data) -{ - g_debug("Clicked on: %d @ %d", dbusmenu_menuitem_get_id(mi), time); - return; -} - -static void -set_props (DbusmenuMenuitem * mi, JsonObject * node) -{ - if (node == NULL) return; - - GList * members = NULL; - for (members = json_object_get_members(node); members != NULL; members = g_list_next(members)) { - const gchar * member = members->data; - - if (!g_strcmp0(member, "id")) { continue; } - if (!g_strcmp0(member, "submenu")) { continue; } - - JsonNode * lnode = json_object_get_member(node, member); - if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } - - GValue value = {0}; - json_node_get_value(lnode, &value); - dbusmenu_menuitem_property_set_value(mi, member, &value); - g_value_unset(&value); - } - - return; -} - -static DbusmenuMenuitem * -layout2menuitem (JsonNode * inlayout) -{ - if (inlayout == NULL) return NULL; - if (JSON_NODE_TYPE(inlayout) != JSON_NODE_OBJECT) return NULL; - - JsonObject * layout = json_node_get_object(inlayout); - - DbusmenuMenuitem * local = NULL; - if (json_object_has_member(layout, "id")) { - JsonNode * node = json_object_get_member(layout, "id"); - g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE, NULL); - local = dbusmenu_menuitem_new_with_id(json_node_get_int(node)); - } else { - local = dbusmenu_menuitem_new(); - } - g_signal_connect(G_OBJECT(local), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_click), NULL); - - set_props(local, layout); - - if (json_object_has_member(layout, "submenu")) { - JsonNode * node = json_object_get_member(layout, "submenu"); - g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_ARRAY, local); - JsonArray * array = json_node_get_array(node); - guint count; - for (count = 0; count < json_array_get_length(array); count++) { - DbusmenuMenuitem * child = layout2menuitem(json_array_get_element(array, count)); - if (child != NULL) { - dbusmenu_menuitem_child_append(local, child); - } - } - } - - /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ - return local; -} +#include "json-loader.h" static JsonArray * root_array = NULL; static guint layouton = 0; @@ -114,7 +47,7 @@ timer_func (gpointer data) } g_debug("Updating to Layout %d", layouton); - dbusmenu_server_set_root(server, layout2menuitem(json_array_get_element(root_array, layouton))); + dbusmenu_server_set_root(server, dbusmenu_json_build_from_node(json_array_get_element(root_array, layouton))); layouton++; return TRUE; -- cgit v1.2.3 From fa34ff87fd2149d3c89c8b00fa8713b8a2b9b563 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 16:04:48 -0500 Subject: Make the code behave exactly the same but with a function call in the middle. --- tests/json-loader.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index 7cfc7d9..94df096 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -1,6 +1,13 @@ #include "json-loader.h" +static GValue * +handle_complex_types (JsonNode * node) +{ + + return NULL; +} + static void set_props (DbusmenuMenuitem * mi, JsonObject * node) { @@ -14,12 +21,20 @@ set_props (DbusmenuMenuitem * mi, JsonObject * node) if (!g_strcmp0(member, "submenu")) { continue; } JsonNode * lnode = json_object_get_member(node, member); - if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } - GValue value = {0}; - json_node_get_value(lnode, &value); - dbusmenu_menuitem_property_set_value(mi, member, &value); - g_value_unset(&value); + if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { + GValue * value = handle_complex_types(lnode); + if (value != NULL) { + dbusmenu_menuitem_property_set_value(mi, member, value); + g_value_unset(value); + g_free(value); + } + } else { + GValue value = {0}; + json_node_get_value(lnode, &value); + dbusmenu_menuitem_property_set_value(mi, member, &value); + g_value_unset(&value); + } } return; -- cgit v1.2.3 From fc3ce0689dacf6396b54e51f6a9c9f24a4a6b9ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 16:19:57 -0500 Subject: Restructuring a bit to make it more reusable. --- tests/json-loader.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index 94df096..aa11aa5 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -2,9 +2,27 @@ #include "json-loader.h" static GValue * -handle_complex_types (JsonNode * node) +node2value (JsonNode * node) { + if (node == NULL) { + return NULL; + } + + GValue * value = g_new0(GValue, 1); + if (JSON_NODE_TYPE(node) == JSON_NODE_VALUE) { + json_node_get_value(node, value); + return value; + } + + if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) { + } + + + if (JSON_NODE_TYPE(node) == JSON_NODE_OBJECT) { + } + + g_free(value); return NULL; } @@ -21,19 +39,12 @@ set_props (DbusmenuMenuitem * mi, JsonObject * node) if (!g_strcmp0(member, "submenu")) { continue; } JsonNode * lnode = json_object_get_member(node, member); + GValue * value = node2value(lnode); - if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { - GValue * value = handle_complex_types(lnode); - if (value != NULL) { - dbusmenu_menuitem_property_set_value(mi, member, value); - g_value_unset(value); - g_free(value); - } - } else { - GValue value = {0}; - json_node_get_value(lnode, &value); - dbusmenu_menuitem_property_set_value(mi, member, &value); - g_value_unset(&value); + if (value != NULL) { + dbusmenu_menuitem_property_set_value(mi, member, value); + g_value_unset(value); + g_free(value); } } -- cgit v1.2.3 From ced63228a6304953dcd57adcc6a1f9906b2d9a21 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 16:54:33 -0500 Subject: Turn objects into hashmaps --- tests/json-loader.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index aa11aa5..e61a49a 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -1,5 +1,6 @@ #include "json-loader.h" +#include static GValue * node2value (JsonNode * node) @@ -17,9 +18,39 @@ node2value (JsonNode * node) if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) { } - if (JSON_NODE_TYPE(node) == JSON_NODE_OBJECT) { + JsonObject * obj = json_node_get_object(node); + + GType type = dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE); + GHashTable * hash = (GHashTable *)dbus_g_type_specialized_construct(type); + + g_value_init(value, type); + g_value_take_boxed(value, hash); + + DBusGTypeSpecializedAppendContext ctx; + dbus_g_type_specialized_init_append(value, &ctx); + + GList * members = NULL; + for (members = json_object_get_members(obj); members != NULL; members = g_list_next(members)) { + const gchar * member = members->data; + + JsonNode * lnode = json_object_get_member(obj, member); + GValue * value = node2value(lnode); + + if (value != NULL) { + GValue name = {0}; + g_value_init(&name, G_TYPE_STRING); + g_value_set_static_string(&name, member); + + dbus_g_type_specialized_map_append(&ctx, &name, value); + + g_value_unset(&name); + g_value_unset(value); + g_free(value); + } + } + } g_free(value); -- cgit v1.2.3 From ccd36f867b28766e708ab7bdbbd36fda3492a8fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 17:13:32 -0500 Subject: Okay, so now we're handling the complex areas. --- tests/json-loader.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index e61a49a..64e1579 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -17,6 +17,31 @@ node2value (JsonNode * node) } if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) { + JsonArray * array = json_node_get_array(node); + JsonNode * first = json_array_get_element(array, 0); + + if (JSON_NODE_TYPE(first) == JSON_NODE_VALUE) { + + } else { + GValue * subvalue = node2value(first); + GType type = dbus_g_type_get_collection("GPtrArray", G_VALUE_TYPE(subvalue)); + gpointer * wrapper = dbus_g_type_specialized_construct(type); + + g_value_init(value, type); + g_value_take_boxed(value, wrapper); + + DBusGTypeSpecializedAppendContext ctx; + dbus_g_type_specialized_init_append(value, &ctx); + + dbus_g_type_specialized_collection_append(&ctx, subvalue); + int i; + for (i = 1; i < json_array_get_length(array); i++) { + GValue * subvalue = node2value(node); + dbus_g_type_specialized_collection_append(&ctx, subvalue); + } + + dbus_g_type_specialized_collection_end_append(&ctx); + } } if (JSON_NODE_TYPE(node) == JSON_NODE_OBJECT) { @@ -50,11 +75,9 @@ node2value (JsonNode * node) g_free(value); } } - } - g_free(value); - return NULL; + return value; } static void -- cgit v1.2.3 From 3bbd2b821624a706b94a297e7e46442b9ae227f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 17:24:09 -0500 Subject: Okay, now we've got some basic code for dealing with value arrays --- tests/json-loader.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/json-loader.c b/tests/json-loader.c index 64e1579..2f27bff 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -21,6 +21,37 @@ node2value (JsonNode * node) JsonNode * first = json_array_get_element(array, 0); if (JSON_NODE_TYPE(first) == JSON_NODE_VALUE) { + GValue subvalue = {0}; + json_node_get_value(first, &subvalue); + + if (G_VALUE_TYPE(&subvalue) == G_TYPE_STRING) { + GArray * garray = g_array_sized_new(TRUE, TRUE, sizeof(gchar *), json_array_get_length(array)); + g_value_init(value, G_TYPE_STRV); + g_value_take_boxed(value, garray->data); + + int i; + for (i = 0; i < json_array_get_length(array); i++) { + const gchar * str = json_node_get_string(first); + gchar * dupstr = g_strdup(str); + g_array_append_val(garray, dupstr); + } + + g_array_free(garray, FALSE); + } else { + GValueArray * varray = g_value_array_new(json_array_get_length(array)); + g_value_init(value, G_TYPE_VALUE_ARRAY); + g_value_take_boxed(value, varray); + + g_value_array_append(varray, &subvalue); + g_value_unset(&subvalue); + + int i; + for (i = 1; i < json_array_get_length(array); i++) { + json_node_get_value(first, &subvalue); + g_value_array_append(varray, &subvalue); + g_value_unset(&subvalue); + } + } } else { GValue * subvalue = node2value(first); -- cgit v1.2.3 From d2ee9c6261888a13b0f531ad119b008b130daee9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 17:56:45 -0500 Subject: Adding a JSON loader --- .bzrignore | 1 + tests/Makefile.am | 42 +++++++++++++++++++++++++++++++-- tests/test-json-server.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 tests/test-json-server.c diff --git a/.bzrignore b/.bzrignore index 1079d9f..d2d26a9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -185,3 +185,4 @@ m4/gtk-doc.m4 tests/dbusmenu-jsonloader.pc tests/libdbusmenu-jsonloader.la tests/libdbusmenu_jsonloader_la-json-loader.lo +tests/test-json-server diff --git a/tests/Makefile.am b/tests/Makefile.am index d9468bb..9b95db0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,8 +7,9 @@ TESTS = \ test-glib-properties \ test-glib-proxy \ test-glib-simple-items \ - test-gtk-objects-test \ test-glib-submenu \ + test-json \ + test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ test-gtk-reorder @@ -31,7 +32,8 @@ check_PROGRAMS = \ test-gtk-shortcut-client \ test-gtk-shortcut-server \ test-glib-simple-items \ - test-gtk-reorder-server + test-gtk-reorder-server \ + test-json-server XVFB_RUN=". $(srcdir)/run-xvfb.sh" @@ -118,6 +120,42 @@ test_glib_layout_client_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +###################### +# Test JSON +###################### + +test-json: test-json-client test-json-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --task ./test-json-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + +test_json_server_SOURCES = \ + test-json-server.c + +test_json_server_CFLAGS = \ + -I $(srcdir)/.. \ + -I $(srcdir) \ + $(DBUSMENUGLIB_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + -Wall -Werror + +test_json_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + libdbusmenu-jsonloader.la \ + $(DBUSMENUTESTS_LIBS) \ + $(DBUSMENUGLIB_LIBS) + +test_json_client_SOURCES = \ + test-json-client.c + +test_json_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_json_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + ###################### # Test Glib Submenu ###################### diff --git a/tests/test-json-server.c b/tests/test-json-server.c new file mode 100644 index 0000000..b2b8341 --- /dev/null +++ b/tests/test-json-server.c @@ -0,0 +1,60 @@ +#include + +#include +#include +#include +#include + +#include +#include + +#include "json-loader.h" + +static GMainLoop * mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char ** argv) +{ + GError * error = NULL; + + g_type_init(); + + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + + DbusmenuServer * server = dbusmenu_server_new("/org/test"); + + DbusmenuMenuitem * root = dbusmenu_json_build_from_file(argv[1]); + g_return_val_if_fail(root!=NULL, 1); + + dbusmenu_server_set_root(server, root); + + g_timeout_add(3000, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} -- cgit v1.2.3 From 3db8acbd9f0fa9bed9519b8db6ab31e08f430962 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 17:59:52 -0500 Subject: Adding in a test json file. --- tests/Makefile.am | 3 +- tests/test-json-01.json | 4023 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 4025 insertions(+), 1 deletion(-) create mode 100644 tests/test-json-01.json diff --git a/tests/Makefile.am b/tests/Makefile.am index 9b95db0..2dd2cf7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -495,7 +495,8 @@ EXTRA_DIST = \ dbusmenu-gtk/mago_tests/data/several_submenus_recursive.json \ dbusmenu-gtk/mago_tests/data/several_submenus_utf8.json \ dbusmenu-gtk/mago_tests/data/static.json \ - dbusmenu-gtk/mago_tests/data/test-gtk-label.json + dbusmenu-gtk/mago_tests/data/test-gtk-label.json \ + test-json-01.json CLEANFILES = \ dbusmenu-gtk/mago_tests/dbusmenu.pyc diff --git a/tests/test-json-01.json b/tests/test-json-01.json new file mode 100644 index 0000000..a46a6d6 --- /dev/null +++ b/tests/test-json-01.json @@ -0,0 +1,4023 @@ +{ + "id": 0, + "children-display": "submenu", + "submenu": [ + { + "id": 5, + "enabled": TRUE, + "label": "File", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 6, + "shortcut": [["Control", "q"]], + "enabled": TRUE, + "label": "Quit", + "visible": TRUE + }, + { + "id": 7, + "shortcut": [["Control", "Shift", "w"]], + "enabled": TRUE, + "label": "Close all", + "visible": TRUE + }, + { + "id": 8, + "shortcut": [["Control", "w"]], + "enabled": TRUE, + "label": "Close", + "visible": TRUE + }, + { + "id": 9, + "type": "separator" + }, + { + "id": 10, + "enabled": TRUE, + "label": "Send by Email...", + "visible": TRUE + }, + { + "id": 11, + "shortcut": [["Control", "p"]], + "enabled": TRUE, + "label": "Print...", + "visible": TRUE + }, + { + "id": 12, + "enabled": TRUE, + "label": "Page Setup", + "visible": TRUE + }, + { + "id": 13, + "type": "separator" + }, + { + "id": 14, + "enabled": TRUE, + "label": "Revert", + "visible": TRUE + }, + { + "id": 15, + "enabled": TRUE, + "label": "Save as Template...", + "visible": TRUE + }, + { + "id": 16, + "enabled": TRUE, + "label": "Save a Copy...", + "visible": TRUE + }, + { + "id": 17, + "shortcut": [["Control", "Shift", "s"]], + "enabled": TRUE, + "label": "Save As...", + "visible": TRUE + }, + { + "id": 18, + "shortcut": [["Control", "s"]], + "enabled": TRUE, + "label": "Save", + "visible": TRUE + }, + { + "id": 19, + "type": "separator" + }, + { + "id": 20, + "enabled": TRUE, + "label": "Open Recent", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 21, + "enabled": TRUE, + "label": "Document History", + "visible": TRUE + }, + { + "id": 22, + "type": "separator" + }, + { + "id": 23, + "shortcut": [["Control", "2"]], + "enabled": TRUE, + "label": "giggity.jpg", + "visible": TRUE + }, + { + "id": 24, + "shortcut": [["Control", "1"]], + "enabled": TRUE, + "label": "Icon Height.svg", + "visible": TRUE + } + ] + }, + { + "id": 25, + "enabled": TRUE, + "label": "Open Location...", + "visible": TRUE + }, + { + "id": 26, + "shortcut": [["Control", "Alt", "o"]], + "enabled": TRUE, + "label": "Open as Layers...", + "visible": TRUE + }, + { + "id": 27, + "shortcut": [["Control", "o"]], + "enabled": TRUE, + "label": "Open...", + "visible": TRUE + }, + { + "id": 28, + "enabled": TRUE, + "label": "Create", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 29, + "enabled": TRUE, + "label": "Web Page Themes", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 30, + "enabled": TRUE, + "label": "Classic.Gimp.Org", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 31, + "enabled": TRUE, + "label": "Tube Sub-Sub-Button Label...", + "visible": TRUE + }, + { + "id": 32, + "enabled": TRUE, + "label": "Tube Sub-Button Label...", + "visible": TRUE + }, + { + "id": 33, + "enabled": TRUE, + "label": "Tube Button Label...", + "visible": TRUE + }, + { + "id": 34, + "enabled": TRUE, + "label": "Small Header...", + "visible": TRUE + }, + { + "id": 35, + "enabled": TRUE, + "label": "General Tube Labels...", + "visible": TRUE + }, + { + "id": 36, + "enabled": TRUE, + "label": "Big Header...", + "visible": TRUE + } + ] + }, + { + "id": 37, + "enabled": TRUE, + "label": "Beveled Pattern", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 38, + "enabled": TRUE, + "label": "Hrule...", + "visible": TRUE + }, + { + "id": 39, + "enabled": TRUE, + "label": "Heading...", + "visible": TRUE + }, + { + "id": 40, + "enabled": TRUE, + "label": "Button...", + "visible": TRUE + }, + { + "id": 41, + "enabled": TRUE, + "label": "Bullet...", + "visible": TRUE + }, + { + "id": 42, + "enabled": TRUE, + "label": "Arrow...", + "visible": TRUE + } + ] + }, + { + "id": 43, + "enabled": TRUE, + "label": "Alien Glow", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 44, + "enabled": TRUE, + "label": "Hrule...", + "visible": TRUE + }, + { + "id": 45, + "enabled": TRUE, + "label": "Button...", + "visible": TRUE + }, + { + "id": 46, + "enabled": TRUE, + "label": "Bullet...", + "visible": TRUE + }, + { + "id": 47, + "enabled": TRUE, + "label": "Arrow...", + "visible": TRUE + } + ] + } + ] + }, + { + "id": 48, + "enabled": TRUE, + "label": "Patterns", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 49, + "enabled": TRUE, + "label": "Truchet...", + "visible": TRUE + }, + { + "id": 50, + "enabled": TRUE, + "label": "Swirly...", + "visible": TRUE + }, + { + "id": 51, + "enabled": TRUE, + "label": "Swirl-Tile...", + "visible": TRUE + }, + { + "id": 52, + "enabled": TRUE, + "label": "Render Map...", + "visible": TRUE + }, + { + "id": 53, + "enabled": TRUE, + "label": "Land...", + "visible": TRUE + }, + { + "id": 54, + "enabled": TRUE, + "label": "Flatland...", + "visible": TRUE + }, + { + "id": 55, + "enabled": TRUE, + "label": "Camouflage...", + "visible": TRUE + }, + { + "id": 56, + "enabled": TRUE, + "label": "3D Truchet...", + "visible": TRUE + } + ] + }, + { + "id": 57, + "enabled": TRUE, + "label": "Logos", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 58, + "enabled": TRUE, + "label": "Web Title Header...", + "visible": TRUE + }, + { + "id": 59, + "enabled": TRUE, + "label": "Textured...", + "visible": TRUE + }, + { + "id": 60, + "enabled": TRUE, + "label": "Text Circle...", + "visible": TRUE + }, + { + "id": 61, + "enabled": TRUE, + "label": "Starscape...", + "visible": TRUE + }, + { + "id": 62, + "enabled": TRUE, + "label": "Speed Text...", + "visible": TRUE + }, + { + "id": 63, + "enabled": TRUE, + "label": "SOTA Chrome...", + "visible": TRUE + }, + { + "id": 64, + "enabled": TRUE, + "label": "Particle Trace...", + "visible": TRUE + }, + { + "id": 65, + "enabled": TRUE, + "label": "Newsprint Text...", + "visible": TRUE + }, + { + "id": 66, + "enabled": TRUE, + "label": "Neon...", + "visible": TRUE + }, + { + "id": 67, + "enabled": TRUE, + "label": "Imigre-26...", + "visible": TRUE + }, + { + "id": 68, + "enabled": TRUE, + "label": "Gradient Bevel...", + "visible": TRUE + }, + { + "id": 69, + "enabled": TRUE, + "label": "Glowing Hot...", + "visible": TRUE + }, + { + "id": 70, + "enabled": TRUE, + "label": "Glossy...", + "visible": TRUE + }, + { + "id": 71, + "enabled": TRUE, + "label": "Frosty...", + "visible": TRUE + }, + { + "id": 72, + "enabled": TRUE, + "label": "Crystal...", + "visible": TRUE + }, + { + "id": 73, + "enabled": TRUE, + "label": "Cool Metal...", + "visible": TRUE + }, + { + "id": 74, + "enabled": TRUE, + "label": "Comic Book...", + "visible": TRUE + }, + { + "id": 75, + "enabled": TRUE, + "label": "Chrome...", + "visible": TRUE + }, + { + "id": 76, + "enabled": TRUE, + "label": "Chip Away...", + "visible": TRUE + }, + { + "id": 77, + "enabled": TRUE, + "label": "Chalk...", + "visible": TRUE + }, + { + "id": 78, + "enabled": TRUE, + "label": "Carved...", + "visible": TRUE + }, + { + "id": 79, + "enabled": TRUE, + "label": "Bovination...", + "visible": TRUE + }, + { + "id": 80, + "enabled": TRUE, + "label": "Blended...", + "visible": TRUE + }, + { + "id": 81, + "enabled": TRUE, + "label": "Basic I...", + "visible": TRUE + }, + { + "id": 82, + "enabled": TRUE, + "label": "Basic II...", + "visible": TRUE + }, + { + "id": 83, + "enabled": TRUE, + "label": "Alien Neon...", + "visible": TRUE + }, + { + "id": 84, + "enabled": TRUE, + "label": "Alien Glow...", + "visible": TRUE + }, + { + "id": 85, + "enabled": TRUE, + "label": "3D Outline...", + "visible": TRUE + } + ] + }, + { + "id": 86, + "enabled": TRUE, + "label": "Buttons", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 87, + "enabled": TRUE, + "label": "Simple Beveled Button...", + "visible": TRUE + }, + { + "id": 88, + "enabled": TRUE, + "label": "Round Button...", + "visible": TRUE + } + ] + }, + { + "id": 89, + "type": "separator" + }, + { + "id": 90, + "enabled": TRUE, + "label": "xscanimage", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 91, + "enabled": FALSE, + "label": "Device dialog...", + "visible": TRUE + } + ] + }, + { + "id": 92, + "enabled": TRUE, + "label": "Screenshot...", + "visible": TRUE + }, + { + "id": 93, + "shortcut": [["Control", "Shift", "v"]], + "enabled": TRUE, + "label": "From Clipboard", + "visible": TRUE + } + ] + }, + { + "id": 94, + "shortcut": [["Control", "n"]], + "enabled": TRUE, + "label": "New...", + "visible": TRUE + } + ] + }, + { + "id": 95, + "enabled": TRUE, + "label": "Edit", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 96, + "enabled": TRUE, + "label": "Units", + "visible": TRUE + }, + { + "id": 97, + "enabled": TRUE, + "label": "Modules", + "visible": TRUE + }, + { + "id": 98, + "enabled": TRUE, + "label": "Keyboard Shortcuts", + "visible": TRUE + }, + { + "id": 99, + "enabled": TRUE, + "label": "Preferences", + "visible": TRUE + }, + { + "id": 100, + "type": "separator" + }, + { + "id": 101, + "enabled": FALSE, + "label": "Stroke Path...", + "visible": TRUE + }, + { + "id": 102, + "enabled": FALSE, + "label": "Stroke Selection...", + "visible": TRUE + }, + { + "id": 103, + "shortcut": [["Control", "semicolon"]], + "enabled": TRUE, + "label": "Fill with Pattern", + "visible": TRUE + }, + { + "id": 104, + "shortcut": [["Control", "period"]], + "enabled": TRUE, + "label": "Fill with BG Color", + "visible": TRUE + }, + { + "id": 105, + "shortcut": [["Control", "comma"]], + "enabled": TRUE, + "label": "Fill with FG Color", + "visible": TRUE + }, + { + "id": 106, + "shortcut": [["Delete"]], + "enabled": TRUE, + "label": "Clear", + "visible": TRUE + }, + { + "id": 107, + "type": "separator" + }, + { + "id": 108, + "enabled": TRUE, + "label": "Buffer", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 109, + "enabled": TRUE, + "label": "Paste Named...", + "visible": TRUE + }, + { + "id": 110, + "enabled": TRUE, + "label": "Copy Visible Named...", + "visible": TRUE + }, + { + "id": 111, + "enabled": TRUE, + "label": "Copy Named...", + "visible": TRUE + }, + { + "id": 112, + "enabled": TRUE, + "label": "Cut Named...", + "visible": TRUE + } + ] + }, + { + "id": 113, + "enabled": TRUE, + "label": "Paste as", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 114, + "enabled": TRUE, + "label": "New Pattern...", + "visible": TRUE + }, + { + "id": 115, + "enabled": TRUE, + "label": "New Brush...", + "visible": TRUE + }, + { + "id": 116, + "enabled": TRUE, + "label": "New Layer", + "visible": TRUE + }, + { + "id": 117, + "shortcut": [["Control", "Shift", "v"]], + "enabled": TRUE, + "label": "New Image", + "visible": TRUE + } + ] + }, + { + "id": 118, + "enabled": TRUE, + "label": "Paste Into", + "visible": TRUE + }, + { + "id": 119, + "shortcut": [["Control", "v"]], + "enabled": TRUE, + "label": "Paste", + "visible": TRUE + }, + { + "id": 120, + "shortcut": [["Control", "Shift", "c"]], + "enabled": TRUE, + "label": "Copy Visible", + "visible": TRUE + }, + { + "id": 121, + "shortcut": [["Control", "c"]], + "enabled": TRUE, + "label": "Copy", + "visible": TRUE + }, + { + "id": 122, + "shortcut": [["Control", "x"]], + "enabled": TRUE, + "label": "Cut", + "visible": TRUE + }, + { + "id": 123, + "type": "separator" + }, + { + "id": 124, + "enabled": TRUE, + "label": "Undo History", + "visible": TRUE + }, + { + "id": 3, + "enabled": FALSE, + "label": "_Fade...", + "visible": TRUE + }, + { + "id": 2, + "shortcut": [["Control", "y"]], + "enabled": FALSE, + "label": "_Redo", + "visible": TRUE + }, + { + "id": 1, + "shortcut": [["Control", "z"]], + "enabled": FALSE, + "label": "_Undo", + "visible": TRUE + } + ] + }, + { + "id": 125, + "enabled": TRUE, + "label": "Select", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 126, + "enabled": FALSE, + "label": "To Path", + "visible": TRUE + }, + { + "id": 127, + "enabled": TRUE, + "label": "Save to Channel", + "visible": TRUE + }, + { + "id": 128, + "shortcut": [["Shift", "q"]], + "enabled": TRUE, + "toggle-state": 0, + "label": "Toggle Quick Mask", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 129, + "type": "separator" + }, + { + "id": 130, + "enabled": TRUE, + "label": "Distort...", + "visible": TRUE + }, + { + "id": 131, + "enabled": FALSE, + "label": "Border...", + "visible": TRUE + }, + { + "id": 132, + "enabled": FALSE, + "label": "Grow...", + "visible": TRUE + }, + { + "id": 133, + "enabled": FALSE, + "label": "Shrink...", + "visible": TRUE + }, + { + "id": 134, + "enabled": FALSE, + "label": "Sharpen", + "visible": TRUE + }, + { + "id": 135, + "enabled": FALSE, + "label": "Feather...", + "visible": TRUE + }, + { + "id": 136, + "type": "separator" + }, + { + "id": 137, + "enabled": TRUE, + "label": "Selection Editor", + "visible": TRUE + }, + { + "id": 138, + "shortcut": [["Shift", "v"]], + "enabled": FALSE, + "label": "From Path", + "visible": TRUE + }, + { + "id": 139, + "shortcut": [["Shift", "o"]], + "enabled": TRUE, + "label": "By Color", + "visible": TRUE + }, + { + "id": 140, + "shortcut": [["Control", "Shift", "l"]], + "enabled": FALSE, + "label": "Float", + "visible": TRUE + }, + { + "id": 141, + "shortcut": [["Control", "i"]], + "enabled": TRUE, + "label": "Invert", + "visible": TRUE + }, + { + "id": 142, + "shortcut": [["Control", "Shift", "a"]], + "enabled": FALSE, + "label": "None", + "visible": TRUE + }, + { + "id": 143, + "shortcut": [["Control", "a"]], + "enabled": TRUE, + "label": "All", + "visible": TRUE + } + ] + }, + { + "id": 144, + "enabled": TRUE, + "label": "View", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 145, + "enabled": TRUE, + "toggle-state": 1, + "label": "Show Statusbar", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 146, + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Scrollbars", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 147, + "shortcut": [["Control", "Shift", "r"]], + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Rulers", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 148, + "enabled": TRUE, + "toggle-state": 1, + "label": "Show Menubar", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 149, + "enabled": TRUE, + "label": "Padding Color", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 150, + "enabled": TRUE, + "label": "As in Preferences", + "visible": TRUE + }, + { + "id": 151, + "type": "separator" + }, + { + "id": 152, + "enabled": TRUE, + "label": "Select Custom Color...", + "visible": TRUE + }, + { + "id": 153, + "enabled": TRUE, + "label": "Dark Check Color", + "visible": TRUE + }, + { + "id": 154, + "enabled": TRUE, + "label": "Light Check Color", + "visible": TRUE + }, + { + "id": 155, + "enabled": TRUE, + "label": "From Theme", + "visible": TRUE + } + ] + }, + { + "id": 156, + "type": "separator" + }, + { + "id": 157, + "enabled": TRUE, + "toggle-state": 0, + "label": "Snap to Active Path", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 158, + "enabled": TRUE, + "toggle-state": 0, + "label": "Snap to Canvas Edges", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 159, + "enabled": TRUE, + "toggle-state": 0, + "label": "Snap to Grid", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 160, + "enabled": TRUE, + "toggle-state": 1, + "label": "Snap to Guides", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 161, + "type": "separator" + }, + { + "id": 162, + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Sample Points", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 163, + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Grid", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 164, + "shortcut": [["Control", "Shift", "t"]], + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Guides", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 165, + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Layer Boundary", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 166, + "shortcut": [["Control", "t"]], + "enabled": TRUE, + "toggle-state": 0, + "label": "Show Selection", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 167, + "type": "separator" + }, + { + "id": 168, + "enabled": TRUE, + "label": "Display Filters...", + "visible": TRUE + }, + { + "id": 169, + "enabled": TRUE, + "label": "Navigation Window", + "visible": TRUE + }, + { + "id": 170, + "type": "separator" + }, + { + "id": 171, + "shortcut": [["F11"]], + "enabled": TRUE, + "toggle-state": 0, + "label": "Fullscreen", + "toggle-type": "checkmark", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 172, + "enabled": TRUE, + "label": "Open Display...", + "visible": TRUE + } + ] + }, + { + "id": 173, + "shortcut": [["Control", "e"]], + "enabled": TRUE, + "label": "Shrink Wrap", + "visible": TRUE + }, + { + "id": 174, + "type": "separator" + }, + { + "id": 175, + "enabled": TRUE, + "label": "_Zoom (67%)", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 176, + "enabled": TRUE, + "toggle-state": 0, + "label": "Othe_r (67%)...", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 177, + "type": "separator" + }, + { + "id": 178, + "enabled": TRUE, + "toggle-state": 0, + "label": "1:16 (6.25%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 179, + "enabled": TRUE, + "toggle-state": 0, + "label": "1:8 (12.5%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 180, + "enabled": TRUE, + "toggle-state": 0, + "label": "1:4 (25%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 181, + "enabled": TRUE, + "toggle-state": 0, + "label": "1:2 (50%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 182, + "shortcut": [["1"]], + "enabled": TRUE, + "toggle-state": 1, + "label": "1:1 (100%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 183, + "enabled": TRUE, + "toggle-state": 0, + "label": "2:1 (200%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 184, + "enabled": TRUE, + "toggle-state": 0, + "label": "4:1 (400%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 185, + "enabled": TRUE, + "toggle-state": 0, + "label": "8:1 (800%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 186, + "enabled": TRUE, + "toggle-state": 0, + "label": "16:1 (1600%)", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 187, + "type": "separator" + }, + { + "id": 188, + "enabled": TRUE, + "label": "Fill Window", + "visible": TRUE + }, + { + "id": 189, + "shortcut": [["Control", "Shift", "e"]], + "enabled": TRUE, + "label": "Fit Image in Window", + "visible": TRUE + }, + { + "id": 190, + "shortcut": [["plus"]], + "enabled": TRUE, + "label": "Zoom In", + "visible": TRUE + }, + { + "id": 191, + "shortcut": [["minus"]], + "enabled": TRUE, + "label": "Zoom Out", + "visible": TRUE + }, + { + "id": 4, + "shortcut": [["grave"]], + "enabled": TRUE, + "label": "Re_vert Zoom (67%)", + "visible": TRUE + } + ] + }, + { + "id": 192, + "enabled": TRUE, + "toggle-state": 1, + "label": "Dot for Dot", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 193, + "enabled": TRUE, + "label": "New View", + "visible": TRUE + } + ] + }, + { + "id": 194, + "enabled": TRUE, + "label": "Image", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 195, + "shortcut": [["Alt", "Return"]], + "enabled": TRUE, + "label": "Image Properties", + "visible": TRUE + }, + { + "id": 196, + "enabled": TRUE, + "label": "Configure Grid...", + "visible": TRUE + }, + { + "id": 197, + "enabled": TRUE, + "label": "Guides", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 198, + "enabled": TRUE, + "label": "Remove all Guides", + "visible": TRUE + }, + { + "id": 199, + "enabled": TRUE, + "label": "New Guides from Selection", + "visible": TRUE + }, + { + "id": 200, + "enabled": TRUE, + "label": "New Guide...", + "visible": TRUE + }, + { + "id": 201, + "enabled": TRUE, + "label": "New Guide (by Percent)...", + "visible": TRUE + } + ] + }, + { + "id": 202, + "type": "separator" + }, + { + "id": 203, + "enabled": TRUE, + "label": "Align Visible Layers...", + "visible": TRUE + }, + { + "id": 204, + "enabled": TRUE, + "label": "Flatten Image", + "visible": TRUE + }, + { + "id": 205, + "shortcut": [["Control", "m"]], + "enabled": TRUE, + "label": "Merge Visible Layers...", + "visible": TRUE + }, + { + "id": 206, + "type": "separator" + }, + { + "id": 207, + "enabled": TRUE, + "label": "Zealous Crop", + "visible": TRUE + }, + { + "id": 208, + "enabled": TRUE, + "label": "Autocrop Image", + "visible": TRUE + }, + { + "id": 209, + "enabled": FALSE, + "label": "Crop to Selection", + "visible": TRUE + }, + { + "id": 210, + "type": "separator" + }, + { + "id": 211, + "enabled": TRUE, + "label": "Scale Image...", + "visible": TRUE + }, + { + "id": 212, + "enabled": TRUE, + "label": "Print Size...", + "visible": TRUE + }, + { + "id": 213, + "enabled": FALSE, + "label": "Fit Canvas to Selection", + "visible": TRUE + }, + { + "id": 214, + "enabled": TRUE, + "label": "Fit Canvas to Layers", + "visible": TRUE + }, + { + "id": 215, + "enabled": TRUE, + "label": "Canvas Size...", + "visible": TRUE + }, + { + "id": 216, + "type": "separator" + }, + { + "id": 217, + "enabled": TRUE, + "label": "Transform", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 218, + "enabled": TRUE, + "label": "Guillotine", + "visible": TRUE + }, + { + "id": 219, + "type": "separator" + }, + { + "id": 220, + "enabled": TRUE, + "label": "Rotate 180\302\260", + "visible": TRUE + }, + { + "id": 221, + "enabled": TRUE, + "label": "Rotate 90\302\260 counter-clockwise", + "visible": TRUE + }, + { + "id": 222, + "enabled": TRUE, + "label": "Rotate 90\302\260 clockwise", + "visible": TRUE + }, + { + "id": 223, + "type": "separator" + }, + { + "id": 224, + "enabled": TRUE, + "label": "Flip Vertically", + "visible": TRUE + }, + { + "id": 225, + "enabled": TRUE, + "label": "Flip Horizontally", + "visible": TRUE + } + ] + }, + { + "id": 226, + "enabled": TRUE, + "label": "Mode", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 227, + "enabled": TRUE, + "label": "Convert to Color Profile...", + "visible": TRUE + }, + { + "id": 228, + "enabled": TRUE, + "label": "Assign Color Profile...", + "visible": TRUE + }, + { + "id": 229, + "type": "separator" + }, + { + "id": 230, + "enabled": TRUE, + "toggle-state": 0, + "label": "Indexed...", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 231, + "enabled": TRUE, + "toggle-state": 0, + "label": "Grayscale", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 232, + "enabled": TRUE, + "toggle-state": 1, + "label": "RGB", + "toggle-type": "checkmark", + "visible": TRUE + } + ] + }, + { + "id": 233, + "shortcut": [["Control", "d"]], + "enabled": TRUE, + "label": "Duplicate", + "visible": TRUE + } + ] + }, + { + "id": 234, + "enabled": TRUE, + "label": "Layer", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 235, + "enabled": TRUE, + "label": "Autocrop Layer", + "visible": TRUE + }, + { + "id": 236, + "enabled": FALSE, + "label": "Crop to Selection", + "visible": TRUE + }, + { + "id": 237, + "enabled": TRUE, + "label": "Scale Layer...", + "visible": TRUE + }, + { + "id": 238, + "enabled": TRUE, + "label": "Layer to Image Size", + "visible": TRUE + }, + { + "id": 239, + "enabled": TRUE, + "label": "Layer Boundary Size...", + "visible": TRUE + }, + { + "id": 240, + "type": "separator" + }, + { + "id": 241, + "enabled": TRUE, + "label": "Transform", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 242, + "shortcut": [["Control", "Shift", "o"]], + "enabled": TRUE, + "label": "Offset...", + "visible": TRUE + }, + { + "id": 243, + "type": "separator" + }, + { + "id": 244, + "enabled": TRUE, + "label": "Arbitrary Rotation...", + "visible": TRUE + }, + { + "id": 245, + "enabled": TRUE, + "label": "Rotate 180\302\260", + "visible": TRUE + }, + { + "id": 246, + "enabled": TRUE, + "label": "Rotate 90\302\260 counter-clockwise", + "visible": TRUE + }, + { + "id": 247, + "enabled": TRUE, + "label": "Rotate 90\302\260 clockwise", + "visible": TRUE + }, + { + "id": 248, + "type": "separator" + }, + { + "id": 249, + "enabled": TRUE, + "label": "Flip Vertically", + "visible": TRUE + }, + { + "id": 250, + "enabled": TRUE, + "label": "Flip Horizontally", + "visible": TRUE + } + ] + }, + { + "id": 251, + "enabled": TRUE, + "label": "Transparency", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 252, + "enabled": TRUE, + "label": "Intersect with Selection", + "visible": TRUE + }, + { + "id": 253, + "enabled": TRUE, + "label": "Subtract from Selection", + "visible": TRUE + }, + { + "id": 254, + "enabled": TRUE, + "label": "Add to Selection", + "visible": TRUE + }, + { + "id": 255, + "enabled": TRUE, + "label": "Alpha to Selection", + "visible": TRUE + }, + { + "id": 256, + "type": "separator" + }, + { + "id": 257, + "enabled": TRUE, + "label": "Threshold Alpha...", + "visible": TRUE + }, + { + "id": 258, + "enabled": TRUE, + "label": "Semi-Flatten", + "visible": TRUE + }, + { + "id": 259, + "enabled": TRUE, + "label": "Color to Alpha...", + "visible": TRUE + }, + { + "id": 260, + "enabled": TRUE, + "label": "Remove Alpha Channel", + "visible": TRUE + }, + { + "id": 261, + "enabled": FALSE, + "label": "Add Alpha Channel", + "visible": TRUE + } + ] + }, + { + "id": 262, + "enabled": TRUE, + "label": "Mask", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 263, + "enabled": FALSE, + "label": "Intersect with Selection", + "visible": TRUE + }, + { + "id": 264, + "enabled": FALSE, + "label": "Subtract from Selection", + "visible": TRUE + }, + { + "id": 265, + "enabled": FALSE, + "label": "Add to Selection", + "visible": TRUE + }, + { + "id": 266, + "enabled": FALSE, + "label": "Mask to Selection", + "visible": TRUE + }, + { + "id": 267, + "type": "separator" + }, + { + "id": 268, + "enabled": FALSE, + "toggle-state": 0, + "label": "Disable Layer Mask", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 269, + "enabled": FALSE, + "toggle-state": 0, + "label": "Edit Layer Mask", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 270, + "enabled": FALSE, + "toggle-state": 0, + "label": "Show Layer Mask", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 271, + "type": "separator" + }, + { + "id": 272, + "enabled": FALSE, + "label": "Delete Layer Mask", + "visible": TRUE + }, + { + "id": 273, + "enabled": FALSE, + "label": "Apply Layer Mask", + "visible": TRUE + }, + { + "id": 274, + "enabled": TRUE, + "label": "Add Layer Mask...", + "visible": TRUE + } + ] + }, + { + "id": 275, + "enabled": TRUE, + "label": "Stack", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 276, + "enabled": TRUE, + "label": "Reverse Layer Order", + "visible": TRUE + }, + { + "id": 277, + "type": "separator" + }, + { + "id": 278, + "enabled": FALSE, + "label": "Layer to Bottom", + "visible": TRUE + }, + { + "id": 279, + "enabled": FALSE, + "label": "Layer to Top", + "visible": TRUE + }, + { + "id": 280, + "enabled": FALSE, + "label": "Lower Layer", + "visible": TRUE + }, + { + "id": 281, + "enabled": FALSE, + "label": "Raise Layer", + "visible": TRUE + }, + { + "id": 282, + "type": "separator" + }, + { + "id": 283, + "shortcut": [["End"]], + "enabled": FALSE, + "label": "Select Bottom Layer", + "visible": TRUE + }, + { + "id": 284, + "shortcut": [["Home"]], + "enabled": FALSE, + "label": "Select Top Layer", + "visible": TRUE + }, + { + "id": 285, + "shortcut": [["Page_Down"]], + "enabled": FALSE, + "label": "Select Next Layer", + "visible": TRUE + }, + { + "id": 286, + "shortcut": [["Page_Up"]], + "enabled": FALSE, + "label": "Select Previous Layer", + "visible": TRUE + } + ] + }, + { + "id": 287, + "type": "separator", + "children-display": "submenu", + "submenu": [ + { + "id": 288, + "enabled": FALSE, + "label": "Empty", + "visible": TRUE + } + ] + }, + { + "id": 289, + "enabled": TRUE, + "label": "Delete Layer", + "visible": TRUE + }, + { + "id": 290, + "enabled": FALSE, + "label": "Merge Down", + "visible": TRUE + }, + { + "id": 291, + "shortcut": [["Control", "h"]], + "enabled": FALSE, + "label": "Anchor Layer", + "visible": TRUE + }, + { + "id": 292, + "shortcut": [["Control", "Shift", "d"]], + "enabled": TRUE, + "label": "Duplicate Layer", + "visible": TRUE + }, + { + "id": 293, + "enabled": TRUE, + "label": "New from Visible", + "visible": TRUE + }, + { + "id": 294, + "shortcut": [["Control", "Shift", "n"]], + "enabled": TRUE, + "label": "New Layer...", + "visible": TRUE + } + ] + }, + { + "id": 295, + "enabled": TRUE, + "label": "Colors", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 296, + "enabled": TRUE, + "label": "Retinex...", + "visible": TRUE + }, + { + "id": 297, + "enabled": TRUE, + "label": "Maximum RGB...", + "visible": TRUE + }, + { + "id": 298, + "enabled": FALSE, + "label": "Hot...", + "visible": TRUE + }, + { + "id": 299, + "enabled": TRUE, + "label": "Filter Pack...", + "visible": TRUE + }, + { + "id": 300, + "enabled": TRUE, + "label": "Color to Alpha...", + "visible": TRUE + }, + { + "id": 301, + "enabled": TRUE, + "label": "Colorify...", + "visible": TRUE + }, + { + "id": 302, + "type": "separator" + }, + { + "id": 303, + "enabled": TRUE, + "label": "Info", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 304, + "enabled": TRUE, + "label": "Smooth Palette...", + "visible": TRUE + }, + { + "id": 305, + "enabled": TRUE, + "label": "Colorcube Analysis...", + "visible": TRUE + }, + { + "id": 306, + "enabled": TRUE, + "label": "Border Average...", + "visible": TRUE + }, + { + "id": 307, + "enabled": TRUE, + "label": "Histogram", + "visible": TRUE + } + ] + }, + { + "id": 308, + "enabled": TRUE, + "label": "Map", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 309, + "enabled": TRUE, + "label": "Sample Colorize...", + "visible": TRUE + }, + { + "id": 310, + "enabled": TRUE, + "label": "Rotate Colors...", + "visible": TRUE + }, + { + "id": 311, + "enabled": TRUE, + "label": "Palette Map", + "visible": TRUE + }, + { + "id": 312, + "enabled": TRUE, + "label": "Gradient Map", + "visible": TRUE + }, + { + "id": 313, + "enabled": TRUE, + "label": "Color Exchange...", + "visible": TRUE + }, + { + "id": 314, + "enabled": TRUE, + "label": "Alien Map...", + "visible": TRUE + }, + { + "id": 315, + "type": "separator" + }, + { + "id": 316, + "enabled": FALSE, + "label": "Set Colormap...", + "visible": TRUE + }, + { + "id": 317, + "enabled": FALSE, + "label": "Rearrange Colormap...", + "visible": TRUE + } + ] + }, + { + "id": 318, + "enabled": TRUE, + "label": "Components", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 319, + "enabled": FALSE, + "label": "Recompose", + "visible": TRUE + }, + { + "id": 320, + "enabled": TRUE, + "label": "Decompose...", + "visible": TRUE + }, + { + "id": 321, + "enabled": FALSE, + "label": "Compose...", + "visible": TRUE + }, + { + "id": 322, + "enabled": TRUE, + "label": "Channel Mixer...", + "visible": TRUE + } + ] + }, + { + "id": 323, + "enabled": TRUE, + "label": "Auto", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 324, + "enabled": TRUE, + "label": "Stretch HSV", + "visible": TRUE + }, + { + "id": 325, + "enabled": TRUE, + "label": "Stretch Contrast", + "visible": TRUE + }, + { + "id": 326, + "enabled": TRUE, + "label": "Normalize", + "visible": TRUE + }, + { + "id": 327, + "enabled": TRUE, + "label": "Color Enhance", + "visible": TRUE + }, + { + "id": 328, + "enabled": TRUE, + "label": "White Balance", + "visible": TRUE + }, + { + "id": 329, + "enabled": TRUE, + "label": "Equalize", + "visible": TRUE + } + ] + }, + { + "id": 330, + "type": "separator" + }, + { + "id": 331, + "enabled": TRUE, + "toggle-state": 0, + "label": "Use GEGL", + "toggle-type": "checkmark", + "visible": TRUE + }, + { + "id": 332, + "type": "separator" + }, + { + "id": 333, + "enabled": TRUE, + "label": "Value Invert", + "visible": TRUE + }, + { + "id": 334, + "enabled": TRUE, + "label": "Invert", + "visible": TRUE + }, + { + "id": 335, + "type": "separator" + }, + { + "id": 336, + "enabled": TRUE, + "label": "Desaturate...", + "visible": TRUE + }, + { + "id": 337, + "enabled": TRUE, + "label": "Posterize...", + "visible": TRUE + }, + { + "id": 338, + "enabled": TRUE, + "label": "Curves...", + "visible": TRUE + }, + { + "id": 339, + "enabled": TRUE, + "label": "Levels...", + "visible": TRUE + }, + { + "id": 340, + "enabled": TRUE, + "label": "Threshold...", + "visible": TRUE + }, + { + "id": 341, + "enabled": TRUE, + "label": "Brightness-Contrast...", + "visible": TRUE + }, + { + "id": 342, + "enabled": TRUE, + "label": "Colorize...", + "visible": TRUE + }, + { + "id": 343, + "enabled": TRUE, + "label": "Hue-Saturation...", + "visible": TRUE + }, + { + "id": 344, + "enabled": TRUE, + "label": "Color Balance...", + "visible": TRUE + } + ] + }, + { + "id": 345, + "enabled": TRUE, + "label": "Tools", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 346, + "shortcut": [["x"]], + "enabled": TRUE, + "label": "Swap Colors", + "visible": TRUE + }, + { + "id": 347, + "shortcut": [["d"]], + "enabled": TRUE, + "label": "Default Colors", + "visible": TRUE + }, + { + "id": 348, + "shortcut": [["Control", "b"]], + "enabled": TRUE, + "label": "Toolbox", + "visible": TRUE + }, + { + "id": 349, + "type": "separator" + }, + { + "id": 350, + "enabled": TRUE, + "label": "GEGL Operation...", + "visible": TRUE + }, + { + "id": 351, + "shortcut": [["t"]], + "enabled": TRUE, + "label": "Text", + "visible": TRUE + }, + { + "id": 352, + "shortcut": [["Shift", "m"]], + "enabled": TRUE, + "label": "Measure", + "visible": TRUE + }, + { + "id": 353, + "shortcut": [["z"]], + "enabled": TRUE, + "label": "Zoom", + "visible": TRUE + }, + { + "id": 354, + "shortcut": [["o"]], + "enabled": TRUE, + "label": "Color Picker", + "visible": TRUE + }, + { + "id": 355, + "shortcut": [["b"]], + "enabled": TRUE, + "label": "Paths", + "visible": TRUE + }, + { + "id": 356, + "enabled": TRUE, + "label": "Color Tools", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 357, + "enabled": TRUE, + "label": "Desaturate...", + "visible": TRUE + }, + { + "id": 358, + "enabled": TRUE, + "label": "Posterize...", + "visible": TRUE + }, + { + "id": 359, + "enabled": TRUE, + "label": "Curves...", + "visible": TRUE + }, + { + "id": 360, + "enabled": TRUE, + "label": "Levels...", + "visible": TRUE + }, + { + "id": 361, + "enabled": TRUE, + "label": "Threshold...", + "visible": TRUE + }, + { + "id": 362, + "enabled": TRUE, + "label": "Brightness-Contrast...", + "visible": TRUE + }, + { + "id": 363, + "enabled": TRUE, + "label": "Colorize...", + "visible": TRUE + }, + { + "id": 364, + "enabled": TRUE, + "label": "Hue-Saturation...", + "visible": TRUE + }, + { + "id": 365, + "enabled": TRUE, + "label": "Color Balance...", + "visible": TRUE + } + ] + }, + { + "id": 366, + "enabled": TRUE, + "label": "Transform Tools", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 367, + "shortcut": [["Shift", "f"]], + "enabled": TRUE, + "label": "Flip", + "visible": TRUE + }, + { + "id": 368, + "shortcut": [["Shift", "p"]], + "enabled": TRUE, + "label": "Perspective", + "visible": TRUE + }, + { + "id": 369, + "shortcut": [["Shift", "s"]], + "enabled": TRUE, + "label": "Shear", + "visible": TRUE + }, + { + "id": 370, + "shortcut": [["Shift", "t"]], + "enabled": TRUE, + "label": "Scale", + "visible": TRUE + }, + { + "id": 371, + "shortcut": [["Shift", "r"]], + "enabled": TRUE, + "label": "Rotate", + "visible": TRUE + }, + { + "id": 372, + "shortcut": [["Shift", "c"]], + "enabled": TRUE, + "label": "Crop", + "visible": TRUE + }, + { + "id": 373, + "shortcut": [["m"]], + "enabled": TRUE, + "label": "Move", + "visible": TRUE + }, + { + "id": 374, + "shortcut": [["q"]], + "enabled": TRUE, + "label": "Align", + "visible": TRUE + } + ] + }, + { + "id": 375, + "enabled": TRUE, + "label": "Paint Tools", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 376, + "shortcut": [["Shift", "d"]], + "enabled": TRUE, + "label": "Dodge / Burn", + "visible": TRUE + }, + { + "id": 377, + "shortcut": [["s"]], + "enabled": TRUE, + "label": "Smudge", + "visible": TRUE + }, + { + "id": 378, + "shortcut": [["Shift", "u"]], + "enabled": TRUE, + "label": "Blur / Sharpen", + "visible": TRUE + }, + { + "id": 379, + "enabled": TRUE, + "label": "Perspective Clone", + "visible": TRUE + }, + { + "id": 380, + "shortcut": [["h"]], + "enabled": TRUE, + "label": "Heal", + "visible": TRUE + }, + { + "id": 381, + "shortcut": [["c"]], + "enabled": TRUE, + "label": "Clone", + "visible": TRUE + }, + { + "id": 382, + "shortcut": [["k"]], + "enabled": TRUE, + "label": "Ink", + "visible": TRUE + }, + { + "id": 383, + "shortcut": [["a"]], + "enabled": TRUE, + "label": "Airbrush", + "visible": TRUE + }, + { + "id": 384, + "shortcut": [["Shift", "e"]], + "enabled": TRUE, + "label": "Eraser", + "visible": TRUE + }, + { + "id": 385, + "shortcut": [["p"]], + "enabled": TRUE, + "label": "Paintbrush", + "visible": TRUE + }, + { + "id": 386, + "shortcut": [["n"]], + "enabled": TRUE, + "label": "Pencil", + "visible": TRUE + }, + { + "id": 387, + "shortcut": [["l"]], + "enabled": TRUE, + "label": "Blend", + "visible": TRUE + }, + { + "id": 388, + "shortcut": [["Shift", "b"]], + "enabled": TRUE, + "label": "Bucket Fill", + "visible": TRUE + } + ] + }, + { + "id": 389, + "enabled": TRUE, + "label": "Selection Tools", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 390, + "shortcut": [["i"]], + "enabled": TRUE, + "label": "Intelligent Scissors", + "visible": TRUE + }, + { + "id": 391, + "shortcut": [["Shift", "o"]], + "enabled": TRUE, + "label": "By Color Select", + "visible": TRUE + }, + { + "id": 392, + "shortcut": [["u"]], + "enabled": TRUE, + "label": "Fuzzy Select", + "visible": TRUE + }, + { + "id": 393, + "enabled": TRUE, + "label": "Foreground Select", + "visible": TRUE + }, + { + "id": 394, + "shortcut": [["f"]], + "enabled": TRUE, + "label": "Free Select", + "visible": TRUE + }, + { + "id": 395, + "shortcut": [["e"]], + "enabled": TRUE, + "label": "Ellipse Select", + "visible": TRUE + }, + { + "id": 396, + "shortcut": [["r"]], + "enabled": TRUE, + "label": "Rectangle Select", + "visible": TRUE + } + ] + } + ] + }, + { + "id": 397, + "enabled": TRUE, + "label": "Filters", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 398, + "enabled": TRUE, + "label": "Script-Fu", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 399, + "enabled": TRUE, + "label": "Start Server...", + "visible": TRUE + }, + { + "id": 400, + "enabled": TRUE, + "label": "Refresh Scripts", + "visible": TRUE + }, + { + "id": 401, + "enabled": TRUE, + "label": "Console", + "visible": TRUE + } + ] + }, + { + "id": 402, + "enabled": TRUE, + "label": "Python-Fu", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 403, + "enabled": TRUE, + "label": "Console", + "visible": TRUE + } + ] + }, + { + "id": 404, + "type": "separator" + }, + { + "id": 405, + "enabled": TRUE, + "label": "Alpha to Logo", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 406, + "enabled": TRUE, + "label": "Textured...", + "visible": TRUE + }, + { + "id": 407, + "enabled": TRUE, + "label": "Particle Trace...", + "visible": TRUE + }, + { + "id": 408, + "enabled": TRUE, + "label": "Neon...", + "visible": TRUE + }, + { + "id": 409, + "enabled": TRUE, + "label": "Gradient Bevel...", + "visible": TRUE + }, + { + "id": 410, + "enabled": TRUE, + "label": "Glowing Hot...", + "visible": TRUE + }, + { + "id": 411, + "enabled": TRUE, + "label": "Glossy...", + "visible": TRUE + }, + { + "id": 412, + "enabled": TRUE, + "label": "Frosty...", + "visible": TRUE + }, + { + "id": 413, + "enabled": TRUE, + "label": "Cool Metal...", + "visible": TRUE + }, + { + "id": 414, + "enabled": TRUE, + "label": "Comic Book...", + "visible": TRUE + }, + { + "id": 415, + "enabled": TRUE, + "label": "Chrome...", + "visible": TRUE + }, + { + "id": 416, + "enabled": TRUE, + "label": "Chip Away...", + "visible": TRUE + }, + { + "id": 417, + "enabled": TRUE, + "label": "Chalk...", + "visible": TRUE + }, + { + "id": 418, + "enabled": TRUE, + "label": "Bovination...", + "visible": TRUE + }, + { + "id": 419, + "enabled": TRUE, + "label": "Blended...", + "visible": TRUE + }, + { + "id": 420, + "enabled": TRUE, + "label": "Basic I...", + "visible": TRUE + }, + { + "id": 421, + "enabled": TRUE, + "label": "Basic II...", + "visible": TRUE + }, + { + "id": 422, + "enabled": TRUE, + "label": "Alien Neon...", + "visible": TRUE + }, + { + "id": 423, + "enabled": TRUE, + "label": "Alien Glow...", + "visible": TRUE + }, + { + "id": 424, + "enabled": TRUE, + "label": "3D Outline...", + "visible": TRUE + } + ] + }, + { + "id": 425, + "type": "separator" + }, + { + "id": 426, + "enabled": TRUE, + "label": "Animation", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 427, + "enabled": TRUE, + "label": "Unoptimize", + "visible": TRUE + }, + { + "id": 428, + "enabled": TRUE, + "label": "Playback...", + "visible": TRUE + }, + { + "id": 429, + "enabled": TRUE, + "label": "Optimize (for GIF)", + "visible": TRUE + }, + { + "id": 430, + "enabled": TRUE, + "label": "Optimize (Difference)", + "visible": TRUE + }, + { + "id": 431, + "type": "separator" + }, + { + "id": 432, + "enabled": TRUE, + "label": "Waves...", + "visible": TRUE + }, + { + "id": 433, + "enabled": TRUE, + "label": "Spinning Globe...", + "visible": TRUE + }, + { + "id": 434, + "enabled": TRUE, + "label": "Rippling...", + "visible": TRUE + }, + { + "id": 435, + "enabled": TRUE, + "label": "Burn-In...", + "visible": TRUE + }, + { + "id": 436, + "enabled": TRUE, + "label": "Blend...", + "visible": TRUE + } + ] + }, + { + "id": 437, + "enabled": TRUE, + "label": "Web", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 438, + "enabled": TRUE, + "label": "Slice...", + "visible": TRUE + }, + { + "id": 439, + "enabled": TRUE, + "label": "Semi-Flatten", + "visible": TRUE + }, + { + "id": 440, + "enabled": TRUE, + "label": "Image Map...", + "visible": TRUE + } + ] + }, + { + "id": 441, + "enabled": TRUE, + "label": "Render", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 442, + "enabled": TRUE, + "label": "Spyrogimp...", + "visible": TRUE + }, + { + "id": 443, + "enabled": TRUE, + "label": "Sphere Designer...", + "visible": TRUE + }, + { + "id": 444, + "enabled": TRUE, + "label": "Line Nova...", + "visible": TRUE + }, + { + "id": 445, + "enabled": TRUE, + "label": "Lava...", + "visible": TRUE + }, + { + "id": 446, + "enabled": TRUE, + "label": "Gfig...", + "visible": TRUE + }, + { + "id": 447, + "enabled": TRUE, + "label": "Fractal Explorer...", + "visible": TRUE + }, + { + "id": 448, + "enabled": TRUE, + "label": "Circuit...", + "visible": TRUE + }, + { + "id": 449, + "type": "separator" + }, + { + "id": 450, + "enabled": TRUE, + "label": "Pattern", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 451, + "enabled": TRUE, + "label": "Sinus...", + "visible": TRUE + }, + { + "id": 452, + "enabled": TRUE, + "label": "Qbist...", + "visible": TRUE + }, + { + "id": 453, + "enabled": TRUE, + "label": "Maze...", + "visible": TRUE + }, + { + "id": 454, + "enabled": TRUE, + "label": "Jigsaw...", + "visible": TRUE + }, + { + "id": 455, + "enabled": TRUE, + "label": "Grid...", + "visible": TRUE + }, + { + "id": 456, + "enabled": TRUE, + "label": "Diffraction Patterns...", + "visible": TRUE + }, + { + "id": 457, + "enabled": TRUE, + "label": "CML Explorer...", + "visible": TRUE + }, + { + "id": 458, + "enabled": TRUE, + "label": "Checkerboard...", + "visible": TRUE + } + ] + }, + { + "id": 459, + "enabled": TRUE, + "label": "Nature", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 460, + "enabled": TRUE, + "label": "IFS Fractal...", + "visible": TRUE + }, + { + "id": 461, + "enabled": TRUE, + "label": "Flame...", + "visible": TRUE + } + ] + }, + { + "id": 462, + "enabled": TRUE, + "label": "Clouds", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 463, + "enabled": TRUE, + "label": "Solid Noise...", + "visible": TRUE + }, + { + "id": 464, + "enabled": TRUE, + "label": "Plasma...", + "visible": TRUE + }, + { + "id": 465, + "enabled": TRUE, + "label": "Fog...", + "visible": TRUE + }, + { + "id": 466, + "enabled": TRUE, + "label": "Difference Clouds...", + "visible": TRUE + } + ] + } + ] + }, + { + "id": 467, + "enabled": TRUE, + "label": "Map", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 468, + "enabled": TRUE, + "label": "Warp...", + "visible": TRUE + }, + { + "id": 469, + "enabled": TRUE, + "label": "Tile...", + "visible": TRUE + }, + { + "id": 470, + "enabled": TRUE, + "label": "Small Tiles...", + "visible": TRUE + }, + { + "id": 471, + "enabled": TRUE, + "label": "Paper Tile...", + "visible": TRUE + }, + { + "id": 472, + "enabled": TRUE, + "label": "Map Object...", + "visible": TRUE + }, + { + "id": 473, + "enabled": TRUE, + "label": "Make Seamless", + "visible": TRUE + }, + { + "id": 474, + "enabled": TRUE, + "label": "Illusion...", + "visible": TRUE + }, + { + "id": 475, + "enabled": TRUE, + "label": "Fractal Trace...", + "visible": TRUE + }, + { + "id": 476, + "enabled": TRUE, + "label": "Displace...", + "visible": TRUE + }, + { + "id": 477, + "enabled": TRUE, + "label": "Bump Map...", + "visible": TRUE + } + ] + }, + { + "id": 478, + "enabled": TRUE, + "label": "Decor", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 479, + "enabled": FALSE, + "label": "Stencil Chrome...", + "visible": TRUE + }, + { + "id": 480, + "enabled": FALSE, + "label": "Stencil Carve...", + "visible": TRUE + }, + { + "id": 481, + "enabled": FALSE, + "label": "Slide...", + "visible": TRUE + }, + { + "id": 482, + "enabled": FALSE, + "label": "Round Corners...", + "visible": TRUE + }, + { + "id": 483, + "enabled": TRUE, + "label": "Old Photo...", + "visible": TRUE + }, + { + "id": 484, + "enabled": TRUE, + "label": "Fuzzy Border...", + "visible": TRUE + }, + { + "id": 485, + "enabled": TRUE, + "label": "Coffee Stain...", + "visible": TRUE + }, + { + "id": 486, + "enabled": TRUE, + "label": "Add Border...", + "visible": TRUE + }, + { + "id": 487, + "enabled": TRUE, + "label": "Add Bevel...", + "visible": TRUE + } + ] + }, + { + "id": 488, + "enabled": TRUE, + "label": "Artistic", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 489, + "enabled": TRUE, + "label": "Weave...", + "visible": TRUE + }, + { + "id": 490, + "enabled": TRUE, + "label": "Van Gogh (LIC)...", + "visible": TRUE + }, + { + "id": 491, + "enabled": TRUE, + "label": "Softglow...", + "visible": TRUE + }, + { + "id": 492, + "enabled": TRUE, + "label": "Predator...", + "visible": TRUE + }, + { + "id": 493, + "enabled": TRUE, + "label": "Photocopy...", + "visible": TRUE + }, + { + "id": 494, + "enabled": TRUE, + "label": "Oilify...", + "visible": TRUE + }, + { + "id": 495, + "enabled": TRUE, + "label": "GIMPressionist...", + "visible": TRUE + }, + { + "id": 496, + "enabled": TRUE, + "label": "Cubism...", + "visible": TRUE + }, + { + "id": 497, + "enabled": TRUE, + "label": "Clothify...", + "visible": TRUE + }, + { + "id": 498, + "enabled": TRUE, + "label": "Cartoon...", + "visible": TRUE + }, + { + "id": 499, + "enabled": TRUE, + "label": "Apply Canvas...", + "visible": TRUE + } + ] + }, + { + "id": 500, + "enabled": TRUE, + "label": "Combine", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 501, + "enabled": TRUE, + "label": "Filmstrip...", + "visible": TRUE + }, + { + "id": 502, + "enabled": TRUE, + "label": "Depth Merge...", + "visible": TRUE + } + ] + }, + { + "id": 503, + "enabled": TRUE, + "label": "Generic", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 504, + "enabled": TRUE, + "label": "Erode", + "visible": TRUE + }, + { + "id": 505, + "enabled": TRUE, + "label": "Dilate", + "visible": TRUE + }, + { + "id": 506, + "enabled": TRUE, + "label": "Convolution Matrix...", + "visible": TRUE + } + ] + }, + { + "id": 507, + "enabled": TRUE, + "label": "Edge-Detect", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 508, + "enabled": TRUE, + "label": "Sobel...", + "visible": TRUE + }, + { + "id": 509, + "enabled": TRUE, + "label": "Neon...", + "visible": TRUE + }, + { + "id": 510, + "enabled": TRUE, + "label": "Laplace", + "visible": TRUE + }, + { + "id": 511, + "enabled": TRUE, + "label": "Edge...", + "visible": TRUE + }, + { + "id": 512, + "enabled": TRUE, + "label": "Difference of Gaussians...", + "visible": TRUE + } + ] + }, + { + "id": 513, + "enabled": TRUE, + "label": "Noise", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 514, + "enabled": TRUE, + "label": "Spread...", + "visible": TRUE + }, + { + "id": 515, + "enabled": TRUE, + "label": "Slur...", + "visible": TRUE + }, + { + "id": 516, + "enabled": TRUE, + "label": "RGB Noise...", + "visible": TRUE + }, + { + "id": 517, + "enabled": TRUE, + "label": "Pick...", + "visible": TRUE + }, + { + "id": 518, + "enabled": TRUE, + "label": "Hurl...", + "visible": TRUE + }, + { + "id": 519, + "enabled": TRUE, + "label": "HSV Noise...", + "visible": TRUE + } + ] + }, + { + "id": 520, + "enabled": TRUE, + "label": "Light and Shadow", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 521, + "enabled": TRUE, + "label": "Glass Tile...", + "visible": TRUE + }, + { + "id": 522, + "enabled": TRUE, + "label": "Apply Lens...", + "visible": TRUE + }, + { + "id": 523, + "type": "separator" + }, + { + "id": 524, + "enabled": TRUE, + "label": "Xach-Effect...", + "visible": TRUE + }, + { + "id": 525, + "enabled": TRUE, + "label": "Perspective...", + "visible": TRUE + }, + { + "id": 526, + "enabled": TRUE, + "label": "Drop Shadow...", + "visible": TRUE + }, + { + "id": 527, + "type": "separator" + }, + { + "id": 528, + "enabled": TRUE, + "label": "Supernova...", + "visible": TRUE + }, + { + "id": 529, + "enabled": TRUE, + "label": "Sparkle...", + "visible": TRUE + }, + { + "id": 530, + "enabled": TRUE, + "label": "Lighting Effects...", + "visible": TRUE + }, + { + "id": 531, + "enabled": TRUE, + "label": "Lens Flare...", + "visible": TRUE + }, + { + "id": 532, + "enabled": TRUE, + "label": "Gradient Flare...", + "visible": TRUE + } + ] + }, + { + "id": 533, + "enabled": TRUE, + "label": "Distorts", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 534, + "enabled": TRUE, + "label": "Wind...", + "visible": TRUE + }, + { + "id": 535, + "enabled": TRUE, + "label": "Whirl and Pinch...", + "visible": TRUE + }, + { + "id": 536, + "enabled": TRUE, + "label": "Waves...", + "visible": TRUE + }, + { + "id": 537, + "enabled": TRUE, + "label": "Video...", + "visible": TRUE + }, + { + "id": 538, + "enabled": TRUE, + "label": "Value Propagate...", + "visible": TRUE + }, + { + "id": 539, + "enabled": TRUE, + "label": "Shift...", + "visible": TRUE + }, + { + "id": 540, + "enabled": TRUE, + "label": "Ripple...", + "visible": TRUE + }, + { + "id": 541, + "enabled": TRUE, + "label": "Polar Coordinates...", + "visible": TRUE + }, + { + "id": 542, + "enabled": TRUE, + "label": "Pagecurl...", + "visible": TRUE + }, + { + "id": 543, + "enabled": TRUE, + "label": "Newsprint...", + "visible": TRUE + }, + { + "id": 544, + "enabled": TRUE, + "label": "Mosaic...", + "visible": TRUE + }, + { + "id": 545, + "enabled": TRUE, + "label": "Lens Distortion...", + "visible": TRUE + }, + { + "id": 546, + "enabled": TRUE, + "label": "IWarp...", + "visible": TRUE + }, + { + "id": 547, + "enabled": TRUE, + "label": "Erase Every Other Row...", + "visible": TRUE + }, + { + "id": 548, + "enabled": TRUE, + "label": "Engrave...", + "visible": TRUE + }, + { + "id": 549, + "enabled": TRUE, + "label": "Emboss...", + "visible": TRUE + }, + { + "id": 550, + "enabled": TRUE, + "label": "Curve Bend...", + "visible": TRUE + }, + { + "id": 551, + "enabled": TRUE, + "label": "Blinds...", + "visible": TRUE + } + ] + }, + { + "id": 552, + "enabled": TRUE, + "label": "Enhance", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 553, + "enabled": TRUE, + "label": "Unsharp Mask...", + "visible": TRUE + }, + { + "id": 554, + "enabled": TRUE, + "label": "Sharpen...", + "visible": TRUE + }, + { + "id": 555, + "enabled": TRUE, + "label": "Red Eye Removal...", + "visible": TRUE + }, + { + "id": 556, + "enabled": FALSE, + "label": "NL Filter...", + "visible": TRUE + }, + { + "id": 557, + "enabled": TRUE, + "label": "Destripe...", + "visible": TRUE + }, + { + "id": 558, + "enabled": TRUE, + "label": "Despeckle...", + "visible": TRUE + }, + { + "id": 559, + "enabled": TRUE, + "label": "Deinterlace...", + "visible": TRUE + }, + { + "id": 560, + "enabled": TRUE, + "label": "Antialias", + "visible": TRUE + } + ] + }, + { + "id": 561, + "enabled": TRUE, + "label": "Blur", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 562, + "enabled": TRUE, + "label": "Tileable Blur...", + "visible": TRUE + }, + { + "id": 563, + "enabled": TRUE, + "label": "Selective Gaussian Blur...", + "visible": TRUE + }, + { + "id": 564, + "enabled": TRUE, + "label": "Pixelize...", + "visible": TRUE + }, + { + "id": 565, + "enabled": TRUE, + "label": "Motion Blur...", + "visible": TRUE + }, + { + "id": 566, + "enabled": TRUE, + "label": "Gaussian Blur...", + "visible": TRUE + }, + { + "id": 567, + "enabled": TRUE, + "label": "Blur", + "visible": TRUE + } + ] + }, + { + "id": 568, + "type": "separator" + }, + { + "id": 569, + "enabled": TRUE, + "label": "Reset all Filters", + "visible": TRUE + }, + { + "id": 570, + "shortcut": [["Control", "Shift", "f"]], + "enabled": FALSE, + "label": "Re-Show Last", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 571, + "enabled": FALSE, + "label": "Empty", + "visible": TRUE + } + ] + }, + { + "id": 572, + "shortcut": [["Control", "f"]], + "enabled": FALSE, + "label": "Repeat Last", + "visible": TRUE + } + ] + }, + { + "id": 573, + "enabled": TRUE, + "label": "Windows", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 574, + "shortcut": [["Control", "b"]], + "enabled": TRUE, + "label": "Toolbox", + "visible": TRUE + }, + { + "id": 575, + "type": "separator" + }, + { + "id": 576, + "enabled": TRUE, + "label": "Dockable Dialogs", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 577, + "enabled": TRUE, + "label": "Error Console", + "visible": TRUE + }, + { + "id": 578, + "enabled": TRUE, + "label": "Tools", + "visible": TRUE + }, + { + "id": 579, + "enabled": TRUE, + "label": "Templates", + "visible": TRUE + }, + { + "id": 580, + "enabled": TRUE, + "label": "Document History", + "visible": TRUE + }, + { + "id": 581, + "enabled": TRUE, + "label": "Images", + "visible": TRUE + }, + { + "id": 582, + "type": "separator" + }, + { + "id": 583, + "enabled": TRUE, + "label": "Buffers", + "visible": TRUE + }, + { + "id": 584, + "enabled": TRUE, + "label": "Fonts", + "visible": TRUE + }, + { + "id": 585, + "enabled": TRUE, + "label": "Palettes", + "visible": TRUE + }, + { + "id": 586, + "shortcut": [["Control", "g"]], + "enabled": TRUE, + "label": "Gradients", + "visible": TRUE + }, + { + "id": 587, + "shortcut": [["Control", "Shift", "p"]], + "enabled": TRUE, + "label": "Patterns", + "visible": TRUE + }, + { + "id": 588, + "shortcut": [["Control", "Shift", "b"]], + "enabled": TRUE, + "label": "Brushes", + "visible": TRUE + }, + { + "id": 589, + "enabled": TRUE, + "label": "Colors", + "visible": TRUE + }, + { + "id": 590, + "type": "separator" + }, + { + "id": 591, + "enabled": TRUE, + "label": "Sample Points", + "visible": TRUE + }, + { + "id": 592, + "enabled": TRUE, + "label": "Pointer", + "visible": TRUE + }, + { + "id": 593, + "enabled": TRUE, + "label": "Undo History", + "visible": TRUE + }, + { + "id": 594, + "enabled": TRUE, + "label": "Navigation", + "visible": TRUE + }, + { + "id": 595, + "enabled": TRUE, + "label": "Selection Editor", + "visible": TRUE + }, + { + "id": 596, + "enabled": TRUE, + "label": "Histogram", + "visible": TRUE + }, + { + "id": 597, + "enabled": TRUE, + "label": "Colormap", + "visible": TRUE + }, + { + "id": 598, + "enabled": TRUE, + "label": "Paths", + "visible": TRUE + }, + { + "id": 599, + "enabled": TRUE, + "label": "Channels", + "visible": TRUE + }, + { + "id": 600, + "shortcut": [["Control", "l"]], + "enabled": TRUE, + "label": "Layers", + "visible": TRUE + }, + { + "id": 601, + "type": "separator" + }, + { + "id": 602, + "enabled": TRUE, + "label": "Device Status", + "visible": TRUE + }, + { + "id": 603, + "enabled": TRUE, + "label": "Tool Options", + "visible": TRUE + } + ] + }, + { + "id": 604, + "enabled": TRUE, + "label": "Recently Closed Docks", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 605, + "enabled": FALSE, + "label": "Empty", + "visible": TRUE + } + ] + } + ] + }, + { + "id": 606, + "enabled": TRUE, + "label": "Help", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 607, + "enabled": TRUE, + "label": "User Manual", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 608, + "enabled": TRUE, + "label": "Working with Digital Camera Photos", + "visible": TRUE + }, + { + "id": 609, + "enabled": TRUE, + "label": "Using Paths", + "visible": TRUE + }, + { + "id": 610, + "enabled": TRUE, + "label": "Preparing your Images for the Web", + "visible": TRUE + }, + { + "id": 611, + "enabled": TRUE, + "label": "How to Use Dialogs", + "visible": TRUE + }, + { + "id": 612, + "enabled": TRUE, + "label": "Drawing Simple Objects", + "visible": TRUE + }, + { + "id": 613, + "enabled": TRUE, + "label": "Create, Open and Save Files", + "visible": TRUE + }, + { + "id": 614, + "enabled": TRUE, + "label": "Basic Concepts", + "visible": TRUE + } + ] + }, + { + "id": 615, + "enabled": TRUE, + "label": "GIMP Online", + "children-display": "submenu", + "visible": TRUE, + "submenu": [ + { + "id": 616, + "enabled": TRUE, + "label": "User Manual Web Site", + "visible": TRUE + }, + { + "id": 617, + "enabled": TRUE, + "label": "Plug-in Registry", + "visible": TRUE + }, + { + "id": 618, + "enabled": TRUE, + "label": "Main Web Site", + "visible": TRUE + }, + { + "id": 619, + "enabled": TRUE, + "label": "Developer Web Site", + "visible": TRUE + } + ] + }, + { + "id": 620, + "type": "separator" + }, + { + "id": 621, + "enabled": TRUE, + "label": "Procedure Browser", + "visible": TRUE + }, + { + "id": 622, + "enabled": TRUE, + "label": "Plug-In Browser", + "visible": TRUE + }, + { + "id": 623, + "type": "separator" + }, + { + "id": 624, + "enabled": TRUE, + "label": "About", + "visible": TRUE + }, + { + "id": 625, + "enabled": TRUE, + "label": "Tip of the Day", + "visible": TRUE + }, + { + "id": 626, + "shortcut": [["Shift", "F1"]], + "enabled": TRUE, + "label": "Context Help", + "visible": TRUE + }, + { + "id": 627, + "shortcut": [["F1"]], + "enabled": TRUE, + "label": "Help", + "visible": TRUE + } + ] + } + ] +} -- cgit v1.2.3 From cfa184b0c813bbc286dba830f909d4fbbe023352 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 18:01:17 -0500 Subject: Hmm, bug in dbusmenu-dumper there. --- tests/test-json-01.json | 2296 +++++++++++++++++++++++------------------------ 1 file changed, 1148 insertions(+), 1148 deletions(-) diff --git a/tests/test-json-01.json b/tests/test-json-01.json index a46a6d6..a014548 100644 --- a/tests/test-json-01.json +++ b/tests/test-json-01.json @@ -4,31 +4,31 @@ "submenu": [ { "id": 5, - "enabled": TRUE, + "enabled": true, "label": "File", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 6, "shortcut": [["Control", "q"]], - "enabled": TRUE, + "enabled": true, "label": "Quit", - "visible": TRUE + "visible": true }, { "id": 7, "shortcut": [["Control", "Shift", "w"]], - "enabled": TRUE, + "enabled": true, "label": "Close all", - "visible": TRUE + "visible": true }, { "id": 8, "shortcut": [["Control", "w"]], - "enabled": TRUE, + "enabled": true, "label": "Close", - "visible": TRUE + "visible": true }, { "id": 9, @@ -36,22 +36,22 @@ }, { "id": 10, - "enabled": TRUE, + "enabled": true, "label": "Send by Email...", - "visible": TRUE + "visible": true }, { "id": 11, "shortcut": [["Control", "p"]], - "enabled": TRUE, + "enabled": true, "label": "Print...", - "visible": TRUE + "visible": true }, { "id": 12, - "enabled": TRUE, + "enabled": true, "label": "Page Setup", - "visible": TRUE + "visible": true }, { "id": 13, @@ -59,35 +59,35 @@ }, { "id": 14, - "enabled": TRUE, + "enabled": true, "label": "Revert", - "visible": TRUE + "visible": true }, { "id": 15, - "enabled": TRUE, + "enabled": true, "label": "Save as Template...", - "visible": TRUE + "visible": true }, { "id": 16, - "enabled": TRUE, + "enabled": true, "label": "Save a Copy...", - "visible": TRUE + "visible": true }, { "id": 17, "shortcut": [["Control", "Shift", "s"]], - "enabled": TRUE, + "enabled": true, "label": "Save As...", - "visible": TRUE + "visible": true }, { "id": 18, "shortcut": [["Control", "s"]], - "enabled": TRUE, + "enabled": true, "label": "Save", - "visible": TRUE + "visible": true }, { "id": 19, @@ -95,16 +95,16 @@ }, { "id": 20, - "enabled": TRUE, + "enabled": true, "label": "Open Recent", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 21, - "enabled": TRUE, + "enabled": true, "label": "Document History", - "visible": TRUE + "visible": true }, { "id": 22, @@ -113,167 +113,167 @@ { "id": 23, "shortcut": [["Control", "2"]], - "enabled": TRUE, + "enabled": true, "label": "giggity.jpg", - "visible": TRUE + "visible": true }, { "id": 24, "shortcut": [["Control", "1"]], - "enabled": TRUE, + "enabled": true, "label": "Icon Height.svg", - "visible": TRUE + "visible": true } ] }, { "id": 25, - "enabled": TRUE, + "enabled": true, "label": "Open Location...", - "visible": TRUE + "visible": true }, { "id": 26, "shortcut": [["Control", "Alt", "o"]], - "enabled": TRUE, + "enabled": true, "label": "Open as Layers...", - "visible": TRUE + "visible": true }, { "id": 27, "shortcut": [["Control", "o"]], - "enabled": TRUE, + "enabled": true, "label": "Open...", - "visible": TRUE + "visible": true }, { "id": 28, - "enabled": TRUE, + "enabled": true, "label": "Create", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 29, - "enabled": TRUE, + "enabled": true, "label": "Web Page Themes", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 30, - "enabled": TRUE, + "enabled": true, "label": "Classic.Gimp.Org", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 31, - "enabled": TRUE, + "enabled": true, "label": "Tube Sub-Sub-Button Label...", - "visible": TRUE + "visible": true }, { "id": 32, - "enabled": TRUE, + "enabled": true, "label": "Tube Sub-Button Label...", - "visible": TRUE + "visible": true }, { "id": 33, - "enabled": TRUE, + "enabled": true, "label": "Tube Button Label...", - "visible": TRUE + "visible": true }, { "id": 34, - "enabled": TRUE, + "enabled": true, "label": "Small Header...", - "visible": TRUE + "visible": true }, { "id": 35, - "enabled": TRUE, + "enabled": true, "label": "General Tube Labels...", - "visible": TRUE + "visible": true }, { "id": 36, - "enabled": TRUE, + "enabled": true, "label": "Big Header...", - "visible": TRUE + "visible": true } ] }, { "id": 37, - "enabled": TRUE, + "enabled": true, "label": "Beveled Pattern", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 38, - "enabled": TRUE, + "enabled": true, "label": "Hrule...", - "visible": TRUE + "visible": true }, { "id": 39, - "enabled": TRUE, + "enabled": true, "label": "Heading...", - "visible": TRUE + "visible": true }, { "id": 40, - "enabled": TRUE, + "enabled": true, "label": "Button...", - "visible": TRUE + "visible": true }, { "id": 41, - "enabled": TRUE, + "enabled": true, "label": "Bullet...", - "visible": TRUE + "visible": true }, { "id": 42, - "enabled": TRUE, + "enabled": true, "label": "Arrow...", - "visible": TRUE + "visible": true } ] }, { "id": 43, - "enabled": TRUE, + "enabled": true, "label": "Alien Glow", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 44, - "enabled": TRUE, + "enabled": true, "label": "Hrule...", - "visible": TRUE + "visible": true }, { "id": 45, - "enabled": TRUE, + "enabled": true, "label": "Button...", - "visible": TRUE + "visible": true }, { "id": 46, - "enabled": TRUE, + "enabled": true, "label": "Bullet...", - "visible": TRUE + "visible": true }, { "id": 47, - "enabled": TRUE, + "enabled": true, "label": "Arrow...", - "visible": TRUE + "visible": true } ] } @@ -281,256 +281,256 @@ }, { "id": 48, - "enabled": TRUE, + "enabled": true, "label": "Patterns", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 49, - "enabled": TRUE, + "enabled": true, "label": "Truchet...", - "visible": TRUE + "visible": true }, { "id": 50, - "enabled": TRUE, + "enabled": true, "label": "Swirly...", - "visible": TRUE + "visible": true }, { "id": 51, - "enabled": TRUE, + "enabled": true, "label": "Swirl-Tile...", - "visible": TRUE + "visible": true }, { "id": 52, - "enabled": TRUE, + "enabled": true, "label": "Render Map...", - "visible": TRUE + "visible": true }, { "id": 53, - "enabled": TRUE, + "enabled": true, "label": "Land...", - "visible": TRUE + "visible": true }, { "id": 54, - "enabled": TRUE, + "enabled": true, "label": "Flatland...", - "visible": TRUE + "visible": true }, { "id": 55, - "enabled": TRUE, + "enabled": true, "label": "Camouflage...", - "visible": TRUE + "visible": true }, { "id": 56, - "enabled": TRUE, + "enabled": true, "label": "3D Truchet...", - "visible": TRUE + "visible": true } ] }, { "id": 57, - "enabled": TRUE, + "enabled": true, "label": "Logos", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 58, - "enabled": TRUE, + "enabled": true, "label": "Web Title Header...", - "visible": TRUE + "visible": true }, { "id": 59, - "enabled": TRUE, + "enabled": true, "label": "Textured...", - "visible": TRUE + "visible": true }, { "id": 60, - "enabled": TRUE, + "enabled": true, "label": "Text Circle...", - "visible": TRUE + "visible": true }, { "id": 61, - "enabled": TRUE, + "enabled": true, "label": "Starscape...", - "visible": TRUE + "visible": true }, { "id": 62, - "enabled": TRUE, + "enabled": true, "label": "Speed Text...", - "visible": TRUE + "visible": true }, { "id": 63, - "enabled": TRUE, + "enabled": true, "label": "SOTA Chrome...", - "visible": TRUE + "visible": true }, { "id": 64, - "enabled": TRUE, + "enabled": true, "label": "Particle Trace...", - "visible": TRUE + "visible": true }, { "id": 65, - "enabled": TRUE, + "enabled": true, "label": "Newsprint Text...", - "visible": TRUE + "visible": true }, { "id": 66, - "enabled": TRUE, + "enabled": true, "label": "Neon...", - "visible": TRUE + "visible": true }, { "id": 67, - "enabled": TRUE, + "enabled": true, "label": "Imigre-26...", - "visible": TRUE + "visible": true }, { "id": 68, - "enabled": TRUE, + "enabled": true, "label": "Gradient Bevel...", - "visible": TRUE + "visible": true }, { "id": 69, - "enabled": TRUE, + "enabled": true, "label": "Glowing Hot...", - "visible": TRUE + "visible": true }, { "id": 70, - "enabled": TRUE, + "enabled": true, "label": "Glossy...", - "visible": TRUE + "visible": true }, { "id": 71, - "enabled": TRUE, + "enabled": true, "label": "Frosty...", - "visible": TRUE + "visible": true }, { "id": 72, - "enabled": TRUE, + "enabled": true, "label": "Crystal...", - "visible": TRUE + "visible": true }, { "id": 73, - "enabled": TRUE, + "enabled": true, "label": "Cool Metal...", - "visible": TRUE + "visible": true }, { "id": 74, - "enabled": TRUE, + "enabled": true, "label": "Comic Book...", - "visible": TRUE + "visible": true }, { "id": 75, - "enabled": TRUE, + "enabled": true, "label": "Chrome...", - "visible": TRUE + "visible": true }, { "id": 76, - "enabled": TRUE, + "enabled": true, "label": "Chip Away...", - "visible": TRUE + "visible": true }, { "id": 77, - "enabled": TRUE, + "enabled": true, "label": "Chalk...", - "visible": TRUE + "visible": true }, { "id": 78, - "enabled": TRUE, + "enabled": true, "label": "Carved...", - "visible": TRUE + "visible": true }, { "id": 79, - "enabled": TRUE, + "enabled": true, "label": "Bovination...", - "visible": TRUE + "visible": true }, { "id": 80, - "enabled": TRUE, + "enabled": true, "label": "Blended...", - "visible": TRUE + "visible": true }, { "id": 81, - "enabled": TRUE, + "enabled": true, "label": "Basic I...", - "visible": TRUE + "visible": true }, { "id": 82, - "enabled": TRUE, + "enabled": true, "label": "Basic II...", - "visible": TRUE + "visible": true }, { "id": 83, - "enabled": TRUE, + "enabled": true, "label": "Alien Neon...", - "visible": TRUE + "visible": true }, { "id": 84, - "enabled": TRUE, + "enabled": true, "label": "Alien Glow...", - "visible": TRUE + "visible": true }, { "id": 85, - "enabled": TRUE, + "enabled": true, "label": "3D Outline...", - "visible": TRUE + "visible": true } ] }, { "id": 86, - "enabled": TRUE, + "enabled": true, "label": "Buttons", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 87, - "enabled": TRUE, + "enabled": true, "label": "Simple Beveled Button...", - "visible": TRUE + "visible": true }, { "id": 88, - "enabled": TRUE, + "enabled": true, "label": "Round Button...", - "visible": TRUE + "visible": true } ] }, @@ -540,73 +540,73 @@ }, { "id": 90, - "enabled": TRUE, + "enabled": true, "label": "xscanimage", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 91, - "enabled": FALSE, + "enabled": false, "label": "Device dialog...", - "visible": TRUE + "visible": true } ] }, { "id": 92, - "enabled": TRUE, + "enabled": true, "label": "Screenshot...", - "visible": TRUE + "visible": true }, { "id": 93, "shortcut": [["Control", "Shift", "v"]], - "enabled": TRUE, + "enabled": true, "label": "From Clipboard", - "visible": TRUE + "visible": true } ] }, { "id": 94, "shortcut": [["Control", "n"]], - "enabled": TRUE, + "enabled": true, "label": "New...", - "visible": TRUE + "visible": true } ] }, { "id": 95, - "enabled": TRUE, + "enabled": true, "label": "Edit", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 96, - "enabled": TRUE, + "enabled": true, "label": "Units", - "visible": TRUE + "visible": true }, { "id": 97, - "enabled": TRUE, + "enabled": true, "label": "Modules", - "visible": TRUE + "visible": true }, { "id": 98, - "enabled": TRUE, + "enabled": true, "label": "Keyboard Shortcuts", - "visible": TRUE + "visible": true }, { "id": 99, - "enabled": TRUE, + "enabled": true, "label": "Preferences", - "visible": TRUE + "visible": true }, { "id": 100, @@ -614,43 +614,43 @@ }, { "id": 101, - "enabled": FALSE, + "enabled": false, "label": "Stroke Path...", - "visible": TRUE + "visible": true }, { "id": 102, - "enabled": FALSE, + "enabled": false, "label": "Stroke Selection...", - "visible": TRUE + "visible": true }, { "id": 103, "shortcut": [["Control", "semicolon"]], - "enabled": TRUE, + "enabled": true, "label": "Fill with Pattern", - "visible": TRUE + "visible": true }, { "id": 104, "shortcut": [["Control", "period"]], - "enabled": TRUE, + "enabled": true, "label": "Fill with BG Color", - "visible": TRUE + "visible": true }, { "id": 105, "shortcut": [["Control", "comma"]], - "enabled": TRUE, + "enabled": true, "label": "Fill with FG Color", - "visible": TRUE + "visible": true }, { "id": 106, "shortcut": [["Delete"]], - "enabled": TRUE, + "enabled": true, "label": "Clear", - "visible": TRUE + "visible": true }, { "id": 107, @@ -658,104 +658,104 @@ }, { "id": 108, - "enabled": TRUE, + "enabled": true, "label": "Buffer", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 109, - "enabled": TRUE, + "enabled": true, "label": "Paste Named...", - "visible": TRUE + "visible": true }, { "id": 110, - "enabled": TRUE, + "enabled": true, "label": "Copy Visible Named...", - "visible": TRUE + "visible": true }, { "id": 111, - "enabled": TRUE, + "enabled": true, "label": "Copy Named...", - "visible": TRUE + "visible": true }, { "id": 112, - "enabled": TRUE, + "enabled": true, "label": "Cut Named...", - "visible": TRUE + "visible": true } ] }, { "id": 113, - "enabled": TRUE, + "enabled": true, "label": "Paste as", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 114, - "enabled": TRUE, + "enabled": true, "label": "New Pattern...", - "visible": TRUE + "visible": true }, { "id": 115, - "enabled": TRUE, + "enabled": true, "label": "New Brush...", - "visible": TRUE + "visible": true }, { "id": 116, - "enabled": TRUE, + "enabled": true, "label": "New Layer", - "visible": TRUE + "visible": true }, { "id": 117, "shortcut": [["Control", "Shift", "v"]], - "enabled": TRUE, + "enabled": true, "label": "New Image", - "visible": TRUE + "visible": true } ] }, { "id": 118, - "enabled": TRUE, + "enabled": true, "label": "Paste Into", - "visible": TRUE + "visible": true }, { "id": 119, "shortcut": [["Control", "v"]], - "enabled": TRUE, + "enabled": true, "label": "Paste", - "visible": TRUE + "visible": true }, { "id": 120, "shortcut": [["Control", "Shift", "c"]], - "enabled": TRUE, + "enabled": true, "label": "Copy Visible", - "visible": TRUE + "visible": true }, { "id": 121, "shortcut": [["Control", "c"]], - "enabled": TRUE, + "enabled": true, "label": "Copy", - "visible": TRUE + "visible": true }, { "id": 122, "shortcut": [["Control", "x"]], - "enabled": TRUE, + "enabled": true, "label": "Cut", - "visible": TRUE + "visible": true }, { "id": 123, @@ -763,59 +763,59 @@ }, { "id": 124, - "enabled": TRUE, + "enabled": true, "label": "Undo History", - "visible": TRUE + "visible": true }, { "id": 3, - "enabled": FALSE, + "enabled": false, "label": "_Fade...", - "visible": TRUE + "visible": true }, { "id": 2, "shortcut": [["Control", "y"]], - "enabled": FALSE, + "enabled": false, "label": "_Redo", - "visible": TRUE + "visible": true }, { "id": 1, "shortcut": [["Control", "z"]], - "enabled": FALSE, + "enabled": false, "label": "_Undo", - "visible": TRUE + "visible": true } ] }, { "id": 125, - "enabled": TRUE, + "enabled": true, "label": "Select", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 126, - "enabled": FALSE, + "enabled": false, "label": "To Path", - "visible": TRUE + "visible": true }, { "id": 127, - "enabled": TRUE, + "enabled": true, "label": "Save to Channel", - "visible": TRUE + "visible": true }, { "id": 128, "shortcut": [["Shift", "q"]], - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Toggle Quick Mask", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 129, @@ -823,39 +823,39 @@ }, { "id": 130, - "enabled": TRUE, + "enabled": true, "label": "Distort...", - "visible": TRUE + "visible": true }, { "id": 131, - "enabled": FALSE, + "enabled": false, "label": "Border...", - "visible": TRUE + "visible": true }, { "id": 132, - "enabled": FALSE, + "enabled": false, "label": "Grow...", - "visible": TRUE + "visible": true }, { "id": 133, - "enabled": FALSE, + "enabled": false, "label": "Shrink...", - "visible": TRUE + "visible": true }, { "id": 134, - "enabled": FALSE, + "enabled": false, "label": "Sharpen", - "visible": TRUE + "visible": true }, { "id": 135, - "enabled": FALSE, + "enabled": false, "label": "Feather...", - "visible": TRUE + "visible": true }, { "id": 136, @@ -863,106 +863,106 @@ }, { "id": 137, - "enabled": TRUE, + "enabled": true, "label": "Selection Editor", - "visible": TRUE + "visible": true }, { "id": 138, "shortcut": [["Shift", "v"]], - "enabled": FALSE, + "enabled": false, "label": "From Path", - "visible": TRUE + "visible": true }, { "id": 139, "shortcut": [["Shift", "o"]], - "enabled": TRUE, + "enabled": true, "label": "By Color", - "visible": TRUE + "visible": true }, { "id": 140, "shortcut": [["Control", "Shift", "l"]], - "enabled": FALSE, + "enabled": false, "label": "Float", - "visible": TRUE + "visible": true }, { "id": 141, "shortcut": [["Control", "i"]], - "enabled": TRUE, + "enabled": true, "label": "Invert", - "visible": TRUE + "visible": true }, { "id": 142, "shortcut": [["Control", "Shift", "a"]], - "enabled": FALSE, + "enabled": false, "label": "None", - "visible": TRUE + "visible": true }, { "id": 143, "shortcut": [["Control", "a"]], - "enabled": TRUE, + "enabled": true, "label": "All", - "visible": TRUE + "visible": true } ] }, { "id": 144, - "enabled": TRUE, + "enabled": true, "label": "View", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 145, - "enabled": TRUE, + "enabled": true, "toggle-state": 1, "label": "Show Statusbar", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 146, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Scrollbars", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 147, "shortcut": [["Control", "Shift", "r"]], - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Rulers", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 148, - "enabled": TRUE, + "enabled": true, "toggle-state": 1, "label": "Show Menubar", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 149, - "enabled": TRUE, + "enabled": true, "label": "Padding Color", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 150, - "enabled": TRUE, + "enabled": true, "label": "As in Preferences", - "visible": TRUE + "visible": true }, { "id": 151, @@ -970,27 +970,27 @@ }, { "id": 152, - "enabled": TRUE, + "enabled": true, "label": "Select Custom Color...", - "visible": TRUE + "visible": true }, { "id": 153, - "enabled": TRUE, + "enabled": true, "label": "Dark Check Color", - "visible": TRUE + "visible": true }, { "id": 154, - "enabled": TRUE, + "enabled": true, "label": "Light Check Color", - "visible": TRUE + "visible": true }, { "id": 155, - "enabled": TRUE, + "enabled": true, "label": "From Theme", - "visible": TRUE + "visible": true } ] }, @@ -1000,35 +1000,35 @@ }, { "id": 157, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Snap to Active Path", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 158, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Snap to Canvas Edges", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 159, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Snap to Grid", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 160, - "enabled": TRUE, + "enabled": true, "toggle-state": 1, "label": "Snap to Guides", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 161, @@ -1036,45 +1036,45 @@ }, { "id": 162, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Sample Points", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 163, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Grid", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 164, "shortcut": [["Control", "Shift", "t"]], - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Guides", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 165, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Layer Boundary", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 166, "shortcut": [["Control", "t"]], - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Show Selection", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 167, @@ -1082,15 +1082,15 @@ }, { "id": 168, - "enabled": TRUE, + "enabled": true, "label": "Display Filters...", - "visible": TRUE + "visible": true }, { "id": 169, - "enabled": TRUE, + "enabled": true, "label": "Navigation Window", - "visible": TRUE + "visible": true }, { "id": 170, @@ -1099,27 +1099,27 @@ { "id": 171, "shortcut": [["F11"]], - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Fullscreen", "toggle-type": "checkmark", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 172, - "enabled": TRUE, + "enabled": true, "label": "Open Display...", - "visible": TRUE + "visible": true } ] }, { "id": 173, "shortcut": [["Control", "e"]], - "enabled": TRUE, + "enabled": true, "label": "Shrink Wrap", - "visible": TRUE + "visible": true }, { "id": 174, @@ -1127,18 +1127,18 @@ }, { "id": 175, - "enabled": TRUE, + "enabled": true, "label": "_Zoom (67%)", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 176, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Othe_r (67%)...", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 177, @@ -1146,76 +1146,76 @@ }, { "id": 178, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "1:16 (6.25%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 179, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "1:8 (12.5%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 180, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "1:4 (25%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 181, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "1:2 (50%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 182, "shortcut": [["1"]], - "enabled": TRUE, + "enabled": true, "toggle-state": 1, "label": "1:1 (100%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 183, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "2:1 (200%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 184, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "4:1 (400%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 185, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "8:1 (800%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 186, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "16:1 (1600%)", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 187, @@ -1223,106 +1223,106 @@ }, { "id": 188, - "enabled": TRUE, + "enabled": true, "label": "Fill Window", - "visible": TRUE + "visible": true }, { "id": 189, "shortcut": [["Control", "Shift", "e"]], - "enabled": TRUE, + "enabled": true, "label": "Fit Image in Window", - "visible": TRUE + "visible": true }, { "id": 190, "shortcut": [["plus"]], - "enabled": TRUE, + "enabled": true, "label": "Zoom In", - "visible": TRUE + "visible": true }, { "id": 191, "shortcut": [["minus"]], - "enabled": TRUE, + "enabled": true, "label": "Zoom Out", - "visible": TRUE + "visible": true }, { "id": 4, "shortcut": [["grave"]], - "enabled": TRUE, + "enabled": true, "label": "Re_vert Zoom (67%)", - "visible": TRUE + "visible": true } ] }, { "id": 192, - "enabled": TRUE, + "enabled": true, "toggle-state": 1, "label": "Dot for Dot", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 193, - "enabled": TRUE, + "enabled": true, "label": "New View", - "visible": TRUE + "visible": true } ] }, { "id": 194, - "enabled": TRUE, + "enabled": true, "label": "Image", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 195, "shortcut": [["Alt", "Return"]], - "enabled": TRUE, + "enabled": true, "label": "Image Properties", - "visible": TRUE + "visible": true }, { "id": 196, - "enabled": TRUE, + "enabled": true, "label": "Configure Grid...", - "visible": TRUE + "visible": true }, { "id": 197, - "enabled": TRUE, + "enabled": true, "label": "Guides", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 198, - "enabled": TRUE, + "enabled": true, "label": "Remove all Guides", - "visible": TRUE + "visible": true }, { "id": 199, - "enabled": TRUE, + "enabled": true, "label": "New Guides from Selection", - "visible": TRUE + "visible": true }, { "id": 200, - "enabled": TRUE, + "enabled": true, "label": "New Guide...", - "visible": TRUE + "visible": true }, { "id": 201, - "enabled": TRUE, + "enabled": true, "label": "New Guide (by Percent)...", - "visible": TRUE + "visible": true } ] }, @@ -1332,22 +1332,22 @@ }, { "id": 203, - "enabled": TRUE, + "enabled": true, "label": "Align Visible Layers...", - "visible": TRUE + "visible": true }, { "id": 204, - "enabled": TRUE, + "enabled": true, "label": "Flatten Image", - "visible": TRUE + "visible": true }, { "id": 205, "shortcut": [["Control", "m"]], - "enabled": TRUE, + "enabled": true, "label": "Merge Visible Layers...", - "visible": TRUE + "visible": true }, { "id": 206, @@ -1355,21 +1355,21 @@ }, { "id": 207, - "enabled": TRUE, + "enabled": true, "label": "Zealous Crop", - "visible": TRUE + "visible": true }, { "id": 208, - "enabled": TRUE, + "enabled": true, "label": "Autocrop Image", - "visible": TRUE + "visible": true }, { "id": 209, - "enabled": FALSE, + "enabled": false, "label": "Crop to Selection", - "visible": TRUE + "visible": true }, { "id": 210, @@ -1377,33 +1377,33 @@ }, { "id": 211, - "enabled": TRUE, + "enabled": true, "label": "Scale Image...", - "visible": TRUE + "visible": true }, { "id": 212, - "enabled": TRUE, + "enabled": true, "label": "Print Size...", - "visible": TRUE + "visible": true }, { "id": 213, - "enabled": FALSE, + "enabled": false, "label": "Fit Canvas to Selection", - "visible": TRUE + "visible": true }, { "id": 214, - "enabled": TRUE, + "enabled": true, "label": "Fit Canvas to Layers", - "visible": TRUE + "visible": true }, { "id": 215, - "enabled": TRUE, + "enabled": true, "label": "Canvas Size...", - "visible": TRUE + "visible": true }, { "id": 216, @@ -1411,16 +1411,16 @@ }, { "id": 217, - "enabled": TRUE, + "enabled": true, "label": "Transform", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 218, - "enabled": TRUE, + "enabled": true, "label": "Guillotine", - "visible": TRUE + "visible": true }, { "id": 219, @@ -1428,21 +1428,21 @@ }, { "id": 220, - "enabled": TRUE, + "enabled": true, "label": "Rotate 180\302\260", - "visible": TRUE + "visible": true }, { "id": 221, - "enabled": TRUE, + "enabled": true, "label": "Rotate 90\302\260 counter-clockwise", - "visible": TRUE + "visible": true }, { "id": 222, - "enabled": TRUE, + "enabled": true, "label": "Rotate 90\302\260 clockwise", - "visible": TRUE + "visible": true }, { "id": 223, @@ -1450,36 +1450,36 @@ }, { "id": 224, - "enabled": TRUE, + "enabled": true, "label": "Flip Vertically", - "visible": TRUE + "visible": true }, { "id": 225, - "enabled": TRUE, + "enabled": true, "label": "Flip Horizontally", - "visible": TRUE + "visible": true } ] }, { "id": 226, - "enabled": TRUE, + "enabled": true, "label": "Mode", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 227, - "enabled": TRUE, + "enabled": true, "label": "Convert to Color Profile...", - "visible": TRUE + "visible": true }, { "id": 228, - "enabled": TRUE, + "enabled": true, "label": "Assign Color Profile...", - "visible": TRUE + "visible": true }, { "id": 229, @@ -1487,75 +1487,75 @@ }, { "id": 230, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Indexed...", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 231, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Grayscale", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 232, - "enabled": TRUE, + "enabled": true, "toggle-state": 1, "label": "RGB", "toggle-type": "checkmark", - "visible": TRUE + "visible": true } ] }, { "id": 233, "shortcut": [["Control", "d"]], - "enabled": TRUE, + "enabled": true, "label": "Duplicate", - "visible": TRUE + "visible": true } ] }, { "id": 234, - "enabled": TRUE, + "enabled": true, "label": "Layer", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 235, - "enabled": TRUE, + "enabled": true, "label": "Autocrop Layer", - "visible": TRUE + "visible": true }, { "id": 236, - "enabled": FALSE, + "enabled": false, "label": "Crop to Selection", - "visible": TRUE + "visible": true }, { "id": 237, - "enabled": TRUE, + "enabled": true, "label": "Scale Layer...", - "visible": TRUE + "visible": true }, { "id": 238, - "enabled": TRUE, + "enabled": true, "label": "Layer to Image Size", - "visible": TRUE + "visible": true }, { "id": 239, - "enabled": TRUE, + "enabled": true, "label": "Layer Boundary Size...", - "visible": TRUE + "visible": true }, { "id": 240, @@ -1563,17 +1563,17 @@ }, { "id": 241, - "enabled": TRUE, + "enabled": true, "label": "Transform", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 242, "shortcut": [["Control", "Shift", "o"]], - "enabled": TRUE, + "enabled": true, "label": "Offset...", - "visible": TRUE + "visible": true }, { "id": 243, @@ -1581,27 +1581,27 @@ }, { "id": 244, - "enabled": TRUE, + "enabled": true, "label": "Arbitrary Rotation...", - "visible": TRUE + "visible": true }, { "id": 245, - "enabled": TRUE, + "enabled": true, "label": "Rotate 180\302\260", - "visible": TRUE + "visible": true }, { "id": 246, - "enabled": TRUE, + "enabled": true, "label": "Rotate 90\302\260 counter-clockwise", - "visible": TRUE + "visible": true }, { "id": 247, - "enabled": TRUE, + "enabled": true, "label": "Rotate 90\302\260 clockwise", - "visible": TRUE + "visible": true }, { "id": 248, @@ -1609,48 +1609,48 @@ }, { "id": 249, - "enabled": TRUE, + "enabled": true, "label": "Flip Vertically", - "visible": TRUE + "visible": true }, { "id": 250, - "enabled": TRUE, + "enabled": true, "label": "Flip Horizontally", - "visible": TRUE + "visible": true } ] }, { "id": 251, - "enabled": TRUE, + "enabled": true, "label": "Transparency", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 252, - "enabled": TRUE, + "enabled": true, "label": "Intersect with Selection", - "visible": TRUE + "visible": true }, { "id": 253, - "enabled": TRUE, + "enabled": true, "label": "Subtract from Selection", - "visible": TRUE + "visible": true }, { "id": 254, - "enabled": TRUE, + "enabled": true, "label": "Add to Selection", - "visible": TRUE + "visible": true }, { "id": 255, - "enabled": TRUE, + "enabled": true, "label": "Alpha to Selection", - "visible": TRUE + "visible": true }, { "id": 256, @@ -1658,66 +1658,66 @@ }, { "id": 257, - "enabled": TRUE, + "enabled": true, "label": "Threshold Alpha...", - "visible": TRUE + "visible": true }, { "id": 258, - "enabled": TRUE, + "enabled": true, "label": "Semi-Flatten", - "visible": TRUE + "visible": true }, { "id": 259, - "enabled": TRUE, + "enabled": true, "label": "Color to Alpha...", - "visible": TRUE + "visible": true }, { "id": 260, - "enabled": TRUE, + "enabled": true, "label": "Remove Alpha Channel", - "visible": TRUE + "visible": true }, { "id": 261, - "enabled": FALSE, + "enabled": false, "label": "Add Alpha Channel", - "visible": TRUE + "visible": true } ] }, { "id": 262, - "enabled": TRUE, + "enabled": true, "label": "Mask", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 263, - "enabled": FALSE, + "enabled": false, "label": "Intersect with Selection", - "visible": TRUE + "visible": true }, { "id": 264, - "enabled": FALSE, + "enabled": false, "label": "Subtract from Selection", - "visible": TRUE + "visible": true }, { "id": 265, - "enabled": FALSE, + "enabled": false, "label": "Add to Selection", - "visible": TRUE + "visible": true }, { "id": 266, - "enabled": FALSE, + "enabled": false, "label": "Mask to Selection", - "visible": TRUE + "visible": true }, { "id": 267, @@ -1725,27 +1725,27 @@ }, { "id": 268, - "enabled": FALSE, + "enabled": false, "toggle-state": 0, "label": "Disable Layer Mask", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 269, - "enabled": FALSE, + "enabled": false, "toggle-state": 0, "label": "Edit Layer Mask", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 270, - "enabled": FALSE, + "enabled": false, "toggle-state": 0, "label": "Show Layer Mask", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 271, @@ -1753,36 +1753,36 @@ }, { "id": 272, - "enabled": FALSE, + "enabled": false, "label": "Delete Layer Mask", - "visible": TRUE + "visible": true }, { "id": 273, - "enabled": FALSE, + "enabled": false, "label": "Apply Layer Mask", - "visible": TRUE + "visible": true }, { "id": 274, - "enabled": TRUE, + "enabled": true, "label": "Add Layer Mask...", - "visible": TRUE + "visible": true } ] }, { "id": 275, - "enabled": TRUE, + "enabled": true, "label": "Stack", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 276, - "enabled": TRUE, + "enabled": true, "label": "Reverse Layer Order", - "visible": TRUE + "visible": true }, { "id": 277, @@ -1790,27 +1790,27 @@ }, { "id": 278, - "enabled": FALSE, + "enabled": false, "label": "Layer to Bottom", - "visible": TRUE + "visible": true }, { "id": 279, - "enabled": FALSE, + "enabled": false, "label": "Layer to Top", - "visible": TRUE + "visible": true }, { "id": 280, - "enabled": FALSE, + "enabled": false, "label": "Lower Layer", - "visible": TRUE + "visible": true }, { "id": 281, - "enabled": FALSE, + "enabled": false, "label": "Raise Layer", - "visible": TRUE + "visible": true }, { "id": 282, @@ -1819,30 +1819,30 @@ { "id": 283, "shortcut": [["End"]], - "enabled": FALSE, + "enabled": false, "label": "Select Bottom Layer", - "visible": TRUE + "visible": true }, { "id": 284, "shortcut": [["Home"]], - "enabled": FALSE, + "enabled": false, "label": "Select Top Layer", - "visible": TRUE + "visible": true }, { "id": 285, "shortcut": [["Page_Down"]], - "enabled": FALSE, + "enabled": false, "label": "Select Next Layer", - "visible": TRUE + "visible": true }, { "id": 286, "shortcut": [["Page_Up"]], - "enabled": FALSE, + "enabled": false, "label": "Select Previous Layer", - "visible": TRUE + "visible": true } ] }, @@ -1853,95 +1853,95 @@ "submenu": [ { "id": 288, - "enabled": FALSE, + "enabled": false, "label": "Empty", - "visible": TRUE + "visible": true } ] }, { "id": 289, - "enabled": TRUE, + "enabled": true, "label": "Delete Layer", - "visible": TRUE + "visible": true }, { "id": 290, - "enabled": FALSE, + "enabled": false, "label": "Merge Down", - "visible": TRUE + "visible": true }, { "id": 291, "shortcut": [["Control", "h"]], - "enabled": FALSE, + "enabled": false, "label": "Anchor Layer", - "visible": TRUE + "visible": true }, { "id": 292, "shortcut": [["Control", "Shift", "d"]], - "enabled": TRUE, + "enabled": true, "label": "Duplicate Layer", - "visible": TRUE + "visible": true }, { "id": 293, - "enabled": TRUE, + "enabled": true, "label": "New from Visible", - "visible": TRUE + "visible": true }, { "id": 294, "shortcut": [["Control", "Shift", "n"]], - "enabled": TRUE, + "enabled": true, "label": "New Layer...", - "visible": TRUE + "visible": true } ] }, { "id": 295, - "enabled": TRUE, + "enabled": true, "label": "Colors", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 296, - "enabled": TRUE, + "enabled": true, "label": "Retinex...", - "visible": TRUE + "visible": true }, { "id": 297, - "enabled": TRUE, + "enabled": true, "label": "Maximum RGB...", - "visible": TRUE + "visible": true }, { "id": 298, - "enabled": FALSE, + "enabled": false, "label": "Hot...", - "visible": TRUE + "visible": true }, { "id": 299, - "enabled": TRUE, + "enabled": true, "label": "Filter Pack...", - "visible": TRUE + "visible": true }, { "id": 300, - "enabled": TRUE, + "enabled": true, "label": "Color to Alpha...", - "visible": TRUE + "visible": true }, { "id": 301, - "enabled": TRUE, + "enabled": true, "label": "Colorify...", - "visible": TRUE + "visible": true }, { "id": 302, @@ -1949,79 +1949,79 @@ }, { "id": 303, - "enabled": TRUE, + "enabled": true, "label": "Info", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 304, - "enabled": TRUE, + "enabled": true, "label": "Smooth Palette...", - "visible": TRUE + "visible": true }, { "id": 305, - "enabled": TRUE, + "enabled": true, "label": "Colorcube Analysis...", - "visible": TRUE + "visible": true }, { "id": 306, - "enabled": TRUE, + "enabled": true, "label": "Border Average...", - "visible": TRUE + "visible": true }, { "id": 307, - "enabled": TRUE, + "enabled": true, "label": "Histogram", - "visible": TRUE + "visible": true } ] }, { "id": 308, - "enabled": TRUE, + "enabled": true, "label": "Map", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 309, - "enabled": TRUE, + "enabled": true, "label": "Sample Colorize...", - "visible": TRUE + "visible": true }, { "id": 310, - "enabled": TRUE, + "enabled": true, "label": "Rotate Colors...", - "visible": TRUE + "visible": true }, { "id": 311, - "enabled": TRUE, + "enabled": true, "label": "Palette Map", - "visible": TRUE + "visible": true }, { "id": 312, - "enabled": TRUE, + "enabled": true, "label": "Gradient Map", - "visible": TRUE + "visible": true }, { "id": 313, - "enabled": TRUE, + "enabled": true, "label": "Color Exchange...", - "visible": TRUE + "visible": true }, { "id": 314, - "enabled": TRUE, + "enabled": true, "label": "Alien Map...", - "visible": TRUE + "visible": true }, { "id": 315, @@ -2029,93 +2029,93 @@ }, { "id": 316, - "enabled": FALSE, + "enabled": false, "label": "Set Colormap...", - "visible": TRUE + "visible": true }, { "id": 317, - "enabled": FALSE, + "enabled": false, "label": "Rearrange Colormap...", - "visible": TRUE + "visible": true } ] }, { "id": 318, - "enabled": TRUE, + "enabled": true, "label": "Components", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 319, - "enabled": FALSE, + "enabled": false, "label": "Recompose", - "visible": TRUE + "visible": true }, { "id": 320, - "enabled": TRUE, + "enabled": true, "label": "Decompose...", - "visible": TRUE + "visible": true }, { "id": 321, - "enabled": FALSE, + "enabled": false, "label": "Compose...", - "visible": TRUE + "visible": true }, { "id": 322, - "enabled": TRUE, + "enabled": true, "label": "Channel Mixer...", - "visible": TRUE + "visible": true } ] }, { "id": 323, - "enabled": TRUE, + "enabled": true, "label": "Auto", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 324, - "enabled": TRUE, + "enabled": true, "label": "Stretch HSV", - "visible": TRUE + "visible": true }, { "id": 325, - "enabled": TRUE, + "enabled": true, "label": "Stretch Contrast", - "visible": TRUE + "visible": true }, { "id": 326, - "enabled": TRUE, + "enabled": true, "label": "Normalize", - "visible": TRUE + "visible": true }, { "id": 327, - "enabled": TRUE, + "enabled": true, "label": "Color Enhance", - "visible": TRUE + "visible": true }, { "id": 328, - "enabled": TRUE, + "enabled": true, "label": "White Balance", - "visible": TRUE + "visible": true }, { "id": 329, - "enabled": TRUE, + "enabled": true, "label": "Equalize", - "visible": TRUE + "visible": true } ] }, @@ -2125,11 +2125,11 @@ }, { "id": 331, - "enabled": TRUE, + "enabled": true, "toggle-state": 0, "label": "Use GEGL", "toggle-type": "checkmark", - "visible": TRUE + "visible": true }, { "id": 332, @@ -2137,15 +2137,15 @@ }, { "id": 333, - "enabled": TRUE, + "enabled": true, "label": "Value Invert", - "visible": TRUE + "visible": true }, { "id": 334, - "enabled": TRUE, + "enabled": true, "label": "Invert", - "visible": TRUE + "visible": true }, { "id": 335, @@ -2153,87 +2153,87 @@ }, { "id": 336, - "enabled": TRUE, + "enabled": true, "label": "Desaturate...", - "visible": TRUE + "visible": true }, { "id": 337, - "enabled": TRUE, + "enabled": true, "label": "Posterize...", - "visible": TRUE + "visible": true }, { "id": 338, - "enabled": TRUE, + "enabled": true, "label": "Curves...", - "visible": TRUE + "visible": true }, { "id": 339, - "enabled": TRUE, + "enabled": true, "label": "Levels...", - "visible": TRUE + "visible": true }, { "id": 340, - "enabled": TRUE, + "enabled": true, "label": "Threshold...", - "visible": TRUE + "visible": true }, { "id": 341, - "enabled": TRUE, + "enabled": true, "label": "Brightness-Contrast...", - "visible": TRUE + "visible": true }, { "id": 342, - "enabled": TRUE, + "enabled": true, "label": "Colorize...", - "visible": TRUE + "visible": true }, { "id": 343, - "enabled": TRUE, + "enabled": true, "label": "Hue-Saturation...", - "visible": TRUE + "visible": true }, { "id": 344, - "enabled": TRUE, + "enabled": true, "label": "Color Balance...", - "visible": TRUE + "visible": true } ] }, { "id": 345, - "enabled": TRUE, + "enabled": true, "label": "Tools", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 346, "shortcut": [["x"]], - "enabled": TRUE, + "enabled": true, "label": "Swap Colors", - "visible": TRUE + "visible": true }, { "id": 347, "shortcut": [["d"]], - "enabled": TRUE, + "enabled": true, "label": "Default Colors", - "visible": TRUE + "visible": true }, { "id": 348, "shortcut": [["Control", "b"]], - "enabled": TRUE, + "enabled": true, "label": "Toolbox", - "visible": TRUE + "visible": true }, { "id": 349, @@ -2241,326 +2241,326 @@ }, { "id": 350, - "enabled": TRUE, + "enabled": true, "label": "GEGL Operation...", - "visible": TRUE + "visible": true }, { "id": 351, "shortcut": [["t"]], - "enabled": TRUE, + "enabled": true, "label": "Text", - "visible": TRUE + "visible": true }, { "id": 352, "shortcut": [["Shift", "m"]], - "enabled": TRUE, + "enabled": true, "label": "Measure", - "visible": TRUE + "visible": true }, { "id": 353, "shortcut": [["z"]], - "enabled": TRUE, + "enabled": true, "label": "Zoom", - "visible": TRUE + "visible": true }, { "id": 354, "shortcut": [["o"]], - "enabled": TRUE, + "enabled": true, "label": "Color Picker", - "visible": TRUE + "visible": true }, { "id": 355, "shortcut": [["b"]], - "enabled": TRUE, + "enabled": true, "label": "Paths", - "visible": TRUE + "visible": true }, { "id": 356, - "enabled": TRUE, + "enabled": true, "label": "Color Tools", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 357, - "enabled": TRUE, + "enabled": true, "label": "Desaturate...", - "visible": TRUE + "visible": true }, { "id": 358, - "enabled": TRUE, + "enabled": true, "label": "Posterize...", - "visible": TRUE + "visible": true }, { "id": 359, - "enabled": TRUE, + "enabled": true, "label": "Curves...", - "visible": TRUE + "visible": true }, { "id": 360, - "enabled": TRUE, + "enabled": true, "label": "Levels...", - "visible": TRUE + "visible": true }, { "id": 361, - "enabled": TRUE, + "enabled": true, "label": "Threshold...", - "visible": TRUE + "visible": true }, { "id": 362, - "enabled": TRUE, + "enabled": true, "label": "Brightness-Contrast...", - "visible": TRUE + "visible": true }, { "id": 363, - "enabled": TRUE, + "enabled": true, "label": "Colorize...", - "visible": TRUE + "visible": true }, { "id": 364, - "enabled": TRUE, + "enabled": true, "label": "Hue-Saturation...", - "visible": TRUE + "visible": true }, { "id": 365, - "enabled": TRUE, + "enabled": true, "label": "Color Balance...", - "visible": TRUE + "visible": true } ] }, { "id": 366, - "enabled": TRUE, + "enabled": true, "label": "Transform Tools", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 367, "shortcut": [["Shift", "f"]], - "enabled": TRUE, + "enabled": true, "label": "Flip", - "visible": TRUE + "visible": true }, { "id": 368, "shortcut": [["Shift", "p"]], - "enabled": TRUE, + "enabled": true, "label": "Perspective", - "visible": TRUE + "visible": true }, { "id": 369, "shortcut": [["Shift", "s"]], - "enabled": TRUE, + "enabled": true, "label": "Shear", - "visible": TRUE + "visible": true }, { "id": 370, "shortcut": [["Shift", "t"]], - "enabled": TRUE, + "enabled": true, "label": "Scale", - "visible": TRUE + "visible": true }, { "id": 371, "shortcut": [["Shift", "r"]], - "enabled": TRUE, + "enabled": true, "label": "Rotate", - "visible": TRUE + "visible": true }, { "id": 372, "shortcut": [["Shift", "c"]], - "enabled": TRUE, + "enabled": true, "label": "Crop", - "visible": TRUE + "visible": true }, { "id": 373, "shortcut": [["m"]], - "enabled": TRUE, + "enabled": true, "label": "Move", - "visible": TRUE + "visible": true }, { "id": 374, "shortcut": [["q"]], - "enabled": TRUE, + "enabled": true, "label": "Align", - "visible": TRUE + "visible": true } ] }, { "id": 375, - "enabled": TRUE, + "enabled": true, "label": "Paint Tools", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 376, "shortcut": [["Shift", "d"]], - "enabled": TRUE, + "enabled": true, "label": "Dodge / Burn", - "visible": TRUE + "visible": true }, { "id": 377, "shortcut": [["s"]], - "enabled": TRUE, + "enabled": true, "label": "Smudge", - "visible": TRUE + "visible": true }, { "id": 378, "shortcut": [["Shift", "u"]], - "enabled": TRUE, + "enabled": true, "label": "Blur / Sharpen", - "visible": TRUE + "visible": true }, { "id": 379, - "enabled": TRUE, + "enabled": true, "label": "Perspective Clone", - "visible": TRUE + "visible": true }, { "id": 380, "shortcut": [["h"]], - "enabled": TRUE, + "enabled": true, "label": "Heal", - "visible": TRUE + "visible": true }, { "id": 381, "shortcut": [["c"]], - "enabled": TRUE, + "enabled": true, "label": "Clone", - "visible": TRUE + "visible": true }, { "id": 382, "shortcut": [["k"]], - "enabled": TRUE, + "enabled": true, "label": "Ink", - "visible": TRUE + "visible": true }, { "id": 383, "shortcut": [["a"]], - "enabled": TRUE, + "enabled": true, "label": "Airbrush", - "visible": TRUE + "visible": true }, { "id": 384, "shortcut": [["Shift", "e"]], - "enabled": TRUE, + "enabled": true, "label": "Eraser", - "visible": TRUE + "visible": true }, { "id": 385, "shortcut": [["p"]], - "enabled": TRUE, + "enabled": true, "label": "Paintbrush", - "visible": TRUE + "visible": true }, { "id": 386, "shortcut": [["n"]], - "enabled": TRUE, + "enabled": true, "label": "Pencil", - "visible": TRUE + "visible": true }, { "id": 387, "shortcut": [["l"]], - "enabled": TRUE, + "enabled": true, "label": "Blend", - "visible": TRUE + "visible": true }, { "id": 388, "shortcut": [["Shift", "b"]], - "enabled": TRUE, + "enabled": true, "label": "Bucket Fill", - "visible": TRUE + "visible": true } ] }, { "id": 389, - "enabled": TRUE, + "enabled": true, "label": "Selection Tools", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 390, "shortcut": [["i"]], - "enabled": TRUE, + "enabled": true, "label": "Intelligent Scissors", - "visible": TRUE + "visible": true }, { "id": 391, "shortcut": [["Shift", "o"]], - "enabled": TRUE, + "enabled": true, "label": "By Color Select", - "visible": TRUE + "visible": true }, { "id": 392, "shortcut": [["u"]], - "enabled": TRUE, + "enabled": true, "label": "Fuzzy Select", - "visible": TRUE + "visible": true }, { "id": 393, - "enabled": TRUE, + "enabled": true, "label": "Foreground Select", - "visible": TRUE + "visible": true }, { "id": 394, "shortcut": [["f"]], - "enabled": TRUE, + "enabled": true, "label": "Free Select", - "visible": TRUE + "visible": true }, { "id": 395, "shortcut": [["e"]], - "enabled": TRUE, + "enabled": true, "label": "Ellipse Select", - "visible": TRUE + "visible": true }, { "id": 396, "shortcut": [["r"]], - "enabled": TRUE, + "enabled": true, "label": "Rectangle Select", - "visible": TRUE + "visible": true } ] } @@ -2568,50 +2568,50 @@ }, { "id": 397, - "enabled": TRUE, + "enabled": true, "label": "Filters", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 398, - "enabled": TRUE, + "enabled": true, "label": "Script-Fu", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 399, - "enabled": TRUE, + "enabled": true, "label": "Start Server...", - "visible": TRUE + "visible": true }, { "id": 400, - "enabled": TRUE, + "enabled": true, "label": "Refresh Scripts", - "visible": TRUE + "visible": true }, { "id": 401, - "enabled": TRUE, + "enabled": true, "label": "Console", - "visible": TRUE + "visible": true } ] }, { "id": 402, - "enabled": TRUE, + "enabled": true, "label": "Python-Fu", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 403, - "enabled": TRUE, + "enabled": true, "label": "Console", - "visible": TRUE + "visible": true } ] }, @@ -2621,124 +2621,124 @@ }, { "id": 405, - "enabled": TRUE, + "enabled": true, "label": "Alpha to Logo", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 406, - "enabled": TRUE, + "enabled": true, "label": "Textured...", - "visible": TRUE + "visible": true }, { "id": 407, - "enabled": TRUE, + "enabled": true, "label": "Particle Trace...", - "visible": TRUE + "visible": true }, { "id": 408, - "enabled": TRUE, + "enabled": true, "label": "Neon...", - "visible": TRUE + "visible": true }, { "id": 409, - "enabled": TRUE, + "enabled": true, "label": "Gradient Bevel...", - "visible": TRUE + "visible": true }, { "id": 410, - "enabled": TRUE, + "enabled": true, "label": "Glowing Hot...", - "visible": TRUE + "visible": true }, { "id": 411, - "enabled": TRUE, + "enabled": true, "label": "Glossy...", - "visible": TRUE + "visible": true }, { "id": 412, - "enabled": TRUE, + "enabled": true, "label": "Frosty...", - "visible": TRUE + "visible": true }, { "id": 413, - "enabled": TRUE, + "enabled": true, "label": "Cool Metal...", - "visible": TRUE + "visible": true }, { "id": 414, - "enabled": TRUE, + "enabled": true, "label": "Comic Book...", - "visible": TRUE + "visible": true }, { "id": 415, - "enabled": TRUE, + "enabled": true, "label": "Chrome...", - "visible": TRUE + "visible": true }, { "id": 416, - "enabled": TRUE, + "enabled": true, "label": "Chip Away...", - "visible": TRUE + "visible": true }, { "id": 417, - "enabled": TRUE, + "enabled": true, "label": "Chalk...", - "visible": TRUE + "visible": true }, { "id": 418, - "enabled": TRUE, + "enabled": true, "label": "Bovination...", - "visible": TRUE + "visible": true }, { "id": 419, - "enabled": TRUE, + "enabled": true, "label": "Blended...", - "visible": TRUE + "visible": true }, { "id": 420, - "enabled": TRUE, + "enabled": true, "label": "Basic I...", - "visible": TRUE + "visible": true }, { "id": 421, - "enabled": TRUE, + "enabled": true, "label": "Basic II...", - "visible": TRUE + "visible": true }, { "id": 422, - "enabled": TRUE, + "enabled": true, "label": "Alien Neon...", - "visible": TRUE + "visible": true }, { "id": 423, - "enabled": TRUE, + "enabled": true, "label": "Alien Glow...", - "visible": TRUE + "visible": true }, { "id": 424, - "enabled": TRUE, + "enabled": true, "label": "3D Outline...", - "visible": TRUE + "visible": true } ] }, @@ -2748,34 +2748,34 @@ }, { "id": 426, - "enabled": TRUE, + "enabled": true, "label": "Animation", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 427, - "enabled": TRUE, + "enabled": true, "label": "Unoptimize", - "visible": TRUE + "visible": true }, { "id": 428, - "enabled": TRUE, + "enabled": true, "label": "Playback...", - "visible": TRUE + "visible": true }, { "id": 429, - "enabled": TRUE, + "enabled": true, "label": "Optimize (for GIF)", - "visible": TRUE + "visible": true }, { "id": 430, - "enabled": TRUE, + "enabled": true, "label": "Optimize (Difference)", - "visible": TRUE + "visible": true }, { "id": 431, @@ -2783,111 +2783,111 @@ }, { "id": 432, - "enabled": TRUE, + "enabled": true, "label": "Waves...", - "visible": TRUE + "visible": true }, { "id": 433, - "enabled": TRUE, + "enabled": true, "label": "Spinning Globe...", - "visible": TRUE + "visible": true }, { "id": 434, - "enabled": TRUE, + "enabled": true, "label": "Rippling...", - "visible": TRUE + "visible": true }, { "id": 435, - "enabled": TRUE, + "enabled": true, "label": "Burn-In...", - "visible": TRUE + "visible": true }, { "id": 436, - "enabled": TRUE, + "enabled": true, "label": "Blend...", - "visible": TRUE + "visible": true } ] }, { "id": 437, - "enabled": TRUE, + "enabled": true, "label": "Web", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 438, - "enabled": TRUE, + "enabled": true, "label": "Slice...", - "visible": TRUE + "visible": true }, { "id": 439, - "enabled": TRUE, + "enabled": true, "label": "Semi-Flatten", - "visible": TRUE + "visible": true }, { "id": 440, - "enabled": TRUE, + "enabled": true, "label": "Image Map...", - "visible": TRUE + "visible": true } ] }, { "id": 441, - "enabled": TRUE, + "enabled": true, "label": "Render", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 442, - "enabled": TRUE, + "enabled": true, "label": "Spyrogimp...", - "visible": TRUE + "visible": true }, { "id": 443, - "enabled": TRUE, + "enabled": true, "label": "Sphere Designer...", - "visible": TRUE + "visible": true }, { "id": 444, - "enabled": TRUE, + "enabled": true, "label": "Line Nova...", - "visible": TRUE + "visible": true }, { "id": 445, - "enabled": TRUE, + "enabled": true, "label": "Lava...", - "visible": TRUE + "visible": true }, { "id": 446, - "enabled": TRUE, + "enabled": true, "label": "Gfig...", - "visible": TRUE + "visible": true }, { "id": 447, - "enabled": TRUE, + "enabled": true, "label": "Fractal Explorer...", - "visible": TRUE + "visible": true }, { "id": 448, - "enabled": TRUE, + "enabled": true, "label": "Circuit...", - "visible": TRUE + "visible": true }, { "id": 449, @@ -2895,112 +2895,112 @@ }, { "id": 450, - "enabled": TRUE, + "enabled": true, "label": "Pattern", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 451, - "enabled": TRUE, + "enabled": true, "label": "Sinus...", - "visible": TRUE + "visible": true }, { "id": 452, - "enabled": TRUE, + "enabled": true, "label": "Qbist...", - "visible": TRUE + "visible": true }, { "id": 453, - "enabled": TRUE, + "enabled": true, "label": "Maze...", - "visible": TRUE + "visible": true }, { "id": 454, - "enabled": TRUE, + "enabled": true, "label": "Jigsaw...", - "visible": TRUE + "visible": true }, { "id": 455, - "enabled": TRUE, + "enabled": true, "label": "Grid...", - "visible": TRUE + "visible": true }, { "id": 456, - "enabled": TRUE, + "enabled": true, "label": "Diffraction Patterns...", - "visible": TRUE + "visible": true }, { "id": 457, - "enabled": TRUE, + "enabled": true, "label": "CML Explorer...", - "visible": TRUE + "visible": true }, { "id": 458, - "enabled": TRUE, + "enabled": true, "label": "Checkerboard...", - "visible": TRUE + "visible": true } ] }, { "id": 459, - "enabled": TRUE, + "enabled": true, "label": "Nature", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 460, - "enabled": TRUE, + "enabled": true, "label": "IFS Fractal...", - "visible": TRUE + "visible": true }, { "id": 461, - "enabled": TRUE, + "enabled": true, "label": "Flame...", - "visible": TRUE + "visible": true } ] }, { "id": 462, - "enabled": TRUE, + "enabled": true, "label": "Clouds", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 463, - "enabled": TRUE, + "enabled": true, "label": "Solid Noise...", - "visible": TRUE + "visible": true }, { "id": 464, - "enabled": TRUE, + "enabled": true, "label": "Plasma...", - "visible": TRUE + "visible": true }, { "id": 465, - "enabled": TRUE, + "enabled": true, "label": "Fog...", - "visible": TRUE + "visible": true }, { "id": 466, - "enabled": TRUE, + "enabled": true, "label": "Difference Clouds...", - "visible": TRUE + "visible": true } ] } @@ -3008,361 +3008,361 @@ }, { "id": 467, - "enabled": TRUE, + "enabled": true, "label": "Map", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 468, - "enabled": TRUE, + "enabled": true, "label": "Warp...", - "visible": TRUE + "visible": true }, { "id": 469, - "enabled": TRUE, + "enabled": true, "label": "Tile...", - "visible": TRUE + "visible": true }, { "id": 470, - "enabled": TRUE, + "enabled": true, "label": "Small Tiles...", - "visible": TRUE + "visible": true }, { "id": 471, - "enabled": TRUE, + "enabled": true, "label": "Paper Tile...", - "visible": TRUE + "visible": true }, { "id": 472, - "enabled": TRUE, + "enabled": true, "label": "Map Object...", - "visible": TRUE + "visible": true }, { "id": 473, - "enabled": TRUE, + "enabled": true, "label": "Make Seamless", - "visible": TRUE + "visible": true }, { "id": 474, - "enabled": TRUE, + "enabled": true, "label": "Illusion...", - "visible": TRUE + "visible": true }, { "id": 475, - "enabled": TRUE, + "enabled": true, "label": "Fractal Trace...", - "visible": TRUE + "visible": true }, { "id": 476, - "enabled": TRUE, + "enabled": true, "label": "Displace...", - "visible": TRUE + "visible": true }, { "id": 477, - "enabled": TRUE, + "enabled": true, "label": "Bump Map...", - "visible": TRUE + "visible": true } ] }, { "id": 478, - "enabled": TRUE, + "enabled": true, "label": "Decor", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 479, - "enabled": FALSE, + "enabled": false, "label": "Stencil Chrome...", - "visible": TRUE + "visible": true }, { "id": 480, - "enabled": FALSE, + "enabled": false, "label": "Stencil Carve...", - "visible": TRUE + "visible": true }, { "id": 481, - "enabled": FALSE, + "enabled": false, "label": "Slide...", - "visible": TRUE + "visible": true }, { "id": 482, - "enabled": FALSE, + "enabled": false, "label": "Round Corners...", - "visible": TRUE + "visible": true }, { "id": 483, - "enabled": TRUE, + "enabled": true, "label": "Old Photo...", - "visible": TRUE + "visible": true }, { "id": 484, - "enabled": TRUE, + "enabled": true, "label": "Fuzzy Border...", - "visible": TRUE + "visible": true }, { "id": 485, - "enabled": TRUE, + "enabled": true, "label": "Coffee Stain...", - "visible": TRUE + "visible": true }, { "id": 486, - "enabled": TRUE, + "enabled": true, "label": "Add Border...", - "visible": TRUE + "visible": true }, { "id": 487, - "enabled": TRUE, + "enabled": true, "label": "Add Bevel...", - "visible": TRUE + "visible": true } ] }, { "id": 488, - "enabled": TRUE, + "enabled": true, "label": "Artistic", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 489, - "enabled": TRUE, + "enabled": true, "label": "Weave...", - "visible": TRUE + "visible": true }, { "id": 490, - "enabled": TRUE, + "enabled": true, "label": "Van Gogh (LIC)...", - "visible": TRUE + "visible": true }, { "id": 491, - "enabled": TRUE, + "enabled": true, "label": "Softglow...", - "visible": TRUE + "visible": true }, { "id": 492, - "enabled": TRUE, + "enabled": true, "label": "Predator...", - "visible": TRUE + "visible": true }, { "id": 493, - "enabled": TRUE, + "enabled": true, "label": "Photocopy...", - "visible": TRUE + "visible": true }, { "id": 494, - "enabled": TRUE, + "enabled": true, "label": "Oilify...", - "visible": TRUE + "visible": true }, { "id": 495, - "enabled": TRUE, + "enabled": true, "label": "GIMPressionist...", - "visible": TRUE + "visible": true }, { "id": 496, - "enabled": TRUE, + "enabled": true, "label": "Cubism...", - "visible": TRUE + "visible": true }, { "id": 497, - "enabled": TRUE, + "enabled": true, "label": "Clothify...", - "visible": TRUE + "visible": true }, { "id": 498, - "enabled": TRUE, + "enabled": true, "label": "Cartoon...", - "visible": TRUE + "visible": true }, { "id": 499, - "enabled": TRUE, + "enabled": true, "label": "Apply Canvas...", - "visible": TRUE + "visible": true } ] }, { "id": 500, - "enabled": TRUE, + "enabled": true, "label": "Combine", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 501, - "enabled": TRUE, + "enabled": true, "label": "Filmstrip...", - "visible": TRUE + "visible": true }, { "id": 502, - "enabled": TRUE, + "enabled": true, "label": "Depth Merge...", - "visible": TRUE + "visible": true } ] }, { "id": 503, - "enabled": TRUE, + "enabled": true, "label": "Generic", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 504, - "enabled": TRUE, + "enabled": true, "label": "Erode", - "visible": TRUE + "visible": true }, { "id": 505, - "enabled": TRUE, + "enabled": true, "label": "Dilate", - "visible": TRUE + "visible": true }, { "id": 506, - "enabled": TRUE, + "enabled": true, "label": "Convolution Matrix...", - "visible": TRUE + "visible": true } ] }, { "id": 507, - "enabled": TRUE, + "enabled": true, "label": "Edge-Detect", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 508, - "enabled": TRUE, + "enabled": true, "label": "Sobel...", - "visible": TRUE + "visible": true }, { "id": 509, - "enabled": TRUE, + "enabled": true, "label": "Neon...", - "visible": TRUE + "visible": true }, { "id": 510, - "enabled": TRUE, + "enabled": true, "label": "Laplace", - "visible": TRUE + "visible": true }, { "id": 511, - "enabled": TRUE, + "enabled": true, "label": "Edge...", - "visible": TRUE + "visible": true }, { "id": 512, - "enabled": TRUE, + "enabled": true, "label": "Difference of Gaussians...", - "visible": TRUE + "visible": true } ] }, { "id": 513, - "enabled": TRUE, + "enabled": true, "label": "Noise", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 514, - "enabled": TRUE, + "enabled": true, "label": "Spread...", - "visible": TRUE + "visible": true }, { "id": 515, - "enabled": TRUE, + "enabled": true, "label": "Slur...", - "visible": TRUE + "visible": true }, { "id": 516, - "enabled": TRUE, + "enabled": true, "label": "RGB Noise...", - "visible": TRUE + "visible": true }, { "id": 517, - "enabled": TRUE, + "enabled": true, "label": "Pick...", - "visible": TRUE + "visible": true }, { "id": 518, - "enabled": TRUE, + "enabled": true, "label": "Hurl...", - "visible": TRUE + "visible": true }, { "id": 519, - "enabled": TRUE, + "enabled": true, "label": "HSV Noise...", - "visible": TRUE + "visible": true } ] }, { "id": 520, - "enabled": TRUE, + "enabled": true, "label": "Light and Shadow", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 521, - "enabled": TRUE, + "enabled": true, "label": "Glass Tile...", - "visible": TRUE + "visible": true }, { "id": 522, - "enabled": TRUE, + "enabled": true, "label": "Apply Lens...", - "visible": TRUE + "visible": true }, { "id": 523, @@ -3370,21 +3370,21 @@ }, { "id": 524, - "enabled": TRUE, + "enabled": true, "label": "Xach-Effect...", - "visible": TRUE + "visible": true }, { "id": 525, - "enabled": TRUE, + "enabled": true, "label": "Perspective...", - "visible": TRUE + "visible": true }, { "id": 526, - "enabled": TRUE, + "enabled": true, "label": "Drop Shadow...", - "visible": TRUE + "visible": true }, { "id": 527, @@ -3392,252 +3392,252 @@ }, { "id": 528, - "enabled": TRUE, + "enabled": true, "label": "Supernova...", - "visible": TRUE + "visible": true }, { "id": 529, - "enabled": TRUE, + "enabled": true, "label": "Sparkle...", - "visible": TRUE + "visible": true }, { "id": 530, - "enabled": TRUE, + "enabled": true, "label": "Lighting Effects...", - "visible": TRUE + "visible": true }, { "id": 531, - "enabled": TRUE, + "enabled": true, "label": "Lens Flare...", - "visible": TRUE + "visible": true }, { "id": 532, - "enabled": TRUE, + "enabled": true, "label": "Gradient Flare...", - "visible": TRUE + "visible": true } ] }, { "id": 533, - "enabled": TRUE, + "enabled": true, "label": "Distorts", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 534, - "enabled": TRUE, + "enabled": true, "label": "Wind...", - "visible": TRUE + "visible": true }, { "id": 535, - "enabled": TRUE, + "enabled": true, "label": "Whirl and Pinch...", - "visible": TRUE + "visible": true }, { "id": 536, - "enabled": TRUE, + "enabled": true, "label": "Waves...", - "visible": TRUE + "visible": true }, { "id": 537, - "enabled": TRUE, + "enabled": true, "label": "Video...", - "visible": TRUE + "visible": true }, { "id": 538, - "enabled": TRUE, + "enabled": true, "label": "Value Propagate...", - "visible": TRUE + "visible": true }, { "id": 539, - "enabled": TRUE, + "enabled": true, "label": "Shift...", - "visible": TRUE + "visible": true }, { "id": 540, - "enabled": TRUE, + "enabled": true, "label": "Ripple...", - "visible": TRUE + "visible": true }, { "id": 541, - "enabled": TRUE, + "enabled": true, "label": "Polar Coordinates...", - "visible": TRUE + "visible": true }, { "id": 542, - "enabled": TRUE, + "enabled": true, "label": "Pagecurl...", - "visible": TRUE + "visible": true }, { "id": 543, - "enabled": TRUE, + "enabled": true, "label": "Newsprint...", - "visible": TRUE + "visible": true }, { "id": 544, - "enabled": TRUE, + "enabled": true, "label": "Mosaic...", - "visible": TRUE + "visible": true }, { "id": 545, - "enabled": TRUE, + "enabled": true, "label": "Lens Distortion...", - "visible": TRUE + "visible": true }, { "id": 546, - "enabled": TRUE, + "enabled": true, "label": "IWarp...", - "visible": TRUE + "visible": true }, { "id": 547, - "enabled": TRUE, + "enabled": true, "label": "Erase Every Other Row...", - "visible": TRUE + "visible": true }, { "id": 548, - "enabled": TRUE, + "enabled": true, "label": "Engrave...", - "visible": TRUE + "visible": true }, { "id": 549, - "enabled": TRUE, + "enabled": true, "label": "Emboss...", - "visible": TRUE + "visible": true }, { "id": 550, - "enabled": TRUE, + "enabled": true, "label": "Curve Bend...", - "visible": TRUE + "visible": true }, { "id": 551, - "enabled": TRUE, + "enabled": true, "label": "Blinds...", - "visible": TRUE + "visible": true } ] }, { "id": 552, - "enabled": TRUE, + "enabled": true, "label": "Enhance", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 553, - "enabled": TRUE, + "enabled": true, "label": "Unsharp Mask...", - "visible": TRUE + "visible": true }, { "id": 554, - "enabled": TRUE, + "enabled": true, "label": "Sharpen...", - "visible": TRUE + "visible": true }, { "id": 555, - "enabled": TRUE, + "enabled": true, "label": "Red Eye Removal...", - "visible": TRUE + "visible": true }, { "id": 556, - "enabled": FALSE, + "enabled": false, "label": "NL Filter...", - "visible": TRUE + "visible": true }, { "id": 557, - "enabled": TRUE, + "enabled": true, "label": "Destripe...", - "visible": TRUE + "visible": true }, { "id": 558, - "enabled": TRUE, + "enabled": true, "label": "Despeckle...", - "visible": TRUE + "visible": true }, { "id": 559, - "enabled": TRUE, + "enabled": true, "label": "Deinterlace...", - "visible": TRUE + "visible": true }, { "id": 560, - "enabled": TRUE, + "enabled": true, "label": "Antialias", - "visible": TRUE + "visible": true } ] }, { "id": 561, - "enabled": TRUE, + "enabled": true, "label": "Blur", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 562, - "enabled": TRUE, + "enabled": true, "label": "Tileable Blur...", - "visible": TRUE + "visible": true }, { "id": 563, - "enabled": TRUE, + "enabled": true, "label": "Selective Gaussian Blur...", - "visible": TRUE + "visible": true }, { "id": 564, - "enabled": TRUE, + "enabled": true, "label": "Pixelize...", - "visible": TRUE + "visible": true }, { "id": 565, - "enabled": TRUE, + "enabled": true, "label": "Motion Blur...", - "visible": TRUE + "visible": true }, { "id": 566, - "enabled": TRUE, + "enabled": true, "label": "Gaussian Blur...", - "visible": TRUE + "visible": true }, { "id": 567, - "enabled": TRUE, + "enabled": true, "label": "Blur", - "visible": TRUE + "visible": true } ] }, @@ -3647,48 +3647,48 @@ }, { "id": 569, - "enabled": TRUE, + "enabled": true, "label": "Reset all Filters", - "visible": TRUE + "visible": true }, { "id": 570, "shortcut": [["Control", "Shift", "f"]], - "enabled": FALSE, + "enabled": false, "label": "Re-Show Last", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 571, - "enabled": FALSE, + "enabled": false, "label": "Empty", - "visible": TRUE + "visible": true } ] }, { "id": 572, "shortcut": [["Control", "f"]], - "enabled": FALSE, + "enabled": false, "label": "Repeat Last", - "visible": TRUE + "visible": true } ] }, { "id": 573, - "enabled": TRUE, + "enabled": true, "label": "Windows", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 574, "shortcut": [["Control", "b"]], - "enabled": TRUE, + "enabled": true, "label": "Toolbox", - "visible": TRUE + "visible": true }, { "id": 575, @@ -3696,40 +3696,40 @@ }, { "id": 576, - "enabled": TRUE, + "enabled": true, "label": "Dockable Dialogs", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 577, - "enabled": TRUE, + "enabled": true, "label": "Error Console", - "visible": TRUE + "visible": true }, { "id": 578, - "enabled": TRUE, + "enabled": true, "label": "Tools", - "visible": TRUE + "visible": true }, { "id": 579, - "enabled": TRUE, + "enabled": true, "label": "Templates", - "visible": TRUE + "visible": true }, { "id": 580, - "enabled": TRUE, + "enabled": true, "label": "Document History", - "visible": TRUE + "visible": true }, { "id": 581, - "enabled": TRUE, + "enabled": true, "label": "Images", - "visible": TRUE + "visible": true }, { "id": 582, @@ -3737,48 +3737,48 @@ }, { "id": 583, - "enabled": TRUE, + "enabled": true, "label": "Buffers", - "visible": TRUE + "visible": true }, { "id": 584, - "enabled": TRUE, + "enabled": true, "label": "Fonts", - "visible": TRUE + "visible": true }, { "id": 585, - "enabled": TRUE, + "enabled": true, "label": "Palettes", - "visible": TRUE + "visible": true }, { "id": 586, "shortcut": [["Control", "g"]], - "enabled": TRUE, + "enabled": true, "label": "Gradients", - "visible": TRUE + "visible": true }, { "id": 587, "shortcut": [["Control", "Shift", "p"]], - "enabled": TRUE, + "enabled": true, "label": "Patterns", - "visible": TRUE + "visible": true }, { "id": 588, "shortcut": [["Control", "Shift", "b"]], - "enabled": TRUE, + "enabled": true, "label": "Brushes", - "visible": TRUE + "visible": true }, { "id": 589, - "enabled": TRUE, + "enabled": true, "label": "Colors", - "visible": TRUE + "visible": true }, { "id": 590, @@ -3786,64 +3786,64 @@ }, { "id": 591, - "enabled": TRUE, + "enabled": true, "label": "Sample Points", - "visible": TRUE + "visible": true }, { "id": 592, - "enabled": TRUE, + "enabled": true, "label": "Pointer", - "visible": TRUE + "visible": true }, { "id": 593, - "enabled": TRUE, + "enabled": true, "label": "Undo History", - "visible": TRUE + "visible": true }, { "id": 594, - "enabled": TRUE, + "enabled": true, "label": "Navigation", - "visible": TRUE + "visible": true }, { "id": 595, - "enabled": TRUE, + "enabled": true, "label": "Selection Editor", - "visible": TRUE + "visible": true }, { "id": 596, - "enabled": TRUE, + "enabled": true, "label": "Histogram", - "visible": TRUE + "visible": true }, { "id": 597, - "enabled": TRUE, + "enabled": true, "label": "Colormap", - "visible": TRUE + "visible": true }, { "id": 598, - "enabled": TRUE, + "enabled": true, "label": "Paths", - "visible": TRUE + "visible": true }, { "id": 599, - "enabled": TRUE, + "enabled": true, "label": "Channels", - "visible": TRUE + "visible": true }, { "id": 600, "shortcut": [["Control", "l"]], - "enabled": TRUE, + "enabled": true, "label": "Layers", - "visible": TRUE + "visible": true }, { "id": 601, @@ -3851,30 +3851,30 @@ }, { "id": 602, - "enabled": TRUE, + "enabled": true, "label": "Device Status", - "visible": TRUE + "visible": true }, { "id": 603, - "enabled": TRUE, + "enabled": true, "label": "Tool Options", - "visible": TRUE + "visible": true } ] }, { "id": 604, - "enabled": TRUE, + "enabled": true, "label": "Recently Closed Docks", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 605, - "enabled": FALSE, + "enabled": false, "label": "Empty", - "visible": TRUE + "visible": true } ] } @@ -3882,92 +3882,92 @@ }, { "id": 606, - "enabled": TRUE, + "enabled": true, "label": "Help", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 607, - "enabled": TRUE, + "enabled": true, "label": "User Manual", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 608, - "enabled": TRUE, + "enabled": true, "label": "Working with Digital Camera Photos", - "visible": TRUE + "visible": true }, { "id": 609, - "enabled": TRUE, + "enabled": true, "label": "Using Paths", - "visible": TRUE + "visible": true }, { "id": 610, - "enabled": TRUE, + "enabled": true, "label": "Preparing your Images for the Web", - "visible": TRUE + "visible": true }, { "id": 611, - "enabled": TRUE, + "enabled": true, "label": "How to Use Dialogs", - "visible": TRUE + "visible": true }, { "id": 612, - "enabled": TRUE, + "enabled": true, "label": "Drawing Simple Objects", - "visible": TRUE + "visible": true }, { "id": 613, - "enabled": TRUE, + "enabled": true, "label": "Create, Open and Save Files", - "visible": TRUE + "visible": true }, { "id": 614, - "enabled": TRUE, + "enabled": true, "label": "Basic Concepts", - "visible": TRUE + "visible": true } ] }, { "id": 615, - "enabled": TRUE, + "enabled": true, "label": "GIMP Online", "children-display": "submenu", - "visible": TRUE, + "visible": true, "submenu": [ { "id": 616, - "enabled": TRUE, + "enabled": true, "label": "User Manual Web Site", - "visible": TRUE + "visible": true }, { "id": 617, - "enabled": TRUE, + "enabled": true, "label": "Plug-in Registry", - "visible": TRUE + "visible": true }, { "id": 618, - "enabled": TRUE, + "enabled": true, "label": "Main Web Site", - "visible": TRUE + "visible": true }, { "id": 619, - "enabled": TRUE, + "enabled": true, "label": "Developer Web Site", - "visible": TRUE + "visible": true } ] }, @@ -3977,15 +3977,15 @@ }, { "id": 621, - "enabled": TRUE, + "enabled": true, "label": "Procedure Browser", - "visible": TRUE + "visible": true }, { "id": 622, - "enabled": TRUE, + "enabled": true, "label": "Plug-In Browser", - "visible": TRUE + "visible": true }, { "id": 623, @@ -3993,29 +3993,29 @@ }, { "id": 624, - "enabled": TRUE, + "enabled": true, "label": "About", - "visible": TRUE + "visible": true }, { "id": 625, - "enabled": TRUE, + "enabled": true, "label": "Tip of the Day", - "visible": TRUE + "visible": true }, { "id": 626, "shortcut": [["Shift", "F1"]], - "enabled": TRUE, + "enabled": true, "label": "Context Help", - "visible": TRUE + "visible": true }, { "id": 627, "shortcut": [["F1"]], - "enabled": TRUE, + "enabled": true, "label": "Help", - "visible": TRUE + "visible": true } ] } -- cgit v1.2.3 From 3d291c9bd937b20511efbebb938b3a6b059e8b14 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 18:04:06 -0500 Subject: Have the proper case for booleans --- tools/dbusmenu-dumper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index f2e2bec..6ce9655 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -116,6 +116,12 @@ value2string (const GValue * value, int depth) str = collection_dumper(value, depth); } else if (G_VALUE_TYPE(value) == G_TYPE_STRV) { str = strv_dumper(value); + } else if (G_VALUE_TYPE(value) == G_TYPE_BOOLEAN) { + if (g_value_get_boolean(value)) { + str = g_strdup("true"); + } else { + str = g_strdup("false"); + } } else { str = g_strdup_value_contents(value); } -- cgit v1.2.3 From ecfd01992d210f2411d1adac9ed7622837135210 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 18:18:13 -0500 Subject: Adding a test-client bin --- .bzrignore | 1 + tests/Makefile.am | 1 + tests/test-json-client.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/test-json-client.c diff --git a/.bzrignore b/.bzrignore index d2d26a9..e80aadf 100644 --- a/.bzrignore +++ b/.bzrignore @@ -186,3 +186,4 @@ tests/dbusmenu-jsonloader.pc tests/libdbusmenu-jsonloader.la tests/libdbusmenu_jsonloader_la-json-loader.lo tests/test-json-server +tests/test-json-client diff --git a/tests/Makefile.am b/tests/Makefile.am index 2dd2cf7..9dab3eb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ check_PROGRAMS = \ test-gtk-shortcut-server \ test-glib-simple-items \ test-gtk-reorder-server \ + test-json-client \ test-json-server XVFB_RUN=". $(srcdir)/run-xvfb.sh" diff --git a/tests/test-json-client.c b/tests/test-json-client.c new file mode 100644 index 0000000..2d90608 --- /dev/null +++ b/tests/test-json-client.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +GMainLoop * mainloop = NULL; + +int +main (int argv, char ** argc) +{ + g_type_init(); + g_debug("Wait for friends"); + + GError * error = NULL; + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (error != NULL) { + g_error("Unable to get session bus: %s", error->message); + return 1; + } + + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + + gboolean has_owner = FALSE; + gint owner_count = 0; + while (!has_owner && owner_count < 10000) { + org_freedesktop_DBus_name_has_owner(bus_proxy, "org.test", &has_owner, NULL); + owner_count++; + } + + if (owner_count == 10000) { + g_error("Unable to get name owner after 10000 tries"); + return 1; + } + + g_usleep(500000); + + g_debug("Initing"); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Exiting"); + + return 0; +} -- cgit v1.2.3 From dce233d4c70e90cfb0f3862ba66538222ffbb7d6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 18:33:43 -0500 Subject: Starting to link things together... still not working. --- .bzrignore | 1 + tests/Makefile.am | 2 +- tests/test-json-client.c | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.bzrignore b/.bzrignore index e80aadf..ae6fc3d 100644 --- a/.bzrignore +++ b/.bzrignore @@ -187,3 +187,4 @@ tests/libdbusmenu-jsonloader.la tests/libdbusmenu_jsonloader_la-json-loader.lo tests/test-json-server tests/test-json-client +tests/test-json diff --git a/tests/Makefile.am b/tests/Makefile.am index 9dab3eb..3cd4380 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -127,7 +127,7 @@ test_glib_layout_client_LDADD = \ test-json: test-json-client test-json-server Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --task ./test-json-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter output.json --ignore-return --task ./test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@ @chmod +x $@ test_json_server_SOURCES = \ diff --git a/tests/test-json-client.c b/tests/test-json-client.c index 2d90608..7208fa8 100644 --- a/tests/test-json-client.c +++ b/tests/test-json-client.c @@ -23,7 +23,7 @@ main (int argv, char ** argc) gboolean has_owner = FALSE; gint owner_count = 0; while (!has_owner && owner_count < 10000) { - org_freedesktop_DBus_name_has_owner(bus_proxy, "org.test", &has_owner, NULL); + org_freedesktop_DBus_name_has_owner(bus_proxy, "org.dbusmenu.test", &has_owner, NULL); owner_count++; } @@ -36,8 +36,10 @@ main (int argv, char ** argc) g_debug("Initing"); - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); + gchar * command = g_strdup_printf("%s --dbus-name=org.dbusmenu.test --dbus-object=/org/test > %s", argc[1], argc[2]); + g_debug("Executing: %s", command); + + g_spawn_command_line_sync(command, NULL, NULL, NULL, NULL); g_debug("Exiting"); -- cgit v1.2.3 From cba3c47e7fe383c6c3496a55158a86fe6994dd35 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 21:47:43 -0500 Subject: Redirecting output to a file. --- configure.ac | 4 +++- tests/Makefile.am | 1 + tests/test-json-client.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index fdc76fb..598df4a 100644 --- a/configure.ac +++ b/configure.ac @@ -62,8 +62,10 @@ AC_SUBST(DBUSMENUGTK_LIBS) ########################### JSON_GLIB_REQUIRED_VERSION=0.6.0 +GIO_UNIX_REQUIRED_VERSION=2.24 -PKG_CHECK_MODULES(DBUSMENUTESTS, json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION) +PKG_CHECK_MODULES(DBUSMENUTESTS, json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION + gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION) AC_SUBST(DBUSMENUTESTS_CFLAGS) AC_SUBST(DBUSMENUTESTS_LIBS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3cd4380..1f7e36e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -155,6 +155,7 @@ test_json_client_CFLAGS = \ test_json_client_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUTESTS_LIBS) \ $(DBUSMENUGLIB_LIBS) ###################### diff --git a/tests/test-json-client.c b/tests/test-json-client.c index 7208fa8..62eb87c 100644 --- a/tests/test-json-client.c +++ b/tests/test-json-client.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -36,10 +37,16 @@ main (int argv, char ** argc) g_debug("Initing"); - gchar * command = g_strdup_printf("%s --dbus-name=org.dbusmenu.test --dbus-object=/org/test > %s", argc[1], argc[2]); + gchar * command = g_strdup_printf("%s --dbus-name=org.dbusmenu.test --dbus-object=/org/test", argc[1]); g_debug("Executing: %s", command); - g_spawn_command_line_sync(command, NULL, NULL, NULL, NULL); + gchar * output; + g_spawn_command_line_sync(command, &output, NULL, NULL, NULL); + + GFile * ofile = g_file_new_for_commandline_arg(argc[2]); + if (ofile != NULL) { + g_file_replace_contents(ofile, output, g_utf8_strlen(output, -1), NULL, FALSE, 0, NULL, NULL, NULL); + } g_debug("Exiting"); -- cgit v1.2.3 From 89f7fb74fba3d5a42603af450f4642fe43ac0406 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 21:51:17 -0500 Subject: Setting timeout longer --- tests/test-json-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-json-server.c b/tests/test-json-server.c index b2b8341..cf6b605 100644 --- a/tests/test-json-server.c +++ b/tests/test-json-server.c @@ -49,7 +49,7 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); - g_timeout_add(3000, timer_func, NULL); + g_timeout_add(10000, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 8bfa911170eecf8b7c4dda05238777e1c066670f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 22:02:53 -0500 Subject: Comparing at the end and running under Xvfb --- tests/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f7e36e..31a8910 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -127,7 +127,9 @@ test_glib_layout_client_LDADD = \ test-json: test-json-client test-json-server Makefile.am @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter output.json --ignore-return --task ./test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@ + @echo diff test-json-01.json output.json \> /dev/null >> $@ @chmod +x $@ test_json_server_SOURCES = \ -- cgit v1.2.3 From 35589de9fe87c06f07772d9ffae74c2b8ca9141e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 22:07:57 -0500 Subject: Better name, distcheck fix, cleanup. Good stuff. --- tests/Makefile.am | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 31a8910..521cfbb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,8 @@ DBUS_RUNNER=dbus-test-runner +CLEANFILES= + TESTS = \ test-glib-objects-test \ test-glib-layout \ @@ -128,10 +130,12 @@ test_glib_layout_client_LDADD = \ test-json: test-json-client test-json-server Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter output.json --ignore-return --task ./test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@ - @echo diff test-json-01.json output.json \> /dev/null >> $@ + @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter test-json-01.output.json --ignore-return --task ./test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@ + @echo diff $(srcdir)/test-json-01.json test-json-01.output.json \> /dev/null >> $@ @chmod +x $@ +CLEANFILES += test-json-01.output.json + test_json_server_SOURCES = \ test-json-server.c @@ -502,7 +506,7 @@ EXTRA_DIST = \ dbusmenu-gtk/mago_tests/data/test-gtk-label.json \ test-json-01.json -CLEANFILES = \ +CLEANFILES += \ dbusmenu-gtk/mago_tests/dbusmenu.pyc distclean-local: -- cgit v1.2.3 From 65cfbcd1339473de0540ef9037af336ce893d008 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 22:12:07 -0500 Subject: Look at all the values instead of just the first. --- tests/json-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index 2f27bff..97f1c13 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -31,7 +31,7 @@ node2value (JsonNode * node) int i; for (i = 0; i < json_array_get_length(array); i++) { - const gchar * str = json_node_get_string(first); + const gchar * str = json_node_get_string(json_array_get_element(array, i)); gchar * dupstr = g_strdup(str); g_array_append_val(garray, dupstr); } -- cgit v1.2.3 From 21eae6d351fc5608d1d312332dd0d93126fa6050 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 22:27:09 -0500 Subject: Not sure why this flipped, but whatever. --- tests/test-json-01.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-json-01.json b/tests/test-json-01.json index a014548..88e1cbf 100644 --- a/tests/test-json-01.json +++ b/tests/test-json-01.json @@ -1098,8 +1098,8 @@ }, { "id": 171, - "shortcut": [["F11"]], "enabled": true, + "shortcut": [["F11"]], "toggle-state": 0, "label": "Fullscreen", "toggle-type": "checkmark", -- cgit v1.2.3 From 511e68461114325f3685bc547517668b179b4914 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 22:39:59 -0500 Subject: Forgot copyright headers --- tests/json-loader.c | 20 ++++++++++++++++++++ tests/json-loader.h | 20 ++++++++++++++++++++ tests/test-json-client.c | 21 +++++++++++++++++++++ tests/test-json-server.c | 21 +++++++++++++++++++++ 4 files changed, 82 insertions(+) diff --git a/tests/json-loader.c b/tests/json-loader.c index 97f1c13..aad4295 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -1,3 +1,23 @@ +/* +A loader to turn JSON into dbusmenu menuitems + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ #include "json-loader.h" #include diff --git a/tests/json-loader.h b/tests/json-loader.h index 67e1c8b..666bb6e 100644 --- a/tests/json-loader.h +++ b/tests/json-loader.h @@ -1,3 +1,23 @@ +/* +A loader to turn JSON into dbusmenu menuitems + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ #ifndef __DBUSMENU_JSON_LOADER_H__ #define __DBUSMENU_JSON_LOADER_H__ diff --git a/tests/test-json-client.c b/tests/test-json-client.c index 62eb87c..73d64b0 100644 --- a/tests/test-json-client.c +++ b/tests/test-json-client.c @@ -1,3 +1,24 @@ +/* +Test to check the json-loader and dbusmenu-dumper + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + #include #include #include diff --git a/tests/test-json-server.c b/tests/test-json-server.c index cf6b605..fe9507a 100644 --- a/tests/test-json-server.c +++ b/tests/test-json-server.c @@ -1,3 +1,24 @@ +/* +Test to check the json-loader and dbusmenu-dumper + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + #include #include -- cgit v1.2.3 From 4df378827e9db26d9fad707224d25c0455e9d312 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 22:44:06 -0500 Subject: Getting the depends in order. --- tests/dbusmenu-jsonloader.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dbusmenu-jsonloader.pc.in b/tests/dbusmenu-jsonloader.pc.in index 6c48f7e..d042132 100644 --- a/tests/dbusmenu-jsonloader.pc.in +++ b/tests/dbusmenu-jsonloader.pc.in @@ -5,7 +5,7 @@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libdbusmenu-0.1 -Requires: dbus-glib-1 +Requires: dbus-glib-1,dbusmenu-glib,json-glib-1.0 Libs: -L${libdir} -ldbusmenu-jsonloader Name: libdbusmenu-jsonloader -- cgit v1.2.3 From 50b6f428911e3683e66cd2dd352e431815e24eb7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 23:17:13 -0500 Subject: Adding the need libraries for making the library. --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 521cfbb..0fa15fc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,7 +70,8 @@ libdbusmenu_jsonloader_la_CFLAGS = \ -DG_LOG_DOMAIN="\"LIBDBUSMENU-JSONLOADER\"" libdbusmenu_jsonloader_la_LIBADD = \ - $(DBUSMENUGLIB_LIBS) + $(DBUSMENUGLIB_LIBS) \ + $(DBUSMENUTEST_LIBS) pkgconfig_DATA = dbusmenu-jsonloader.pc pkgconfigdir = $(libdir)/pkgconfig -- cgit v1.2.3 From dea48a947149ecc92c99bd084c9c7ea2e32d4577 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 23:20:11 -0500 Subject: Typo --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0fa15fc..d57a578 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -71,7 +71,7 @@ libdbusmenu_jsonloader_la_CFLAGS = \ libdbusmenu_jsonloader_la_LIBADD = \ $(DBUSMENUGLIB_LIBS) \ - $(DBUSMENUTEST_LIBS) + $(DBUSMENUTESTS_LIBS) pkgconfig_DATA = dbusmenu-jsonloader.pc pkgconfigdir = $(libdir)/pkgconfig -- cgit v1.2.3 From 3b991803b808c158edb3062d2b962cdf9d8ed2d2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 23:22:58 -0500 Subject: Adding in the glib lib too. --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index d57a578..63857a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,6 +70,7 @@ libdbusmenu_jsonloader_la_CFLAGS = \ -DG_LOG_DOMAIN="\"LIBDBUSMENU-JSONLOADER\"" libdbusmenu_jsonloader_la_LIBADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) \ $(DBUSMENUTESTS_LIBS) -- cgit v1.2.3 From aa58b4c6b6460a8f9e49953447994b479b9f1705 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 29 Jun 2010 18:12:08 -0500 Subject: Block separators from getting new submenus --- libdbusmenu-gtk/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index c73c90f..a46aef3 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -503,6 +503,7 @@ new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, Dbus #endif if (dbusmenu_menuitem_get_root(mi)) { return; } + if (g_strcmp0(dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_TYPE), DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0) { return; } gpointer ann_menu = g_object_get_data(G_OBJECT(mi), data_menu); GtkMenu * menu = GTK_MENU(ann_menu); -- cgit v1.2.3 From fa0aae428c6859bb4aab12368ad92cf9d8274d3f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Jun 2010 11:13:47 -0500 Subject: Flipping argv/c from review --- tests/test-json-client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-json-client.c b/tests/test-json-client.c index 73d64b0..f9da55e 100644 --- a/tests/test-json-client.c +++ b/tests/test-json-client.c @@ -28,7 +28,7 @@ with this program. If not, see . GMainLoop * mainloop = NULL; int -main (int argv, char ** argc) +main (int argc, char ** argv) { g_type_init(); g_debug("Wait for friends"); @@ -58,13 +58,13 @@ main (int argv, char ** argc) g_debug("Initing"); - gchar * command = g_strdup_printf("%s --dbus-name=org.dbusmenu.test --dbus-object=/org/test", argc[1]); + gchar * command = g_strdup_printf("%s --dbus-name=org.dbusmenu.test --dbus-object=/org/test", argv[1]); g_debug("Executing: %s", command); gchar * output; g_spawn_command_line_sync(command, &output, NULL, NULL, NULL); - GFile * ofile = g_file_new_for_commandline_arg(argc[2]); + GFile * ofile = g_file_new_for_commandline_arg(argv[2]); if (ofile != NULL) { g_file_replace_contents(ofile, output, g_utf8_strlen(output, -1), NULL, FALSE, 0, NULL, NULL, NULL); } -- cgit v1.2.3 From 235abfa96562b5ba4d1876dc99e86551160ee34c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Jul 2010 08:53:34 -0500 Subject: 0.3.4 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 598df4a..bd7fff8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.3, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.4, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.3, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.4, [-Wno-portability]) AM_MAINTAINER_MODE @@ -87,7 +87,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=8 +LIBDBUSMENU_REVISION=9 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 26d44b572f237f592862333d6dbb9d8899259bca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Jul 2010 08:47:23 -0500 Subject: Check to ensure we an get the connection before registering the object. --- libdbusmenu-glib/server.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 0da66cc..13c2843 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -225,15 +225,22 @@ static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(obj); + GError * error = NULL; switch (id) { case PROP_DBUS_OBJECT: g_return_if_fail(priv->dbusobject == NULL); priv->dbusobject = g_value_dup_string(value); - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_connection_register_g_object(connection, - priv->dbusobject, - obj); + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + + if (connection == NULL || error != NULL) { + g_warning("Unable to get session bus: %s", error == NULL ? "No message" : error->message); + if (error != NULL) { g_error_free(error); } + } else { + dbus_g_connection_register_g_object(connection, + priv->dbusobject, + obj); + } break; case PROP_ROOT_NODE: if (priv->root != NULL) { -- cgit v1.2.3 From 72440f055a39e9a80feff00515f7ae8b49237278 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Jul 2010 10:35:23 -0500 Subject: Only tell when we're doing massive debugging. --- libdbusmenu-gtk/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index a46aef3..b406697 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -148,7 +148,9 @@ do_swap_agroup (DbusmenuMenuitem * mi, gpointer userdata) { return FALSE; } + #ifdef MASSIVEDEBUGGING g_debug("Setting shortcut on '%s': %d %X", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL), key, modifiers); + #endif GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(data->client, mi); if (gmi == NULL) { -- cgit v1.2.3 From eff1ffd59b4ca9ccfe11146559e070e8f4cf1f06 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 7 Jul 2010 11:46:37 -0500 Subject: Ratcheting down the warning level of not finding a group. --- libdbusmenu-gtk/menuitem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 9924546..5846aa7 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -264,9 +264,10 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c GtkAccelGroup * group = gtk_accel_group_from_accel_closure(closure); - /* Seriously, if this returns NULL something is seriously - wrong in GTK. */ - g_return_val_if_fail(group != NULL, FALSE); + /* Apparently this is more common than I thought. */ + if (group == NULL) { + return FALSE; + } GtkAccelKey * key = gtk_accel_group_find(group, find_closure, closure); /* Again, not much we can do except complain loudly. */ -- cgit v1.2.3 From f83f5f8dccbbc24f9a6256c3a116391000419004 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 7 Jul 2010 14:45:26 -0500 Subject: Adding NULL protection and a warning --- libdbusmenu-glib/client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index fa233a4..871170a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -561,6 +561,9 @@ build_proxies (DbusmenuClient * client) static gint parse_node_get_id (xmlNodePtr node) { + if (node == NULL) { + return -1; + } if (node->type != XML_ELEMENT_NODE) { return -1; } @@ -886,6 +889,10 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmlNodePtr root = xmlDocGetRootElement(xmldoc); + if (root == NULL) { + g_warning("Unable to get root node of menu XML"); + } + DbusmenuMenuitem * oldroot = priv->root; priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); -- cgit v1.2.3 From 2e974ea0fa59265a0ec4cce29cbb62519ce872cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Jul 2010 10:11:33 -0500 Subject: 0.3.5 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bd7fff8..7ec994b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.4, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.5, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.4, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.5, [-Wno-portability]) AM_MAINTAINER_MODE @@ -87,7 +87,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=9 +LIBDBUSMENU_REVISION=10 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 7c48e370ec2b9c3437a77e81b535b1f20672f817 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 14 Jul 2010 09:02:15 -0500 Subject: Adding protections on dbusmenu_client_send_event() --- libdbusmenu-glib/client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 871170a..2e985d6 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -716,6 +716,17 @@ menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) void dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp) { + g_return_if_fail(DBUSMENU_IS_CLIENT(client)); + g_return_if_fail(id >= 0); + g_return_if_fail(name != NULL); + + if (value == NULL) { + GValue internalval = {0}; + g_value_init(&internalval, G_TYPE_INT); + g_value_set_int(&internalval, 0); + value = &internalval; + } + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, GINT_TO_POINTER(id)); return; -- cgit v1.2.3 From 98b3815a25ffcf89f7d5b062bda254f5fcaa1ab2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 09:35:16 -0500 Subject: 0.3.6 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 7ec994b..6c2400c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.5, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.6, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.5, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.6, [-Wno-portability]) AM_MAINTAINER_MODE @@ -87,7 +87,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=10 +LIBDBUSMENU_REVISION=11 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 9f4213d9d59c84c9c4811a69ee50d4baaab6dc58 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 19 Jul 2010 12:53:38 +0200 Subject: Started to implement click-to-dump --- tools/Makefile.am | 4 +- tools/dbusmenu-dumper.c | 129 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 122 insertions(+), 11 deletions(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index 77d6eef..a36d224 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,11 +10,11 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) -I/usr/include/dbus-1.0 -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) + $(DBUSMENUGLIB_LIBS) -lX11 -ldbus-glib-1 doc_DATA = README.dbusmenu-bench diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 55d631e..4a0dd03 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -21,10 +21,13 @@ with this program. If not, see . */ #include +#include #include #include +#include + static GMainLoop * mainloop = NULL; static void @@ -90,10 +93,104 @@ new_root_cb (DbusmenuClient * client, DbusmenuMenuitem * newroot) return; } +static Window +find_real_window(Display * display, Window w, int depth) +{ + if (depth > 5) { + return None; + } + /*static*/ Atom wm_state = XInternAtom(display, "WM_STATE", False); + Atom type; + int format; + unsigned long nitems, after; + unsigned char* prop; + if (XGetWindowProperty(display, w, wm_state, 0, 0, False, AnyPropertyType, + &type, &format, &nitems, &after, &prop) == Success) { + if (prop != NULL) { + XFree(prop); + } + if (type != None) { + return w; + } + } + Window root, parent; + Window* children; + unsigned int nchildren; + Window ret = None; + if (XQueryTree(display, w, &root, &parent, &children, &nchildren) != 0) { + unsigned int i; + for(i = 0; i < nchildren && ret == None; ++i) { + ret = find_real_window(display, children[ i ], depth + 1); + } + if (children != NULL) { + XFree(children); + } + } + return ret; +} + +static Window +get_window_under_cursor() +{ + Display * display = XOpenDisplay(NULL); + g_return_val_if_fail(display != NULL, None); + + Window root; + Window child; + uint mask; + int rootX, rootY, winX, winY; + XGrabServer(display); + Window root_window = DefaultRootWindow(display); + XQueryPointer(display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &mask); + if (child == None) { + return None; + } + return find_real_window(display, child, 0); +} static gchar * dbusname = NULL; static gchar * dbusobject = NULL; +static gboolean +init_dbus_vars_from_window(Window window) +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *proxy; + + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + g_printerr("Failed to open connection to bus: %s\n", error->message); + g_error_free(error); + return FALSE; + } + + proxy = dbus_g_proxy_new_for_name (connection, + "org.ayatana.AppMenu.Registrar", + "/org/ayatana/AppMenu/Registrar", + "org.ayatana.AppMenu.Registrar"); + + error = NULL; + if (!dbus_g_proxy_call (proxy, "GetMenuForWindow", &error, + G_TYPE_UINT, window, G_TYPE_INVALID, + G_TYPE_STRING, &dbusname, DBUS_TYPE_G_OBJECT_PATH, &dbusobject, G_TYPE_INVALID)) + { + g_printerr("ERROR: %s\n", error->message); + g_error_free(error); + g_object_unref(proxy); + return FALSE; + } + + if (!g_strcmp0(dbusobject, "/")) { + return FALSE; + } + + g_object_unref (proxy); + + return TRUE; +} + static gboolean option_dbusname (const gchar * arg, const gchar * value, gpointer data, GError ** error) { @@ -147,16 +244,30 @@ main (int argc, char ** argv) return 1; } - if (dbusname == NULL) { - g_printerr("ERROR: dbus-name not specified\n"); - usage(); - return 1; - } + if (dbusname == NULL && dbusobject == NULL) { + Window window = get_window_under_cursor(); + if (window == None) { + g_printerr("ERROR: could not get the id for the pointed window\n"); + return 1; + } + g_debug("window: %u", (unsigned int)window); + if (!init_dbus_vars_from_window(window)) { + g_printerr("ERROR: could not find a menu for the pointed window\n"); + return 1; + } + g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); + } else { + if (dbusname == NULL) { + g_printerr("ERROR: dbus-name not specified\n"); + usage(); + return 1; + } - if (dbusobject == NULL) { - g_printerr("ERROR: dbus-object not specified\n"); - usage(); - return 1; + if (dbusobject == NULL) { + g_printerr("ERROR: dbus-object not specified\n"); + usage(); + return 1; + } } DbusmenuClient * client = dbusmenu_client_new (dbusname, dbusobject); -- cgit v1.2.3 From 6da7a3341f028d913fd3ad01d47a59f436b5e780 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 19 Jul 2010 17:21:38 +0200 Subject: Use pkgconfig to find libx11 --- configure.ac | 9 +++++++++ tools/Makefile.am | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b88d96d..99911fa 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,15 @@ PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) +########################### +# Dependencies - tools +########################### + +PKG_CHECK_MODULES(DBUSMENUTOOLS, x11) + +AC_SUBST(DBUSMENUTOOLS_CFLAGS) +AC_SUBST(DBUSMENUTOOLS_LIBS) + ########################### # Dependencies - Testing ########################### diff --git a/tools/Makefile.am b/tools/Makefile.am index a36d224..3cd5538 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,11 +10,11 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) -I/usr/include/dbus-1.0 -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUTOOLS_CFLAGS) -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) -lX11 -ldbus-glib-1 + $(DBUSMENUGLIB_LIBS) $(DBUSMENUTOOLS_LIBS) doc_DATA = README.dbusmenu-bench -- cgit v1.2.3 From df399dd383c3ceaea44e6b173a842c7bfd1664ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 14:15:31 -0500 Subject: Introducting a function to bring together all our get_properties_async friends. --- libdbusmenu-glib/client.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 2e985d6..bb7b4ee 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -109,6 +109,7 @@ static gint parse_layout (DbusmenuClient * client, const gchar * layout); static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); +static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data); /* Build a type */ G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT); @@ -310,6 +311,16 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal funcs */ +/* A function to group all the get_properties commands to make them + more efficient over dbus. */ +static void +get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + org_ayatana_dbusmenu_get_properties_async(priv->menuproxy, id, properties, callback, user_data); + return; +} + /* Annoying little wrapper to make the right function update */ static void layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client) @@ -370,7 +381,7 @@ id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client) gchar * properties[1] = {NULL}; /* This gets them all */ g_debug("Getting properties"); g_object_ref(menuitem); - org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_cb, menuitem); + get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_cb, menuitem); return; } @@ -821,7 +832,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it gchar * properties[1] = {NULL}; /* This gets them all */ g_object_ref(item); - org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); + get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); } else { g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); } @@ -830,7 +841,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* XXX: We shouldn't need to get the properties everytime we reuse an entry */ gchar * properties[1] = {NULL}; /* This gets them all */ g_object_ref(item); - org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item); + get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item); } xmlNodePtr children; -- cgit v1.2.3 From d7b7d66cea89b1466c9c9d462c648339ef5df1be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 14:46:00 -0500 Subject: Build our two arrays and look at putting data into them. --- libdbusmenu-glib/client.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index bb7b4ee..73b52e5 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -78,6 +78,9 @@ struct _DbusmenuClientPrivate DBusGProxy * dbusproxy; GHashTable * type_handlers; + + GArray * delayed_property_list; + GArray * delayed_property_listeners; }; typedef struct _newItemPropData newItemPropData; @@ -88,6 +91,14 @@ struct _newItemPropData DbusmenuMenuitem * parent; }; +typedef struct _properties_listener_t properties_listener_t; +struct _properties_listener_t { + DbusmenuClient * client; + gint id; + org_ayatana_dbusmenu_get_properties_reply callback; + gpointer user_data; +}; + #define DBUSMENU_CLIENT_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_CLIENT, DbusmenuClientPrivate)) @@ -212,6 +223,9 @@ dbusmenu_client_init (DbusmenuClient *self) priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); + priv->delayed_property_listeners = g_array_new(FALSE, FALSE, sizeof(properties_listener_t)); + return; } @@ -220,6 +234,9 @@ dbusmenu_client_dispose (GObject *object) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(object); + /* TODO: Handle delayed_property_list */ + /* TODO: Handle delayed_property_listeners */ + if (priv->layoutcall != NULL) { dbus_g_proxy_cancel_call(priv->menuproxy, priv->layoutcall); priv->layoutcall = NULL; @@ -317,6 +334,32 @@ static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + + if (properties == NULL || properties[0] == NULL) { + /* get all case */ + if (priv->delayed_property_list->len != 0) { + /* If there are entries in the list, then we'll need to + remove them all, and start over */ + gchar ** dataregion = (gchar **)g_array_free(priv->delayed_property_list, FALSE); + if (dataregion != NULL) { + g_strfreev(dataregion); + } + priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); + } + } else { + /* there could be a list we care about */ + /* TODO: No one uses this today */ + /* TODO: Copy them into the list */ + } + + properties_listener_t listener = {0}; + listener.client = client; + listener.id = id; + listener.callback = callback; + listener.user_data = user_data; + + g_array_append_val(priv->delayed_property_listeners, listener); + org_ayatana_dbusmenu_get_properties_async(priv->menuproxy, id, properties, callback, user_data); return; } -- cgit v1.2.3 From d3eff171a5dbfcdc1da55164097255244b5dc3a6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 15:09:13 -0500 Subject: Building up an idle function, let's issue this on DBus! --- libdbusmenu-glib/client.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 73b52e5..2328fb1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -81,6 +81,7 @@ struct _DbusmenuClientPrivate GArray * delayed_property_list; GArray * delayed_property_listeners; + gint delayed_idle; }; typedef struct _newItemPropData newItemPropData; @@ -223,6 +224,7 @@ dbusmenu_client_init (DbusmenuClient *self) priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + priv->delayed_idle = 0; priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); priv->delayed_property_listeners = g_array_new(FALSE, FALSE, sizeof(properties_listener_t)); @@ -234,6 +236,11 @@ dbusmenu_client_dispose (GObject *object) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(object); + if (priv->delayed_idle != 0) { + g_source_remove(priv->delayed_idle); + priv->delayed_idle = 0; + } + /* TODO: Handle delayed_property_list */ /* TODO: Handle delayed_property_listeners */ @@ -328,6 +335,55 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal funcs */ +/* Call back from getting the group properties, now we need + to unwind and call the various functions. */ +static void +get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *error, gpointer userdata) +{ + + return; +} + +/* Idle handler to send out all of our property requests as one big + lovely property request. */ +static gboolean +get_properties_idle (gpointer user_data) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); + //org_ayatana_dbusmenu_get_properties_async(priv->menuproxy, id, properties, callback, user_data); + + if (priv->delayed_property_listeners->len == 0) { + g_warning("Odd, idle func got no listeners."); + return FALSE; + } + + GArray * idlist = g_array_new(FALSE, FALSE, sizeof(gint)); + gint i; + for (i = 0; i < priv->delayed_property_listeners->len; i++) { + g_array_append_val(idlist, g_array_index(priv->delayed_property_listeners, properties_listener_t, i).id); + } + + org_ayatana_dbusmenu_get_group_properties_async(priv->menuproxy, idlist, (const gchar **)priv->delayed_property_list->data, get_properties_callback, priv->delayed_property_listeners); + + /* Free ID List */ + g_array_free(idlist, TRUE); + + /* Free properties */ + gchar ** dataregion = (gchar **)g_array_free(priv->delayed_property_list, FALSE); + if (dataregion != NULL) { + g_strfreev(dataregion); + } + priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); + + /* Rebuild the listeners */ + priv->delayed_property_listeners = g_array_new(FALSE, FALSE, sizeof(properties_listener_t)); + + /* Make sure we set for a new idle */ + priv->delayed_idle = 0; + + return FALSE; +} + /* A function to group all the get_properties commands to make them more efficient over dbus. */ static void @@ -360,7 +416,10 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert g_array_append_val(priv->delayed_property_listeners, listener); - org_ayatana_dbusmenu_get_properties_async(priv->menuproxy, id, properties, callback, user_data); + if (priv->delayed_idle == 0) { + priv->delayed_idle = g_idle_add(get_properties_idle, client); + } + return; } -- cgit v1.2.3 From fe94f6d9c9e676565e73bcd7597540411901f87b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 15:49:00 -0500 Subject: Fleshing out the callback, need some more data to test though. --- libdbusmenu-glib/client.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 2328fb1..ff5b33b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -340,6 +340,33 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) static void get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *error, gpointer userdata) { + GArray * listeners = (GArray *)userdata; + int i; + + if (error != NULL) { + /* If we get an error, all our callbacks need to hear about it. */ + g_warning("Group Properties error: %s", error->message); + for (i = 0; i < listeners->len; i++) { + properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); + listener->callback(proxy, NULL, error, listener->user_data); + } + g_array_free(listeners, TRUE); + return; + } + + /* Callback all the folks we can find */ + for (i = 0; i < OUT_properties->len; i++) { + g_error("Properties type: %s", G_OBJECT_TYPE_NAME(g_ptr_array_index(OUT_properties, i))); + + } + + /* Provide errors for those who we can't */ + for (i = 0; i < listeners->len; i++) { + + } + + /* Clean up */ + g_array_free(listeners, TRUE); return; } @@ -357,6 +384,7 @@ get_properties_idle (gpointer user_data) return FALSE; } + /* Build up an ID list to pass */ GArray * idlist = g_array_new(FALSE, FALSE, sizeof(gint)); gint i; for (i = 0; i < priv->delayed_property_listeners->len; i++) { -- cgit v1.2.3 From 960663e01f1bb8a59e20b62892f6945868c510d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 16:47:40 -0500 Subject: Initial write of group properties, has errors though :( --- libdbusmenu-glib/server.c | 49 ++++++++++++++++++++++++++++++++--------- tests/test-glib-layout-server.c | 1 + 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 13c2843..42fe61f 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -37,8 +37,8 @@ License version 3 and version 2.1 along with this program. If not, see /* DBus Prototypes */ static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); -static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, GPtrArray * properties, GHashTable ** dict, GError ** error); -static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error); +static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); +static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); @@ -480,7 +480,7 @@ _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * propert } static gboolean -_dbusmenu_server_get_properties (DbusmenuServer * server, gint id, GPtrArray * properties, GHashTable ** dict, GError ** error) +_dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); @@ -501,16 +501,45 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, GPtrArray * p return TRUE; } +/* Handles getting a bunch of properties from a variety of menu items + to make one mega dbus message */ static gboolean -_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error) +_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error) { - if (error != NULL) { - g_set_error(error, - error_quark(), - NOT_IMPLEMENTED, - "The GetGroupProperties function is not implemented, sorry."); + /* Build an initial pointer array */ + *values = g_ptr_array_new(); + + /* Go through each ID to get that ID's properties */ + int idcnt; + for (idcnt = 0; idcnt < ids->len; idcnt++) { + GHashTable * idprops = NULL; + GError * error = NULL; + gint id = g_array_index(ids, int, idcnt); + + /* Get the properties for this ID the old fashioned way. */ + if (!_dbusmenu_server_get_properties(server, id, properties, &idprops, &error)) { + g_warning("Error getting the properties from ID %d: %s", id, error->message); + g_error_free(error); + error = NULL; + continue; + } + + GValueArray * valarray = g_value_array_new(2); + + GValue idval = {0}; + g_value_init(&idval, G_TYPE_INT); + g_value_set_int(&idval, id); + g_value_array_append(valarray, &idval); + + GValue propval = {0}; + g_value_init(&propval, G_TYPE_HASH_TABLE); + g_value_set_boxed(&propval, idprops); + g_value_array_append(valarray, &propval); + + g_ptr_array_add(*values, valarray); } - return FALSE; + + return TRUE; } static void diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index 111e164..d739726 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -78,6 +78,7 @@ main (int argc, char ** argv) GError * error = NULL; g_type_init(); + g_log_set_always_fatal(G_LOG_LEVEL_WARNING); DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); -- cgit v1.2.3 From 68e46ae11fda7dc9e9a7eada5b105536bdf9f574 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 20:42:36 -0500 Subject: Apparently it's a GValueArray. Feel like I'm coding freakin' Python. Guess and check. --- libdbusmenu-glib/server.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 42fe61f..dc505a1 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -38,7 +38,7 @@ License version 3 and version 2.1 along with this program. If not, see static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); -static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error); +static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GValueArray ** values, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); @@ -504,10 +504,10 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** prop /* Handles getting a bunch of properties from a variety of menu items to make one mega dbus message */ static gboolean -_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error) +_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GValueArray ** values, GError ** error) { /* Build an initial pointer array */ - *values = g_ptr_array_new(); + *values = g_value_array_new(ids->len); /* Go through each ID to get that ID's properties */ int idcnt; @@ -536,7 +536,11 @@ _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gc g_value_set_boxed(&propval, idprops); g_value_array_append(valarray, &propval); - g_ptr_array_add(*values, valarray); + GValue * valwrapper = g_new0(GValue, 1); + g_value_init(valwrapper, G_TYPE_VALUE_ARRAY); + g_value_set_boxed(valwrapper, valarray); + + g_value_array_append(*values, valwrapper); } return TRUE; -- cgit v1.2.3 From 63601bed2c1bb3ffb786efa6c25e47fa97c0acb0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 21:19:19 -0500 Subject: Switch array back and use the helpers, duh, now it works. --- libdbusmenu-glib/server.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index dc505a1..08a6631 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -38,10 +38,13 @@ License version 3 and version 2.1 along with this program. If not, see static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); -static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GValueArray ** values, GError ** error); +static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); +/* DBus Helpers */ +static void _gvalue_array_append_int(GValueArray *array, gint i); +static void _gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict); #include "dbusmenu-server.h" @@ -504,10 +507,10 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** prop /* Handles getting a bunch of properties from a variety of menu items to make one mega dbus message */ static gboolean -_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GValueArray ** values, GError ** error) +_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error) { /* Build an initial pointer array */ - *values = g_value_array_new(ids->len); + *values = g_ptr_array_new(); /* Go through each ID to get that ID's properties */ int idcnt; @@ -526,26 +529,17 @@ _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gc GValueArray * valarray = g_value_array_new(2); - GValue idval = {0}; - g_value_init(&idval, G_TYPE_INT); - g_value_set_int(&idval, id); - g_value_array_append(valarray, &idval); + _gvalue_array_append_int(valarray, id); + _gvalue_array_append_hashtable(valarray, idprops); - GValue propval = {0}; - g_value_init(&propval, G_TYPE_HASH_TABLE); - g_value_set_boxed(&propval, idprops); - g_value_array_append(valarray, &propval); - - GValue * valwrapper = g_new0(GValue, 1); - g_value_init(valwrapper, G_TYPE_VALUE_ARRAY); - g_value_set_boxed(valwrapper, valarray); - - g_value_array_append(*values, valwrapper); + g_ptr_array_add(*values, valarray); } return TRUE; } +/* Allocate a value on the stack for the int and append + it to the array. */ static void _gvalue_array_append_int(GValueArray *array, gint i) { @@ -557,6 +551,8 @@ _gvalue_array_append_int(GValueArray *array, gint i) g_value_unset(&value); } +/* Allocate a value on the stack for the hashtable and append + it to the array. */ static void _gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict) { @@ -577,7 +573,7 @@ serialize_menuitem(gpointer data, gpointer user_data) gint id = dbusmenu_menuitem_get_id(mi); GHashTable * dict = dbusmenu_menuitem_properties_copy(mi); - GValueArray * item = g_value_array_new(1); + GValueArray * item = g_value_array_new(2); _gvalue_array_append_int(item, id); _gvalue_array_append_hashtable(item, dict); -- cgit v1.2.3 From e9e9462196b283161cefff84f19a2c9a6130b3ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Jul 2010 21:32:48 -0500 Subject: Unpacking the array and getting the fields out. --- libdbusmenu-glib/client.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ff5b33b..7c040ce 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -343,6 +343,8 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e GArray * listeners = (GArray *)userdata; int i; + g_debug("Get properties callback: %d", OUT_properties->len); + if (error != NULL) { /* If we get an error, all our callbacks need to hear about it. */ g_warning("Group Properties error: %s", error->message); @@ -356,7 +358,25 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e /* Callback all the folks we can find */ for (i = 0; i < OUT_properties->len; i++) { - g_error("Properties type: %s", G_OBJECT_TYPE_NAME(g_ptr_array_index(OUT_properties, i))); + GValueArray * varray = (GValueArray *)g_ptr_array_index(OUT_properties, i); + + if (varray->n_values != 2) { + g_warning("Value Array is %d entries long but we expected 2.", varray->n_values); + continue; + } + + GValue * vid = g_value_array_get_nth(varray, 0); + GValue * vproperties = g_value_array_get_nth(varray, 1); + + if (G_VALUE_TYPE(vid) != G_TYPE_INT) { + g_warning("ID Entry not holding an int: %s", G_VALUE_TYPE_NAME(vid)); + } + if (G_VALUE_TYPE(vproperties) != dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) { + g_warning("Properties Entry not holding an a{sv}: %s", G_VALUE_TYPE_NAME(vproperties)); + } + + // gint id = g_value_get_int(vid); + // GHashTable * properties = g_value_get_boxed(vproperties); } -- cgit v1.2.3 From 20ad762cf2fc9511b237007ec7412f6574e09223 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 05:37:35 -0500 Subject: Adding open menu signal --- libdbusmenu-glib/dbus-menu.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 53b67de..f2f1db6 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -344,6 +344,9 @@ License version 3 and version 2.1 along with this program. If not, see + + + -- cgit v1.2.3 From eab9731dcd26336aa44aee62073881919201df6f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 05:48:07 -0500 Subject: Changing to name to match --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index f2f1db6..b09604b 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -344,7 +344,7 @@ License version 3 and version 2.1 along with this program. If not, see - + -- cgit v1.2.3 From 93c287ff9d2c7029eb275f10cf5f372b0edb54ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 05:55:55 -0500 Subject: Docs and a tense fix --- libdbusmenu-glib/dbus-menu.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index b09604b..b4f4439 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -344,8 +344,16 @@ License version 3 and version 2.1 along with this program. If not, see - - + + + The server is requesting that all clients displaying this + menu open it to the user. This would be for things like + hotkeys that when the user presses them the menu should + open and display itself to the user. + + + ID of the menu that should be activated + -- cgit v1.2.3 From 646c74694e86d6e5d479028a7dbd8cf9a1aca37a Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Tue, 20 Jul 2010 14:51:23 +0200 Subject: Ripped some code from wnckprop to do proper click-to-dump --- configure.ac | 11 ++++-- tools/Makefile.am | 4 +- tools/dbusmenu-dumper.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 99911fa..2e95d55 100644 --- a/configure.ac +++ b/configure.ac @@ -51,13 +51,16 @@ AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) ########################### -# Dependencies - tools +# Dependencies - dumper ########################### -PKG_CHECK_MODULES(DBUSMENUTOOLS, x11) +X11_REQUIRED_VERSION=1.3 -AC_SUBST(DBUSMENUTOOLS_CFLAGS) -AC_SUBST(DBUSMENUTOOLS_LIBS) +PKG_CHECK_MODULES(DBUSMENUDUMPER, gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION) + +AC_SUBST(DBUSMENUDUMPER_CFLAGS) +AC_SUBST(DBUSMENUDUMPER_LIBS) ########################### # Dependencies - Testing diff --git a/tools/Makefile.am b/tools/Makefile.am index 3cd5538..ab7a598 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,11 +10,11 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUTOOLS_CFLAGS) -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUDUMPER_CFLAGS) -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) $(DBUSMENUTOOLS_LIBS) + $(DBUSMENUGLIB_LIBS) $(DBUSMENUDUMPER_LIBS) doc_DATA = README.dbusmenu-bench diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 4a0dd03..3a47f21 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -23,6 +23,10 @@ with this program. If not, see . #include #include +#include +#include +#include + #include #include @@ -93,6 +97,12 @@ new_root_cb (DbusmenuClient * client, DbusmenuMenuitem * newroot) return; } +/* Window clicking ***************************************************/ +static GdkFilterReturn +click_filter (GdkXEvent *gdk_xevent, + GdkEvent *event, + gpointer data); + static Window find_real_window(Display * display, Window w, int depth) { @@ -148,6 +158,91 @@ get_window_under_cursor() return find_real_window(display, child, 0); } +static void +uninstall_click_filter (void) +{ + GdkWindow *root; + + root = gdk_get_default_root_window (); + gdk_window_remove_filter (root, (GdkFilterFunc) click_filter, NULL); + + gdk_pointer_ungrab (GDK_CURRENT_TIME); + gdk_keyboard_ungrab (GDK_CURRENT_TIME); + + gtk_main_quit (); +} + +static GdkFilterReturn +click_filter (GdkXEvent *gdk_xevent, + GdkEvent *event, + gpointer data) + +{ + XEvent *xevent = (XEvent *) gdk_xevent; + gboolean *success = (gboolean *)data; + + switch (xevent->type) { + case ButtonPress: + uninstall_click_filter(); + *success = TRUE; + return GDK_FILTER_REMOVE; + case KeyPress: + if (xevent->xkey.keycode == XKeysymToKeycode(gdk_display, XK_Escape)) { + uninstall_click_filter(); + *success = FALSE; + return GDK_FILTER_REMOVE; + } + break; + default: + break; + } + + return GDK_FILTER_CONTINUE; +} + +static gboolean +install_click_filter (gpointer data) +{ + GdkGrabStatus status; + GdkCursor *cross; + GdkWindow *root; + + root = gdk_get_default_root_window(); + + gdk_window_add_filter(root, (GdkFilterFunc) click_filter, data); + + cross = gdk_cursor_new(GDK_CROSS); + status = gdk_pointer_grab(root, FALSE, GDK_BUTTON_PRESS_MASK, + NULL, cross, GDK_CURRENT_TIME); + gdk_cursor_unref(cross); + + if (status != GDK_GRAB_SUCCESS) { + g_warning("Pointer grab failed.\n"); + uninstall_click_filter(); + return FALSE; + } + + status = gdk_keyboard_grab(root, FALSE, GDK_CURRENT_TIME); + if (status != GDK_GRAB_SUCCESS) { + g_warning("Keyboard grab failed.\n"); + uninstall_click_filter(); + return FALSE; + } + + gdk_flush(); + return FALSE; +} + +static gboolean +wait_for_click (int argc, char **argv) +{ + gtk_init(&argc, &argv); + gboolean success; + g_idle_add (install_click_filter, (gpointer)(&success)); + gtk_main (); + return success; +} + static gchar * dbusname = NULL; static gchar * dbusobject = NULL; @@ -191,6 +286,7 @@ init_dbus_vars_from_window(Window window) return TRUE; } +/* Option parser *****************************************************/ static gboolean option_dbusname (const gchar * arg, const gchar * value, gpointer data, GError ** error) { @@ -245,6 +341,9 @@ main (int argc, char ** argv) } if (dbusname == NULL && dbusobject == NULL) { + if (!wait_for_click(argc, argv)) { + return 1; + } Window window = get_window_under_cursor(); if (window == None) { g_printerr("ERROR: could not get the id for the pointed window\n"); @@ -256,6 +355,7 @@ main (int argc, char ** argv) return 1; } g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); + return 1; } else { if (dbusname == NULL) { g_printerr("ERROR: dbus-name not specified\n"); -- cgit v1.2.3 From 463b05a77a8e21e60ffe197f58461b0fb02ed930 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Tue, 20 Jul 2010 14:58:16 +0200 Subject: Clean up --- tools/dbusmenu-dumper.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 3a47f21..4ddb057 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -104,17 +104,17 @@ click_filter (GdkXEvent *gdk_xevent, gpointer data); static Window -find_real_window(Display * display, Window w, int depth) +find_real_window (Window w, int depth) { if (depth > 5) { return None; } - /*static*/ Atom wm_state = XInternAtom(display, "WM_STATE", False); + /*static*/ Atom wm_state = XInternAtom(gdk_display, "WM_STATE", False); Atom type; int format; unsigned long nitems, after; unsigned char* prop; - if (XGetWindowProperty(display, w, wm_state, 0, 0, False, AnyPropertyType, + if (XGetWindowProperty(gdk_display, w, wm_state, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &prop) == Success) { if (prop != NULL) { XFree(prop); @@ -127,10 +127,10 @@ find_real_window(Display * display, Window w, int depth) Window* children; unsigned int nchildren; Window ret = None; - if (XQueryTree(display, w, &root, &parent, &children, &nchildren) != 0) { + if (XQueryTree(gdk_display, w, &root, &parent, &children, &nchildren) != 0) { unsigned int i; for(i = 0; i < nchildren && ret == None; ++i) { - ret = find_real_window(display, children[ i ], depth + 1); + ret = find_real_window(children[ i ], depth + 1); } if (children != NULL) { XFree(children); @@ -140,22 +140,17 @@ find_real_window(Display * display, Window w, int depth) } static Window -get_window_under_cursor() +get_window_under_cursor (void) { - Display * display = XOpenDisplay(NULL); - g_return_val_if_fail(display != NULL, None); - Window root; Window child; uint mask; int rootX, rootY, winX, winY; - XGrabServer(display); - Window root_window = DefaultRootWindow(display); - XQueryPointer(display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &mask); + XQueryPointer(gdk_display, gdk_x11_get_default_root_xwindow(), &root, &child, &rootX, &rootY, &winX, &winY, &mask); if (child == None) { return None; } - return find_real_window(display, child, 0); + return find_real_window(child, 0); } static void @@ -234,9 +229,8 @@ install_click_filter (gpointer data) } static gboolean -wait_for_click (int argc, char **argv) +wait_for_click (void) { - gtk_init(&argc, &argv); gboolean success; g_idle_add (install_click_filter, (gpointer)(&success)); gtk_main (); @@ -341,7 +335,8 @@ main (int argc, char ** argv) } if (dbusname == NULL && dbusobject == NULL) { - if (!wait_for_click(argc, argv)) { + gtk_init(&argc, &argv); + if (!wait_for_click()) { return 1; } Window window = get_window_under_cursor(); -- cgit v1.2.3 From 70961ba202ced579d434e19f185f442684814722 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Tue, 20 Jul 2010 15:03:39 +0200 Subject: Unbreak command line parser --- tools/dbusmenu-dumper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 4ddb057..82ca5c1 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -314,7 +314,8 @@ usage (void) static GOptionEntry general_options[] = { {"dbus-name", 'd', 0, G_OPTION_ARG_CALLBACK, option_dbusname, "The name of the program to connect to (i.e. org.test.bob", "dbusname"}, - {"dbus-object", 'o', 0, G_OPTION_ARG_CALLBACK, option_dbusobject, "The path to the Dbus object (i.e /org/test/bob/alvin)", "dbusobject"} + {"dbus-object", 'o', 0, G_OPTION_ARG_CALLBACK, option_dbusobject, "The path to the Dbus object (i.e /org/test/bob/alvin)", "dbusobject"}, + {NULL} }; int @@ -350,7 +351,6 @@ main (int argc, char ** argv) return 1; } g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); - return 1; } else { if (dbusname == NULL) { g_printerr("ERROR: dbus-name not specified\n"); -- cgit v1.2.3 From 63bb196ef8482430bbf742a7a6389a9897766f43 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 08:18:22 -0500 Subject: Adding a timestamp --- libdbusmenu-glib/dbus-menu.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index b4f4439..9e8013c 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -354,6 +354,9 @@ License version 3 and version 2.1 along with this program. If not, see ID of the menu that should be activated + + The time that the event occured + -- cgit v1.2.3 From f034bdd080b7579b0e5e57c8f34780a756bb8b17 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 09:11:01 -0500 Subject: Finding the listener and calling it's callback. --- libdbusmenu-glib/client.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7c040ce..ab00636 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -335,6 +335,23 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal funcs */ +/* Quick little function to search through the listeners and find + one that matches an ID */ +static properties_listener_t * +find_listener (GArray * listeners, guint index, gint id) +{ + if (index >= listeners->len) { + return NULL; + } + + properties_listener_t * retval = &g_array_index(listeners, properties_listener_t, index); + if (retval->id == id) { + return retval; + } + + return find_listener(listeners, index + 1, id); +} + /* Call back from getting the group properties, now we need to unwind and call the various functions. */ static void @@ -375,9 +392,12 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e g_warning("Properties Entry not holding an a{sv}: %s", G_VALUE_TYPE_NAME(vproperties)); } - // gint id = g_value_get_int(vid); - // GHashTable * properties = g_value_get_boxed(vproperties); + gint id = g_value_get_int(vid); + GHashTable * properties = g_value_get_boxed(vproperties); + + properties_listener_t * listener = find_listener(listeners, 0, id); + listener->callback(proxy, properties, NULL, listener->user_data); } /* Provide errors for those who we can't */ -- cgit v1.2.3 From 08fae7619012309a0ef9024c1e91effc7bf99529 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 09:38:13 -0500 Subject: Tracking who we reply to, and ensuring that we reply to everyone. --- libdbusmenu-glib/client.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ab00636..4faf7c6 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -94,10 +94,10 @@ struct _newItemPropData typedef struct _properties_listener_t properties_listener_t; struct _properties_listener_t { - DbusmenuClient * client; gint id; org_ayatana_dbusmenu_get_properties_reply callback; gpointer user_data; + gboolean replied; }; #define DBUSMENU_CLIENT_GET_PRIVATE(o) \ @@ -398,11 +398,22 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e properties_listener_t * listener = find_listener(listeners, 0, id); listener->callback(proxy, properties, NULL, listener->user_data); + listener->replied = TRUE; } /* Provide errors for those who we can't */ + GError * localerror = NULL; for (i = 0; i < listeners->len; i++) { - + properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); + if (!listener->replied) { + if (localerror == NULL) { + g_set_error_literal(&localerror, 0, 0, "Error getting properties for ID"); + } + listener->callback(proxy, NULL, localerror, listener->user_data); + } + } + if (localerror != NULL) { + g_error_free(localerror); } /* Clean up */ @@ -477,10 +488,10 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert } properties_listener_t listener = {0}; - listener.client = client; listener.id = id; listener.callback = callback; listener.user_data = user_data; + listener.replied = FALSE; g_array_append_val(priv->delayed_property_listeners, listener); -- cgit v1.2.3 From 7941bec0ab70845d60efd374b5dae4976197e4b5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 09:55:08 -0500 Subject: Cleaning up our arrays, with some callbacks, eh, it's what we gotta do. --- libdbusmenu-glib/client.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 4faf7c6..5e8c08a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -241,8 +241,38 @@ dbusmenu_client_dispose (GObject *object) priv->delayed_idle = 0; } - /* TODO: Handle delayed_property_list */ - /* TODO: Handle delayed_property_listeners */ + /* Only used for queueing up a new command, so we can + just drop this array. */ + if (priv->delayed_property_list == NULL) { + gchar ** dataregion = (gchar **)g_array_free(priv->delayed_property_list, FALSE); + if (dataregion != NULL) { + g_strfreev(dataregion); + } + priv->delayed_property_list = NULL; + } + + if (priv->delayed_property_listeners == NULL) { + gint i; + GError * localerror = NULL; + + /* Making sure all the callbacks get called so that if they had + memory in their user_data that needs to be free'd that happens. */ + for (i = 0; i < priv->delayed_property_listeners->len; i++) { + properties_listener_t * listener = &g_array_index(priv->delayed_property_listeners, properties_listener_t, i); + if (!listener->replied) { + if (localerror == NULL) { + g_set_error_literal(&localerror, 0, 0, "DbusmenuClient Shutdown"); + } + listener->callback(priv->menuproxy, NULL, localerror, listener->user_data); + } + } + if (localerror != NULL) { + g_error_free(localerror); + } + + g_array_free(priv->delayed_property_listeners, TRUE); + priv->delayed_property_listeners = NULL; + } if (priv->layoutcall != NULL) { dbus_g_proxy_cancel_call(priv->menuproxy, priv->layoutcall); -- cgit v1.2.3 From 2e95e1f828ce1b75331e99883244c94f7629408f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 10:14:02 -0500 Subject: Putting properties debug message under massive debugging. --- libdbusmenu-glib/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5e8c08a..bd391e0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -390,7 +390,9 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e GArray * listeners = (GArray *)userdata; int i; + #ifdef MASSIVEDEBUGGING g_debug("Get properties callback: %d", OUT_properties->len); + #endif if (error != NULL) { /* If we get an error, all our callbacks need to hear about it. */ -- cgit v1.2.3 From 57547736e1a274928546a291147a199f67d1bc50 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 11:00:35 -0500 Subject: Ensuring that we only reply once. Shouldn't be an issue... --- libdbusmenu-glib/client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index bd391e0..84e0efc 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -429,8 +429,12 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e properties_listener_t * listener = find_listener(listeners, 0, id); - listener->callback(proxy, properties, NULL, listener->user_data); - listener->replied = TRUE; + if (!listener->replied) { + listener->callback(proxy, properties, NULL, listener->user_data); + listener->replied = TRUE; + } else { + g_warning("Odd, we've already replied to the listener on ID %d", id); + } } /* Provide errors for those who we can't */ -- cgit v1.2.3 From 90ebe32795a5af7f659da78ba96414c49c268b46 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 11:08:32 -0500 Subject: Making sure we got a listener before we go all callin' stuff on it. --- libdbusmenu-glib/client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 84e0efc..1c962dd 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -428,6 +428,10 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e GHashTable * properties = g_value_get_boxed(vproperties); properties_listener_t * listener = find_listener(listeners, 0, id); + if (listener == NULL) { + g_warning("Unable to find listener for ID %d", id); + continue; + } if (!listener->replied) { listener->callback(proxy, properties, NULL, listener->user_data); -- cgit v1.2.3 From bb0a4f168ea59d6afdfbe9a5c9473ef1ee6f37ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 11:26:08 -0500 Subject: Add a check to protect against adding the same ID twice to the queue. --- libdbusmenu-glib/client.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 1c962dd..e962f78 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -509,6 +509,14 @@ static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + if (find_listener(priv->delayed_property_listeners, 0, id) != NULL) { + g_warning("Asking for properties from same ID twice: %d", id); + GError * localerror = NULL; + g_set_error_literal(&localerror, 0, 0, "ID already queued"); + callback(priv->menuproxy, NULL, localerror, user_data); + g_error_free(localerror); + return; + } if (properties == NULL || properties[0] == NULL) { /* get all case */ -- cgit v1.2.3 From 9abd75fc8f41e0d1642bfd8dbf3cb6aaae36dfda Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 11:31:36 -0500 Subject: Adding in an error domain, because, well, GError likes that. --- libdbusmenu-glib/client.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index e962f78..b142e15 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -122,6 +122,7 @@ static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data); +static GQuark error_domain (void); /* Build a type */ G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT); @@ -261,7 +262,7 @@ dbusmenu_client_dispose (GObject *object) properties_listener_t * listener = &g_array_index(priv->delayed_property_listeners, properties_listener_t, i); if (!listener->replied) { if (localerror == NULL) { - g_set_error_literal(&localerror, 0, 0, "DbusmenuClient Shutdown"); + g_set_error_literal(&localerror, error_domain(), 0, "DbusmenuClient Shutdown"); } listener->callback(priv->menuproxy, NULL, localerror, listener->user_data); } @@ -365,6 +366,16 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal funcs */ +static GQuark +error_domain (void) +{ + static GQuark error = 0; + if (error == 0) { + error = g_quark_from_static_string(G_LOG_DOMAIN "-CLIENT"); + } + return error; +} + /* Quick little function to search through the listeners and find one that matches an ID */ static properties_listener_t * @@ -447,7 +458,7 @@ get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *e properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); if (!listener->replied) { if (localerror == NULL) { - g_set_error_literal(&localerror, 0, 0, "Error getting properties for ID"); + g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID"); } listener->callback(proxy, NULL, localerror, listener->user_data); } @@ -512,7 +523,7 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert if (find_listener(priv->delayed_property_listeners, 0, id) != NULL) { g_warning("Asking for properties from same ID twice: %d", id); GError * localerror = NULL; - g_set_error_literal(&localerror, 0, 0, "ID already queued"); + g_set_error_literal(&localerror, error_domain(), 0, "ID already queued"); callback(priv->menuproxy, NULL, localerror, user_data); g_error_free(localerror); return; -- cgit v1.2.3 From 508c02c4188070e326839a3bbbf3e161592d7e4f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 11:39:56 -0500 Subject: Fixing error handling in get_properties_new_cb --- libdbusmenu-glib/client.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b142e15..b59aecd 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -906,16 +906,19 @@ menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, static void menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) { + g_return_if_fail(data != NULL); + newItemPropData * propdata = (newItemPropData *)data; + if (error != NULL) { g_warning("Error getting properties on a new menuitem: %s", error->message); - g_object_unref(data); + g_object_unref(propdata->item); + g_free(data); return; } - g_return_if_fail(data != NULL); - newItemPropData * propdata = (newItemPropData *)data; DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(propdata->client); + /* Extra ref as get_properties will unref once itself */ g_object_ref(propdata->item); menuitem_get_properties_cb (proxy, properties, error, propdata->item); -- cgit v1.2.3 From 8c9e1febb85e0bd28cfc175cd015a4a1934baf55 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 12:13:18 -0500 Subject: Pulling the layout count update into a function along with signalling it. --- libdbusmenu-glib/server.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 08a6631..7a39f1e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -48,6 +48,8 @@ static void _gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict #include "dbusmenu-server.h" +static void layout_update_signal (DbusmenuServer * server); + #define DBUSMENU_VERSION_NUMBER 2 /* Privates, I'll show you mine... */ @@ -260,8 +262,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) } else { g_debug("Setting root node to NULL"); } - priv->layout_revision++; - g_signal_emit(obj, signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + layout_update_signal(DBUSMENU_SERVER(obj)); break; default: g_return_if_reached(); @@ -305,6 +306,16 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) return; } +/* Signals that the layout has been updated */ +static void +layout_update_signal (DbusmenuServer * server) +{ + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + priv->layout_revision++; + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + return; +} + static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server) { @@ -335,10 +346,7 @@ menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint menuitem_signals_create(child, server); g_list_foreach(dbusmenu_menuitem_get_children(child), added_check_children, server); - /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ - DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + layout_update_signal(server); return; } @@ -346,19 +354,14 @@ static void menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server) { menuitem_signals_remove(child, server); - /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ - DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + layout_update_signal(server); return; } static void menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, guint oldpos, DbusmenuServer * server) { - DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + layout_update_signal(server); return; } -- cgit v1.2.3 From fe213d96ed2ff025c1c60cbffb4e0dd562d1c154 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 12:27:03 -0500 Subject: Adding in an idle function that queues the updates. --- libdbusmenu-glib/server.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7a39f1e..4afd0c2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -60,6 +60,7 @@ struct _DbusmenuServerPrivate DbusmenuMenuitem * root; gchar * dbusobject; gint layout_revision; + guint layout_idle; }; #define DBUSMENU_SERVER_GET_PRIVATE(o) \ @@ -201,6 +202,7 @@ dbusmenu_server_init (DbusmenuServer *self) priv->root = NULL; priv->dbusobject = NULL; priv->layout_revision = 1; + priv->layout_idle = 0; return; } @@ -210,6 +212,10 @@ dbusmenu_server_dispose (GObject *object) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(object); + if (priv->layout_idle != 0) { + g_source_remove(priv->layout_idle); + } + if (priv->root != NULL) { dbusmenu_menuitem_foreach(priv->root, menuitem_signals_remove, object); g_object_unref(priv->root); @@ -306,13 +312,32 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) return; } +/* Handle actually signalling in the idle loop. This way we collect all + the updates. */ +static gboolean +layout_update_idle (gpointer user_data) +{ + DbusmenuServer * server = DBUSMENU_SERVER(user_data); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + + priv->layout_idle = 0; + + return FALSE; +} + /* Signals that the layout has been updated */ static void layout_update_signal (DbusmenuServer * server) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + + if (priv->layout_idle == 0) { + priv->layout_idle = g_idle_add(layout_update_idle, server); + } + return; } -- cgit v1.2.3 From ae9a8d2c2fa9b657b20516737bf72dbc2be7102d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 12:58:29 -0500 Subject: Slight optimization to not create a useless structure. --- libdbusmenu-glib/client.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b59aecd..b68c3b3 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -618,10 +618,9 @@ id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client) DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); g_return_if_fail(menuitem != NULL); - gchar * properties[1] = {NULL}; /* This gets them all */ g_debug("Getting properties"); g_object_ref(menuitem); - get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_cb, menuitem); + get_properties_globber(client, id, NULL, menuitem_get_properties_cb, menuitem); return; } @@ -1073,18 +1072,16 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it propdata->item = item; propdata->parent = parent; - gchar * properties[1] = {NULL}; /* This gets them all */ g_object_ref(item); - get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); + get_properties_globber(client, id, NULL, menuitem_get_properties_new_cb, propdata); } else { g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); } } else { /* Refresh the properties */ /* XXX: We shouldn't need to get the properties everytime we reuse an entry */ - gchar * properties[1] = {NULL}; /* This gets them all */ g_object_ref(item); - get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item); + get_properties_globber(client, id, NULL, menuitem_get_properties_replace_cb, item); } xmlNodePtr children; -- cgit v1.2.3 From 871df0f10c49d538d80a405c1420bddf8baff79b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 13:21:14 -0500 Subject: Pulling out the new item code into a function --- libdbusmenu-glib/client.c | 50 +++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b59aecd..baa3e93 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1038,6 +1038,36 @@ dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb)( return; } +/* Builds a new child with property requests and everything + else to clean up the code a bit */ +static DbusmenuMenuitem * +parse_layout_new_child (gint id, DbusmenuClient * client, DbusmenuMenuitem * parent) +{ + DbusmenuMenuitem * item = NULL; + + /* Build a new item */ + item = DBUSMENU_MENUITEM(dbusmenu_client_menuitem_new(id, client)); + if (parent == NULL) { + dbusmenu_menuitem_set_root(item, TRUE); + } + + /* Get the properties queued up for this item */ + /* Not happy allocating about this, but I need these :( */ + newItemPropData * propdata = g_new0(newItemPropData, 1); + if (propdata != NULL) { + propdata->client = client; + propdata->item = item; + propdata->parent = parent; + + g_object_ref(item); + get_properties_globber(client, id, NULL, menuitem_get_properties_new_cb, propdata); + } else { + g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); + } + + return item; +} + /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * @@ -1060,25 +1090,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } /* Build a new item */ - item = DBUSMENU_MENUITEM(dbusmenu_client_menuitem_new(id, client)); - if (parent == NULL) { - dbusmenu_menuitem_set_root(item, TRUE); - } - - /* Get the properties queued up for this item */ - /* Not happy about this, but I need these :( */ - newItemPropData * propdata = g_new0(newItemPropData, 1); - if (propdata != NULL) { - propdata->client = client; - propdata->item = item; - propdata->parent = parent; - - gchar * properties[1] = {NULL}; /* This gets them all */ - g_object_ref(item); - get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); - } else { - g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); - } + item = parse_layout_new_child(id, client, parent); } else { /* Refresh the properties */ /* XXX: We shouldn't need to get the properties everytime we reuse an entry */ -- cgit v1.2.3 From 42f883725a882b1391e79d96efbdcead50dae98c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 13:24:22 -0500 Subject: Pulling out the update code into it's own function as well. --- libdbusmenu-glib/client.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index baa3e93..257ad3f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1068,6 +1068,15 @@ parse_layout_new_child (gint id, DbusmenuClient * client, DbusmenuMenuitem * par return item; } +/* Refresh the properties on this item */ +static void +parse_layout_update (DbusmenuMenuitem * item, DbusmenuClient * client) +{ + g_object_ref(item); + get_properties_globber(client, dbusmenu_menuitem_get_id(item), NULL, menuitem_get_properties_replace_cb, item); + return; +} + /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * @@ -1092,11 +1101,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Build a new item */ item = parse_layout_new_child(id, client, parent); } else { - /* Refresh the properties */ - /* XXX: We shouldn't need to get the properties everytime we reuse an entry */ - gchar * properties[1] = {NULL}; /* This gets them all */ - g_object_ref(item); - get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item); + parse_layout_update(item, client); } xmlNodePtr children; -- cgit v1.2.3 From 4e30bfbc1203e5c3135f5f541cf7c8ea3efcb62c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 13:34:18 -0500 Subject: Making it so that we create the child, and then move down it's XML tree. --- libdbusmenu-glib/client.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 257ad3f..aad9fdc 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1127,17 +1127,15 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } } - DbusmenuMenuitem * newchildmi = parse_layout_xml(client, children, childmi, item, proxy); - - if (newchildmi != childmi) { - if (childmi != NULL) { - dbusmenu_menuitem_child_delete(item, childmi); - } - dbusmenu_menuitem_child_add_position(item, newchildmi, position); - g_object_unref(newchildmi); + if (childmi == NULL) { + childmi = parse_layout_new_child(id, client, parent); + dbusmenu_menuitem_child_add_position(item, childmi, position); + g_object_unref(childmi); } else { dbusmenu_menuitem_child_reorder(item, childmi, position); } + + parse_layout_xml(client, children, childmi, item, proxy); } /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ -- cgit v1.2.3 From 88f54f11f9020b5ade4cc4e7b8df2d9f24b83622 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 13:49:06 -0500 Subject: Turns out you have to pass the right parameters to EVERY function. They don't teach you that in school. Test suite FTW. --- 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 aad9fdc..5b9e406 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1128,7 +1128,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } if (childmi == NULL) { - childmi = parse_layout_new_child(id, client, parent); + childmi = parse_layout_new_child(childid, client, item); dbusmenu_menuitem_child_add_position(item, childmi, position); g_object_unref(childmi); } else { -- cgit v1.2.3 From 7180f1940bfa95ed9cc7d06a38ed8e459b8aa18f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 13:55:10 -0500 Subject: Switching to the assumption that the item is made before calling parse_layout_xml(), and making it true. --- libdbusmenu-glib/client.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5b9e406..e9a4e59 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1089,20 +1089,9 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it #ifdef MASSIVEDEBUGGING g_debug("Client looking at node with id: %d", id); #endif - /* If we don't have any item, or the IDs don't match */ - if (item == NULL || dbusmenu_menuitem_get_id(item) != id) { - if (item != NULL) { - if (parent != NULL) { - dbusmenu_menuitem_child_delete(parent, item); - } - item = NULL; - } - /* Build a new item */ - item = parse_layout_new_child(id, client, parent); - } else { - parse_layout_update(item, client); - } + g_return_val_if_fail(item != NULL, NULL); + g_return_val_if_fail(id == dbusmenu_menuitem_get_id(item), NULL); xmlNodePtr children; guint position; @@ -1133,6 +1122,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it g_object_unref(childmi); } else { dbusmenu_menuitem_child_reorder(item, childmi, position); + parse_layout_update(childmi, client); } parse_layout_xml(client, children, childmi, item, proxy); @@ -1175,6 +1165,10 @@ parse_layout (DbusmenuClient * client, const gchar * layout) DbusmenuMenuitem * oldroot = priv->root; + if (priv->root == NULL) { + priv->root = parse_layout_new_child(0, client, NULL); + } + priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); xmlFreeDoc(xmldoc); -- cgit v1.2.3 From 25fa88e0f02624887022ff78e987fecfadb8ffaf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 14:01:12 -0500 Subject: Updating properties on the root node. --- libdbusmenu-glib/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index e9a4e59..67c5354 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1167,6 +1167,8 @@ parse_layout (DbusmenuClient * client, const gchar * layout) if (priv->root == NULL) { priv->root = parse_layout_new_child(0, client, NULL); + } else { + parse_layout_update(priv->root, client); } priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); -- cgit v1.2.3 From 464535d5f3482e0ff08834a79512ce04dfd5883e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 15:04:40 -0500 Subject: Move the parse to the end and make it dual pass through the list of children. --- libdbusmenu-glib/client.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 67c5354..078b6ad 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1124,8 +1124,6 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it dbusmenu_menuitem_child_reorder(item, childmi, position); parse_layout_update(childmi, client); } - - parse_layout_xml(client, children, childmi, item, proxy); } /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ @@ -1139,6 +1137,23 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } g_list_free(oldchildren); + /* We've got everything built up at this node and reconcilled */ + /* now it's time to recurse down the tree. */ + children = node->children; + GList * childmis = dbusmenu_menuitem_get_children(item); + while (children != NULL && childmis != NULL) { + parse_layout_xml(client, children, DBUSMENU_MENUITEM(childmis->data), item, proxy); + + children = children->next; + childmis = g_list_next(childmis); + } + if (children != NULL) { + g_warning("Sync failed, now we've got extra XML nodes."); + } + if (childmis != NULL) { + g_warning("Sync failed, now we've got extra menu items."); + } + return item; } -- cgit v1.2.3 From 2ef5fad1187c79a33dae89971cc75d5ed7287c42 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 15:07:22 -0500 Subject: Adding in some comments. --- libdbusmenu-glib/client.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 078b6ad..4dcf90c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1082,6 +1082,7 @@ parse_layout_update (DbusmenuMenuitem * item, DbusmenuClient * client) static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) { + /* First verify and figure out what we've got */ gint id = parse_node_get_id(node); if (id < 0) { return NULL; @@ -1093,11 +1094,14 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it g_return_val_if_fail(item != NULL, NULL); g_return_val_if_fail(id == dbusmenu_menuitem_get_id(item), NULL); + /* Some variables */ xmlNodePtr children; guint position; 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++) { /* g_debug("Looking at child: %d", position); */ gint childid = parse_node_get_id(children); @@ -1106,6 +1110,8 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } DbusmenuMenuitem * childmi = NULL; + /* First see if we can recycle a node that we've already built + on this menu item */ GList * childsearch = NULL; for (childsearch = oldchildren; childsearch != NULL; childsearch = g_list_next(childsearch)) { DbusmenuMenuitem * cs_mi = DBUSMENU_MENUITEM(childsearch->data); @@ -1117,16 +1123,19 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } if (childmi == NULL) { + /* If we can't recycle, then we build a new one */ childmi = parse_layout_new_child(childid, client, item); dbusmenu_menuitem_child_add_position(item, childmi, position); g_object_unref(childmi); } else { + /* If we can recycle, make sure it's in the right place */ dbusmenu_menuitem_child_reorder(item, childmi, position); parse_layout_update(childmi, client); } } - /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ + /* Remove any children that are no longer used by this version of + the layout. */ GList * oldchildleft = NULL; for (oldchildleft = oldchildren; oldchildleft != NULL; oldchildleft = g_list_next(oldchildleft)) { DbusmenuMenuitem * oldmi = DBUSMENU_MENUITEM(oldchildleft->data); -- cgit v1.2.3 From 7467274b62cd6db89dc51a9b0e4ad0b5b3bc6f91 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 15:15:24 -0500 Subject: After getting all the nodes requested at a particular level we should flush the properties requests. --- libdbusmenu-glib/client.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 4dcf90c..5ecfbde 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -514,6 +514,25 @@ get_properties_idle (gpointer user_data) return FALSE; } +/* Forces a call out to start getting properties with the menu items + that we have queued up already. */ +static void +get_properties_flush (DbusmenuClient * client) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + + if (priv->delayed_idle != 0) { + g_source_remove(priv->delayed_idle); + priv->delayed_idle = 0; + } + + get_properties_idle(client); + + dbus_g_connection_flush(priv->session_bus); + + return; +} + /* A function to group all the get_properties commands to make them more efficient over dbus. */ static void @@ -1147,6 +1166,10 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it g_list_free(oldchildren); /* We've got everything built up at this node and reconcilled */ + + /* Flush the properties requests */ + get_properties_flush(client); + /* now it's time to recurse down the tree. */ children = node->children; GList * childmis = dbusmenu_menuitem_get_children(item); -- cgit v1.2.3 From 76b3d5020bef447e78cc6205309464b411b13836 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 15:17:50 -0500 Subject: If there's no idle setup we don't need to worry about flushing, there's nothing to do. --- libdbusmenu-glib/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5ecfbde..5e1fe0c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -521,11 +521,13 @@ get_properties_flush (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - if (priv->delayed_idle != 0) { - g_source_remove(priv->delayed_idle); - priv->delayed_idle = 0; + if (priv->delayed_idle == 0) { + return; } + g_source_remove(priv->delayed_idle); + priv->delayed_idle = 0; + get_properties_idle(client); dbus_g_connection_flush(priv->session_bus); -- cgit v1.2.3 From 3d98145e318bb486451603c2a312e65c14ea809f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:09:35 -0500 Subject: Building the signal slot --- libdbusmenu-glib/server.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index f4e3527..4daf448 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -58,10 +58,10 @@ G_BEGIN_DECLS @id_prop_update: Slot for #DbusmenuServer::id-prop-update. @id_update: Slot for #DbusmenuServer::id-update. @layout_updated: Slot for #DbusmenuServer::layout-update. + @item_activation_requested: Slot for #DbusmenuServer::item-activation-requested. @dbusmenu_server_reserved1: Reserved for future use. @dbusmenu_server_reserved2: Reserved for future use. @dbusmenu_server_reserved3: Reserved for future use. - @dbusmenu_server_reserved4: Reserved for future use. The class implementing the virtual functions for #DbusmenuServer. */ @@ -73,12 +73,12 @@ struct _DbusmenuServerClass { void (*id_prop_update)(gint id, gchar * property, gchar * value); void (*id_update)(gint id); void (*layout_updated)(gint revision); + void (*item_activation_requested)(gint id, guint timestamp); /* Reserved */ void (*dbusmenu_server_reserved1)(void); void (*dbusmenu_server_reserved2)(void); void (*dbusmenu_server_reserved3)(void); - void (*dbusmenu_server_reserved4)(void); }; /** -- cgit v1.2.3 From 903aaf402c081506173b31c755fe58338b6cd930 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:15:25 -0500 Subject: Actually build the signal and put it on the object. --- libdbusmenu-glib/server-marshal.list | 1 + libdbusmenu-glib/server.c | 17 +++++++++++++++++ libdbusmenu-glib/server.h | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server-marshal.list b/libdbusmenu-glib/server-marshal.list index 1689a05..0d68c4e 100644 --- a/libdbusmenu-glib/server-marshal.list +++ b/libdbusmenu-glib/server-marshal.list @@ -1,2 +1,3 @@ VOID: INT, STRING, POINTER VOID: UINT, INT +VOID: INT, UINT diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 13c2843..deee5da 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -65,6 +65,7 @@ enum { ID_PROP_UPDATE, ID_UPDATE, LAYOUT_UPDATED, + ITEM_ACTIVATION, LAST_SIGNAL }; @@ -165,6 +166,22 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) NULL, NULL, _dbusmenu_server_marshal_VOID__UINT_INT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_INT); + /** + DbusmenuServer::item-activation-requested: + @arg0: The #DbusmenuServer emitting the signal. + @arg1: The ID of the parent for this update. + @arg2: The timestamp of when the event happened + + This is signaled when a menuitem under this server + sends it's activate signal. + */ + signals[ITEM_ACTIVATION] = g_signal_new(DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION, + G_TYPE_FROM_CLASS(class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(DbusmenuServerClass, item_activation), + NULL, NULL, + _dbusmenu_server_marshal_VOID__INT_UINT, + G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT); g_object_class_install_property (object_class, PROP_DBUS_OBJECT, diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 4daf448..a9bf213 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -46,6 +46,7 @@ G_BEGIN_DECLS #define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated" #define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated" #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED "layout-updated" +#define DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION "item-activation-requested" #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" @@ -73,7 +74,7 @@ struct _DbusmenuServerClass { void (*id_prop_update)(gint id, gchar * property, gchar * value); void (*id_update)(gint id); void (*layout_updated)(gint revision); - void (*item_activation_requested)(gint id, guint timestamp); + void (*item_activation)(gint id, guint timestamp); /* Reserved */ void (*dbusmenu_server_reserved1)(void); -- cgit v1.2.3 From 4fbfb66b98d31283facfd425a91d084c61288ac8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:21:13 -0500 Subject: Setting up listening on the menuitems to send the activate signal over. --- libdbusmenu-glib/server.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index deee5da..aa8dfac 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -376,6 +376,15 @@ menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint return; } +/* Called when a menu item emits its activated signal so it + gets passed across the bus. */ +static void +menuitem_activated (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server) +{ + g_signal_emit(G_OBJECT(server), signals[ITEM_ACTIVATION], 0, dbusmenu_menuitem_get_id(mi), timestamp, TRUE); + return; +} + /* Connects all the signals that we're interested in coming from a menuitem */ static void @@ -385,6 +394,7 @@ menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data) g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(menuitem_child_removed), data); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(menuitem_child_moved), data); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menuitem_property_changed), data); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activated), data); return; } -- cgit v1.2.3 From fd7ffaa78b2c75db0b8138903d7272ed15641ce1 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 22 Jul 2010 10:44:33 +0200 Subject: Fix menu order in submenus --- libdbusmenu-gtk/client.c | 4 +- tests/Makefile.am | 47 ++++++++++++- tests/test-gtk-reorder-server.c | 19 ++++-- tests/test-gtk-submenu-client.c | 143 ++++++++++++++++++++++++++++++++++++++++ tests/test-gtk-submenu-server.c | 86 ++++++++++++++++++++++++ 5 files changed, 289 insertions(+), 10 deletions(-) create mode 100644 tests/test-gtk-submenu-client.c create mode 100644 tests/test-gtk-submenu-server.c diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index b406697..b5b509f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -491,7 +491,7 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* Oh, we're a child, let's deal with that */ if (parent != NULL) { - new_child(parent, item, dbusmenu_menuitem_get_position_realized(item, parent), DBUSMENU_GTKCLIENT(client)); + new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); } return; @@ -519,7 +519,7 @@ new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, Dbus } GtkMenuItem * childmi = dbusmenu_gtkclient_menuitem_get(gtkclient, child); - gtk_menu_shell_insert(GTK_MENU_SHELL(menu), GTK_WIDGET(childmi), dbusmenu_menuitem_get_position_realized(child, mi)); + gtk_menu_shell_insert(GTK_MENU_SHELL(menu), GTK_WIDGET(childmi), position); gtk_widget_show(GTK_WIDGET(menu)); return; diff --git a/tests/Makefile.am b/tests/Makefile.am index 63857a2..9f621cb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,8 @@ TESTS = \ test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ - test-gtk-reorder + test-gtk-reorder \ + test-gtk-submenu check_PROGRAMS = \ glib-server-nomenu \ @@ -36,7 +37,9 @@ check_PROGRAMS = \ test-glib-simple-items \ test-gtk-reorder-server \ test-json-client \ - test-json-server + test-json-server \ + test-gtk-submenu-server \ + test-gtk-submenu-client XVFB_RUN=". $(srcdir)/run-xvfb.sh" @@ -453,6 +456,46 @@ test_gtk_reorder_server_LDADD = \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) +######################### +# Test GTK Submenu +######################### + +test-gtk-submenu: test-gtk-submenu-client test-gtk-submenu-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-submenu-client --task-name Client --task ./test-gtk-submenu-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + +test_gtk_submenu_server_SOURCES = \ + test-gtk-submenu-server.c + +test_gtk_submenu_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_submenu_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) + +test_gtk_submenu_client_SOURCES = \ + test-gtk-submenu-client.c + +test_gtk_submenu_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_submenu_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) + ######################### # Test Mago ######################### diff --git a/tests/test-gtk-reorder-server.c b/tests/test-gtk-reorder-server.c index eee9bb8..a3fadb1 100644 --- a/tests/test-gtk-reorder-server.c +++ b/tests/test-gtk-reorder-server.c @@ -41,17 +41,18 @@ guint ordering [NUMBER_TESTS][NUMBER_ENTRIES] = { }; gchar * names [NUMBER_ENTRIES] = { - "One", "Two", "Three", "Four", "Five" + "0", "1", "2", "3", "4" }; DbusmenuMenuitem * entries[NUMBER_ENTRIES] = {0}; DbusmenuMenuitem * root = NULL; - +DbusmenuMenuitem * parent = NULL; gint test = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; +#if 0 static gboolean timer_func (gpointer data) { @@ -65,13 +66,14 @@ timer_func (gpointer data) int i; for (i = 0; i < NUMBER_ENTRIES; i++) { g_debug("Putting entry '%d' at position '%d'", i, ordering[test][i]); - dbusmenu_menuitem_child_reorder(root, entries[i], ordering[test][i]); + dbusmenu_menuitem_child_reorder(parent, entries[i], ordering[test][i]); dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); } test++; return TRUE; } +#endif int main (int argc, char ** argv) @@ -101,13 +103,18 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); int i; + parent = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(parent, "label", "Parent"); + dbusmenu_menuitem_child_append(root, parent); + for (i = 0; i < NUMBER_ENTRIES; i++) { entries[i] = dbusmenu_menuitem_new(); - dbusmenu_menuitem_child_append(root, entries[i]); + dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); + dbusmenu_menuitem_child_append(parent, entries[i]); } - timer_func(NULL); - g_timeout_add_seconds(5, timer_func, NULL); + //timer_func(NULL); + //g_timeout_add_seconds(5, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-gtk-submenu-client.c b/tests/test-gtk-submenu-client.c new file mode 100644 index 0000000..2e1ef7a --- /dev/null +++ b/tests/test-gtk-submenu-client.c @@ -0,0 +1,143 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +static gboolean check_menu_content(GtkMenu * menu, char ** content) +{ + GList * child = gtk_container_get_children(GTK_CONTAINER(menu)); + char ** expected = content; + for (; child != NULL; child = g_list_next(child), ++expected) { + if (*expected == NULL) { + g_warning("Too many gtk items"); + return FALSE; + } + const char * label = gtk_menu_item_get_label(GTK_MENU_ITEM(child->data)); + if (g_strcmp0(label, *expected) != 0) { + g_warning("Expected '%s', got '%s'", *expected, label); + return FALSE; + } + } + if (*expected != NULL) { + g_warning("Not enough gtk items"); + return FALSE; + } + return TRUE; +} + +static void +abort_test(const char * message) +{ + if (message) { + g_warning("%s", message); + } + passed = FALSE; + g_main_loop_quit(mainloop); +} + +static gboolean +timer_func (gpointer data) +{ + static char * root_content[] = { "Folder 1", "Folder 2", NULL }; + static char * folder1_content[] = { "1.1", "1.2", "1.3", NULL }; + static char * folder2_content[] = { "2.1", "2.2", "2.3", NULL }; + + GtkMenuItem * root_item = GTK_MENU_ITEM(data); + GtkMenu * menu = GTK_MENU(gtk_menu_item_get_submenu(root_item)); + + /* Root */ + if (!check_menu_content(menu, root_content)) { + abort_test("Checking root content failed"); + return FALSE; + } + + /* Folder 1 */ + GList * child = gtk_container_get_children(GTK_CONTAINER(menu)); + GtkMenuItem * item = GTK_MENU_ITEM(child->data); + GtkMenu * folder_menu = GTK_MENU(gtk_menu_item_get_submenu(item)); + if (!folder_menu) { + abort_test("Folder 1 has no menu"); + return FALSE; + } + + if (!check_menu_content(folder_menu, folder1_content)) { + abort_test("Checking folder1 content failed"); + return FALSE; + } + + /* Folder 2 */ + child = g_list_next(child); + item = GTK_MENU_ITEM(child->data); + folder_menu = GTK_MENU(gtk_menu_item_get_submenu(item)); + if (!folder_menu) { + abort_test("Folder 2 has no menu"); + return FALSE; + } + + if (!check_menu_content(folder_menu, folder2_content)) { + abort_test("Checking folder2 content failed"); + return FALSE; + } + + passed = TRUE; + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char ** argv) +{ + gtk_init(&argc, &argv); + + g_debug("Client Initialized. Waiting."); + /* Make sure the server starts up and all that */ + g_usleep(500000); + + g_debug("Building Window"); + GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget * menubar = gtk_menu_bar_new(); + GtkWidget * menuitem = gtk_menu_item_new_with_label("Test"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(dbusmenu_gtkmenu_new ("glib.label.test", "/org/test"))); + gtk_widget_show(menuitem); + gtk_menu_bar_append(menubar, menuitem); + gtk_widget_show(menubar); + gtk_container_add(GTK_CONTAINER(window), menubar); + gtk_window_set_title(GTK_WINDOW(window), "libdbusmenu-gtk test"); + gtk_widget_show(window); + + g_timeout_add_seconds(1, timer_func, menuitem); + + g_debug("Entering Mainloop"); + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 1; + } +} diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c new file mode 100644 index 0000000..ed9cf79 --- /dev/null +++ b/tests/test-gtk-submenu-server.c @@ -0,0 +1,86 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include +#include +#include +#include + +#include +#include + +DbusmenuMenuitem * +add_item(DbusmenuMenuitem * parent, const char * label) +{ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(item, "label", label); + dbusmenu_menuitem_child_append(parent, item); + return item; +} + +int +main (int argc, char ** argv) +{ + GError * error = NULL; + + g_type_init(); + + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + + DbusmenuServer * server = dbusmenu_server_new("/org/test"); + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + dbusmenu_server_set_root(server, root); + + DbusmenuMenuitem * item; + item = add_item(root, "Folder 1"); + add_item(item, "1.1"); + add_item(item, "1.2"); + add_item(item, "1.3"); + + item = add_item(root, "Folder 2"); + add_item(item, "2.1"); + add_item(item, "2.2"); + add_item(item, "2.3"); + + GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} + -- cgit v1.2.3 From d96d7282b58e60141cde234e106ab3281f50d7b6 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 22 Jul 2010 11:31:48 +0200 Subject: Reverted changes to test-gtk-reorder-server --- tests/test-gtk-reorder-server.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/test-gtk-reorder-server.c b/tests/test-gtk-reorder-server.c index a3fadb1..eee9bb8 100644 --- a/tests/test-gtk-reorder-server.c +++ b/tests/test-gtk-reorder-server.c @@ -41,18 +41,17 @@ guint ordering [NUMBER_TESTS][NUMBER_ENTRIES] = { }; gchar * names [NUMBER_ENTRIES] = { - "0", "1", "2", "3", "4" + "One", "Two", "Three", "Four", "Five" }; DbusmenuMenuitem * entries[NUMBER_ENTRIES] = {0}; DbusmenuMenuitem * root = NULL; -DbusmenuMenuitem * parent = NULL; + gint test = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; -#if 0 static gboolean timer_func (gpointer data) { @@ -66,14 +65,13 @@ timer_func (gpointer data) int i; for (i = 0; i < NUMBER_ENTRIES; i++) { g_debug("Putting entry '%d' at position '%d'", i, ordering[test][i]); - dbusmenu_menuitem_child_reorder(parent, entries[i], ordering[test][i]); + dbusmenu_menuitem_child_reorder(root, entries[i], ordering[test][i]); dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); } test++; return TRUE; } -#endif int main (int argc, char ** argv) @@ -103,18 +101,13 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); int i; - parent = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(parent, "label", "Parent"); - dbusmenu_menuitem_child_append(root, parent); - for (i = 0; i < NUMBER_ENTRIES; i++) { entries[i] = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); - dbusmenu_menuitem_child_append(parent, entries[i]); + dbusmenu_menuitem_child_append(root, entries[i]); } - //timer_func(NULL); - //g_timeout_add_seconds(5, timer_func, NULL); + timer_func(NULL); + g_timeout_add_seconds(5, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From d52e108200e0214e770e9cf151f5b96af5ee41f5 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 22 Jul 2010 21:05:53 +0200 Subject: Test fixes. --- tests/Makefile.am | 1 - tests/test-gtk-submenu-server.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 9f621cb..839305f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,7 +10,6 @@ TESTS = \ test-glib-proxy \ test-glib-simple-items \ test-glib-submenu \ - test-json \ test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c index ed9cf79..ba3993e 100644 --- a/tests/test-gtk-submenu-server.c +++ b/tests/test-gtk-submenu-server.c @@ -29,6 +29,16 @@ with this program. If not, see . #include #include +static GMainLoop *mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + g_main_loop_quit (mainloop); + + return FALSE; +} + DbusmenuMenuitem * add_item(DbusmenuMenuitem * parent, const char * label) { @@ -76,7 +86,9 @@ main (int argc, char ** argv) add_item(item, "2.2"); add_item(item, "2.3"); - GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); + g_timeout_add_seconds(3, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_debug("Quiting"); -- cgit v1.2.3 From 8c75a152b79446cf8a63a79097b05b6fd620e778 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 22 Jul 2010 21:09:39 +0200 Subject: Bump version. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 93aa557..d54dc41 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.6, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.7, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.6, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.7, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 9b82146e224aa02bc77d1a5a57cf931cadd86438 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Fri, 30 Jul 2010 12:29:54 -0500 Subject: Bump version to 0.3.8. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index d54dc41..d8211b1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.7, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.8, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.7, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.8, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 30e2a62868255de3d48efc9462ee465e95c041e3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Aug 2010 20:24:17 -0500 Subject: 0.3.9 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index d8211b1..c90e8bf 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.8, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.9, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.8, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.9, [-Wno-portability]) AM_MAINTAINER_MODE @@ -99,7 +99,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=11 +LIBDBUSMENU_REVISION=12 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From a68fa500006320df74beb336c5daf2f2f0950560 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 5 Aug 2010 19:05:51 +0200 Subject: debug-- --- tools/dbusmenu-dumper.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 40ab1e1..9e66236 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -445,12 +445,10 @@ main (int argc, char ** argv) g_printerr("ERROR: could not get the id for the pointed window\n"); return 1; } - g_debug("window: %u", (unsigned int)window); if (!init_dbus_vars_from_window(window)) { g_printerr("ERROR: could not find a menu for the pointed window\n"); return 1; } - g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); } else { if (dbusname == NULL) { g_printerr("ERROR: dbus-name not specified\n"); -- cgit v1.2.3 From 845a83ce74926c1cfc4362cf022035d017242dda Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 5 Aug 2010 19:34:18 +0200 Subject: Seems the test passes after all --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 839305f..9f621cb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,6 +10,7 @@ TESTS = \ test-glib-proxy \ test-glib-simple-items \ test-glib-submenu \ + test-json \ test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ -- cgit v1.2.3 From e22b44483407aac56d6b50705bed890038e469a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Aug 2010 11:11:13 -0500 Subject: Making the dumper sort the properties to make it more predictable. --- tests/test-json-01.json | 386 ++++++++++++++++++++++++------------------------ tools/dbusmenu-dumper.c | 9 +- 2 files changed, 201 insertions(+), 194 deletions(-) diff --git a/tests/test-json-01.json b/tests/test-json-01.json index 88e1cbf..08e9112 100644 --- a/tests/test-json-01.json +++ b/tests/test-json-01.json @@ -4,30 +4,30 @@ "submenu": [ { "id": 5, + "children-display": "submenu", "enabled": true, "label": "File", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 6, - "shortcut": [["Control", "q"]], "enabled": true, "label": "Quit", + "shortcut": [["Control", "q"]], "visible": true }, { "id": 7, - "shortcut": [["Control", "Shift", "w"]], "enabled": true, "label": "Close all", + "shortcut": [["Control", "Shift", "w"]], "visible": true }, { "id": 8, - "shortcut": [["Control", "w"]], "enabled": true, "label": "Close", + "shortcut": [["Control", "w"]], "visible": true }, { @@ -42,9 +42,9 @@ }, { "id": 11, - "shortcut": [["Control", "p"]], "enabled": true, "label": "Print...", + "shortcut": [["Control", "p"]], "visible": true }, { @@ -77,16 +77,16 @@ }, { "id": 17, - "shortcut": [["Control", "Shift", "s"]], "enabled": true, "label": "Save As...", + "shortcut": [["Control", "Shift", "s"]], "visible": true }, { "id": 18, - "shortcut": [["Control", "s"]], "enabled": true, "label": "Save", + "shortcut": [["Control", "s"]], "visible": true }, { @@ -95,9 +95,9 @@ }, { "id": 20, + "children-display": "submenu", "enabled": true, "label": "Open Recent", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -112,16 +112,16 @@ }, { "id": 23, - "shortcut": [["Control", "2"]], "enabled": true, "label": "giggity.jpg", + "shortcut": [["Control", "2"]], "visible": true }, { "id": 24, - "shortcut": [["Control", "1"]], "enabled": true, "label": "Icon Height.svg", + "shortcut": [["Control", "1"]], "visible": true } ] @@ -134,37 +134,37 @@ }, { "id": 26, - "shortcut": [["Control", "Alt", "o"]], "enabled": true, "label": "Open as Layers...", + "shortcut": [["Control", "Alt", "o"]], "visible": true }, { "id": 27, - "shortcut": [["Control", "o"]], "enabled": true, "label": "Open...", + "shortcut": [["Control", "o"]], "visible": true }, { "id": 28, + "children-display": "submenu", "enabled": true, "label": "Create", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 29, + "children-display": "submenu", "enabled": true, "label": "Web Page Themes", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 30, + "children-display": "submenu", "enabled": true, "label": "Classic.Gimp.Org", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -207,9 +207,9 @@ }, { "id": 37, + "children-display": "submenu", "enabled": true, "label": "Beveled Pattern", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -246,9 +246,9 @@ }, { "id": 43, + "children-display": "submenu", "enabled": true, "label": "Alien Glow", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -281,9 +281,9 @@ }, { "id": 48, + "children-display": "submenu", "enabled": true, "label": "Patterns", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -338,9 +338,9 @@ }, { "id": 57, + "children-display": "submenu", "enabled": true, "label": "Logos", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -515,9 +515,9 @@ }, { "id": 86, + "children-display": "submenu", "enabled": true, "label": "Buttons", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -540,9 +540,9 @@ }, { "id": 90, + "children-display": "submenu", "enabled": true, "label": "xscanimage", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -561,27 +561,27 @@ }, { "id": 93, - "shortcut": [["Control", "Shift", "v"]], "enabled": true, "label": "From Clipboard", + "shortcut": [["Control", "Shift", "v"]], "visible": true } ] }, { "id": 94, - "shortcut": [["Control", "n"]], "enabled": true, "label": "New...", + "shortcut": [["Control", "n"]], "visible": true } ] }, { "id": 95, + "children-display": "submenu", "enabled": true, "label": "Edit", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -626,30 +626,30 @@ }, { "id": 103, - "shortcut": [["Control", "semicolon"]], "enabled": true, "label": "Fill with Pattern", + "shortcut": [["Control", "semicolon"]], "visible": true }, { "id": 104, - "shortcut": [["Control", "period"]], "enabled": true, "label": "Fill with BG Color", + "shortcut": [["Control", "period"]], "visible": true }, { "id": 105, - "shortcut": [["Control", "comma"]], "enabled": true, "label": "Fill with FG Color", + "shortcut": [["Control", "comma"]], "visible": true }, { "id": 106, - "shortcut": [["Delete"]], "enabled": true, "label": "Clear", + "shortcut": [["Delete"]], "visible": true }, { @@ -658,9 +658,9 @@ }, { "id": 108, + "children-display": "submenu", "enabled": true, "label": "Buffer", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -691,9 +691,9 @@ }, { "id": 113, + "children-display": "submenu", "enabled": true, "label": "Paste as", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -716,9 +716,9 @@ }, { "id": 117, - "shortcut": [["Control", "Shift", "v"]], "enabled": true, "label": "New Image", + "shortcut": [["Control", "Shift", "v"]], "visible": true } ] @@ -731,30 +731,30 @@ }, { "id": 119, - "shortcut": [["Control", "v"]], "enabled": true, "label": "Paste", + "shortcut": [["Control", "v"]], "visible": true }, { "id": 120, - "shortcut": [["Control", "Shift", "c"]], "enabled": true, "label": "Copy Visible", + "shortcut": [["Control", "Shift", "c"]], "visible": true }, { "id": 121, - "shortcut": [["Control", "c"]], "enabled": true, "label": "Copy", + "shortcut": [["Control", "c"]], "visible": true }, { "id": 122, - "shortcut": [["Control", "x"]], "enabled": true, "label": "Cut", + "shortcut": [["Control", "x"]], "visible": true }, { @@ -775,25 +775,25 @@ }, { "id": 2, - "shortcut": [["Control", "y"]], "enabled": false, "label": "_Redo", + "shortcut": [["Control", "y"]], "visible": true }, { "id": 1, - "shortcut": [["Control", "z"]], "enabled": false, "label": "_Undo", + "shortcut": [["Control", "z"]], "visible": true } ] }, { "id": 125, + "children-display": "submenu", "enabled": true, "label": "Select", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -810,10 +810,10 @@ }, { "id": 128, - "shortcut": [["Shift", "q"]], "enabled": true, - "toggle-state": 0, "label": "Toggle Quick Mask", + "shortcut": [["Shift", "q"]], + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, @@ -869,93 +869,93 @@ }, { "id": 138, - "shortcut": [["Shift", "v"]], "enabled": false, "label": "From Path", + "shortcut": [["Shift", "v"]], "visible": true }, { "id": 139, - "shortcut": [["Shift", "o"]], "enabled": true, "label": "By Color", + "shortcut": [["Shift", "o"]], "visible": true }, { "id": 140, - "shortcut": [["Control", "Shift", "l"]], "enabled": false, "label": "Float", + "shortcut": [["Control", "Shift", "l"]], "visible": true }, { "id": 141, - "shortcut": [["Control", "i"]], "enabled": true, "label": "Invert", + "shortcut": [["Control", "i"]], "visible": true }, { "id": 142, - "shortcut": [["Control", "Shift", "a"]], "enabled": false, "label": "None", + "shortcut": [["Control", "Shift", "a"]], "visible": true }, { "id": 143, - "shortcut": [["Control", "a"]], "enabled": true, "label": "All", + "shortcut": [["Control", "a"]], "visible": true } ] }, { "id": 144, + "children-display": "submenu", "enabled": true, "label": "View", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 145, "enabled": true, - "toggle-state": 1, "label": "Show Statusbar", + "toggle-state": 1, "toggle-type": "checkmark", "visible": true }, { "id": 146, "enabled": true, - "toggle-state": 0, "label": "Show Scrollbars", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 147, - "shortcut": [["Control", "Shift", "r"]], "enabled": true, - "toggle-state": 0, "label": "Show Rulers", + "shortcut": [["Control", "Shift", "r"]], + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 148, "enabled": true, - "toggle-state": 1, "label": "Show Menubar", + "toggle-state": 1, "toggle-type": "checkmark", "visible": true }, { "id": 149, + "children-display": "submenu", "enabled": true, "label": "Padding Color", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1001,32 +1001,32 @@ { "id": 157, "enabled": true, - "toggle-state": 0, "label": "Snap to Active Path", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 158, "enabled": true, - "toggle-state": 0, "label": "Snap to Canvas Edges", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 159, "enabled": true, - "toggle-state": 0, "label": "Snap to Grid", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 160, "enabled": true, - "toggle-state": 1, "label": "Snap to Guides", + "toggle-state": 1, "toggle-type": "checkmark", "visible": true }, @@ -1037,42 +1037,42 @@ { "id": 162, "enabled": true, - "toggle-state": 0, "label": "Show Sample Points", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 163, "enabled": true, - "toggle-state": 0, "label": "Show Grid", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 164, - "shortcut": [["Control", "Shift", "t"]], "enabled": true, - "toggle-state": 0, "label": "Show Guides", + "shortcut": [["Control", "Shift", "t"]], + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 165, "enabled": true, - "toggle-state": 0, "label": "Show Layer Boundary", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 166, - "shortcut": [["Control", "t"]], "enabled": true, - "toggle-state": 0, "label": "Show Selection", + "shortcut": [["Control", "t"]], + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, @@ -1098,12 +1098,12 @@ }, { "id": 171, + "children-display": "submenu", "enabled": true, + "label": "Fullscreen", "shortcut": [["F11"]], "toggle-state": 0, - "label": "Fullscreen", "toggle-type": "checkmark", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1116,9 +1116,9 @@ }, { "id": 173, - "shortcut": [["Control", "e"]], "enabled": true, "label": "Shrink Wrap", + "shortcut": [["Control", "e"]], "visible": true }, { @@ -1127,16 +1127,16 @@ }, { "id": 175, + "children-display": "submenu", "enabled": true, "label": "_Zoom (67%)", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 176, "enabled": true, - "toggle-state": 0, "label": "Othe_r (67%)...", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, @@ -1147,73 +1147,73 @@ { "id": 178, "enabled": true, - "toggle-state": 0, "label": "1:16 (6.25%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 179, "enabled": true, - "toggle-state": 0, "label": "1:8 (12.5%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 180, "enabled": true, - "toggle-state": 0, "label": "1:4 (25%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 181, "enabled": true, - "toggle-state": 0, "label": "1:2 (50%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 182, - "shortcut": [["1"]], "enabled": true, - "toggle-state": 1, "label": "1:1 (100%)", + "shortcut": [["1"]], + "toggle-state": 1, "toggle-type": "checkmark", "visible": true }, { "id": 183, "enabled": true, - "toggle-state": 0, "label": "2:1 (200%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 184, "enabled": true, - "toggle-state": 0, "label": "4:1 (400%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 185, "enabled": true, - "toggle-state": 0, "label": "8:1 (800%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 186, "enabled": true, - "toggle-state": 0, "label": "16:1 (1600%)", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, @@ -1229,30 +1229,30 @@ }, { "id": 189, - "shortcut": [["Control", "Shift", "e"]], "enabled": true, "label": "Fit Image in Window", + "shortcut": [["Control", "Shift", "e"]], "visible": true }, { "id": 190, - "shortcut": [["plus"]], "enabled": true, "label": "Zoom In", + "shortcut": [["plus"]], "visible": true }, { "id": 191, - "shortcut": [["minus"]], "enabled": true, "label": "Zoom Out", + "shortcut": [["minus"]], "visible": true }, { "id": 4, - "shortcut": [["grave"]], "enabled": true, "label": "Re_vert Zoom (67%)", + "shortcut": [["grave"]], "visible": true } ] @@ -1260,8 +1260,8 @@ { "id": 192, "enabled": true, - "toggle-state": 1, "label": "Dot for Dot", + "toggle-state": 1, "toggle-type": "checkmark", "visible": true }, @@ -1275,16 +1275,16 @@ }, { "id": 194, + "children-display": "submenu", "enabled": true, "label": "Image", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 195, - "shortcut": [["Alt", "Return"]], "enabled": true, "label": "Image Properties", + "shortcut": [["Alt", "Return"]], "visible": true }, { @@ -1295,9 +1295,9 @@ }, { "id": 197, + "children-display": "submenu", "enabled": true, "label": "Guides", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1344,9 +1344,9 @@ }, { "id": 205, - "shortcut": [["Control", "m"]], "enabled": true, "label": "Merge Visible Layers...", + "shortcut": [["Control", "m"]], "visible": true }, { @@ -1411,9 +1411,9 @@ }, { "id": 217, + "children-display": "submenu", "enabled": true, "label": "Transform", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1464,9 +1464,9 @@ }, { "id": 226, + "children-display": "submenu", "enabled": true, "label": "Mode", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1488,24 +1488,24 @@ { "id": 230, "enabled": true, - "toggle-state": 0, "label": "Indexed...", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 231, "enabled": true, - "toggle-state": 0, "label": "Grayscale", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 232, "enabled": true, - "toggle-state": 1, "label": "RGB", + "toggle-state": 1, "toggle-type": "checkmark", "visible": true } @@ -1513,18 +1513,18 @@ }, { "id": 233, - "shortcut": [["Control", "d"]], "enabled": true, "label": "Duplicate", + "shortcut": [["Control", "d"]], "visible": true } ] }, { "id": 234, + "children-display": "submenu", "enabled": true, "label": "Layer", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1563,16 +1563,16 @@ }, { "id": 241, + "children-display": "submenu", "enabled": true, "label": "Transform", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 242, - "shortcut": [["Control", "Shift", "o"]], "enabled": true, "label": "Offset...", + "shortcut": [["Control", "Shift", "o"]], "visible": true }, { @@ -1623,9 +1623,9 @@ }, { "id": 251, + "children-display": "submenu", "enabled": true, "label": "Transparency", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1690,9 +1690,9 @@ }, { "id": 262, + "children-display": "submenu", "enabled": true, "label": "Mask", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1726,24 +1726,24 @@ { "id": 268, "enabled": false, - "toggle-state": 0, "label": "Disable Layer Mask", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 269, "enabled": false, - "toggle-state": 0, "label": "Edit Layer Mask", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, { "id": 270, "enabled": false, - "toggle-state": 0, "label": "Show Layer Mask", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, @@ -1773,9 +1773,9 @@ }, { "id": 275, + "children-display": "submenu", "enabled": true, "label": "Stack", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1818,38 +1818,38 @@ }, { "id": 283, - "shortcut": [["End"]], "enabled": false, "label": "Select Bottom Layer", + "shortcut": [["End"]], "visible": true }, { "id": 284, - "shortcut": [["Home"]], "enabled": false, "label": "Select Top Layer", + "shortcut": [["Home"]], "visible": true }, { "id": 285, - "shortcut": [["Page_Down"]], "enabled": false, "label": "Select Next Layer", + "shortcut": [["Page_Down"]], "visible": true }, { "id": 286, - "shortcut": [["Page_Up"]], "enabled": false, "label": "Select Previous Layer", + "shortcut": [["Page_Up"]], "visible": true } ] }, { "id": 287, - "type": "separator", "children-display": "submenu", + "type": "separator", "submenu": [ { "id": 288, @@ -1873,16 +1873,16 @@ }, { "id": 291, - "shortcut": [["Control", "h"]], "enabled": false, "label": "Anchor Layer", + "shortcut": [["Control", "h"]], "visible": true }, { "id": 292, - "shortcut": [["Control", "Shift", "d"]], "enabled": true, "label": "Duplicate Layer", + "shortcut": [["Control", "Shift", "d"]], "visible": true }, { @@ -1893,18 +1893,18 @@ }, { "id": 294, - "shortcut": [["Control", "Shift", "n"]], "enabled": true, "label": "New Layer...", + "shortcut": [["Control", "Shift", "n"]], "visible": true } ] }, { "id": 295, + "children-display": "submenu", "enabled": true, "label": "Colors", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1949,9 +1949,9 @@ }, { "id": 303, + "children-display": "submenu", "enabled": true, "label": "Info", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -1982,9 +1982,9 @@ }, { "id": 308, + "children-display": "submenu", "enabled": true, "label": "Map", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2043,9 +2043,9 @@ }, { "id": 318, + "children-display": "submenu", "enabled": true, "label": "Components", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2076,9 +2076,9 @@ }, { "id": 323, + "children-display": "submenu", "enabled": true, "label": "Auto", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2126,8 +2126,8 @@ { "id": 331, "enabled": true, - "toggle-state": 0, "label": "Use GEGL", + "toggle-state": 0, "toggle-type": "checkmark", "visible": true }, @@ -2209,30 +2209,30 @@ }, { "id": 345, + "children-display": "submenu", "enabled": true, "label": "Tools", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 346, - "shortcut": [["x"]], "enabled": true, "label": "Swap Colors", + "shortcut": [["x"]], "visible": true }, { "id": 347, - "shortcut": [["d"]], "enabled": true, "label": "Default Colors", + "shortcut": [["d"]], "visible": true }, { "id": 348, - "shortcut": [["Control", "b"]], "enabled": true, "label": "Toolbox", + "shortcut": [["Control", "b"]], "visible": true }, { @@ -2247,44 +2247,44 @@ }, { "id": 351, - "shortcut": [["t"]], "enabled": true, "label": "Text", + "shortcut": [["t"]], "visible": true }, { "id": 352, - "shortcut": [["Shift", "m"]], "enabled": true, "label": "Measure", + "shortcut": [["Shift", "m"]], "visible": true }, { "id": 353, - "shortcut": [["z"]], "enabled": true, "label": "Zoom", + "shortcut": [["z"]], "visible": true }, { "id": 354, - "shortcut": [["o"]], "enabled": true, "label": "Color Picker", + "shortcut": [["o"]], "visible": true }, { "id": 355, - "shortcut": [["b"]], "enabled": true, "label": "Paths", + "shortcut": [["b"]], "visible": true }, { "id": 356, + "children-display": "submenu", "enabled": true, "label": "Color Tools", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2345,95 +2345,95 @@ }, { "id": 366, + "children-display": "submenu", "enabled": true, "label": "Transform Tools", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 367, - "shortcut": [["Shift", "f"]], "enabled": true, "label": "Flip", + "shortcut": [["Shift", "f"]], "visible": true }, { "id": 368, - "shortcut": [["Shift", "p"]], "enabled": true, "label": "Perspective", + "shortcut": [["Shift", "p"]], "visible": true }, { "id": 369, - "shortcut": [["Shift", "s"]], "enabled": true, "label": "Shear", + "shortcut": [["Shift", "s"]], "visible": true }, { "id": 370, - "shortcut": [["Shift", "t"]], "enabled": true, "label": "Scale", + "shortcut": [["Shift", "t"]], "visible": true }, { "id": 371, - "shortcut": [["Shift", "r"]], "enabled": true, "label": "Rotate", + "shortcut": [["Shift", "r"]], "visible": true }, { "id": 372, - "shortcut": [["Shift", "c"]], "enabled": true, "label": "Crop", + "shortcut": [["Shift", "c"]], "visible": true }, { "id": 373, - "shortcut": [["m"]], "enabled": true, "label": "Move", + "shortcut": [["m"]], "visible": true }, { "id": 374, - "shortcut": [["q"]], "enabled": true, "label": "Align", + "shortcut": [["q"]], "visible": true } ] }, { "id": 375, + "children-display": "submenu", "enabled": true, "label": "Paint Tools", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 376, - "shortcut": [["Shift", "d"]], "enabled": true, "label": "Dodge / Burn", + "shortcut": [["Shift", "d"]], "visible": true }, { "id": 377, - "shortcut": [["s"]], "enabled": true, "label": "Smudge", + "shortcut": [["s"]], "visible": true }, { "id": 378, - "shortcut": [["Shift", "u"]], "enabled": true, "label": "Blur / Sharpen", + "shortcut": [["Shift", "u"]], "visible": true }, { @@ -2444,95 +2444,95 @@ }, { "id": 380, - "shortcut": [["h"]], "enabled": true, "label": "Heal", + "shortcut": [["h"]], "visible": true }, { "id": 381, - "shortcut": [["c"]], "enabled": true, "label": "Clone", + "shortcut": [["c"]], "visible": true }, { "id": 382, - "shortcut": [["k"]], "enabled": true, "label": "Ink", + "shortcut": [["k"]], "visible": true }, { "id": 383, - "shortcut": [["a"]], "enabled": true, "label": "Airbrush", + "shortcut": [["a"]], "visible": true }, { "id": 384, - "shortcut": [["Shift", "e"]], "enabled": true, "label": "Eraser", + "shortcut": [["Shift", "e"]], "visible": true }, { "id": 385, - "shortcut": [["p"]], "enabled": true, "label": "Paintbrush", + "shortcut": [["p"]], "visible": true }, { "id": 386, - "shortcut": [["n"]], "enabled": true, "label": "Pencil", + "shortcut": [["n"]], "visible": true }, { "id": 387, - "shortcut": [["l"]], "enabled": true, "label": "Blend", + "shortcut": [["l"]], "visible": true }, { "id": 388, - "shortcut": [["Shift", "b"]], "enabled": true, "label": "Bucket Fill", + "shortcut": [["Shift", "b"]], "visible": true } ] }, { "id": 389, + "children-display": "submenu", "enabled": true, "label": "Selection Tools", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 390, - "shortcut": [["i"]], "enabled": true, "label": "Intelligent Scissors", + "shortcut": [["i"]], "visible": true }, { "id": 391, - "shortcut": [["Shift", "o"]], "enabled": true, "label": "By Color Select", + "shortcut": [["Shift", "o"]], "visible": true }, { "id": 392, - "shortcut": [["u"]], "enabled": true, "label": "Fuzzy Select", + "shortcut": [["u"]], "visible": true }, { @@ -2543,23 +2543,23 @@ }, { "id": 394, - "shortcut": [["f"]], "enabled": true, "label": "Free Select", + "shortcut": [["f"]], "visible": true }, { "id": 395, - "shortcut": [["e"]], "enabled": true, "label": "Ellipse Select", + "shortcut": [["e"]], "visible": true }, { "id": 396, - "shortcut": [["r"]], "enabled": true, "label": "Rectangle Select", + "shortcut": [["r"]], "visible": true } ] @@ -2568,16 +2568,16 @@ }, { "id": 397, + "children-display": "submenu", "enabled": true, "label": "Filters", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 398, + "children-display": "submenu", "enabled": true, "label": "Script-Fu", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2602,9 +2602,9 @@ }, { "id": 402, + "children-display": "submenu", "enabled": true, "label": "Python-Fu", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2621,9 +2621,9 @@ }, { "id": 405, + "children-display": "submenu", "enabled": true, "label": "Alpha to Logo", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2748,9 +2748,9 @@ }, { "id": 426, + "children-display": "submenu", "enabled": true, "label": "Animation", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2815,9 +2815,9 @@ }, { "id": 437, + "children-display": "submenu", "enabled": true, "label": "Web", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2842,9 +2842,9 @@ }, { "id": 441, + "children-display": "submenu", "enabled": true, "label": "Render", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2895,9 +2895,9 @@ }, { "id": 450, + "children-display": "submenu", "enabled": true, "label": "Pattern", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2952,9 +2952,9 @@ }, { "id": 459, + "children-display": "submenu", "enabled": true, "label": "Nature", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -2973,9 +2973,9 @@ }, { "id": 462, + "children-display": "submenu", "enabled": true, "label": "Clouds", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3008,9 +3008,9 @@ }, { "id": 467, + "children-display": "submenu", "enabled": true, "label": "Map", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3077,9 +3077,9 @@ }, { "id": 478, + "children-display": "submenu", "enabled": true, "label": "Decor", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3140,9 +3140,9 @@ }, { "id": 488, + "children-display": "submenu", "enabled": true, "label": "Artistic", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3215,9 +3215,9 @@ }, { "id": 500, + "children-display": "submenu", "enabled": true, "label": "Combine", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3236,9 +3236,9 @@ }, { "id": 503, + "children-display": "submenu", "enabled": true, "label": "Generic", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3263,9 +3263,9 @@ }, { "id": 507, + "children-display": "submenu", "enabled": true, "label": "Edge-Detect", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3302,9 +3302,9 @@ }, { "id": 513, + "children-display": "submenu", "enabled": true, "label": "Noise", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3347,9 +3347,9 @@ }, { "id": 520, + "children-display": "submenu", "enabled": true, "label": "Light and Shadow", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3424,9 +3424,9 @@ }, { "id": 533, + "children-display": "submenu", "enabled": true, "label": "Distorts", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3541,9 +3541,9 @@ }, { "id": 552, + "children-display": "submenu", "enabled": true, "label": "Enhance", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3598,9 +3598,9 @@ }, { "id": 561, + "children-display": "submenu", "enabled": true, "label": "Blur", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3653,10 +3653,10 @@ }, { "id": 570, - "shortcut": [["Control", "Shift", "f"]], + "children-display": "submenu", "enabled": false, "label": "Re-Show Last", - "children-display": "submenu", + "shortcut": [["Control", "Shift", "f"]], "visible": true, "submenu": [ { @@ -3669,25 +3669,25 @@ }, { "id": 572, - "shortcut": [["Control", "f"]], "enabled": false, "label": "Repeat Last", + "shortcut": [["Control", "f"]], "visible": true } ] }, { "id": 573, + "children-display": "submenu", "enabled": true, "label": "Windows", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 574, - "shortcut": [["Control", "b"]], "enabled": true, "label": "Toolbox", + "shortcut": [["Control", "b"]], "visible": true }, { @@ -3696,9 +3696,9 @@ }, { "id": 576, + "children-display": "submenu", "enabled": true, "label": "Dockable Dialogs", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3755,23 +3755,23 @@ }, { "id": 586, - "shortcut": [["Control", "g"]], "enabled": true, "label": "Gradients", + "shortcut": [["Control", "g"]], "visible": true }, { "id": 587, - "shortcut": [["Control", "Shift", "p"]], "enabled": true, "label": "Patterns", + "shortcut": [["Control", "Shift", "p"]], "visible": true }, { "id": 588, - "shortcut": [["Control", "Shift", "b"]], "enabled": true, "label": "Brushes", + "shortcut": [["Control", "Shift", "b"]], "visible": true }, { @@ -3840,9 +3840,9 @@ }, { "id": 600, - "shortcut": [["Control", "l"]], "enabled": true, "label": "Layers", + "shortcut": [["Control", "l"]], "visible": true }, { @@ -3865,9 +3865,9 @@ }, { "id": 604, + "children-display": "submenu", "enabled": true, "label": "Recently Closed Docks", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3882,16 +3882,16 @@ }, { "id": 606, + "children-display": "submenu", "enabled": true, "label": "Help", - "children-display": "submenu", "visible": true, "submenu": [ { "id": 607, + "children-display": "submenu", "enabled": true, "label": "User Manual", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -3940,9 +3940,9 @@ }, { "id": 615, + "children-display": "submenu", "enabled": true, "label": "GIMP Online", - "children-display": "submenu", "visible": true, "submenu": [ { @@ -4005,16 +4005,16 @@ }, { "id": 626, - "shortcut": [["Shift", "F1"]], "enabled": true, "label": "Context Help", + "shortcut": [["Shift", "F1"]], "visible": true }, { "id": 627, - "shortcut": [["F1"]], "enabled": true, "label": "Help", + "shortcut": [["F1"]], "visible": true } ] diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 9e66236..3256f7e 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -135,13 +135,20 @@ value2string (const GValue * value, int depth) return str; } +static gint +list_str_cmp (gconstpointer a, gconstpointer b) +{ + return g_strcmp0((gchar *)a, (gchar *)b); +} + static void print_menuitem (DbusmenuMenuitem * item, int depth) { gchar * space = g_strnfill(depth, ' '); g_print("%s\"id\": %d", space, dbusmenu_menuitem_get_id(item)); - GList * properties = dbusmenu_menuitem_properties_list(item); + GList * properties_raw = dbusmenu_menuitem_properties_list(item); + GList * properties = g_list_sort(properties_raw, list_str_cmp); GList * property; for (property = properties; property != NULL; property = g_list_next(property)) { const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); -- cgit v1.2.3 From 8985df16ddfd5cae82236b076131b69fb8d12803 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Aug 2010 11:15:15 -0500 Subject: 0.3.10 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c90e8bf..5419c4c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.9, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.10, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.9, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.10, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 466fa0fc57ab1bec842a158f549387e141464221 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Aug 2010 16:25:40 -0500 Subject: Increasing timer for ARM to get a build. --- tests/test-glib-properties-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 434465a..ae7b80b 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -121,7 +121,7 @@ static void layout_updated (DbusmenuClient * client, gpointer data) { g_debug("Layout Updated"); - g_timeout_add (250, layout_verify_timer, client); + g_timeout_add (500, layout_verify_timer, client); return; } -- cgit v1.2.3 From dc103227e86bf67c8c9118010887f8ba7c924e35 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 10:58:16 -0500 Subject: Handling comment nodes better. --- libdbusmenu-glib/client.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7c73b7b..98049d5 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1126,6 +1126,9 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* g_debug("Looking at child: %d", position); */ gint childid = parse_node_get_id(children); 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; @@ -1143,11 +1146,13 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } if (childmi == NULL) { + g_debug("Building new menu item %d at position %d", childid, position); /* If we can't recycle, then we build a new one */ childmi = parse_layout_new_child(childid, client, item); dbusmenu_menuitem_child_add_position(item, childmi, position); g_object_unref(childmi); } else { + g_debug("Recycling menu item %d at position %d", childid, position); /* If we can recycle, make sure it's in the right place */ dbusmenu_menuitem_child_reorder(item, childmi, position); parse_layout_update(childmi, client); @@ -1175,6 +1180,19 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it children = node->children; GList * childmis = dbusmenu_menuitem_get_children(item); while (children != NULL && childmis != NULL) { + gint xmlid = parse_node_get_id(children); + /* 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; + continue; + } + + #if 1 + gint miid = dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(childmis->data)); + 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); children = children->next; -- cgit v1.2.3 From d2bd004b2cbb7a383d1b75200fe857091f6fe89c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 10:59:53 -0500 Subject: Putting the debugging messages under MASSIVEDEBUGGING --- libdbusmenu-glib/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 98049d5..73a7aac 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1146,13 +1146,17 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } if (childmi == NULL) { + #ifdef MASSIVEDEBUGGING g_debug("Building new menu item %d at position %d", childid, position); + #endif /* If we can't recycle, then we build a new one */ childmi = parse_layout_new_child(childid, client, item); dbusmenu_menuitem_child_add_position(item, childmi, position); g_object_unref(childmi); } else { + #ifdef MASSIVEDEBUGGING g_debug("Recycling menu item %d at position %d", childid, position); + #endif /* If we can recycle, make sure it's in the right place */ dbusmenu_menuitem_child_reorder(item, childmi, position); parse_layout_update(childmi, client); @@ -1188,7 +1192,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it continue; } - #if 1 + #ifdef MASSIVEDEBUGGING gint miid = dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(childmis->data)); g_debug("Recursing parse_layout_xml. XML ID: %d MI ID: %d", xmlid, miid); #endif -- cgit v1.2.3 From 98b759aaa21779694f5708a93d900c3204742133 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 17 Aug 2010 16:12:48 -0500 Subject: Getting the signal for the request to activate the item --- libdbusmenu-glib/client.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 73a7aac..d127b21 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -123,6 +123,7 @@ static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data); static GQuark error_domain (void); +static void item_activated (DBusGProxy * proxy, gint id, gint timestamp, DbusmenuClient * client); /* Build a type */ G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT); @@ -582,6 +583,14 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert return; } +/* Called when a server item wants to activate the menu */ +static void +item_activated (DBusGProxy * proxy, gint id, gint timestamp, DbusmenuClient * client) +{ + + return; +} + /* Annoying little wrapper to make the right function update */ static void layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client) @@ -821,6 +830,10 @@ build_proxies (DbusmenuClient * client) dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_INT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "ItemUpdated", G_CALLBACK(id_update), client, NULL); + dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_UINT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->menuproxy, "ItemActivationRequested", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->menuproxy, "ItemActivationRequested", G_CALLBACK(item_activated), client, NULL); + update_layout(client); return; -- cgit v1.2.3 From 65d0fad51540858ca7a8cf850f6d0c3e0feaf949 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 17 Aug 2010 16:45:09 -0500 Subject: Getting to the menu item. --- libdbusmenu-glib/client.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d127b21..25d64b6 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -123,7 +123,7 @@ static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data); static GQuark error_domain (void); -static void item_activated (DBusGProxy * proxy, gint id, gint timestamp, DbusmenuClient * client); +static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); /* Build a type */ G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT); @@ -585,8 +585,21 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert /* Called when a server item wants to activate the menu */ static void -item_activated (DBusGProxy * proxy, gint id, gint timestamp, DbusmenuClient * client) +item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client) { + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + + if (priv->root == NULL) { + g_warning("Asked to activate item %d when we don't have a menu structure.", id); + return; + } + + DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); + if (menuitem == NULL) { + g_warning("Unable to find menu item %d to activate.", id); + return; + } + return; } -- cgit v1.2.3 From 6566022e1f2afc97d6ffafbec3ca54bf63fd19f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 17 Aug 2010 20:42:22 -0500 Subject: Adding a new signal for when items activate. --- .bzrignore | 3 +++ libdbusmenu-glib/Makefile.am | 15 +++++++++++++++ libdbusmenu-glib/client-marshal.list | 1 + libdbusmenu-glib/client.c | 18 ++++++++++++++++++ libdbusmenu-glib/client.h | 6 ++++-- 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 libdbusmenu-glib/client-marshal.list diff --git a/.bzrignore b/.bzrignore index ae6fc3d..b21c55f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -188,3 +188,6 @@ tests/libdbusmenu_jsonloader_la-json-loader.lo tests/test-json-server tests/test-json-client tests/test-json +libdbusmenu-glib/client-marshal.c +libdbusmenu-glib/client-marshal.h +libdbusmenu-glib/libdbusmenu_glib_la-client-marshal.lo diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 3df1513..0a6513f 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -4,6 +4,7 @@ CLEANFILES = EXTRA_DIST = \ dbusmenu-glib.pc.in \ dbus-menu.xml \ + client-marshal.list \ menuitem-marshal.list \ server-marshal.list @@ -32,6 +33,8 @@ libdbusmenu_glib_la_SOURCES = \ server.c \ server-marshal.h \ server-marshal.c \ + client-marshal.h \ + client-marshal.c \ client-menuitem.h \ client-menuitem.c \ client.h \ @@ -54,6 +57,8 @@ pkgconfigdir = $(libdir)/pkgconfig BUILT_SOURCES = \ dbusmenu-client.h \ dbusmenu-server.h \ + client-marshal.h \ + client-marshal.c \ menuitem-marshal.h \ menuitem-marshal.c \ server-marshal.h \ @@ -73,6 +78,16 @@ dbusmenu-client.h: dbus-menu.xml --output=dbusmenu-client.h \ $(srcdir)/dbus-menu.xml +client-marshal.h: $(srcdir)/client-marshal.list + glib-genmarshal --header \ + --prefix=_dbusmenu_client_marshal $(srcdir)/client-marshal.list \ + > client-marshal.h + +client-marshal.c: $(srcdir)/client-marshal.list + glib-genmarshal --body \ + --prefix=_dbusmenu_client_marshal $(srcdir)/client-marshal.list \ + > client-marshal.c + server-marshal.h: $(srcdir)/server-marshal.list glib-genmarshal --header \ --prefix=_dbusmenu_server_marshal $(srcdir)/server-marshal.list \ diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list new file mode 100644 index 0000000..34e3956 --- /dev/null +++ b/libdbusmenu-glib/client-marshal.list @@ -0,0 +1 @@ +VOID: OBJECT, UINT diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 25d64b6..7b1a762 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -41,6 +41,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client-menuitem.h" #include "dbusmenu-client.h" #include "server-marshal.h" +#include "client-marshal.h" /* Properties */ enum { @@ -54,6 +55,7 @@ enum { LAYOUT_UPDATED, ROOT_CHANGED, NEW_MENUITEM, + ITEM_ACTIVATE, LAST_SIGNAL }; @@ -188,6 +190,22 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); + /** + DbusmenuClient::item-activate: + @arg0: The #DbusmenuClient object + @arg1: The #DbusmenuMenuitem activated + @arg2: A timestamp that the event happened at + + Signaled when the server wants to activate an item in + order to display the menu. + */ + signals[ITEM_ACTIVATE] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DbusmenuClientClass, item_activate), + NULL, NULL, + _dbusmenu_client_marshal_VOID__OBJECT_UINT, + G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); 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 2b76f5e..6ca2232 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -46,6 +46,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED "layout-updated" #define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED "root-changed" #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem" +#define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate" #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" @@ -59,10 +60,10 @@ G_BEGIN_DECLS @parent_class: #GObjectClass @layout_updated: Slot for #DbusmenuClient::layout-updated. @new_menuitem: Slot for #DbusmenuClient::new-menuitem. + @item_activate: Slote for #DbusmenuClient::item-activate. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @reserved3: Reserved for future use. - @reserved4: Reserved for future use. A simple class that takes all of the information from a #DbusmenuServer over DBus and makes the same set of @@ -75,12 +76,13 @@ struct _DbusmenuClientClass { void (*layout_updated)(void); void (*root_changed) (DbusmenuMenuitem * newroot); void (*new_menuitem) (DbusmenuMenuitem * newitem); + void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); /* Reserved for future use */ void (*reserved1) (void); void (*reserved2) (void); void (*reserved3) (void); - void (*reserved4) (void); + /* void (*reserved4) (void); */ }; /** -- cgit v1.2.3 From 8fd2e5cea3d717c2332aeefe9c74f6ac9bebe4af Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 17 Aug 2010 20:45:19 -0500 Subject: Passing the signal up the pipe --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7b1a762..cc91b32 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -618,6 +618,7 @@ item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * c return; } + g_signal_emit(G_OBJECT(client), signals[ITEM_ACTIVATE], 0, menuitem, timestamp, TRUE); return; } -- cgit v1.2.3 From 939c18d85dde7bdd5340c853c1f334b809fc65d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 17 Aug 2010 20:53:13 -0500 Subject: Connected into the item activate signal --- libdbusmenu-gtk/client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index b5b509f..e7761fb 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -54,6 +54,7 @@ static void new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpoint static void new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, DbusmenuGtkClient * gtkclient); static void delete_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, DbusmenuGtkClient * gtkclient); static void move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint old, DbusmenuGtkClient * gtkclient); +static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); @@ -91,7 +92,9 @@ dbusmenu_gtkclient_init (DbusmenuGtkClient *self) dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_DEFAULT, new_item_normal); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_SEPARATOR, new_item_seperator); + /* TODO: I think these can be handled in the class... */ g_signal_connect(G_OBJECT(self), DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM, G_CALLBACK(new_menuitem), NULL); + g_signal_connect(G_OBJECT(self), DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE, G_CALLBACK(item_activate), NULL); return; } @@ -431,6 +434,15 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata) return; } +/* Signaled when we should show a menuitem at request of the application + that it is in. */ +static void +item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) +{ + + return; +} + #ifdef MASSIVEDEBUGGING static void destroy_gmi (GtkMenuItem * gmi, DbusmenuMenuitem * mi) -- cgit v1.2.3 From 607107ea135b2579c30a9efff08c626538892045 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 09:14:35 -0500 Subject: Activate the mnemonic when requested by the server --- libdbusmenu-gtk/client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index e7761fb..da81544 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -439,6 +439,22 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata) static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { + gpointer pmenu = g_object_get_data(G_OBJECT(mi), data_menu); + if (pmenu == NULL) { + g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); + return; + } + + GtkWidget * parent = gtk_widget_get_parent(GTK_WIDGET(pmenu)); + if (parent == NULL) { + g_warning("Activated menu item's menu doesn't have a parent? ID: %d", dbusmenu_menuitem_get_id(mi)); + return; + } + + if (!gtk_widget_mnemonic_activate(parent, FALSE)) { + g_warning("Unable to activate item: %d", dbusmenu_menuitem_get_id(mi)); + return; + } return; } -- cgit v1.2.3 From 82edd0f8c1c742adea170d76ea382b5d1aa8db94 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Aug 2010 13:39:44 -0500 Subject: 0.3.11 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5419c4c..a5c8248 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.10, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.11, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.10, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.11, [-Wno-portability]) AM_MAINTAINER_MODE @@ -99,7 +99,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=12 +LIBDBUSMENU_REVISION=13 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 3cd94732c2393b0ff73b9e89f3ae4d300aedbaad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 20 Aug 2010 09:21:21 -0500 Subject: Increasing the max size of the string --- libdbusmenu-glib/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 73a7aac..4a93b8e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1225,7 +1225,8 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmlDocPtr xmldoc; - xmldoc = xmlReadMemory(layout, g_utf8_strlen(layout, 16*1024), "dbusmenu.xml", NULL, 0); + /* 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); -- cgit v1.2.3 From fc9d42883ae66f91ac330bd32bc3ffe31d88393c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 20 Aug 2010 14:49:33 -0500 Subject: Adding the signal and function to show the menu item to the user. --- libdbusmenu-glib/menuitem.c | 36 ++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/menuitem.h | 11 ++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 623539c..ea69776 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -70,6 +70,7 @@ enum { CHILD_REMOVED, CHILD_MOVED, REALIZED, + SHOW_TO_USER, LAST_SIGNAL }; @@ -211,6 +212,22 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) NULL, NULL, _dbusmenu_menuitem_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE); + /** + DbusmenuMenuitem::show-to-user: + @arg0: The #DbusmenuMenuitem which should be shown. + @arg1: Timestamp the event happened at + + Signaled when the application would like the visualization + of this menu item shown to the user. This usually requires + going over the bus to get it done. + */ + signals[SHOW_TO_USER] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(DbusmenuMenuitemClass, show_to_user), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT, G_TYPE_NONE); g_object_class_install_property (object_class, PROP_ID, g_param_spec_int(PROP_ID_S, "ID for the menu item", @@ -1349,3 +1366,22 @@ dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_a return; } + +/** + 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) +{ + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + + g_signal_emit(G_OBJECT(mi), signals[SHOW_TO_USER], 0, timestamp, TRUE); + + return; +} diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index e17d851..9be938b 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -49,6 +49,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED "child-moved" #define DBUSMENU_MENUITEM_SIGNAL_REALIZED "realized" #define DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID (g_signal_lookup(DBUSMENU_MENUITEM_SIGNAL_REALIZED, DBUSMENU_TYPE_MENUITEM)) +#define DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER "show-to-user" #define DBUSMENU_MENUITEM_PROP_TYPE "type" #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" @@ -124,10 +125,7 @@ typedef void (*dbusmenu_menuitem_buildxml_slot_t) (DbusmenuMenuitem * mi, GPtrAr * @buildxml: Virtual function that appends the strings required to represent this menu item in the menu XML file. * @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information. * @send_about_to_show: Virtual function that notifies server that the client is about to show a menu. - * @reserved1: Reserved for future use. - * @reserved2: Reserved for future use. - * @reserved3: Reserved for future use. - * @reserved4: Reserved for future use. + * @show_to_user: Slot for #DbusmenuMenuitem::show-to-user. */ typedef struct _DbusmenuMenuitemClass DbusmenuMenuitemClass; struct _DbusmenuMenuitemClass @@ -147,7 +145,8 @@ struct _DbusmenuMenuitemClass void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); void (*send_about_to_show) (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); - void (*reserved1) (void); + void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data); + /* void (*reserved1) (void); */ /* void (*reserved2) (void); */ /* void (*reserved3) (void); */ /* void (*reserved4) (void); -- realized, realloc when bumping lib version */ @@ -192,6 +191,8 @@ void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMen void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); +void dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp); + /** * SECTION:menuitem * @short_description: A lowlevel represenation of a menuitem -- cgit v1.2.3 From b2ab47c71a8a2e1d517c6594ae3f8bdf9e539285 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 20 Aug 2010 14:50:41 -0500 Subject: Changing to be the right signal in teh server --- 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 d1b4888..26e7a0d 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -410,7 +410,7 @@ menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint /* Called when a menu item emits its activated signal so it gets passed across the bus. */ static void -menuitem_activated (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server) +menuitem_shown (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server) { g_signal_emit(G_OBJECT(server), signals[ITEM_ACTIVATION], 0, dbusmenu_menuitem_get_id(mi), timestamp, TRUE); return; @@ -425,7 +425,7 @@ menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data) g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(menuitem_child_removed), data); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(menuitem_child_moved), data); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menuitem_property_changed), data); - g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activated), data); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER, G_CALLBACK(menuitem_shown), data); return; } -- cgit v1.2.3 From 8b9843002a14e8954404f4991db2a9a54988c06b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 20 Aug 2010 16:39:12 -0500 Subject: Making it so that items show. --- libdbusmenu-gtk/client.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index da81544..4938601 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -434,27 +434,52 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata) return; } +/* Goes through the tree of items and ensure's that all the items + above us are also displayed. */ +static void +activate_helper (GtkWidget * item) +{ + GtkWidget * parent = gtk_widget_get_parent(item); + + if (parent != NULL && GTK_IS_MENU_SHELL(parent)) { + GtkWidget * attach = NULL; + + if (GTK_IS_MENU(parent)) { + attach = gtk_menu_get_attach_widget(GTK_MENU(parent)); + } + + if (attach != NULL) { + activate_helper(attach); + } + + gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), item); + } + + return; +} + /* Signaled when we should show a menuitem at request of the application that it is in. */ static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { - gpointer pmenu = g_object_get_data(G_OBJECT(mi), data_menu); - if (pmenu == NULL) { + gpointer pitem = g_object_get_data(G_OBJECT(mi), data_menuitem); + if (pitem == NULL) { g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); return; } - GtkWidget * parent = gtk_widget_get_parent(GTK_WIDGET(pmenu)); - if (parent == NULL) { - g_warning("Activated menu item's menu doesn't have a parent? ID: %d", dbusmenu_menuitem_get_id(mi)); + gpointer pmenu = g_object_get_data(G_OBJECT(mi), data_menu); + if (pmenu == NULL) { + g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); return; } - if (!gtk_widget_mnemonic_activate(parent, FALSE)) { - g_warning("Unable to activate item: %d", dbusmenu_menuitem_get_id(mi)); - return; - } + GtkWidget * item = GTK_WIDGET(pitem); + + activate_helper(item); + + gtk_menu_shell_select_first(GTK_MENU_SHELL(pmenu), FALSE); return; } -- cgit v1.2.3 From 49ff3029a6cc08287e39371f079dc2109a896901 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 20 Aug 2010 16:47:06 -0500 Subject: Restructuring so that we pass the menu --- libdbusmenu-gtk/client.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 4938601..44f95fe 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -437,22 +437,25 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata) /* Goes through the tree of items and ensure's that all the items above us are also displayed. */ static void -activate_helper (GtkWidget * item) +activate_helper (GtkMenuShell * shell) { - GtkWidget * parent = gtk_widget_get_parent(item); + if (shell == NULL) { + return; + } - if (parent != NULL && GTK_IS_MENU_SHELL(parent)) { - GtkWidget * attach = NULL; - - if (GTK_IS_MENU(parent)) { - attach = gtk_menu_get_attach_widget(GTK_MENU(parent)); - } + if (GTK_IS_MENU(shell)) { + GtkWidget * attach = gtk_menu_get_attach_widget(GTK_MENU(shell)); if (attach != NULL) { - activate_helper(attach); - } + GtkWidget * parent = gtk_widget_get_parent(GTK_WIDGET(attach)); - gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), item); + if (parent != NULL) { + if (GTK_IS_MENU(parent)) { + activate_helper(GTK_MENU_SHELL(parent)); + } + gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), attach); + } + } } return; @@ -463,22 +466,13 @@ activate_helper (GtkWidget * item) static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { - gpointer pitem = g_object_get_data(G_OBJECT(mi), data_menuitem); - if (pitem == NULL) { - g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); - return; - } - gpointer pmenu = g_object_get_data(G_OBJECT(mi), data_menu); if (pmenu == NULL) { g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); return; } - GtkWidget * item = GTK_WIDGET(pitem); - - activate_helper(item); - + activate_helper(GTK_MENU_SHELL(pmenu)); gtk_menu_shell_select_first(GTK_MENU_SHELL(pmenu), FALSE); return; -- cgit v1.2.3 From b8b16bdfc5f52a306bacaa34776c3d159e16fbc2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 20 Aug 2010 16:52:02 -0500 Subject: Showing items as part of the test to ensure we don't break. --- tests/test-gtk-submenu-client.c | 9 ++++++++- tests/test-gtk-submenu-server.c | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/test-gtk-submenu-client.c b/tests/test-gtk-submenu-client.c index 2e1ef7a..ec46122 100644 --- a/tests/test-gtk-submenu-client.c +++ b/tests/test-gtk-submenu-client.c @@ -102,6 +102,12 @@ timer_func (gpointer data) } passed = TRUE; + return FALSE; +} + +gboolean +finished_func (gpointer user_data) +{ g_main_loop_quit(mainloop); return FALSE; } @@ -127,7 +133,8 @@ main (int argc, char ** argv) gtk_window_set_title(GTK_WINDOW(window), "libdbusmenu-gtk test"); gtk_widget_show(window); - g_timeout_add_seconds(1, timer_func, menuitem); + g_timeout_add_seconds(2, timer_func, menuitem); + g_timeout_add_seconds(6, finished_func, menuitem); g_debug("Entering Mainloop"); mainloop = g_main_loop_new(NULL, FALSE); diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c index ba3993e..11cede0 100644 --- a/tests/test-gtk-submenu-server.c +++ b/tests/test-gtk-submenu-server.c @@ -39,6 +39,17 @@ timer_func (gpointer data) return FALSE; } +static gboolean +show_item (gpointer pmi) +{ + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(pmi); + g_debug("Showing item"); + + dbusmenu_menuitem_show_to_user(mi, 0); + + return FALSE; +} + DbusmenuMenuitem * add_item(DbusmenuMenuitem * parent, const char * label) { @@ -81,12 +92,16 @@ main (int argc, char ** argv) add_item(item, "1.2"); add_item(item, "1.3"); + g_timeout_add_seconds(2, show_item, item); + item = add_item(root, "Folder 2"); add_item(item, "2.1"); add_item(item, "2.2"); add_item(item, "2.3"); - g_timeout_add_seconds(3, timer_func, NULL); + g_timeout_add_seconds(4, show_item, item); + + g_timeout_add_seconds(6, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 8156d1d7abd95d7f4c0cb564bb9e3c4921a87b60 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Aug 2010 09:25:40 -0500 Subject: Adding a check on the client object from code review --- libdbusmenu-glib/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index cc91b32..0a06c5e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -605,6 +605,8 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client) { + g_return_if_fail(DBUSMENU_IS_CLIENT(client)); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); if (priv->root == NULL) { -- cgit v1.2.3 From 985ae78d54febec59f11ce58984d8adc59e84baf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 10:28:12 -0500 Subject: Adding an event-error slot --- libdbusmenu-glib/client.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 6ca2232..dcbe5c2 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -60,10 +60,10 @@ G_BEGIN_DECLS @parent_class: #GObjectClass @layout_updated: Slot for #DbusmenuClient::layout-updated. @new_menuitem: Slot for #DbusmenuClient::new-menuitem. - @item_activate: Slote for #DbusmenuClient::item-activate. + @item_activate: Slot for #DbusmenuClient::item-activate. + @event_error: Slot for #DbusmenuClient::event-error. @reserved1: Reserved for future use. @reserved2: Reserved for future use. - @reserved3: Reserved for future use. A simple class that takes all of the information from a #DbusmenuServer over DBus and makes the same set of @@ -77,11 +77,12 @@ struct _DbusmenuClientClass { void (*root_changed) (DbusmenuMenuitem * newroot); void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); + void (*event_error) (DbusmenuMenuitem * item, gchar * event, GValue * data, guint timestamp); /* Reserved for future use */ void (*reserved1) (void); void (*reserved2) (void); - void (*reserved3) (void); + /* void (*reserved3) (void); */ /* void (*reserved4) (void); */ }; -- cgit v1.2.3 From ffd29638de796d57380def939ef23c7ad8e892cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 10:34:33 -0500 Subject: Creating a signal for the error situation on the signal. --- libdbusmenu-glib/client-marshal.list | 1 + libdbusmenu-glib/client.c | 19 +++++++++++++++++++ libdbusmenu-glib/client.h | 1 + 3 files changed, 21 insertions(+) diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list index 34e3956..f1d6a9f 100644 --- a/libdbusmenu-glib/client-marshal.list +++ b/libdbusmenu-glib/client-marshal.list @@ -1 +1,2 @@ VOID: OBJECT, UINT +VOID: OBJECT, STRING, POINTER, UINT diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d88478c..ac9561e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -56,6 +56,7 @@ enum { ROOT_CHANGED, NEW_MENUITEM, ITEM_ACTIVATE, + EVENT_ERROR, LAST_SIGNAL }; @@ -206,6 +207,24 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, NULL, _dbusmenu_client_marshal_VOID__OBJECT_UINT, G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); + /** + DbusmenuClient::event-error: + @arg0: The #DbusmenuClient object + @arg1: The #DbusmenuMenuitem sent an event + @arg2: The ID of the event sent + @arg3: The data sent along with the event + @arg4: A timestamp that the event happened at + + Signal sent to show that there was an error in sending the event + to the server. + */ + signals[ITEM_ACTIVATE] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_EVENT_ERROR, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DbusmenuClientClass, event_error), + NULL, NULL, + _dbusmenu_client_marshal_VOID__OBJECT_STRING_POINTER_UINT, + G_TYPE_NONE, 4, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_UINT); 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 dcbe5c2..24d8f57 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -47,6 +47,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED "root-changed" #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem" #define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate" +#define DBUSMENU_CLIENT_SIGNAL_EVENT_ERROR "event-error" #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" -- cgit v1.2.3 From 9a8c525d75c3f92351c0e60f15504d061fde4160 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 10:56:29 -0500 Subject: Building a data structure to track all the data we need to emit the event error signal --- libdbusmenu-glib/client.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ac9561e..5d0325a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -103,6 +103,16 @@ struct _properties_listener_t { gboolean replied; }; +typedef struct _event_data_t event_data_t; +struct _event_data_t { + DbusmenuClient * client; + DbusmenuMenuitem * menuitem; + gchar * event; + GValue data; + guint timestamp; +}; + + #define DBUSMENU_CLIENT_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_CLIENT, DbusmenuClientPrivate)) @@ -1044,10 +1054,18 @@ menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GEr static void menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) { + event_data_t * edata = (event_data_t *)userdata; + if (error != NULL) { g_warning("Unable to call menu item %d: %s", GPOINTER_TO_INT(userdata), error->message); + g_signal_emit(edata->client, signals[EVENT_ERROR], 0, edata->menuitem, edata->event, edata->data, edata->timestamp, TRUE); } + g_value_unset(&edata->data); + g_free(edata->event); + g_object_unref(edata->menuitem); + g_free(edata); + return; } @@ -1060,6 +1078,13 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name g_return_if_fail(id >= 0); g_return_if_fail(name != NULL); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); + if (mi == NULL) { + g_warning("Asked to activate a menuitem %d that we don't know about", id); + return; + } + if (value == NULL) { GValue internalval = {0}; g_value_init(&internalval, G_TYPE_INT); @@ -1067,8 +1092,16 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name value = &internalval; } - DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, GINT_TO_POINTER(id)); + event_data_t * edata = g_new0(event_data_t, 1); + edata->client = client; + edata->menuitem = mi; + g_object_ref(edata->menuitem); + edata->event = g_strdup(name); + g_value_init(&edata->data, G_VALUE_TYPE(value)); + g_value_copy(value, &edata->data); + edata->timestamp = timestamp; + + org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, edata); return; } -- cgit v1.2.3 From db3d95c01f91456d042c507c9dfe91e75276c5e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 14:17:39 -0500 Subject: Removing death timer message --- tests/test-gtk-label-client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 070c278..4316b8e 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -105,7 +105,6 @@ verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) static gboolean timer_func (gpointer data) { - g_debug("Death timer. Oops. Got to: %d", layouton); passed = TRUE; g_main_loop_quit(mainloop); return FALSE; -- cgit v1.2.3 From 21e96fee225eab6ee2bee051c90a7458cf867b7f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 14:45:26 -0500 Subject: Changing to result instead of just errors. --- libdbusmenu-glib/client-marshal.list | 2 +- libdbusmenu-glib/client.c | 14 ++++++++------ libdbusmenu-glib/client.h | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list index f1d6a9f..2e14491 100644 --- a/libdbusmenu-glib/client-marshal.list +++ b/libdbusmenu-glib/client-marshal.list @@ -1,2 +1,2 @@ VOID: OBJECT, UINT -VOID: OBJECT, STRING, POINTER, UINT +VOID: OBJECT, STRING, POINTER, UINT, POINTER diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5d0325a..43bde5f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -56,7 +56,7 @@ enum { ROOT_CHANGED, NEW_MENUITEM, ITEM_ACTIVATE, - EVENT_ERROR, + EVENT_RESULT, LAST_SIGNAL }; @@ -224,17 +224,18 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) @arg2: The ID of the event sent @arg3: The data sent along with the event @arg4: A timestamp that the event happened at + @arg5: Possibly the error in sending the event (or NULL) Signal sent to show that there was an error in sending the event to the server. */ - signals[ITEM_ACTIVATE] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_EVENT_ERROR, + signals[EVENT_RESULT] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (DbusmenuClientClass, event_error), + G_STRUCT_OFFSET (DbusmenuClientClass, event_result), NULL, NULL, - _dbusmenu_client_marshal_VOID__OBJECT_STRING_POINTER_UINT, - G_TYPE_NONE, 4, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_UINT); + _dbusmenu_client_marshal_VOID__OBJECT_STRING_POINTER_UINT_POINTER, + G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_UINT, 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", @@ -1058,9 +1059,10 @@ menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) if (error != NULL) { g_warning("Unable to call menu item %d: %s", GPOINTER_TO_INT(userdata), error->message); - g_signal_emit(edata->client, signals[EVENT_ERROR], 0, edata->menuitem, edata->event, edata->data, edata->timestamp, TRUE); } + g_signal_emit(edata->client, signals[EVENT_RESULT], 0, edata->menuitem, edata->event, edata->data, edata->timestamp, error, TRUE); + g_value_unset(&edata->data); g_free(edata->event); g_object_unref(edata->menuitem); diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 24d8f57..5d4b5c3 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -47,7 +47,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED "root-changed" #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem" #define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate" -#define DBUSMENU_CLIENT_SIGNAL_EVENT_ERROR "event-error" +#define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT "event-result" #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" @@ -62,7 +62,7 @@ G_BEGIN_DECLS @layout_updated: Slot for #DbusmenuClient::layout-updated. @new_menuitem: Slot for #DbusmenuClient::new-menuitem. @item_activate: Slot for #DbusmenuClient::item-activate. - @event_error: Slot for #DbusmenuClient::event-error. + @event_result: Slot for #DbusmenuClient::event-error. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @@ -78,7 +78,7 @@ struct _DbusmenuClientClass { void (*root_changed) (DbusmenuMenuitem * newroot); void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); - void (*event_error) (DbusmenuMenuitem * item, gchar * event, GValue * data, guint timestamp); + void (*event_result) (DbusmenuMenuitem * item, gchar * event, GValue * data, guint timestamp, GError * error); /* Reserved for future use */ void (*reserved1) (void); -- cgit v1.2.3 From 510263800720ca5f8980ade0a3d0e9d564b3ddff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 15:18:19 -0500 Subject: Removing unused variable --- tests/test-gtk-label-client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 4316b8e..14eb5bd 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -22,7 +22,6 @@ with this program. If not, see . #include #include -static guint layouton = 0; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static guint death_timer = 0; -- cgit v1.2.3 From 34824cf6f98cd623b0368e4dbc9eaf65110572d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Aug 2010 15:21:59 -0500 Subject: 0.3.12 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a5c8248..5ccf9c3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.11, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.12, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.11, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.12, [-Wno-portability]) AM_MAINTAINER_MODE @@ -99,7 +99,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=13 +LIBDBUSMENU_REVISION=14 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 8a2340c7249a714bf5c7128082b8c0c26f20a05f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 14:31:44 -0500 Subject: Adding in an events test --- .bzrignore | 3 + tests/Makefile.am | 34 ++++++++++++ tests/test-glib-events-client.c | 119 ++++++++++++++++++++++++++++++++++++++++ tests/test-glib-events-server.c | 109 ++++++++++++++++++++++++++++++++++++ 4 files changed, 265 insertions(+) create mode 100644 tests/test-glib-events-client.c create mode 100644 tests/test-glib-events-server.c diff --git a/.bzrignore b/.bzrignore index b21c55f..c1088c1 100644 --- a/.bzrignore +++ b/.bzrignore @@ -191,3 +191,6 @@ tests/test-json libdbusmenu-glib/client-marshal.c libdbusmenu-glib/client-marshal.h libdbusmenu-glib/libdbusmenu_glib_la-client-marshal.lo +tests/test-glib-events +tests/test-glib-events-client +tests/test-glib-events-server diff --git a/tests/Makefile.am b/tests/Makefile.am index 9f621cb..aa79c8f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,6 +5,7 @@ CLEANFILES= TESTS = \ test-glib-objects-test \ + test-glib-events \ test-glib-layout \ test-glib-properties \ test-glib-proxy \ @@ -20,6 +21,8 @@ TESTS = \ check_PROGRAMS = \ glib-server-nomenu \ test-glib-objects \ + test-glib-events-client \ + test-glib-events-server \ test-glib-layout-client \ test-glib-layout-server \ test-glib-properties-client \ @@ -128,6 +131,37 @@ test_glib_layout_client_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +###################### +# Test Glib Events +###################### + +test-glib-events: test-glib-events-client test-glib-events-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(DBUS_RUNNER) --task ./test-glib-events-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + +test_glib_events_server_SOURCES = \ + test-glib-events-server.c + +test_glib_events_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_events_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + +test_glib_events_client_SOURCES = \ + test-glib-events-client.c + +test_glib_events_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_events_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + ###################### # Test JSON ###################### diff --git a/tests/test-glib-events-client.c b/tests/test-glib-events-client.c new file mode 100644 index 0000000..57762cd --- /dev/null +++ b/tests/test-glib-events-client.c @@ -0,0 +1,119 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include +#include + +#include "test-glib-submenu.h" + +static guint layouton = 0; +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +static void +realization (DbusmenuMenuitem * mi) +{ + const gchar * value; + gboolean original = passed; + + value = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY); + + if (layouton % 2 == 0) { + if (value == NULL) { + passed = FALSE; + } + } else { + if (value != NULL) { + passed = FALSE; + } + } + + if (original != passed) { + g_debug("Oops, this is where we failed"); + } + + return; +} + +static void +layout_updated (DbusmenuClient * client, gpointer data) +{ + g_debug("Layout Updated"); + + DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(client); + if (menuroot == NULL) { + g_debug("Root is NULL?"); + return; + } + + GList * children = dbusmenu_menuitem_get_children(menuroot); + if (children == NULL) { + g_debug("No Children on root -- fail"); + passed = FALSE; + } else { + for (; children != NULL; children = g_list_next(children)) { + g_signal_connect(G_OBJECT(children->data), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(realization), NULL); + } + } + + layouton++; + + if (layouts[layouton].id == -1) { + g_main_loop_quit(mainloop); + } + + return; +} + +static gboolean +timer_func (gpointer data) +{ + g_debug("Death timer. Oops. Got to: %d", layouton); + passed = FALSE; + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + DbusmenuClient * client = dbusmenu_client_new("org.dbusmenu.test", "/org/test"); + g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); + + g_timeout_add_seconds(10, timer_func, client); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref(G_OBJECT(client)); + + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 1; + } +} diff --git a/tests/test-glib-events-server.c b/tests/test-glib-events-server.c new file mode 100644 index 0000000..68f7004 --- /dev/null +++ b/tests/test-glib-events-server.c @@ -0,0 +1,109 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "test-glib-submenu.h" + + +static DbusmenuMenuitem * +layout2menuitem (layout_t * layout) +{ + if (layout == NULL || layout->id == 0) return NULL; + + DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); + + if (layout->submenu != NULL) { + guint count; + for (count = 0; layout->submenu[count].id != -1; count++) { + DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]); + if (child != NULL) { + dbusmenu_menuitem_child_append(local, child); + } + } + } + + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ + return local; +} + +static guint layouton = 0; +static DbusmenuServer * server = NULL; +static GMainLoop * mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + if (layouts[layouton].id == -1) { + g_main_loop_quit(mainloop); + return FALSE; + } + g_debug("Updating to Layout %d", layouton); + + dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + layouton++; + + return TRUE; +} + +int +main (int argc, char ** argv) +{ + GError * error = NULL; + + g_type_init(); + + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + + server = dbusmenu_server_new("/org/test"); + + timer_func(NULL); + g_timeout_add(2500, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} -- cgit v1.2.3 From c0674ee7a6f7a2bf83f19e3c897cdda918c52d6f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 14:50:05 -0500 Subject: First phase of restructuring these tests, now we can move on to testing. --- tests/test-glib-events-client.c | 46 ++------------------------ tests/test-glib-events-server.c | 71 +++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 82 deletions(-) diff --git a/tests/test-glib-events-client.c b/tests/test-glib-events-client.c index 57762cd..9b05ca6 100644 --- a/tests/test-glib-events-client.c +++ b/tests/test-glib-events-client.c @@ -26,35 +26,9 @@ with this program. If not, see . #include "test-glib-submenu.h" -static guint layouton = 0; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; -static void -realization (DbusmenuMenuitem * mi) -{ - const gchar * value; - gboolean original = passed; - - value = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY); - - if (layouton % 2 == 0) { - if (value == NULL) { - passed = FALSE; - } - } else { - if (value != NULL) { - passed = FALSE; - } - } - - if (original != passed) { - g_debug("Oops, this is where we failed"); - } - - return; -} - static void layout_updated (DbusmenuClient * client, gpointer data) { @@ -66,21 +40,7 @@ layout_updated (DbusmenuClient * client, gpointer data) return; } - GList * children = dbusmenu_menuitem_get_children(menuroot); - if (children == NULL) { - g_debug("No Children on root -- fail"); - passed = FALSE; - } else { - for (; children != NULL; children = g_list_next(children)) { - g_signal_connect(G_OBJECT(children->data), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(realization), NULL); - } - } - - layouton++; - - if (layouts[layouton].id == -1) { - g_main_loop_quit(mainloop); - } + dbusmenu_menuitem_handle_event(menuroot, "clicked", NULL, 0); return; } @@ -88,7 +48,7 @@ layout_updated (DbusmenuClient * client, gpointer data) static gboolean timer_func (gpointer data) { - g_debug("Death timer. Oops. Got to: %d", layouton); + g_debug("Death timer. Oops."); passed = FALSE; g_main_loop_quit(mainloop); return FALSE; @@ -102,7 +62,7 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new("org.dbusmenu.test", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); - g_timeout_add_seconds(10, timer_func, client); + g_timeout_add_seconds(5, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-glib-events-server.c b/tests/test-glib-events-server.c index 68f7004..db4f5c5 100644 --- a/tests/test-glib-events-server.c +++ b/tests/test-glib-events-server.c @@ -29,47 +29,24 @@ with this program. If not, see . #include #include -#include "test-glib-submenu.h" - - -static DbusmenuMenuitem * -layout2menuitem (layout_t * layout) -{ - if (layout == NULL || layout->id == 0) return NULL; - - DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); - - if (layout->submenu != NULL) { - guint count; - for (count = 0; layout->submenu[count].id != -1; count++) { - DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]); - if (child != NULL) { - dbusmenu_menuitem_child_append(local, child); - } - } - } - - /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ - return local; -} - -static guint layouton = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +static void +handle_event (void) { + g_debug("Handle event"); + g_main_loop_quit(mainloop); + return; +} static gboolean timer_func (gpointer data) { - if (layouts[layouton].id == -1) { - g_main_loop_quit(mainloop); - return FALSE; - } - g_debug("Updating to Layout %d", layouton); - - dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); - layouton++; - - return TRUE; + passed = FALSE; + g_debug("Never got a signal"); + g_main_loop_quit(mainloop); + return FALSE; } int @@ -96,14 +73,30 @@ main (int argc, char ** argv) } server = dbusmenu_server_new("/org/test"); + DbusmenuMenuitem * menuitem = dbusmenu_menuitem_new(); + dbusmenu_server_set_root(server, menuitem); - timer_func(NULL); - g_timeout_add(2500, timer_func, NULL); + g_signal_connect(G_OBJECT(menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(handle_event), NULL); + + g_timeout_add_seconds(3, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); - g_debug("Quiting"); + if (passed) { + int i; - return 0; + for (i = 0; i < 10; i++) { + g_debug("Ignoring signals: %d", i); + g_usleep(100 * 1000); + } + } + + if (passed) { + g_debug("Test Passed"); + return 0; + } else { + g_debug("Test Failed"); + return 1; + } } -- cgit v1.2.3 From 72f52f7f170e28a87ed58436d438aa1bea2ecf11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 15:20:48 -0500 Subject: Setting default timeout to 2 seconds. We need to be responsive. --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 43bde5f..7051e96 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -876,6 +876,7 @@ build_proxies (DbusmenuClient * client) } g_object_add_weak_pointer(G_OBJECT(priv->menuproxy), (gpointer *)&priv->menuproxy); g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", G_CALLBACK(proxy_destroyed), client); + dbus_g_proxy_set_default_timeout(priv->menuproxy, 2000); /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != NULL) { -- cgit v1.2.3 From 6b16918eb4343bbe1c3be8c2806020c8e6c40284 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 15:29:49 -0500 Subject: Fleshing out the test to get all happy --- tests/test-glib-events-client.c | 32 ++++++++++++++++++++++++++++++++ tests/test-glib-events-server.c | 4 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/test-glib-events-client.c b/tests/test-glib-events-client.c index 9b05ca6..688529c 100644 --- a/tests/test-glib-events-client.c +++ b/tests/test-glib-events-client.c @@ -28,6 +28,37 @@ with this program. If not, see . static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; +static gboolean first = TRUE; + +static void +event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GValue * data, guint timestamp, GError * error, gpointer user_data) +{ + g_debug("Event status: %s", error == NULL ? "Sent" : "Error"); + + if (first && error != NULL) { + passed = FALSE; + g_debug("First signal back failed."); + g_main_loop_quit(mainloop); + return; + } + + if (!first && error == NULL) { + passed = FALSE; + g_debug("Second signal didn't fail."); + g_main_loop_quit(mainloop); + return; + } + + if (!first && error != NULL) { + g_debug("Second signal failed: pass."); + g_main_loop_quit(mainloop); + return; + } + + first = FALSE; + dbusmenu_menuitem_handle_event(item, "clicked", NULL, 0); + return; +} static void layout_updated (DbusmenuClient * client, gpointer data) @@ -61,6 +92,7 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new("org.dbusmenu.test", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); + g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_CALLBACK(event_status), NULL); g_timeout_add_seconds(5, timer_func, client); diff --git a/tests/test-glib-events-server.c b/tests/test-glib-events-server.c index db4f5c5..0d1e0b1 100644 --- a/tests/test-glib-events-server.c +++ b/tests/test-glib-events-server.c @@ -86,9 +86,9 @@ main (int argc, char ** argv) if (passed) { int i; - for (i = 0; i < 10; i++) { + for (i = 0; i < 5; i++) { g_debug("Ignoring signals: %d", i); - g_usleep(100 * 1000); + g_usleep(1000 * 1000); } } -- cgit v1.2.3 From 2f8fef94c6491d501b735aec916055054d5c6d83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 15:57:42 -0500 Subject: Adding checking of all the parameters in the signature --- tests/test-glib-events-client.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/test-glib-events-client.c b/tests/test-glib-events-client.c index 688529c..97d5caf 100644 --- a/tests/test-glib-events-client.c +++ b/tests/test-glib-events-client.c @@ -26,6 +26,10 @@ with this program. If not, see . #include "test-glib-submenu.h" +#define TIMESTAMP_VALUE 54 +#define DATA_VALUE 32 +#define USER_VALUE 76 + static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static gboolean first = TRUE; @@ -35,6 +39,27 @@ event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GV { g_debug("Event status: %s", error == NULL ? "Sent" : "Error"); + if (timestamp != TIMESTAMP_VALUE) { + g_debug("Timestamp value pass fail got: %d", timestamp); + passed = FALSE; + g_main_loop_quit(mainloop); + return; + } + + if (g_value_get_int(data) != DATA_VALUE) { + g_debug("Data value pass fail got: %d", g_value_get_int(data)); + passed = FALSE; + g_main_loop_quit(mainloop); + return; + } + + if (GPOINTER_TO_INT(user_data) != USER_VALUE) { + g_debug("User value pass fail got: %d", GPOINTER_TO_INT(user_data)); + passed = FALSE; + g_main_loop_quit(mainloop); + return; + } + if (first && error != NULL) { passed = FALSE; g_debug("First signal back failed."); @@ -56,12 +81,12 @@ event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GV } first = FALSE; - dbusmenu_menuitem_handle_event(item, "clicked", NULL, 0); + dbusmenu_menuitem_handle_event(item, "clicked", data, timestamp); return; } static void -layout_updated (DbusmenuClient * client, gpointer data) +layout_updated (DbusmenuClient * client, gpointer user_data) { g_debug("Layout Updated"); @@ -71,7 +96,11 @@ layout_updated (DbusmenuClient * client, gpointer data) return; } - dbusmenu_menuitem_handle_event(menuroot, "clicked", NULL, 0); + GValue data = {0}; + g_value_init(&data, G_TYPE_INT); + g_value_set_int(&data, DATA_VALUE); + + dbusmenu_menuitem_handle_event(menuroot, "clicked", &data, TIMESTAMP_VALUE); return; } @@ -92,7 +121,7 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new("org.dbusmenu.test", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); - g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_CALLBACK(event_status), NULL); + g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_CALLBACK(event_status), GINT_TO_POINTER(USER_VALUE)); g_timeout_add_seconds(5, timer_func, client); -- cgit v1.2.3 From 0b3dc82b5f2885d7ef3dca837f7fa02b0e73012b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 16:13:59 -0500 Subject: Fixing the parameter type --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7051e96..3f06618 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1059,10 +1059,10 @@ menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) event_data_t * edata = (event_data_t *)userdata; if (error != NULL) { - g_warning("Unable to call menu item %d: %s", GPOINTER_TO_INT(userdata), error->message); + g_warning("Unable to call event '%s' on menu item %d: %s", edata->event, dbusmenu_menuitem_get_id(edata->menuitem), error->message); } - g_signal_emit(edata->client, signals[EVENT_RESULT], 0, edata->menuitem, edata->event, edata->data, edata->timestamp, error, TRUE); + g_signal_emit(edata->client, signals[EVENT_RESULT], 0, edata->menuitem, edata->event, &edata->data, edata->timestamp, error, TRUE); g_value_unset(&edata->data); g_free(edata->event); -- cgit v1.2.3 From 8ea939e19d5f50d020e33a08237105a96ed4ae30 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Aug 2010 17:01:01 -0500 Subject: Instead of setting the default timeout, we're copying the generated code to set a custom timeout for the event signal --- libdbusmenu-glib/client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 3f06618..ca16c9a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -876,7 +876,6 @@ build_proxies (DbusmenuClient * client) } g_object_add_weak_pointer(G_OBJECT(priv->menuproxy), (gpointer *)&priv->menuproxy); g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", G_CALLBACK(proxy_destroyed), client); - dbus_g_proxy_set_default_timeout(priv->menuproxy, 2000); /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != NULL) { @@ -1104,7 +1103,12 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name g_value_copy(value, &edata->data); edata->timestamp = timestamp; - org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, edata); + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (menuitem_call_cb); + stuff->userdata = edata; + dbus_g_proxy_begin_call_with_timeout (priv->menuproxy, "Event", org_ayatana_dbusmenu_event_async_callback, stuff, _dbus_glib_async_data_free, 1000, G_TYPE_INT, id, G_TYPE_STRING, name, G_TYPE_VALUE, value, G_TYPE_UINT, timestamp, G_TYPE_INVALID); + return; } -- cgit v1.2.3 From cbb0f2c5ae4381b2627fcfb9fe7a57d80460ec44 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Mon, 30 Aug 2010 16:13:06 -0400 Subject: Grab your junk. --- libdbusmenu-gtk/client.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 44f95fe..72f5b0b 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -447,18 +447,26 @@ activate_helper (GtkMenuShell * shell) GtkWidget * attach = gtk_menu_get_attach_widget(GTK_MENU(shell)); if (attach != NULL) { - GtkWidget * parent = gtk_widget_get_parent(GTK_WIDGET(attach)); + GtkWidget * parent = gtk_widget_get_parent(attach); + GtkWidget *toplevel = gtk_widget_get_toplevel (attach); if (parent != NULL) { if (GTK_IS_MENU(parent)) { activate_helper(GTK_MENU_SHELL(parent)); } + + if (!GTK_MENU_SHELL (parent)->active) { + gtk_grab_add (parent); + GTK_MENU_SHELL (parent)->have_grab = TRUE; + GTK_MENU_SHELL (parent)->active = TRUE; + } + gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), attach); } } } - return; + return; } /* Signaled when we should show a menuitem at request of the application -- cgit v1.2.3 From 95d4df8bfd7c9a2aa87be499460507b29f947478 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Sep 2010 09:40:37 -0500 Subject: 0.3.13 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5ccf9c3..792d065 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.12, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.13, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.12, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.13, [-Wno-portability]) AM_MAINTAINER_MODE @@ -99,7 +99,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=14 +LIBDBUSMENU_REVISION=15 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From b4e81b6ac723fab2e91de6b7a8e106e23ffd4dc6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Sep 2010 13:15:02 -0500 Subject: Building up a structure and passing it back on in a callback to clear the bus. --- 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 26e7a0d..d7f6de4 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -659,6 +659,33 @@ _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * pro return TRUE; } +/* Structure for holding the event data for the idle function + to pick it up. */ +typedef struct _idle_event_t idle_event_t; +struct _idle_event_t { + DbusmenuMenuitem * mi; + gchar * eventid; + GValue data; + guint timestamp; +}; + +/* A handler for else where in the main loop so that the dbusmenu + event response doesn't get blocked */ +static gboolean +event_local_handler (gpointer user_data) +{ + idle_event_t * data = (idle_event_t *)user_data; + + dbusmenu_menuitem_handle_event(data->mi, data->eventid, &data->data, data->timestamp); + + g_object_unref(data->mi); + g_free(data->eventid); + g_value_unset(&data->data); + g_free(data); + return FALSE; +} + +/* Handles the even coming off of DBus */ static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error) { @@ -676,7 +703,15 @@ _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValu return FALSE; } - dbusmenu_menuitem_handle_event(mi, eventid, data, timestamp); + idle_event_t * event_data = g_new0(idle_event_t, 0); + event_data->mi = mi; + g_object_ref(event_data->mi); + event_data->eventid = g_strdup(eventid); + event_data->timestamp = timestamp; + g_value_init(&(event_data->data), G_VALUE_TYPE(data)); + g_value_copy(data, &(event_data->data)); + + g_timeout_add(0, event_local_handler, event_data); return TRUE; } -- cgit v1.2.3 From e06405076da675f90446098160730ff34d268667 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Sep 2010 13:34:32 -0500 Subject: Turns out you should really allocate things with the allocation function. Who'd have guessed that! --- 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 d7f6de4..d2f4096 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -703,7 +703,7 @@ _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValu return FALSE; } - idle_event_t * event_data = g_new0(idle_event_t, 0); + idle_event_t * event_data = g_new0(idle_event_t, 1); event_data->mi = mi; g_object_ref(event_data->mi); event_data->eventid = g_strdup(eventid); -- cgit v1.2.3 From 72164ef8c31d3327f88259eeafecc8eead6dc9e3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Sep 2010 09:24:38 -0500 Subject: Unreffing the hashtable. --- libdbusmenu-glib/server.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index d2f4096..68afb92 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -633,6 +633,10 @@ serialize_menuitem(gpointer data, gpointer user_data) _gvalue_array_append_hashtable(item, dict); g_ptr_array_add(output, item); + + g_hash_table_unref(dict); + + return; } static gboolean -- cgit v1.2.3 From 6c3c66e1ccbe10364cb04a7bf1816001bb2fe560 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Sep 2010 11:28:35 -0500 Subject: 0.3.14 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 792d065..7e7bf6b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.13, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.14, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.13, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.14, [-Wno-portability]) AM_MAINTAINER_MODE @@ -99,7 +99,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=15 +LIBDBUSMENU_REVISION=16 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From d177c5f4692279198a2ff4b7e21e92208a69075b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2010 16:33:38 -0500 Subject: Turn about to show into an activate for those with children. --- libdbusmenu-glib/menuitem.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ea69776..fb12163 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -97,6 +97,7 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * 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, const GValue * value, guint timestamp); +static void send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); /* GObject stuff */ G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT); @@ -114,6 +115,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) object_class->get_property = get_property; klass->handle_event = handle_event; + klass->send_about_to_show = send_about_to_show; /** DbusmenuMenuitem::property-changed: @@ -387,6 +389,28 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g return; } +/* Handles our about to show signal on items that submenus + exist. This is sending just activate now, but we should + probably consider a special signal in the future if GTK + gets more sophisticated about this. */ +static void +send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data) +{ + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + + if (dbusmenu_menuitem_get_children(mi) == NULL) { + g_warning("About to Show called on an item wihtout submenus. We're ignoring it."); + } else { + g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, 0 /* timestamp */, TRUE); + } + + if (cb != NULL) { + cb(mi, cb_data); + } + + return; +} + /* Public interface */ /** -- cgit v1.2.3 From 56b4d9a181b29082051ed9c0e4743eca52eac52f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Sep 2010 11:42:28 -0500 Subject: Adding in ChangeLog and AUTHORS dist-hooks --- Makefile.am | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Makefile.am b/Makefile.am index 3853d2a..b5fff3e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,3 +12,29 @@ SUBDIRS = \ po DISTCHECK_CONFIGURE_FLAGS = --enable-introspection --enable-gtk-doc + +dist-hook: + @if test -d "$(top_srcdir)/.bzr"; \ + then \ + echo Creating ChangeLog && \ + ( cd "$(top_srcdir)" && \ + echo '# Generated by Makefile. Do not edit.'; echo; \ + $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \ + && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \ + || (rm -f ChangeLog.tmp; \ + echo Failed to generate ChangeLog >&2 ); \ + else \ + echo Failed to generate ChangeLog: not a branch >&2; \ + fi + @if test -d "$(top_srcdir)/.bzr"; \ + then \ + echo Creating AUTHORS && \ + ( cd "$(top_srcdir)" && \ + echo '# Generated by Makefile. Do not edit.'; echo; \ + $(top_srcdir)/missing --run bzr log --long --levels=0 | grep -e "^\s*author:" -e "^\s*committer:" | cut -d ":" -f 2 | cut -d "<" -f 1 | sort -u) > AUTHORS.tmp \ + && mv -f AUTHORS.tmp $(top_distdir)/AUTHORS \ + || (rm -f AUTHORS.tmp; \ + echo Failed to generate AUTHORS >&2 ); \ + else \ + echo Failed to generate AUTHORS: not a branch >&2; \ + fi -- cgit v1.2.3 From 9cc32d2064b803d005b1e0824022528a295c8fdd Mon Sep 17 00:00:00 2001 From: David Barth Date: Wed, 22 Sep 2010 14:16:17 +0200 Subject: 0.3.15 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 7e7bf6b..576caad 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.14, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.15, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.14, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.15, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From d7c35c09381063b16ef2221fd3edf1d537ac5578 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 22 Sep 2010 09:39:21 -0500 Subject: Removing the typedef for the callback --- libdbusmenu-glib/client-menuitem.c | 6 +++--- libdbusmenu-glib/menuitem.c | 6 +++--- libdbusmenu-glib/menuitem.h | 14 ++------------ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index 979cf79..9c21065 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -46,7 +46,7 @@ static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self); static void dbusmenu_client_menuitem_dispose (GObject *object); static void dbusmenu_client_menuitem_finalize (GObject *object); static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); -static void send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); +static void send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM); @@ -112,7 +112,7 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g typedef struct _about_to_show_t about_to_show_t; struct _about_to_show_t { DbusmenuMenuitem * mi; - dbusmenu_menuitem_about_to_show_cb cb; + void (*cb) (DbusmenuMenuitem * mi, gpointer user_data); gpointer cb_data; }; @@ -131,7 +131,7 @@ about_to_show_cb (gpointer user_data) /* Passes the about to show signal on through the client. */ static void -send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data) +send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data) { DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); if (cb == NULL) { diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index fb12163..ef037d1 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -97,7 +97,7 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * 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, const GValue * value, guint timestamp); -static void send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); +static void send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); /* GObject stuff */ G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT); @@ -394,7 +394,7 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g probably consider a special signal in the future if GTK gets more sophisticated about this. */ static void -send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data) +send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); @@ -1374,7 +1374,7 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const called if possible. */ void -dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data) +dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); #ifdef MASSIVEDEBUGGING diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 9be938b..a505c9c 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -94,16 +94,6 @@ struct _DbusmenuMenuitem GObject parent; }; -/** - * dbusmenu_menuitem_about_to_show_cb: - * @mi: Menu item that should be shown - * @user_data: (closure): Extra user data sent with the function - * - * Callback prototype for a callback that is called when the - * menu should be shown. - */ -typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpointer user_data); - /** * dbusmenu_menuitem_buildxml_slot_t: * @mi: (in): Menu item that should be built from @@ -143,7 +133,7 @@ struct _DbusmenuMenuitemClass /* Virtual functions */ dbusmenu_menuitem_buildxml_slot_t buildxml; void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); - void (*send_about_to_show) (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); + 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); /* void (*reserved1) (void); */ @@ -189,7 +179,7 @@ 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, const GValue * value, guint timestamp); -void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); +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 d41d1003c3933e0f4116b231650a715c0156501b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 22 Sep 2010 10:01:52 -0500 Subject: Reintroduce the typedef so we don't break the API --- libdbusmenu-glib/menuitem.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index a505c9c..d7cf586 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -94,6 +94,16 @@ struct _DbusmenuMenuitem GObject parent; }; +/** + * dbusmenu_menuitem_about_to_show_cb: + * @mi: Menu item that should be shown + * @user_data: (closure): Extra user data sent with the function + * + * Callback prototype for a callback that is called when the + * menu should be shown. + */ +typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpointer user_data); + /** * dbusmenu_menuitem_buildxml_slot_t: * @mi: (in): Menu item that should be built from -- cgit v1.2.3 From ba03e53fb680f3efb84156fa35926fef2ea3b36d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 22 Sep 2010 10:17:58 -0500 Subject: 0.3.16 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 576caad..6f894fd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.15, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.16, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.15, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.16, [-Wno-portability]) AM_MAINTAINER_MODE @@ -99,7 +99,7 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) ########################### LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=16 +LIBDBUSMENU_REVISION=17 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 46cf6414f55a027f0eaf3b85701479fb5fe12441 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 24 Sep 2010 14:38:24 -0500 Subject: Making sure to reference the accel group --- libdbusmenu-gtk/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 6970d59..0f8592c 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -249,6 +249,7 @@ dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * } priv->agroup = agroup; + g_object_ref(priv->agroup); return; } -- cgit v1.2.3 From 7fa04256d9aac8e1ea2a2982a7b93276fb981fa4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 27 Sep 2010 20:11:29 -0500 Subject: Only flush at the top level --- libdbusmenu-glib/client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ca16c9a..91dc356 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1283,8 +1283,10 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* We've got everything built up at this node and reconcilled */ - /* Flush the properties requests */ - get_properties_flush(client); + /* Flush the properties requests if this is the first level */ + if (dbusmenu_menuitem_get_id(parent) == 0) { + get_properties_flush(client); + } /* now it's time to recurse down the tree. */ children = node->children; -- cgit v1.2.3 From 761c9cc00f19001548d23fe09a3e1676e728ad73 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 27 Sep 2010 20:15:46 -0500 Subject: Set a maximum number of entries to queue before sending the message. --- libdbusmenu-glib/client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 91dc356..52cb24f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -43,6 +43,10 @@ License version 3 and version 2.1 along with this program. If not, see #include "server-marshal.h" #include "client-marshal.h" +/* How many property requests should we queue before + sending the message on dbus */ +#define MAX_PROPERTIES_TO_QUEUE 100 + /* Properties */ enum { PROP_0, @@ -628,6 +632,13 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert priv->delayed_idle = g_idle_add(get_properties_idle, client); } + /* Look at how many proprites we have queued up and + make it so that we don't leave too many in one + request. */ + if (priv->delayed_property_listeners->len == MAX_PROPERTIES_TO_QUEUE) { + get_properties_flush(client); + } + return; } -- cgit v1.2.3 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(+) 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(-) 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 682fd63278c0306437d43c827d7873403d3575af Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 6 Oct 2010 10:13:09 -0400 Subject: instead of always building gtk2 and gtk3, add a --with-gtk= flag to configure to specify which to build with --- configure.ac | 45 +++++++++++------- libdbusmenu-gtk/Makefile.am | 91 +++++++++++++++++-------------------- libdbusmenu-gtk/dbusmenu-gtk3.pc.in | 2 +- libdbusmenu-gtk/genericmenuitem.c | 40 +++++++++++----- tools/testapp/Makefile.am | 8 +++- 5 files changed, 105 insertions(+), 81 deletions(-) diff --git a/configure.ac b/configure.ac index ff8dc78..a525612 100644 --- a/configure.ac +++ b/configure.ac @@ -48,23 +48,33 @@ AC_SUBST(DBUSMENUGLIB_LIBS) ########################### GTK_REQUIRED_VERSION=2.16 -GTK3_REQUIRED_VERSION=2.90 - -PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) - -AC_SUBST(DBUSMENUGTK_CFLAGS) -AC_SUBST(DBUSMENUGTK_LIBS) - -PKG_CHECK_MODULES(DBUSMENUGTK3, gtk+-3.0 >= $GTK3_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) - -AC_SUBST(DBUSMENUGTK3_CFLAGS) -AC_SUBST(DBUSMENUGTK3_LIBS) +GTK3_REQUIRED_VERSION=2.91 + +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], + [Which version of gtk to use @<:@default=2@:>@])], + [], + [with_gtk=2]) +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) + AC_SUBST(DBUSMENUGTK_CFLAGS) + AC_SUBST(DBUSMENUGTK_LIBS) + AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available]) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) + AC_SUBST(DBUSMENUGTK_CFLAGS) + AC_SUBST(DBUSMENUGTK_LIBS) + ], + [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] +) +AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) ########################### # Dependencies - Testing @@ -155,5 +165,6 @@ libdbusmenu Configuration: Prefix: $prefix Massive Debugging: $with_massivedebugging + GTK+ Version: $with_gtk ]) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 4f38b63..cfa4230 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -1,22 +1,27 @@ CLEANFILES = -EXTRA_DIST = \ - dbusmenu-gtk.pc.in \ - dbusmenu-gtk3.pc.in +if USE_GTK3 +VER=3 +GTKGIR=Gtk-3.0 +GTKVALA=gtk+-3.0 +lib_LTLIBRARIES = libdbusmenu-gtk3.la +else +VER= +GTKGIR=Gtk-2.0 +GTKVALA=gtk+-2.0 +lib_LTLIBRARIES = libdbusmenu-gtk.la +endif -lib_LTLIBRARIES = \ - libdbusmenu-gtk.la \ - libdbusmenu-gtk3.la +EXTRA_DIST = \ + dbusmenu-gtk$(VER).pc.in -libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/ -libdbusmenu_gtk3includedir=$(includedir)/libdbusmenu3-0.1/libdbusmenu-gtk/ +libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk$(VER)/ libdbusmenu_gtkinclude_HEADERS = \ client.h \ menu.h \ menuitem.h -libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) libdbusmenu_gtk_la_SOURCES = \ client.h \ @@ -27,27 +32,31 @@ libdbusmenu_gtk_la_SOURCES = \ menu.c \ menuitem.h \ menuitem.c -libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) libdbusmenu_gtk_la_LDFLAGS = \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ -no-undefined \ -export-symbols-regex "^[^_].*" -libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) libdbusmenu_gtk_la_CFLAGS = \ $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" -libdbusmenu_gtk3_la_CFLAGS = \ - $(DBUSMENUGTK3_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" libdbusmenu_gtk_la_LIBADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGTK_LIBS) -libdbusmenu_gtk3_la_LIBADD = \ - ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGTK3_LIBS) -pkgconfig_DATA = dbusmenu-gtk.pc dbusmenu-gtk3.pc +# We duplicate these here because Automake won't let us use $(VER) on the left hand side. +# Since we carefully use $(VER) in the right hand side above, we can assign the same values. +# Only one version of the library is every compiled at the same time, so it is safe to reuse +# the right hand sides like this. +libdbusmenu_gtk3includedir = $(libdbusmenu_gtkincludedir) +libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) +libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) +libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) +libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) +libdbusmenu_gtk3_la_LIBADD = $(libdbusmenu_gtk_la_LIBADD) + +pkgconfig_DATA = dbusmenu-gtk$(VER).pc pkgconfigdir = $(libdir)/pkgconfig ######################### @@ -66,25 +75,22 @@ if HAVE_INTROSPECTION introspection_sources = $(libdbusmenu_gtkinclude_HEADERS) -DbusmenuGtk-0.2.gir: libdbusmenu-gtk.la +DbusmenuGtk$(VER)-0.2.gir: libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_INCLUDES = \ GObject-2.0 \ - Gtk-2.0 \ + $(GTKGIR) \ Dbusmenu-Glib-0.2 DbusmenuGtk_0_2_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk.la +DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -DbusmenuGtk3-0.2.gir: libdbusmenu-gtk3.la -DbusmenuGtk3_0_2_gir_INCLUDES = \ - GObject-2.0 \ - Gtk-3.0 \ - Dbusmenu-Glib-0.2 -DbusmenuGtk3_0_2_gir_CFLAGS = $(DBUSMENUGTK3_CFLAGS) -I$(top_srcdir) -DbusmenuGtk3_0_2_gir_LIBS = libdbusmenu-gtk3.la -DbusmenuGtk3_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) +# We duplicate these for the same reason as libdbusmenu_gtk3includedir above +DbusmenuGtk3_0_2_gir_INCLUDES = $(DbusmenuGtk_0_2_gir_INCLUDES) +DbusmenuGtk3_0_2_gir_CFLAGS = $(DbusmenuGtk_0_2_gir_CFLAGS) +DbusmenuGtk3_0_2_gir_LIBS = $(DbusmenuGtk_0_2_gir_LIBS) +DbusmenuGtk3_0_2_gir_FILES = $(DbusmenuGtk_0_2_gir_FILES) -INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir DbusmenuGtk3-0.2.gir +INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.2.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -103,39 +109,24 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = DbusmenuGtk-0.2.vapi DbusmenuGtk3-0.2.vapi +vapi_DATA = DbusmenuGtk$(VER)-0.2.vapi -DbusmenuGtk-0.2.vapi: DbusmenuGtk-0.2.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk-0.2 \ +DbusmenuGtk$(VER)-0.2.vapi: DbusmenuGtk$(VER)-0.2.tmp.gir Makefile.am + $(VALA_API_GEN) --library=DbusmenuGtk$(VER)-0.2 \ --pkg gdk-pixbuf-2.0 \ - --pkg gtk+-2.0 \ - --pkg atk \ - --pkg Dbusmenu-Glib-0.2 \ - --vapidir=$(top_builddir)/libdbusmenu-glib \ - $< - -DbusmenuGtk3-0.2.vapi: DbusmenuGtk3-0.2.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk3-0.2 \ - --pkg gdk-pixbuf-3.0 \ - --pkg gtk+-3.0 \ + --pkg $(GTKVALA) \ --pkg atk \ --pkg Dbusmenu-Glib-0.2 \ --vapidir=$(top_builddir)/libdbusmenu-glib \ $< -DbusmenuGtk-0.2.tmp.gir: DbusmenuGtk-0.2.gir - $(SED) \ - -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ - -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ - $< > $@ - -DbusmenuGtk3-0.2.tmp.gir: DbusmenuGtk3-0.2.gir +DbusmenuGtk$(VER)-0.2.tmp.gir: DbusmenuGtk$(VER)-0.2.gir $(SED) \ -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ $< > $@ -CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.2.tmp.gir DbusmenuGtk3-0.2.tmp.gir +CLEANFILES += $(vapi_DATA) DbusmenuGtk$(VER)-0.2.tmp.gir endif diff --git a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in index e2c4cc3..1a3410e 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-3.1 +Cflags: -I${includedir}/libdbusmenu-0.1 Requires: dbus-glib-1 dbusmenu-glib Libs: -L${libdir} -ldbusmenu-gtk3 diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 8f40d93..b357d82 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -51,7 +51,6 @@ static void genericmenuitem_class_init (GenericmenuitemClass *klass); static void genericmenuitem_init (Genericmenuitem *self); static void genericmenuitem_dispose (GObject *object); static void genericmenuitem_finalize (GObject *object); -static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); static void set_label (GtkMenuItem * menu_item, const gchar * label); static const gchar * get_label (GtkMenuItem * menu_item); static void activate (GtkMenuItem * menu_item); @@ -59,8 +58,13 @@ static void activate (GtkMenuItem * menu_item); /* GObject stuff */ G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); -/* Globals */ +#if HAVE_GTK3 +static void draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr); +static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, cairo_t *cr) = NULL; +#else +static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) = NULL; +#endif /* Initializing all of the classes. Most notably we're disabling the drawing of the check early. */ @@ -121,6 +125,17 @@ genericmenuitem_finalize (GObject *object) /* Checks to see if we should be drawing a little box at all. If we should be, let's do that, otherwise we're going suppress the box drawing. */ +#if HAVE_GTK3 +static void +draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr) +{ + Genericmenuitem * self = GENERICMENUITEM(check_menu_item); + if (self->priv->check_type != GENERICMENUITEM_CHECK_TYPE_NONE) { + parent_draw_indicator(check_menu_item, cr); + } + return; +} +#else static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) { @@ -130,6 +145,7 @@ draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) } return; } +#endif /* A small helper to look through the widgets in the box and find the one that is the label. */ @@ -320,32 +336,32 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) GtkCheckMenuItem * check = GTK_CHECK_MENU_ITEM(item); - gboolean old_active = check->active; - gboolean old_inconsist = check->inconsistent; + gboolean old_active = gtk_check_menu_item_get_active (check); + gboolean old_inconsist = gtk_check_menu_item_get_inconsistent (check); switch (item->priv->state) { case GENERICMENUITEM_STATE_UNCHECKED: - check->active = FALSE; - check->inconsistent = FALSE; + gtk_check_menu_item_set_active (check, FALSE); + gtk_check_menu_item_set_inconsistent (check, FALSE); break; case GENERICMENUITEM_STATE_CHECKED: - check->active = TRUE; - check->inconsistent = FALSE; + gtk_check_menu_item_set_active (check, TRUE); + gtk_check_menu_item_set_inconsistent (check, FALSE); break; case GENERICMENUITEM_STATE_INDETERMINATE: - check->active = TRUE; - check->inconsistent = TRUE; + gtk_check_menu_item_set_active (check, TRUE); + gtk_check_menu_item_set_inconsistent (check, TRUE); break; default: g_warning("Generic Menuitem invalid check state: %d", state); return; } - if (old_active != check->active) { + if (old_active != gtk_check_menu_item_get_active (check)) { g_object_notify(G_OBJECT(item), "active"); } - if (old_inconsist != check->inconsistent) { + if (old_inconsist != gtk_check_menu_item_get_inconsistent (check)) { g_object_notify(G_OBJECT(item), "inconsistent"); } diff --git a/tools/testapp/Makefile.am b/tools/testapp/Makefile.am index a8b42dd..39de532 100644 --- a/tools/testapp/Makefile.am +++ b/tools/testapp/Makefile.am @@ -1,4 +1,10 @@ +if USE_GTK3 +VER=3 +else +VER= +endif + libexec_PROGRAMS = dbusmenu-testapp dbusmenu_testapp_SOURCES = \ @@ -12,6 +18,6 @@ dbusmenu_testapp_CFLAGS = \ dbusmenu_testapp_LDADD = \ $(builddir)/../../libdbusmenu-glib/libdbusmenu-glib.la \ - $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) -- cgit v1.2.3 From 4439a1f8d31e49fc1a3cd4c7c8a1508bdabaca1f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 13:00:25 -0500 Subject: Change library version --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 6f894fd..23680b7 100644 --- a/configure.ac +++ b/configure.ac @@ -98,8 +98,8 @@ AC_PATH_PROG([VALA_API_GEN], [vapigen]) # Lib versioning ########################### -LIBDBUSMENU_CURRENT=1 -LIBDBUSMENU_REVISION=17 +LIBDBUSMENU_CURRENT=2 +LIBDBUSMENU_REVISION=0 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 5eca4acf78ee4b606930253cdd433735d621224a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:05:42 -0500 Subject: Taking back the reserved --- libdbusmenu-glib/client.h | 12 +++++++++--- libdbusmenu-glib/menuitem-proxy.h | 10 ++++++++++ libdbusmenu-glib/menuitem.h | 19 +++++++++++++++---- libdbusmenu-glib/server.h | 21 ++++++++++++++------- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 5d4b5c3..a1cf58b 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -65,6 +65,10 @@ G_BEGIN_DECLS @event_result: Slot for #DbusmenuClient::event-error. @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 @@ -80,11 +84,13 @@ struct _DbusmenuClientClass { void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); void (*event_result) (DbusmenuMenuitem * item, gchar * event, GValue * data, guint timestamp, GError * error); - /* Reserved for future use */ + /*< Private >*/ void (*reserved1) (void); void (*reserved2) (void); - /* void (*reserved3) (void); */ - /* void (*reserved4) (void); */ + void (*reserved3) (void); + void (*reserved4) (void); + void (*reserved5) (void); + void (*reserved6) (void); }; /** diff --git a/libdbusmenu-glib/menuitem-proxy.h b/libdbusmenu-glib/menuitem-proxy.h index 56c4941..69f5c7d 100644 --- a/libdbusmenu-glib/menuitem-proxy.h +++ b/libdbusmenu-glib/menuitem-proxy.h @@ -48,11 +48,21 @@ typedef struct _DbusmenuMenuitemProxyClass DbusmenuMenuitemProxyClass; /** DbusmenuMenuitemProxyClass: @parent_class: The Class of #DbusmeneMenuitem + @reserved1: Reserved for future use. + @reserved2: Reserved for future use. + @reserved3: Reserved for future use. + @reserved4: Reserved for future use. Functions and signal slots for #DbusmenuMenuitemProxy. */ struct _DbusmenuMenuitemProxyClass { DbusmenuMenuitemClass parent_class; + + /*< Private >*/ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); }; /** diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index d7cf586..399ed9c 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -126,6 +126,13 @@ typedef void (*dbusmenu_menuitem_buildxml_slot_t) (DbusmenuMenuitem * mi, GPtrAr * @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information. * @send_about_to_show: Virtual function that notifies server that the client is about to show a menu. * @show_to_user: Slot for #DbusmenuMenuitem::show-to-user. + * + * @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. */ typedef struct _DbusmenuMenuitemClass DbusmenuMenuitemClass; struct _DbusmenuMenuitemClass @@ -146,10 +153,14 @@ struct _DbusmenuMenuitemClass 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); - /* void (*reserved1) (void); */ - /* void (*reserved2) (void); */ - /* void (*reserved3) (void); */ - /* void (*reserved4) (void); -- realized, realloc when bumping lib version */ + + /*< Private >*/ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); + void (*reserved5) (void); + void (*reserved6) (void); }; GType dbusmenu_menuitem_get_type (void); diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index a9bf213..7d56457 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -60,9 +60,13 @@ G_BEGIN_DECLS @id_update: Slot for #DbusmenuServer::id-update. @layout_updated: Slot for #DbusmenuServer::layout-update. @item_activation_requested: Slot for #DbusmenuServer::item-activation-requested. - @dbusmenu_server_reserved1: Reserved for future use. - @dbusmenu_server_reserved2: Reserved for future use. - @dbusmenu_server_reserved3: Reserved for future use. + + @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. The class implementing the virtual functions for #DbusmenuServer. */ @@ -76,10 +80,13 @@ struct _DbusmenuServerClass { void (*layout_updated)(gint revision); void (*item_activation)(gint id, guint timestamp); - /* Reserved */ - void (*dbusmenu_server_reserved1)(void); - void (*dbusmenu_server_reserved2)(void); - void (*dbusmenu_server_reserved3)(void); + /*< Private >*/ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); + void (*reserved5) (void); + void (*reserved6) (void); }; /** -- cgit v1.2.3 From 650d606580a1cf5842470ecf9dd97b166eed55d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:07:22 -0500 Subject: Going to 6 privates like others --- libdbusmenu-gtk/client.h | 6 +++++- libdbusmenu-gtk/menu.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.h b/libdbusmenu-gtk/client.h index a7c96ee..2793faf 100644 --- a/libdbusmenu-gtk/client.h +++ b/libdbusmenu-gtk/client.h @@ -50,6 +50,8 @@ G_BEGIN_DECLS @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. */ typedef struct _DbusmenuGtkClientClass DbusmenuGtkClientClass; struct _DbusmenuGtkClientClass { @@ -58,11 +60,13 @@ struct _DbusmenuGtkClientClass { /* Signals */ void (*root_changed) (DbusmenuMenuitem * newroot); - /* Reserved */ + /*< Private >*/ void (*reserved1) (void); void (*reserved2) (void); void (*reserved3) (void); void (*reserved4) (void); + void (*reserved5) (void); + void (*reserved6) (void); }; /** diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h index 5147d30..0601d0a 100644 --- a/libdbusmenu-gtk/menu.h +++ b/libdbusmenu-gtk/menu.h @@ -49,16 +49,20 @@ G_BEGIN_DECLS @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. */ typedef struct _DbusmenuGtkMenuClass DbusmenuGtkMenuClass; struct _DbusmenuGtkMenuClass { GtkMenuClass parent_class; - /* Reserved */ + /*< Private >*/ void (*reserved1) (void); void (*reserved2) (void); void (*reserved3) (void); void (*reserved4) (void); + void (*reserved5) (void); + void (*reserved6) (void); }; /** -- cgit v1.2.3 From 3dcaae7b7da97aa3b84f94ed5ebc3f6fba86cc41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:14:21 -0500 Subject: Putting the pointer to the private area in the instance --- libdbusmenu-glib/client.c | 1 - libdbusmenu-glib/client.h | 5 +++++ libdbusmenu-glib/menuitem-proxy.c | 1 - libdbusmenu-glib/menuitem-proxy.h | 8 ++++++-- libdbusmenu-glib/menuitem.c | 1 - libdbusmenu-glib/menuitem.h | 5 +++++ libdbusmenu-glib/server.c | 2 -- libdbusmenu-glib/server.h | 5 +++++ 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ca16c9a..30a415b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -62,7 +62,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; struct _DbusmenuClientPrivate { DbusmenuMenuitem * root; diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index a1cf58b..32813d9 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -56,6 +56,8 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" #define DBUSMENU_CLIENT_TYPES_IMAGE "standard" +typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; + /** DbusmenuClientClass: @parent_class: #GObjectClass @@ -103,6 +105,9 @@ struct _DbusmenuClientClass { typedef struct _DbusmenuClient DbusmenuClient; struct _DbusmenuClient { GObject parent; + + /*< Private >*/ + DbusmenuClientPrivate * priv; }; typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); diff --git a/libdbusmenu-glib/menuitem-proxy.c b/libdbusmenu-glib/menuitem-proxy.c index 2dd5ada..f4eaae3 100644 --- a/libdbusmenu-glib/menuitem-proxy.c +++ b/libdbusmenu-glib/menuitem-proxy.c @@ -32,7 +32,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem-proxy.h" -typedef struct _DbusmenuMenuitemProxyPrivate DbusmenuMenuitemProxyPrivate; struct _DbusmenuMenuitemProxyPrivate { DbusmenuMenuitem * mi; gulong sig_property_changed; diff --git a/libdbusmenu-glib/menuitem-proxy.h b/libdbusmenu-glib/menuitem-proxy.h index 69f5c7d..cde92a9 100644 --- a/libdbusmenu-glib/menuitem-proxy.h +++ b/libdbusmenu-glib/menuitem-proxy.h @@ -42,8 +42,9 @@ G_BEGIN_DECLS #define DBUSMENU_IS_MENUITEM_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_MENUITEM_PROXY)) #define DBUSMENU_MENUITEM_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_MENUITEM_PROXY, DbusmenuMenuitemProxyClass)) -typedef struct _DbusmenuMenuitemProxy DbusmenuMenuitemProxy; -typedef struct _DbusmenuMenuitemProxyClass DbusmenuMenuitemProxyClass; +typedef struct _DbusmenuMenuitemProxy DbusmenuMenuitemProxy; +typedef struct _DbusmenuMenuitemProxyClass DbusmenuMenuitemProxyClass; +typedef struct _DbusmenuMenuitemProxyPrivate DbusmenuMenuitemProxyPrivate; /** DbusmenuMenuitemProxyClass: @@ -73,6 +74,9 @@ struct _DbusmenuMenuitemProxyClass { */ struct _DbusmenuMenuitemProxy { DbusmenuMenuitem parent; + + /*< Private >*/ + DbusmenuMenuitemPrivate * priv; }; GType dbusmenu_menuitem_proxy_get_type (void); diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ef037d1..e9b70d4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -52,7 +52,6 @@ License version 3 and version 2.1 along with this program. If not, see out of data that we have. They can still be gotten using accessor functions, but are protected appropriately. */ -typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate; struct _DbusmenuMenuitemPrivate { gint id; diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 399ed9c..ff8d713 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -78,6 +78,8 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU "submenu" +typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate; + /** * DbusmenuMenuitem: * @@ -92,6 +94,9 @@ typedef struct _DbusmenuMenuitem DbusmenuMenuitem; struct _DbusmenuMenuitem { GObject parent; + + /*< Private >*/ + DbusmenuMenuitemPrivate * priv; }; /** diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 68afb92..5c9826e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -53,8 +53,6 @@ static void layout_update_signal (DbusmenuServer * server); #define DBUSMENU_VERSION_NUMBER 2 /* Privates, I'll show you mine... */ -typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; - struct _DbusmenuServerPrivate { DbusmenuMenuitem * root; diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 7d56457..5668258 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -53,6 +53,8 @@ G_BEGIN_DECLS #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" #define DBUSMENU_SERVER_PROP_VERSION "version" +typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; + /** DbusmenuServerClass: @parent_class: #GObjectClass @@ -99,6 +101,9 @@ struct _DbusmenuServerClass { typedef struct _DbusmenuServer DbusmenuServer; struct _DbusmenuServer { GObject parent; + + /*< Private >*/ + DbusmenuServerPrivate * priv; }; GType dbusmenu_server_get_type (void); -- cgit v1.2.3 From 176f561e6959611b96e4c1525958fce757a6fb46 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:16:55 -0500 Subject: Private pointers in instance structs --- libdbusmenu-gtk/client.c | 1 - libdbusmenu-gtk/client.h | 5 +++++ libdbusmenu-gtk/menu.c | 1 - libdbusmenu-gtk/menu.h | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 6970d59..7de93e1 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -37,7 +37,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "genericmenuitem.h" /* Private */ -typedef struct _DbusmenuGtkClientPrivate DbusmenuGtkClientPrivate; struct _DbusmenuGtkClientPrivate { GtkAccelGroup * agroup; }; diff --git a/libdbusmenu-gtk/client.h b/libdbusmenu-gtk/client.h index 2793faf..c986a5d 100644 --- a/libdbusmenu-gtk/client.h +++ b/libdbusmenu-gtk/client.h @@ -43,6 +43,8 @@ G_BEGIN_DECLS #define DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED +typedef struct _DbusmenuGtkClientPrivate DbusmenuGtkClientPrivate; + /** DbusmenuGtkClientClass: @parent_class: #GtkMenuClass @@ -76,6 +78,9 @@ struct _DbusmenuGtkClientClass { typedef struct _DbusmenuGtkClient DbusmenuGtkClient; struct _DbusmenuGtkClient { DbusmenuClient parent; + + /*< Private >*/ + DbusmenuGtkClientPrivate * priv; }; GType dbusmenu_gtkclient_get_type (void); diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 4fa546b..14dcb89 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -44,7 +44,6 @@ enum { }; /* Private */ -typedef struct _DbusmenuGtkMenuPrivate DbusmenuGtkMenuPrivate; struct _DbusmenuGtkMenuPrivate { DbusmenuGtkClient * client; diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h index 0601d0a..896e466 100644 --- a/libdbusmenu-gtk/menu.h +++ b/libdbusmenu-gtk/menu.h @@ -42,6 +42,8 @@ G_BEGIN_DECLS #define DBUSMENU_IS_GTKMENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_GTKMENU_TYPE)) #define DBUSMENU_GTKMENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuClass)) +typedef struct _DbusmenuGtkMenuPrivate DbusmenuGtkMenuPrivate; + /** DbusmenuGtkMenuClass: @parent_class: #GtkMenuClass @@ -72,6 +74,9 @@ struct _DbusmenuGtkMenuClass { typedef struct _DbusmenuGtkMenu DbusmenuGtkMenu; struct _DbusmenuGtkMenu { GtkMenu parent; + + /*< Private >*/ + DbusmenuGtkMenuPrivate * priv; }; GType dbusmenu_gtkmenu_get_type (void); -- cgit v1.2.3 From e437868558658d3c949b787566ab5668a0194d3a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:21:44 -0500 Subject: Switching to using the pointer in the instance --- libdbusmenu-glib/menuitem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index e9b70d4..73b765b 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -83,8 +83,7 @@ enum { #define PROP_ID_S "id" -#define DBUSMENU_MENUITEM_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_MENUITEM, DbusmenuMenuitemPrivate)) +#define DBUSMENU_MENUITEM_GET_PRIVATE(o) (DBUSMENU_MENUITEM(o)->priv) /* Prototypes */ static void dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass); @@ -289,6 +288,8 @@ _g_value_free (gpointer data) static void dbusmenu_menuitem_init (DbusmenuMenuitem *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), DBUSMENU_TYPE_MENUITEM, DbusmenuMenuitemPrivate); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(self); priv->id = -1; -- cgit v1.2.3 From 5a6267a9735df4f2e0abc3c60cf820569998847b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:22:56 -0500 Subject: Switching to using the pointer in the instance --- libdbusmenu-glib/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 5c9826e..c5cf2fe 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -61,8 +61,7 @@ struct _DbusmenuServerPrivate guint layout_idle; }; -#define DBUSMENU_SERVER_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_SERVER, DbusmenuServerPrivate)) +#define DBUSMENU_SERVER_GET_PRIVATE(o) (DBUSMENU_SERVER(o)->priv) /* Signals */ enum { @@ -212,6 +211,8 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) static void dbusmenu_server_init (DbusmenuServer *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), DBUSMENU_TYPE_SERVER, DbusmenuServerPrivate); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(self); priv->root = NULL; -- cgit v1.2.3 From 7a07a55969ba3700ad7d447a38171bfaec889ec6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:24:07 -0500 Subject: Switching to using the pointer in the instance --- libdbusmenu-glib/client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 30a415b..6a51764 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -112,8 +112,7 @@ struct _event_data_t { }; -#define DBUSMENU_CLIENT_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_CLIENT, DbusmenuClientPrivate)) +#define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) /* GObject Stuff */ static void dbusmenu_client_class_init (DbusmenuClientClass *klass); @@ -253,6 +252,8 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) static void dbusmenu_client_init (DbusmenuClient *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), DBUSMENU_TYPE_CLIENT, DbusmenuClientPrivate); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(self); priv->root = NULL; -- cgit v1.2.3 From 149033eb701b43a0b830f86ec96dcd5dfe77d5e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:26:33 -0500 Subject: Switching to using the pointer in the instance --- libdbusmenu-glib/menuitem-proxy.c | 5 +++-- libdbusmenu-glib/menuitem-proxy.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/menuitem-proxy.c b/libdbusmenu-glib/menuitem-proxy.c index f4eaae3..7acb541 100644 --- a/libdbusmenu-glib/menuitem-proxy.c +++ b/libdbusmenu-glib/menuitem-proxy.c @@ -48,8 +48,7 @@ enum { #define PROP_MENU_ITEM_S "menu-item" -#define DBUSMENU_MENUITEM_PROXY_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_MENUITEM_PROXY, DbusmenuMenuitemProxyPrivate)) +#define DBUSMENU_MENUITEM_PROXY_GET_PRIVATE(o) (DBUSMENU_MENUITEM_PROXY(o)->priv) static void dbusmenu_menuitem_proxy_class_init (DbusmenuMenuitemProxyClass *klass); static void dbusmenu_menuitem_proxy_init (DbusmenuMenuitemProxy *self); @@ -91,6 +90,8 @@ dbusmenu_menuitem_proxy_class_init (DbusmenuMenuitemProxyClass *klass) static void dbusmenu_menuitem_proxy_init (DbusmenuMenuitemProxy *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), DBUSMENU_TYPE_MENUITEM_PROXY, DbusmenuMenuitemProxyPrivate); + DbusmenuMenuitemProxyPrivate * priv = DBUSMENU_MENUITEM_PROXY_GET_PRIVATE(self); priv->mi = NULL; diff --git a/libdbusmenu-glib/menuitem-proxy.h b/libdbusmenu-glib/menuitem-proxy.h index cde92a9..2a22efe 100644 --- a/libdbusmenu-glib/menuitem-proxy.h +++ b/libdbusmenu-glib/menuitem-proxy.h @@ -76,7 +76,7 @@ struct _DbusmenuMenuitemProxy { DbusmenuMenuitem parent; /*< Private >*/ - DbusmenuMenuitemPrivate * priv; + DbusmenuMenuitemProxyPrivate * priv; }; GType dbusmenu_menuitem_proxy_get_type (void); -- cgit v1.2.3 From f8d472db4415096f7a5e99e14aa3b1af290d2098 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 Oct 2010 16:29:26 -0500 Subject: Switching to using the pointer in the instance --- libdbusmenu-gtk/client.c | 5 +++-- libdbusmenu-gtk/menu.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 7de93e1..487971f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -41,8 +41,7 @@ struct _DbusmenuGtkClientPrivate { GtkAccelGroup * agroup; }; -#define DBUSMENU_GTKCLIENT_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_GTKCLIENT_TYPE, DbusmenuGtkClientPrivate)) +#define DBUSMENU_GTKCLIENT_GET_PRIVATE(o) (DBUSMENU_GTKCLIENT(o)->priv) /* Prototypes */ static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass); @@ -84,6 +83,8 @@ dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass) static void dbusmenu_gtkclient_init (DbusmenuGtkClient *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), DBUSMENU_GTKCLIENT_TYPE, DbusmenuGtkClientPrivate); + DbusmenuGtkClientPrivate * priv = DBUSMENU_GTKCLIENT_GET_PRIVATE(self); priv->agroup = NULL; diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 14dcb89..ace8e8a 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -51,8 +51,7 @@ struct _DbusmenuGtkMenuPrivate { gchar * dbus_name; }; -#define DBUSMENU_GTKMENU_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuPrivate)) +#define DBUSMENU_GTKMENU_GET_PRIVATE(o) (DBUSMENU_GTKMENU(o)->priv) /* Prototypes */ static void dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass); @@ -109,6 +108,8 @@ menu_focus_cb(DbusmenuGtkMenu * menu, gpointer userdata) static void dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuPrivate); + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(self); priv->client = NULL; -- cgit v1.2.3 From 7ba22007311d5ed891a8dbb29e76873c74ea4ea6 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 13 Oct 2010 08:42:42 -0400 Subject: ship both .pc files in EXTRA_DIST --- libdbusmenu-gtk/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index cfa4230..b30cac9 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -14,7 +14,8 @@ lib_LTLIBRARIES = libdbusmenu-gtk.la endif EXTRA_DIST = \ - dbusmenu-gtk$(VER).pc.in + dbusmenu-gtk.pc.in \ + dbusmenu-gtk3.pc.in libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk$(VER)/ -- cgit v1.2.3 From bcf8f4955ec6f6fce426a71fddb5c28bcc7dd804 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 Oct 2010 16:05:17 -0500 Subject: Dropping dbus-glib from the build requirements --- configure.ac | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.ac b/configure.ac index 23680b7..c8d18b1 100644 --- a/configure.ac +++ b/configure.ac @@ -33,11 +33,9 @@ GNOME_DOC_INIT ########################### GLIB_REQUIRED_VERSION=2.18 -DBUS_REQUIRED_VERSION=0.76 XML_REQUIRED_VERSION=2.6 PKG_CHECK_MODULES(DBUSMENUGLIB, glib-2.0 >= $GLIB_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION libxml-2.0 >= $XML_REQUIRED_VERSION) AC_SUBST(DBUSMENUGLIB_CFLAGS) @@ -51,7 +49,6 @@ GTK_REQUIRED_VERSION=2.16 PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION libxml-2.0 >= $XML_REQUIRED_VERSION) AC_SUBST(DBUSMENUGTK_CFLAGS) -- cgit v1.2.3 From 43ed1f7c65381c84da61998066ef45c89e0ed035 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 Oct 2010 16:07:36 -0500 Subject: Dropping the built headers from the build --- libdbusmenu-glib/Makefile.am | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 0a6513f..faf0634 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -20,8 +20,6 @@ libdbusmenu_glibinclude_HEADERS = \ client.h libdbusmenu_glib_la_SOURCES = \ - dbusmenu-server.h \ - dbusmenu-client.h \ menuitem.h \ menuitem.c \ menuitem-marshal.h \ @@ -55,8 +53,6 @@ pkgconfig_DATA = dbusmenu-glib.pc pkgconfigdir = $(libdir)/pkgconfig BUILT_SOURCES = \ - dbusmenu-client.h \ - dbusmenu-server.h \ client-marshal.h \ client-marshal.c \ menuitem-marshal.h \ @@ -64,20 +60,6 @@ BUILT_SOURCES = \ server-marshal.h \ server-marshal.c -dbusmenu-server.h: dbus-menu.xml - dbus-binding-tool \ - --prefix=_dbusmenu_server \ - --mode=glib-server \ - --output=dbusmenu-server.h \ - $(srcdir)/dbus-menu.xml - -dbusmenu-client.h: dbus-menu.xml - dbus-binding-tool \ - --prefix=_dbusmenu_client \ - --mode=glib-client \ - --output=dbusmenu-client.h \ - $(srcdir)/dbus-menu.xml - client-marshal.h: $(srcdir)/client-marshal.list glib-genmarshal --header \ --prefix=_dbusmenu_client_marshal $(srcdir)/client-marshal.list \ -- cgit v1.2.3 From 096f22a1b8fb8052e78ede98257556cef332da7a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 Oct 2010 16:54:03 -0500 Subject: Make the XML into something we can include in the source --- libdbusmenu-glib/Makefile.am | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index faf0634..be70cfa 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -20,6 +20,8 @@ libdbusmenu_glibinclude_HEADERS = \ client.h libdbusmenu_glib_la_SOURCES = \ + dbus-menu.xml.h \ + dbus-menu.xml.c \ menuitem.h \ menuitem.c \ menuitem-marshal.h \ @@ -52,7 +54,18 @@ libdbusmenu_glib_la_LIBADD = \ pkgconfig_DATA = dbusmenu-glib.pc pkgconfigdir = $(libdir)/pkgconfig +%.xml.h: %.xml + echo "extern const char * $(subst -,_,$(subst .,_,$(basename $@)));" > $@ + +%.xml.c: %.xml + echo "const char * $(subst -,_,$(subst .,_,$(basename $@))) = " > $@ + sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ + echo ";" >> $@ + + BUILT_SOURCES = \ + dbus-menu.xml.c \ + dbus-menu.xml.h \ client-marshal.h \ client-marshal.c \ menuitem-marshal.h \ @@ -60,6 +73,8 @@ BUILT_SOURCES = \ server-marshal.h \ server-marshal.c +CLEANFILES += $(BUILT_SOURCES) + client-marshal.h: $(srcdir)/client-marshal.list glib-genmarshal --header \ --prefix=_dbusmenu_client_marshal $(srcdir)/client-marshal.list \ -- cgit v1.2.3 From d998c52eb34f2203d6c322528497486f493470a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 09:54:58 -0500 Subject: Ignoring our new file friends --- .bzrignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bzrignore b/.bzrignore index c1088c1..c60cc9c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -194,3 +194,6 @@ libdbusmenu-glib/libdbusmenu_glib_la-client-marshal.lo tests/test-glib-events tests/test-glib-events-client tests/test-glib-events-server +libdbusmenu-glib/dbus-menu.xml.c +libdbusmenu-glib/dbus-menu.xml.h +libdbusmenu-glib/libdbusmenu_glib_la-dbus-menu.xml.lo -- cgit v1.2.3 From f309ec2bb22cda3e2f763f96bb6a08652d9373d8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 10:55:58 -0500 Subject: Changing the way the static interface information is generated --- libdbusmenu-glib/server.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index c5cf2fe..bbccd73 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -30,10 +30,14 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#include + #include "menuitem-private.h" #include "server.h" #include "server-marshal.h" +#include "dbus-menu.xml.h" + /* DBus Prototypes */ static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); @@ -46,8 +50,6 @@ static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id static void _gvalue_array_append_int(GValueArray *array, gint i); static void _gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict); -#include "dbusmenu-server.h" - static void layout_update_signal (DbusmenuServer * server); #define DBUSMENU_VERSION_NUMBER 2 @@ -91,6 +93,10 @@ enum { LAST_ERROR }; +/* Globals */ +static GDBusNodeInfo * dbusmenu_node_info = NULL; +static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; + /* Prototype */ static void dbusmenu_server_class_init (DbusmenuServerClass *class); static void dbusmenu_server_init (DbusmenuServer *self); @@ -203,7 +209,23 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - dbus_g_object_type_install_info(DBUSMENU_TYPE_SERVER, &dbus_glib__dbusmenu_server_object_info); + if (dbusmenu_node_info == NULL) { + GError * error = NULL; + + dbusmenu_node_info = g_dbus_node_info_new_for_xml(dbus_menu_xml, &error); + if (error != NULL) { + g_error("Unable to parse DBusmenu Interface description: %s", error->message); + g_error_free(error); + } + } + + if (dbusmenu_interface_info == NULL) { + dbusmenu_interface_info = g_dbus_node_info_lookup_interface(dbusmenu_node_info, "org.ayatana.dbusmenu"); + + if (dbusmenu_interface_info == NULL) { + g_error("Unable to find interface 'org.ayatana.dbusmenu'"); + } + } return; } -- cgit v1.2.3 From 23b8623959467e965c83b8bd6458575c0eca34cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 11:17:23 -0500 Subject: Setting up the private variables that we're going to do need to set this stuff up --- libdbusmenu-glib/server.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index bbccd73..6f5d45c 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -61,6 +61,10 @@ struct _DbusmenuServerPrivate gchar * dbusobject; gint layout_revision; guint layout_idle; + + GDBusConnection * bus; + GCancellable * bus_lookup; + guint dbus_registration; }; #define DBUSMENU_SERVER_GET_PRIVATE(o) (DBUSMENU_SERVER(o)->priv) @@ -241,6 +245,9 @@ dbusmenu_server_init (DbusmenuServer *self) priv->dbusobject = NULL; priv->layout_revision = 1; priv->layout_idle = 0; + priv->bus = NULL; + priv->bus_lookup = NULL; + priv->dbus_registration = 0; return; } @@ -259,6 +266,27 @@ dbusmenu_server_dispose (GObject *object) g_object_unref(priv->root); } + if (priv->dbus_registration != 0) { + g_dbus_connection_unregister_object(priv->bus, priv->dbus_registration); + priv->dbus_registration = 0; + } + + if (priv->bus != NULL) { + g_object_unref(priv->bus); + priv->bus = NULL; + } + + if (priv->bus_lookup != NULL) { + if (!g_cancellable_is_cancelled(priv->bus_lookup)) { + /* Note, this may case the async function to run at + some point in the future. That's okay, it'll get an + error, but just FYI */ + g_cancellable_cancel(priv->bus_lookup); + } + g_object_unref(priv->bus_lookup); + priv->bus_lookup = NULL; + } + G_OBJECT_CLASS (dbusmenu_server_parent_class)->dispose (object); return; } -- cgit v1.2.3 From a797369ae885c2df81620b90ce6eaa2a9de1de87 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 11:47:18 -0500 Subject: Changing the registration of the object on the bus --- libdbusmenu-glib/server.c | 87 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 6f5d45c..5729128 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -98,8 +98,9 @@ enum { }; /* Globals */ -static GDBusNodeInfo * dbusmenu_node_info = NULL; -static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; +static GDBusNodeInfo * dbusmenu_node_info = NULL; +static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; +static const GDBusInterfaceVTable dbusmenu_interface_table = {0}; /* Prototype */ static void dbusmenu_server_class_init (DbusmenuServerClass *class); @@ -108,6 +109,8 @@ static void dbusmenu_server_dispose (GObject *object); static void dbusmenu_server_finalize (GObject *object); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +static void register_object (DbusmenuServer * server); +static void bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data); static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server); static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint pos, DbusmenuServer * server); static void menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server); @@ -302,21 +305,21 @@ static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(obj); - GError * error = NULL; switch (id) { case PROP_DBUS_OBJECT: g_return_if_fail(priv->dbusobject == NULL); priv->dbusobject = g_value_dup_string(value); - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - if (connection == NULL || error != NULL) { - g_warning("Unable to get session bus: %s", error == NULL ? "No message" : error->message); - if (error != NULL) { g_error_free(error); } + if (priv->bus == NULL) { + if (priv->bus_lookup == NULL) { + priv->bus_lookup = g_cancellable_new(); + g_return_if_fail(priv->bus_lookup != NULL); + } + + g_bus_get(G_BUS_TYPE_SESSION, priv->bus_lookup, bus_got_cb, obj); } else { - dbus_g_connection_register_g_object(connection, - priv->dbusobject, - obj); + register_object(DBUSMENU_SERVER(obj)); } break; case PROP_ROOT_NODE: @@ -378,6 +381,70 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) return; } +/* Register the object on the dbus bus */ +static void +register_object (DbusmenuServer * server) +{ + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + /* Object info */ + g_return_if_fail(priv->bus != NULL); + g_return_if_fail(priv->dbusobject != NULL); + + /* Class info */ + g_return_if_fail(dbusmenu_node_info != NULL); + g_return_if_fail(dbusmenu_interface_info != NULL); + + /* We might block on this in the future, but it'd be nice if + we could change the object path. Thinking about it... */ + if (priv->dbus_registration != 0) { + g_dbus_connection_unregister_object(priv->bus, priv->dbus_registration); + priv->dbus_registration = 0; + } + + GError * error = NULL; + priv->dbus_registration = g_dbus_connection_register_object(priv->bus, + priv->dbusobject, + dbusmenu_interface_info, + &dbusmenu_interface_table, + server, + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to register object on bus: %s", error->message); + g_error_free(error); + } + + return; +} + +/* Callback from asking GIO to get us the session bus */ +static void +bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data) +{ + GError * error = NULL; + + GDBusConnection * bus = g_bus_get_finish(result, &error); + + if (error != NULL) { + g_warning("Unable to get session bus: %s", error->message); + g_error_free(error); + return; + } + + /* Note: We're not using the user_data before we check for + the error so that in the cancelled case at destruction of + the object we don't end up with an invalid object. */ + + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(user_data); + priv->bus = bus; + + register_object(DBUSMENU_SERVER(user_data)); + + return; +} + /* Handle actually signalling in the idle loop. This way we collect all the updates. */ static gboolean -- cgit v1.2.3 From 0db52d9f483d8d63024c3dc83d1cb5709c4b3f81 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 11:59:43 -0500 Subject: Moving globals --- libdbusmenu-glib/server.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 5729128..3a45f62 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -97,11 +97,6 @@ enum { LAST_ERROR }; -/* Globals */ -static GDBusNodeInfo * dbusmenu_node_info = NULL; -static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; -static const GDBusInterfaceVTable dbusmenu_interface_table = {0}; - /* Prototype */ static void dbusmenu_server_class_init (DbusmenuServerClass *class); static void dbusmenu_server_init (DbusmenuServer *self); @@ -118,6 +113,11 @@ static void menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data); static void menuitem_signals_remove (DbusmenuMenuitem * mi, gpointer data); static GQuark error_quark (void); +/* Globals */ +static GDBusNodeInfo * dbusmenu_node_info = NULL; +static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; +static const GDBusInterfaceVTable dbusmenu_interface_table = {0}; + G_DEFINE_TYPE (DbusmenuServer, dbusmenu_server, G_TYPE_OBJECT); static void -- cgit v1.2.3 From e80a7c4d027837c6d67fd4de52914b32b0bc30d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 12:11:41 -0500 Subject: Filling out the vtable --- libdbusmenu-glib/server.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 3a45f62..df57994 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -106,6 +106,21 @@ 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 register_object (DbusmenuServer * server); static void bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data); +static void bus_method_call (GDBusConnection * connection, + const gchar * sender, + const gchar * path, + const gchar * interface, + const gchar * method, + GVariant * params, + GDBusMethodInvocation * invocation, + gpointer user_data); +static GVariant * bus_get_prop (GDBusConnection * connection, + const gchar * sender, + const gchar * path, + const gchar * interface, + const gchar * property, + GError ** error, + gpointer user_data); static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server); static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint pos, DbusmenuServer * server); static void menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server); @@ -116,7 +131,11 @@ static GQuark error_quark (void); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; -static const GDBusInterfaceVTable dbusmenu_interface_table = {0}; +static const GDBusInterfaceVTable dbusmenu_interface_table = { + method_call: bus_method_call, + get_property: bus_get_prop, + set_property: NULL /* No properties that can be set */ +}; G_DEFINE_TYPE (DbusmenuServer, dbusmenu_server, G_TYPE_OBJECT); @@ -445,6 +464,24 @@ bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data) return; } +/* Function for the GDBus vtable to handle all method calls and dish + them out the appropriate functions */ +static void +bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) +{ + + return; +} + +/* For the GDBus vtable but we only have one property so it's pretty + simple. */ +static GVariant * +bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data) +{ + + return NULL; +} + /* Handle actually signalling in the idle loop. This way we collect all the updates. */ static gboolean -- cgit v1.2.3 From 53eee1c44b504a06ca72c0f7e3d21d2b69bc6905 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 12:18:08 -0500 Subject: Whitespace --- libdbusmenu-glib/server.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index df57994..d7ccaf8 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -98,14 +98,22 @@ enum { }; /* Prototype */ -static void dbusmenu_server_class_init (DbusmenuServerClass *class); -static void dbusmenu_server_init (DbusmenuServer *self); -static void dbusmenu_server_dispose (GObject *object); -static void dbusmenu_server_finalize (GObject *object); -static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); -static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); -static void register_object (DbusmenuServer * server); -static void bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data); +static void dbusmenu_server_class_init (DbusmenuServerClass *class); +static void dbusmenu_server_init (DbusmenuServer *self); +static void dbusmenu_server_dispose (GObject *object); +static void dbusmenu_server_finalize (GObject *object); +static void set_property (GObject * obj, + guint id, + const GValue * value, + GParamSpec * pspec); +static void get_property (GObject * obj, + guint id, + GValue * value, + GParamSpec * pspec); +static void register_object (DbusmenuServer * server); +static void bus_got_cb (GObject * obj, + GAsyncResult * result, + gpointer user_data); static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, @@ -121,12 +129,22 @@ static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * property, GError ** error, gpointer user_data); -static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server); -static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint pos, DbusmenuServer * server); -static void menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server); -static void menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data); -static void menuitem_signals_remove (DbusmenuMenuitem * mi, gpointer data); -static GQuark error_quark (void); +static void menuitem_property_changed (DbusmenuMenuitem * mi, + gchar * property, + GValue * value, + DbusmenuServer * server); +static void menuitem_child_added (DbusmenuMenuitem * parent, + DbusmenuMenuitem * child, + guint pos, + DbusmenuServer * server); +static void menuitem_child_removed (DbusmenuMenuitem * parent, + DbusmenuMenuitem * child, + DbusmenuServer * server); +static void menuitem_signals_create (DbusmenuMenuitem * mi, + gpointer data); +static void menuitem_signals_remove (DbusmenuMenuitem * mi, + gpointer data); +static GQuark error_quark (void); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; -- cgit v1.2.3 From 9b7061a33a014f2b83d970698b31ff5e0e33e129 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 12:20:29 -0500 Subject: Moving the interface name into a define --- 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 d7ccaf8..aabad9a 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -52,7 +52,8 @@ static void _gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict static void layout_update_signal (DbusmenuServer * server); -#define DBUSMENU_VERSION_NUMBER 2 +#define DBUSMENU_VERSION_NUMBER 2 +#define DBUSMENU_INTERFACE "org.ayatana.dbusmenu" /* Privates, I'll show you mine... */ struct _DbusmenuServerPrivate @@ -264,10 +265,10 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) } if (dbusmenu_interface_info == NULL) { - dbusmenu_interface_info = g_dbus_node_info_lookup_interface(dbusmenu_node_info, "org.ayatana.dbusmenu"); + dbusmenu_interface_info = g_dbus_node_info_lookup_interface(dbusmenu_node_info, DBUSMENU_INTERFACE); if (dbusmenu_interface_info == NULL) { - g_error("Unable to find interface 'org.ayatana.dbusmenu'"); + g_error("Unable to find interface '" DBUSMENU_INTERFACE "'"); } } -- cgit v1.2.3 From 1f98fff4723354444fe41fe3492b4a1681fdef14 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 12:27:33 -0500 Subject: Fleshing out the property get function --- libdbusmenu-glib/server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index aabad9a..7a1b98e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -497,8 +497,14 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data) { + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(user_data); + + /* None of these should happen */ + g_return_val_if_fail(g_strcmp0(interface, DBUSMENU_INTERFACE) == 0, NULL); + g_return_val_if_fail(g_strcmp0(path, priv->dbusobject) == 0, NULL); + g_return_val_if_fail(g_strcmp0(property, "version") == 0, NULL); - return NULL; + return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); } /* Handle actually signalling in the idle loop. This way we collect all -- cgit v1.2.3 From 2cc94b5a4b7016d8bf01eec34b6ff7e771d8e682 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 13:42:38 -0500 Subject: Setting up a method table for the dbus interface --- libdbusmenu-glib/server.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7a1b98e..ddf242f 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -98,6 +98,21 @@ enum { LAST_ERROR }; +/* Method Table */ +typedef void (*MethodTableFunc) (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); + +typedef struct _method_table_t method_table_t; +struct _method_table_t { + const gchar * interned_name; + MethodTableFunc func; +}; + +enum { + METHOD_GET_LAYOUT = 0, + /* Counter, do not remove! */ + METHOD_COUNT +}; + /* Prototype */ static void dbusmenu_server_class_init (DbusmenuServerClass *class); static void dbusmenu_server_init (DbusmenuServer *self); @@ -155,6 +170,7 @@ static const GDBusInterfaceVTable dbusmenu_interface_table = { get_property: bus_get_prop, set_property: NULL /* No properties that can be set */ }; +static method_table_t dbusmenu_method_table[METHOD_COUNT]; G_DEFINE_TYPE (DbusmenuServer, dbusmenu_server, G_TYPE_OBJECT); @@ -272,6 +288,10 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) } } + /* Building our Method table :( */ + dbusmenu_method_table[METHOD_GET_LAYOUT].interned_name = g_intern_static_string("GetLayout"); + dbusmenu_method_table[METHOD_GET_LAYOUT].func = NULL; + return; } -- cgit v1.2.3 From e170f6516419cf403931916ac9f6a4b3a0b1997c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 13:43:09 -0500 Subject: Fleshing out the method call function to use the table --- libdbusmenu-glib/server.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index ddf242f..493bbdf 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -508,7 +508,27 @@ bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data) static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { + int i; + const gchar * interned_method = g_intern_string(method); + + for (i = 0; i < METHOD_COUNT; i++) { + if (dbusmenu_method_table[i].interned_name == interned_method) { + if (dbusmenu_method_table[i].func != NULL) { + return dbusmenu_method_table[i].func(DBUSMENU_SERVER(user_data), params, invocation); + } else { + /* If we have a null function we're responding but nothing else. */ + g_dbus_method_invocation_return_value(invocation, NULL); + return; + } + } + } + /* We're here because there's an error */ + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NOT_IMPLEMENTED, + "Unable to find method '%s'", + method); return; } -- cgit v1.2.3 From a7ec487bdcf1383fc5ccbd69af543b1f6f93fd1a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 13:54:49 -0500 Subject: Porting over GetLayout --- libdbusmenu-glib/server.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 493bbdf..cc0d0b3 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -39,7 +39,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "dbus-menu.xml.h" /* DBus Prototypes */ -static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error); @@ -161,6 +160,9 @@ static void menuitem_signals_create (DbusmenuMenuitem * mi, static void menuitem_signals_remove (DbusmenuMenuitem * mi, gpointer data); static GQuark error_quark (void); +static void bus_get_layout (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -290,7 +292,7 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) /* Building our Method table :( */ dbusmenu_method_table[METHOD_GET_LAYOUT].interned_name = g_intern_static_string("GetLayout"); - dbusmenu_method_table[METHOD_GET_LAYOUT].func = NULL; + dbusmenu_method_table[METHOD_GET_LAYOUT].func = bus_get_layout; return; } @@ -670,12 +672,15 @@ error_quark (void) } /* DBus interface */ -static gboolean -_dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error) +static void +bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - *revision = priv->layout_revision; + gint parent = 0; + g_variant_get(params, "(i)", &parent); + + guint revision = priv->layout_revision; GPtrArray * xmlarray = g_ptr_array_new(); if (parent == 0) { @@ -688,26 +693,31 @@ _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revis } else { DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent); if (item == NULL) { - if (error != NULL) { - g_set_error(error, - error_quark(), - INVALID_MENUITEM_ID, - "The ID supplied %d does not refer to a menu item we have", - parent); - } - return FALSE; + g_dbus_method_invocation_return_error(invocation, + error_quark(), + INVALID_MENUITEM_ID, + "The ID supplied %d does not refer to a menu item we have", + parent); + return; } dbusmenu_menuitem_buildxml(item, xmlarray); } g_ptr_array_add(xmlarray, NULL); /* build string */ - *layout = g_strjoinv("", (gchar **)xmlarray->pdata); + gchar * layout = g_strjoinv("", (gchar **)xmlarray->pdata); g_ptr_array_foreach(xmlarray, xmlarray_foreach_free, NULL); g_ptr_array_free(xmlarray, TRUE); - return TRUE; + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(us)", + revision, + layout)); + + g_free(layout); + + return; } static gboolean -- cgit v1.2.3 From 92942cc10074b24d7e0c13e76754ab149c27b923 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 16:00:38 -0500 Subject: Adding a helper function to get the menuitem properties as a variant --- libdbusmenu-glib/menuitem-private.h | 1 + libdbusmenu-glib/menuitem.c | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/libdbusmenu-glib/menuitem-private.h b/libdbusmenu-glib/menuitem-private.h index 3a0c026..2028464 100644 --- a/libdbusmenu-glib/menuitem-private.h +++ b/libdbusmenu-glib/menuitem-private.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS 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); G_END_DECLS diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 73b765b..5e700a5 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1220,6 +1220,50 @@ dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) return ret; } +/* Looks at each value in the hashtable and tries to convert it + into a variant and add it to our variant builder */ +static void +variant_helper (gpointer in_key, gpointer in_value, gpointer user_data) +{ + GValue vval = {0}; + g_value_init(&vval, G_TYPE_VARIANT); + + if (!g_value_transform((GValue *)in_value, &vval)) { + g_warning("Unable to convert property '%s' of type '%s'", (gchar *)in_key, G_VALUE_TYPE_NAME(in_value)); + return; + } + + g_variant_builder_add((GVariantBuilder *)user_data, "{sv}", in_key, g_value_get_variant(&vval)); + g_value_unset(&vval); + + return; +} + +/** + 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. +*/ +GVariant * +dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); + + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + + g_hash_table_foreach(priv->properties, variant_helper, builder); + + GVariant * final_variant = g_variant_builder_end(builder); + g_variant_builder_unref(builder); + return final_variant; +} + /** dbusmenu_menuitem_set_root: @mi: #DbusmenuMenuitem to set whether it's root -- cgit v1.2.3 From d11d10ce3d399be36d889d386a3a88a8487ca4fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 16:17:19 -0500 Subject: Implement the get_properties function --- libdbusmenu-glib/server.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index cc0d0b3..73aa3c2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -41,7 +41,6 @@ License version 3 and version 2.1 along with this program. If not, see /* DBus Prototypes */ static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); -static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); @@ -108,6 +107,7 @@ struct _method_table_t { enum { METHOD_GET_LAYOUT = 0, + METHOD_GET_GROUP_PROPERTIES, /* Counter, do not remove! */ METHOD_COUNT }; @@ -163,6 +163,9 @@ static GQuark error_quark (void); static void bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); +static void bus_get_group_properties (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -294,6 +297,9 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) dbusmenu_method_table[METHOD_GET_LAYOUT].interned_name = g_intern_static_string("GetLayout"); dbusmenu_method_table[METHOD_GET_LAYOUT].func = bus_get_layout; + dbusmenu_method_table[METHOD_GET_GROUP_PROPERTIES].interned_name = g_intern_static_string("GetGroupProperties"); + dbusmenu_method_table[METHOD_GET_GROUP_PROPERTIES].func = bus_get_group_properties; + return; } @@ -789,36 +795,29 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** prop /* Handles getting a bunch of properties from a variety of menu items to make one mega dbus message */ -static gboolean -_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, gchar ** properties, GPtrArray ** values, GError ** error) +static void +bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { - /* Build an initial pointer array */ - *values = g_ptr_array_new(); + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + GVariantIter * ids = NULL; + g_variant_get_child(params, 0, "ai", &ids); - /* Go through each ID to get that ID's properties */ - int idcnt; - for (idcnt = 0; idcnt < ids->len; idcnt++) { - GHashTable * idprops = NULL; - GError * error = NULL; - gint id = g_array_index(ids, int, idcnt); + GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("a(ia{sv})")); - /* Get the properties for this ID the old fashioned way. */ - if (!_dbusmenu_server_get_properties(server, id, properties, &idprops, &error)) { - g_warning("Error getting the properties from ID %d: %s", id, error->message); - g_error_free(error); - error = NULL; - continue; - } + GVariant * id; + while ((id = g_variant_iter_next_value(ids)) != NULL) { + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, g_variant_get_int32(id)); + if (mi == NULL) continue; - GValueArray * valarray = g_value_array_new(2); + g_variant_builder_add(builder, "ia{sv}", g_variant_get_int32(id), dbusmenu_menuitem_properties_variant(mi)); + } - _gvalue_array_append_int(valarray, id); - _gvalue_array_append_hashtable(valarray, idprops); + GVariant * ret = g_variant_builder_end(builder); + g_variant_builder_unref(builder); - g_ptr_array_add(*values, valarray); - } + g_dbus_method_invocation_return_value(invocation, ret); - return TRUE; + return; } /* Allocate a value on the stack for the int and append -- cgit v1.2.3 From 1487c6bc178268b128982b40fa8d4a315dc3c72a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 16:31:14 -0500 Subject: Converting over GetChildren --- libdbusmenu-glib/server.c | 83 ++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 52 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 73aa3c2..f3fb197 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -42,11 +42,7 @@ License version 3 and version 2.1 along with this program. If not, see static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); -static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); -/* DBus Helpers */ -static void _gvalue_array_append_int(GValueArray *array, gint i); -static void _gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict); static void layout_update_signal (DbusmenuServer * server); @@ -108,6 +104,7 @@ struct _method_table_t { enum { METHOD_GET_LAYOUT = 0, METHOD_GET_GROUP_PROPERTIES, + METHOD_GET_CHILDREN, /* Counter, do not remove! */ METHOD_COUNT }; @@ -166,6 +163,9 @@ static void bus_get_layout (DbusmenuServer * server, static void bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); +static void bus_get_children (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -300,6 +300,9 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) dbusmenu_method_table[METHOD_GET_GROUP_PROPERTIES].interned_name = g_intern_static_string("GetGroupProperties"); dbusmenu_method_table[METHOD_GET_GROUP_PROPERTIES].func = bus_get_group_properties; + dbusmenu_method_table[METHOD_GET_CHILDREN].interned_name = g_intern_static_string("GetChildren"); + dbusmenu_method_table[METHOD_GET_CHILDREN].func = bus_get_children; + return; } @@ -820,74 +823,50 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho return; } -/* Allocate a value on the stack for the int and append - it to the array. */ -static void -_gvalue_array_append_int(GValueArray *array, gint i) -{ - GValue value = {0}; - - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, i); - g_value_array_append(array, &value); - g_value_unset(&value); -} - -/* Allocate a value on the stack for the hashtable and append - it to the array. */ -static void -_gvalue_array_append_hashtable(GValueArray *array, GHashTable * dict) -{ - GValue value = {0}; - - g_value_init(&value, dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)); - g_value_set_boxed(&value, dict); - g_value_array_append(array, &value); - g_value_unset(&value); -} - +/* Turn a menuitem into an variant and attach it to the + VariantBuilder we passed in */ static void serialize_menuitem(gpointer data, gpointer user_data) { DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); - GPtrArray * output = (GPtrArray *)(user_data); + GVariantBuilder * builder = (GVariantBuilder *)(user_data); gint id = dbusmenu_menuitem_get_id(mi); - GHashTable * dict = dbusmenu_menuitem_properties_copy(mi); + GVariant * props = dbusmenu_menuitem_properties_variant(mi); - GValueArray * item = g_value_array_new(2); - _gvalue_array_append_int(item, id); - _gvalue_array_append_hashtable(item, dict); - - g_ptr_array_add(output, item); - - g_hash_table_unref(dict); + g_variant_builder_add(builder, "ia{sv}", id, props); return; } -static gboolean -_dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error) +/* Gets the children and their properties of the ID that is + passed into the function */ +static void +bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { - if (error != NULL) { - g_set_error(error, - error_quark(), - INVALID_MENUITEM_ID, - "The ID supplied %d does not refer to a menu item we have", - id); - } - return FALSE; + g_dbus_method_invocation_return_error(invocation, + error_quark(), + INVALID_MENUITEM_ID, + "The ID supplied %d does not refer to a menu item we have", + id); + return; } - *output = g_ptr_array_new(); + GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("a(ia{sv})")); + GList * children = dbusmenu_menuitem_get_children(mi); - g_list_foreach(children, serialize_menuitem, *output); + g_list_foreach(children, serialize_menuitem, builder); - return TRUE; + GVariant * ret = g_variant_builder_end(builder); + g_variant_builder_unref(builder); + + g_dbus_method_invocation_return_value(invocation, ret); + return; } /* Structure for holding the event data for the idle function -- cgit v1.2.3 From 966d397a36971552609e24bb8071fdb69c4c279a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Oct 2010 16:49:47 -0500 Subject: Coverting GetProperty --- libdbusmenu-glib/server.c | 49 ++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index f3fb197..e83015a 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -39,7 +39,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "dbus-menu.xml.h" /* DBus Prototypes */ -static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); @@ -105,6 +104,7 @@ enum { METHOD_GET_LAYOUT = 0, METHOD_GET_GROUP_PROPERTIES, METHOD_GET_CHILDREN, + METHOD_GET_PROPERTY, /* Counter, do not remove! */ METHOD_COUNT }; @@ -166,6 +166,9 @@ static void bus_get_group_properties (DbusmenuServer * server, static void bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); +static void bus_get_property (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -303,6 +306,9 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) dbusmenu_method_table[METHOD_GET_CHILDREN].interned_name = g_intern_static_string("GetChildren"); dbusmenu_method_table[METHOD_GET_CHILDREN].func = bus_get_children; + dbusmenu_method_table[METHOD_GET_PROPERTY].interned_name = g_intern_static_string("GetProperty"); + dbusmenu_method_table[METHOD_GET_PROPERTY].func = bus_get_property; + return; } @@ -729,49 +735,48 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio return; } -static gboolean -_dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error) +/* Get a single property off of a single menuitem */ +static void +bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); + const gchar * property = g_variant_get_string(g_variant_get_child_value(params, 1), NULL); + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { - if (error != NULL) { - g_set_error(error, + g_dbus_method_invocation_return_error(invocation, error_quark(), INVALID_MENUITEM_ID, "The ID supplied %d does not refer to a menu item we have", id); - } - return FALSE; + return; } - const gchar * prop = dbusmenu_menuitem_property_get(mi, property); + const GValue * prop = dbusmenu_menuitem_property_get_value(mi, property); if (prop == NULL) { - if (error != NULL) { - g_set_error(error, + g_dbus_method_invocation_return_error(invocation, error_quark(), INVALID_PROPERTY_NAME, "The property '%s' does not exist on menuitem with ID of %d", property, id); - } - return FALSE; + return; } - if (value == NULL) { - if (error != NULL) { - g_set_error(error, - error_quark(), - UNKNOWN_DBUS_ERROR, - "Uhm, yeah. We didn't get anywhere to put the value, that's really weird. Seems impossible really."); - } - return FALSE; + GValue vval = {0}; + g_value_init(&vval, G_TYPE_VARIANT); + + if (!g_value_transform(prop, &vval)) { + g_warning("Unable to convert property '%s' value from type '%s' to variant", property, G_VALUE_TYPE_NAME(prop)); } - *value = g_strdup(prop); + g_dbus_method_invocation_return_value(invocation, g_value_get_variant(&vval)); + g_value_unset(&vval); - return TRUE; + return; } static gboolean -- cgit v1.2.3 From abfd276f1d5aa79ebc30d9dccbe4e4d58315c499 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Oct 2010 11:47:09 -0500 Subject: Converting GetProperties --- libdbusmenu-glib/server.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index e83015a..a2d34d5 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -39,7 +39,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "dbus-menu.xml.h" /* DBus Prototypes */ -static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); @@ -105,6 +104,7 @@ enum { METHOD_GET_GROUP_PROPERTIES, METHOD_GET_CHILDREN, METHOD_GET_PROPERTY, + METHOD_GET_PROPERTIES, /* Counter, do not remove! */ METHOD_COUNT }; @@ -169,6 +169,9 @@ static void bus_get_children (DbusmenuServer * server, static void bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); +static void bus_get_properties (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -309,6 +312,9 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) dbusmenu_method_table[METHOD_GET_PROPERTY].interned_name = g_intern_static_string("GetProperty"); dbusmenu_method_table[METHOD_GET_PROPERTY].func = bus_get_property; + dbusmenu_method_table[METHOD_GET_PROPERTIES].interned_name = g_intern_static_string("GetProperties"); + dbusmenu_method_table[METHOD_GET_PROPERTIES].func = bus_get_properties; + return; } @@ -779,26 +785,30 @@ bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat return; } -static gboolean -_dbusmenu_server_get_properties (DbusmenuServer * server, gint id, gchar ** properties, GHashTable ** dict, GError ** error) +/* Get some properties off of a single menuitem */ +static void +bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { - if (error != NULL) { - g_set_error(error, + g_dbus_method_invocation_return_error(invocation, error_quark(), INVALID_MENUITEM_ID, "The ID supplied %d does not refer to a menu item we have", id); - } - return FALSE; + return; } - *dict = dbusmenu_menuitem_properties_copy(mi); + GVariant * dict = dbusmenu_menuitem_properties_variant(mi); - return TRUE; + g_dbus_method_invocation_return_value(invocation, dict); + + return; } /* Handles getting a bunch of properties from a variety of menu items -- cgit v1.2.3 From 41df5ff0de7c2b9391acf93b58a5f1c803878a05 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Oct 2010 13:41:58 -0500 Subject: Porting over the event function --- libdbusmenu-glib/server.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index a2d34d5..2fdc1ef 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -39,7 +39,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "dbus-menu.xml.h" /* DBus Prototypes */ -static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); static void layout_update_signal (DbusmenuServer * server); @@ -105,6 +104,7 @@ enum { METHOD_GET_CHILDREN, METHOD_GET_PROPERTY, METHOD_GET_PROPERTIES, + METHOD_EVENT, /* Counter, do not remove! */ METHOD_COUNT }; @@ -172,6 +172,9 @@ static void bus_get_property (DbusmenuServer * server, static void bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); +static void bus_event (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -315,6 +318,9 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) dbusmenu_method_table[METHOD_GET_PROPERTIES].interned_name = g_intern_static_string("GetProperties"); dbusmenu_method_table[METHOD_GET_PROPERTIES].func = bus_get_properties; + dbusmenu_method_table[METHOD_EVENT].interned_name = g_intern_static_string("Event"); + dbusmenu_method_table[METHOD_EVENT].func = bus_event; + return; } @@ -910,34 +916,37 @@ event_local_handler (gpointer user_data) return FALSE; } -/* Handles the even coming off of DBus */ -static gboolean -_dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error) +/* Handles the events coming off of DBus */ +static void +bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { - if (error != NULL) { - g_set_error(error, - error_quark(), - INVALID_MENUITEM_ID, - "The ID supplied %d does not refer to a menu item we have", - id); - } - return FALSE; + g_dbus_method_invocation_return_error(invocation, + error_quark(), + INVALID_MENUITEM_ID, + "The ID supplied %d does not refer to a menu item we have", + id); + return; } idle_event_t * event_data = g_new0(idle_event_t, 1); event_data->mi = mi; g_object_ref(event_data->mi); - event_data->eventid = g_strdup(eventid); - event_data->timestamp = timestamp; - g_value_init(&(event_data->data), G_VALUE_TYPE(data)); - g_value_copy(data, &(event_data->data)); + event_data->eventid = g_strdup(g_variant_get_string(g_variant_get_child_value(params, 1), NULL)); + event_data->timestamp = g_variant_get_uint32(g_variant_get_child_value(params, 3)); + + /* TODO: Need to figure out converting a variant to a value */ + g_value_init(&(event_data->data), G_TYPE_INT); + g_value_set_int(&(event_data->data), 0); g_timeout_add(0, event_local_handler, event_data); - return TRUE; + + g_dbus_method_invocation_return_value(invocation, NULL); + return; } /* Recieve the About To Show function. Pass it to our menu item. */ -- cgit v1.2.3 From 5c07a374c78a73fee4030a61c74ab3a99fc8bcc5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Oct 2010 13:48:05 -0500 Subject: Porting over AboutToShow --- libdbusmenu-glib/server.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 2fdc1ef..42463a9 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -38,9 +38,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "dbus-menu.xml.h" -/* DBus Prototypes */ -static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); - static void layout_update_signal (DbusmenuServer * server); #define DBUSMENU_VERSION_NUMBER 2 @@ -105,6 +102,7 @@ enum { METHOD_GET_PROPERTY, METHOD_GET_PROPERTIES, METHOD_EVENT, + METHOD_ABOUT_TO_SHOW, /* Counter, do not remove! */ METHOD_COUNT }; @@ -175,6 +173,9 @@ static void bus_get_properties (DbusmenuServer * server, static void bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation); +static void bus_about_to_show (DbusmenuServer * server, + GVariant * params, + GDBusMethodInvocation * invocation); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -321,6 +322,9 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) dbusmenu_method_table[METHOD_EVENT].interned_name = g_intern_static_string("Event"); dbusmenu_method_table[METHOD_EVENT].func = bus_event; + dbusmenu_method_table[METHOD_ABOUT_TO_SHOW].interned_name = g_intern_static_string("AboutToShow"); + dbusmenu_method_table[METHOD_ABOUT_TO_SHOW].func = bus_about_to_show; + return; } @@ -950,26 +954,26 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i } /* Recieve the About To Show function. Pass it to our menu item. */ -static gboolean -_dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error) +static void +bus_about_to_show (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { - if (error != NULL) { - g_set_error(error, - error_quark(), - INVALID_MENUITEM_ID, - "The ID supplied %d does not refer to a menu item we have", - id); - } - return FALSE; + g_dbus_method_invocation_return_error(invocation, + error_quark(), + INVALID_MENUITEM_ID, + "The ID supplied %d does not refer to a menu item we have", + id); + return; } /* GTK+ does not support about-to-show concept for now */ - *need_update = FALSE; - return TRUE; + g_dbus_method_invocation_return_value(invocation, + g_variant_new_boolean(FALSE)); + return; } /* Public Interface */ -- cgit v1.2.3 From 37596991960990c127336ccc8527832a35d595ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Oct 2010 16:10:55 -0500 Subject: Making signals emit on dbus as well as locally. --- libdbusmenu-glib/server.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 42463a9..652b2a8 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -589,6 +589,15 @@ layout_update_idle (gpointer user_data) DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + if (priv->dbusobject != NULL && priv->bus != NULL) { + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + DBUSMENU_INTERFACE, + "LayoutUpdated", + g_variant_new("(ui)", priv->layout_revision, 0), + NULL); + } priv->layout_idle = 0; @@ -612,7 +621,29 @@ layout_update_signal (DbusmenuServer * server) static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server) { + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, value, TRUE); + + if (priv->dbusobject != NULL && priv->bus != NULL) { + GValue variantval = {0}; + g_value_init(&variantval, G_TYPE_VARIANT); + + if (!g_value_transform(value, &variantval)) { + g_warning("Unable to convert property '%s' of type %s to a variant", property, G_VALUE_TYPE_NAME(value)); + } + GVariant * variant = g_value_get_variant(&variantval); + + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + DBUSMENU_INTERFACE, + "ItemPropertyUpdated", + g_variant_new("(isv)", dbusmenu_menuitem_get_id(mi), property, variant), + NULL); + + g_value_unset(&variantval); + } return; } @@ -663,7 +694,20 @@ menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint static void menuitem_shown (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server) { + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + g_signal_emit(G_OBJECT(server), signals[ITEM_ACTIVATION], 0, dbusmenu_menuitem_get_id(mi), timestamp, TRUE); + + if (priv->dbusobject != NULL && priv->bus != NULL) { + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + DBUSMENU_INTERFACE, + "ItemPropertyUpdated", + g_variant_new("(iu)", dbusmenu_menuitem_get_id(mi), timestamp), + NULL); + } + return; } -- 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(-) 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(-) 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(+) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 c083bd5c6cf41d4e618f7e646a8dc60a59f07063 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 08:26:35 -0600 Subject: Adding in the deprecation flags even if we can't really use them yet. --- Makefile.am | 5 +++++ configure.ac | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Makefile.am b/Makefile.am index b5fff3e..c2c0980 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,11 @@ SUBDIRS = \ DISTCHECK_CONFIGURE_FLAGS = --enable-introspection --enable-gtk-doc +## Can't disable deprecations yet, working on that, but +## we want to get there. +# +# DISTCHECK_CONFIGURE_FLAGS = --enable-introspection --enable-gtk-doc --disable-deprecations + dist-hook: @if test -d "$(top_srcdir)/.bzr"; \ then \ diff --git a/configure.ac b/configure.ac index 2bd8042..71358a7 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,15 @@ AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) +AC_ARG_ENABLE([deprecations], + [AS_HELP_STRING([--enable-deprecations], + [allow deprecated API usage @<:@default=yes@:>@])], + [], + [enable_deprecations=yes]) +AS_IF([test "x$enable_deprecations" = xno], + [CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES"] +) + ########################### # GTK Doc ########################### -- cgit v1.2.3 From b3768eaec11202758801a3dd0f94a2ab315f4a0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 11:23:00 -0600 Subject: 0.3.90 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 71358a7..4a7bc86 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.16, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.90, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.16, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.90, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From e4b55fd76e9506e3ecfe98b60518849c8b1ac87d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 13:20:29 -0600 Subject: Switching the headers and private variables --- libdbusmenu-glib/client.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 6a51764..2aa938c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.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 @@ -39,7 +39,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem.h" #include "menuitem-private.h" #include "client-menuitem.h" -#include "dbusmenu-client.h" #include "server-marshal.h" #include "client-marshal.h" @@ -69,15 +68,15 @@ struct _DbusmenuClientPrivate gchar * dbus_object; gchar * dbus_name; - DBusGConnection * session_bus; - DBusGProxy * menuproxy; - DBusGProxy * propproxy; - DBusGProxyCall * layoutcall; + GDBusConnection * session_bus; + GDBusProxy * menuproxy; + GDBusProxy * propproxy; + GCancellable * layoutcall; gint current_revision; gint my_revision; - DBusGProxy * dbusproxy; + GDBusProxy * dbusproxy; GHashTable * type_handlers; -- cgit v1.2.3 From 6d36d55acf43696ba371d1af757e0662d89918d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 13:20:48 -0600 Subject: Changing the flush --- libdbusmenu-glib/client.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 2aa938c..8ede85d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -562,6 +562,21 @@ get_properties_idle (gpointer user_data) return FALSE; } +/* Report and error if we're unable to flush the connection, likely + to be a cause of some other issues. */ +static void +connection_flush_cb (GObject * object, GAsyncResult * result, gpointer user_data) +{ + GError * error = NULL; + + if (!g_dbus_connection_flush_finish(G_DBUS_CONNECTION(object), result, &error)) { + g_warning("Unable to flush DBus connection: %s", error->message); + g_error_free(error); + } + + return; +} + /* Forces a call out to start getting properties with the menu items that we have queued up already. */ static void @@ -578,7 +593,11 @@ get_properties_flush (DbusmenuClient * client) get_properties_idle(client); - dbus_g_connection_flush(priv->session_bus); + /* I'm not sure this flush is necissary with GDBus running the + DBus connection in another thread. But, I don't think that + it'll hurt anything either, so I'm leaving it in. */ + g_return_if_fail(priv->session_bus != NULL); + g_dbus_connection_flush(priv->session_bus, NULL, connection_flush_cb, NULL); return; } -- cgit v1.2.3 From 51c9cc0eb87f0a379c891a23162e232b1f597bd6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 13:57:22 -0600 Subject: Changing the flow for creating the async session bus. It is now cancellable. --- libdbusmenu-glib/client.c | 65 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8ede85d..f662f74 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -69,6 +69,8 @@ struct _DbusmenuClientPrivate gchar * dbus_name; GDBusConnection * session_bus; + GCancelable * session_bus_cancel; + GDBusProxy * menuproxy; GDBusProxy * propproxy; GCancellable * layoutcall; @@ -261,6 +263,8 @@ dbusmenu_client_init (DbusmenuClient *self) priv->dbus_name = NULL; priv->session_bus = NULL; + priv->session_bus_cancel = NULL; + priv->menuproxy = NULL; priv->propproxy = NULL; priv->layoutcall = NULL; @@ -339,7 +343,16 @@ dbusmenu_client_dispose (GObject *object) g_object_unref(G_OBJECT(priv->dbusproxy)); priv->dbusproxy = NULL; } - priv->session_bus = NULL; + + if (priv->session_bus_cancel != NULL) { + g_cancellable_cancel(priv->session_bus_cancel); + g_object_unref(priv->session_bus_cancel); + priv->session_bus_cancel = NULL; + } + if (priv->session_bus != NULL) { + g_object_unref(priv->session_bus); + priv->session_bus = NULL; + } if (priv->root != NULL) { g_object_unref(G_OBJECT(priv->root)); @@ -848,6 +861,37 @@ proxy_destroyed (GObject * gobj_proxy, gpointer userdata) return; } +/* Respond to us getting the session bus (hopefully) or handle + the error if not */ +void +session_bus_cb (GObject * object, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + + /* NOTE: We're not using any other variables before checking + the result because they could be destroyed and thus invalid */ + GDBusConnection * bus = g_bus_get_finish(res, &error); + if (error != NULL) { + g_warning("Unable to get session bus: %s", error->message); + g_error_free(error); + return; + } + + /* If this wasn't cancelled, we should be good */ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + priv->session_bus = bus; + + if (priv->session_bus_cancel != NULL) { + g_object_unref(priv->session_bus_cancel); + priv->session_bus_cancel = NULL; + } + + /* Retry to build the proxies now that we have a bus */ + build_proxies(DBUSMENU_CLIENT(user_data)); + + return; +} + /* When we have a name and an object, build the two proxies and get the first version of the layout */ static void @@ -859,11 +903,20 @@ build_proxies (DbusmenuClient * client) g_return_if_fail(priv->dbus_object != NULL); g_return_if_fail(priv->dbus_name != NULL); - priv->session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - if (error != NULL) { - g_error("Unable to get session bus: %s", error->message); - g_error_free(error); - build_dbus_proxy(client); + if (priv->session_bus == NULL) { + /* We don't have the session bus yet, that's okay, but + we need to handle that. */ + + /* If we're already running we don't need to look again. */ + if (priv->session_bus_cancel == NULL) { + priv->session_bus_cancel = g_cancellable_new(); + + /* Async get the session bus */ + g_bus_get(G_BUS_SESSION, priv->session_bus_cancel, session_bus_cb, client); + } + + /* This function exists, it'll be called again when we get + the session bus so this condition will be ignored */ return; } -- cgit v1.2.3 From 030de7ba74d6560ef61b31913c244a4be1d5116b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 14:26:31 -0600 Subject: Removing the proxy for the property interface on the object as GDBus puts that in the standard proxy now --- libdbusmenu-glib/client.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f662f74..f672696 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -69,10 +69,9 @@ struct _DbusmenuClientPrivate gchar * dbus_name; GDBusConnection * session_bus; - GCancelable * session_bus_cancel; + GCancellable * session_bus_cancel; GDBusProxy * menuproxy; - GDBusProxy * propproxy; GCancellable * layoutcall; gint current_revision; @@ -266,7 +265,6 @@ dbusmenu_client_init (DbusmenuClient *self) priv->session_bus_cancel = NULL; priv->menuproxy = NULL; - priv->propproxy = NULL; priv->layoutcall = NULL; priv->current_revision = 0; @@ -335,10 +333,6 @@ dbusmenu_client_dispose (GObject *object) g_object_unref(G_OBJECT(priv->menuproxy)); priv->menuproxy = NULL; } - if (priv->propproxy != NULL) { - g_object_unref(G_OBJECT(priv->propproxy)); - priv->propproxy = NULL; - } if (priv->dbusproxy != NULL) { g_object_unref(G_OBJECT(priv->dbusproxy)); priv->dbusproxy = NULL; @@ -920,20 +914,6 @@ build_proxies (DbusmenuClient * client) return; } - priv->propproxy = dbus_g_proxy_new_for_name_owner(priv->session_bus, - priv->dbus_name, - priv->dbus_object, - DBUS_INTERFACE_PROPERTIES, - &error); - if (error != NULL) { - g_warning("Unable to get property proxy for %s on %s: %s", priv->dbus_name, priv->dbus_object, error->message); - g_error_free(error); - build_dbus_proxy(client); - return; - } - g_object_add_weak_pointer(G_OBJECT(priv->propproxy), (gpointer *)&priv->propproxy); - g_signal_connect(G_OBJECT(priv->propproxy), "destroy", G_CALLBACK(proxy_destroyed), client); - priv->menuproxy = dbus_g_proxy_new_for_name_owner(priv->session_bus, priv->dbus_name, priv->dbus_object, @@ -1551,10 +1531,6 @@ dbusmenu_client_get_root (DbusmenuClient * client) DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - if (priv->propproxy == NULL) { - return NULL; - } - #ifdef MASSIVEDEBUGGING g_debug("Client get root: %X", (guint)priv->root); #endif -- cgit v1.2.3 From efd88243d8e4e8911f08e86744ef13387ac4ae6a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 14:30:46 -0600 Subject: Including the interface description and building the objects from it once --- libdbusmenu-glib/client.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f672696..30dce89 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -41,6 +41,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client-menuitem.h" #include "server-marshal.h" #include "client-marshal.h" +#include "dbus-menu.xml.h" /* Properties */ enum { @@ -136,6 +137,10 @@ static void get_properties_globber (DbusmenuClient * client, gint id, const gcha static GQuark error_domain (void); static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); +/* Globals */ +static GDBusNodeInfo * dbusmenu_node_info = NULL; +static GDBusInterfaceInfo * dbusmenu_interface_info = NULL; + /* Build a type */ G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT); @@ -246,6 +251,24 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + if (dbusmenu_node_info == NULL) { + GError * error = NULL; + + dbusmenu_node_info = g_dbus_node_info_new_for_xml(dbus_menu_xml, &error); + if (error != NULL) { + g_error("Unable to parse DBusmenu Interface description: %s", error->message); + g_error_free(error); + } + } + + if (dbusmenu_interface_info == NULL) { + dbusmenu_interface_info = g_dbus_node_info_lookup_interface(dbusmenu_node_info, DBUSMENU_INTERFACE); + + if (dbusmenu_interface_info == NULL) { + g_error("Unable to find interface '" DBUSMENU_INTERFACE "'"); + } + } + return; } -- cgit v1.2.3 From 08053906621fc5240e7bb7a549a09b0acf930809 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 15:04:45 -0600 Subject: Adding a cancellable for the menu proxy in the private object --- libdbusmenu-glib/client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 30dce89..17f52b4 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -73,6 +73,8 @@ struct _DbusmenuClientPrivate GCancellable * session_bus_cancel; GDBusProxy * menuproxy; + GCancellable * menuproxy_cancel; + GCancellable * layoutcall; gint current_revision; @@ -288,6 +290,8 @@ dbusmenu_client_init (DbusmenuClient *self) priv->session_bus_cancel = NULL; priv->menuproxy = NULL; + priv->menuproxy_cancel = NULL; + priv->layoutcall = NULL; priv->current_revision = 0; @@ -352,15 +356,26 @@ dbusmenu_client_dispose (GObject *object) dbus_g_proxy_cancel_call(priv->menuproxy, priv->layoutcall); priv->layoutcall = NULL; } + + /* Bring down the menu proxy, ensure we're not + looking for one at the same time. */ + if (priv->menuproxy_cancel != NULL) { + g_cancellable_cancel(priv->menuproxy_cancel); + g_object_unref(priv->menuproxy_cancel); + priv->menuproxy_cancel = NULL; + } if (priv->menuproxy != NULL) { g_object_unref(G_OBJECT(priv->menuproxy)); priv->menuproxy = NULL; } + if (priv->dbusproxy != NULL) { g_object_unref(G_OBJECT(priv->dbusproxy)); priv->dbusproxy = NULL; } + /* Bring down the session bus, ensure we're not + looking for one at the same time. */ if (priv->session_bus_cancel != NULL) { g_cancellable_cancel(priv->session_bus_cancel); g_object_unref(priv->session_bus_cancel); -- cgit v1.2.3 From 88cc4c919ee836870a326f22eb0b773f8395aeec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 15:05:22 -0600 Subject: Reshuffling the creation of the menu proxy to be async with a callback. --- libdbusmenu-glib/client.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 17f52b4..42144ae 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -138,6 +138,7 @@ static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * propert static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data); static GQuark error_domain (void); static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); +static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -952,17 +953,33 @@ build_proxies (DbusmenuClient * client) return; } - priv->menuproxy = dbus_g_proxy_new_for_name_owner(priv->session_bus, - priv->dbus_name, - priv->dbus_object, - "org.ayatana.dbusmenu", - &error); - if (error != NULL) { - g_warning("Unable to get dbusmenu proxy for %s on %s: %s", priv->dbus_name, priv->dbus_object, error->message); - g_error_free(error); - build_dbus_proxy(client); - return; + /* Build us a menu proxy */ + if (priv->menuproxy == NULL) { + + /* Check to see if we're already building one */ + if (priv->menuproxy_cancel == NULL) { + priv->menuproxy_cancel = g_cancellable_new(); + + g_dbus_proxy_new(priv->session_bus, + G_DBUS_PROXY_FLAGS_NONE, + dbusmenu_interface_info, + priv->dbus_name, + priv->dbus_object, + DBUSMENU_INTERFACE, + priv->menuproxy_cancel, + menuproxy_build_cb, + client); + } } + + return; +} + +/* Callback when we know if the menu proxy can be created or + not and do something with it! */ +static void +menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) +{ g_object_add_weak_pointer(G_OBJECT(priv->menuproxy), (gpointer *)&priv->menuproxy); g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", G_CALLBACK(proxy_destroyed), client); -- cgit v1.2.3 From 567ff35378371596e1304cad97f634969e954cc1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Nov 2010 16:56:07 -0600 Subject: Adjusting how the menu proxy gets built up and signals connected --- libdbusmenu-glib/client.c | 83 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 42144ae..d2bfc8f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -139,6 +139,8 @@ static void get_properties_globber (DbusmenuClient * client, gint id, const gcha static GQuark error_domain (void); static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); +static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data); +static void menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -980,8 +982,25 @@ build_proxies (DbusmenuClient * client) static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) { - g_object_add_weak_pointer(G_OBJECT(priv->menuproxy), (gpointer *)&priv->menuproxy); - g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", G_CALLBACK(proxy_destroyed), client); + GError * error = NULL; + + /* NOTE: We're not using any other variables before checking + the result because they could be destroyed and thus invalid */ + GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error); + if (error != NULL) { + g_warning("Unable to get menu proxy: %s", error->message); + g_error_free(error); + return; + } + + /* If this wasn't cancelled, we should be good */ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); + priv->menuproxy = proxy; + + if (priv->menuproxy_cancel != NULL) { + g_object_unref(priv->menuproxy_cancel); + priv->menuproxy_cancel = NULL; + } /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != NULL) { @@ -989,22 +1008,58 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) priv->dbusproxy = NULL; } - dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_INT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdated", G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdated", G_CALLBACK(layout_update), client, NULL); + g_signal_connect(priv->menuproxy, "g-signal", G_CALLBACK(menuproxy_signal_cb), client); + g_signal_connect(priv->menuproxy, "notify::g-name-owner", G_CALLBACK(menuproxy_name_changed_cb), client); - dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_STRING_POINTER, G_TYPE_NONE, G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); - dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); + update_layout(client); - dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->menuproxy, "ItemUpdated", G_CALLBACK(id_update), client, NULL); + return; +} + +/* Handle the case where we change owners */ +static void +menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data) +{ + GDBusProxy * proxy = G_DBUS_PROXY(object); - dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_UINT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); - dbus_g_proxy_add_signal(priv->menuproxy, "ItemActivationRequested", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->menuproxy, "ItemActivationRequested", G_CALLBACK(item_activated), client, NULL); + gchar * owner = g_dbus_proxy_get_name_owner(proxy); - update_layout(client); + if (owner == NULL) { + /* Oh, no! We lost our owner! */ + proxy_destroyed(G_OBJECT(proxy), user_data); + } else { + g_free(owner); + } + + return; +} + +/* Handle the signals out of the proxy */ +static void +menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data) +{ + g_return_if_fail(DBUSMENU_IS_CLIENT(user_data)); + DbusmenuClient * client = DBUSMENU_CLIENT(user_data); + + 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, "ItemPropertyUpdated") == 0) { + gint id; gchar * property; GVariant * value; + g_variant_get(params, "(isv)", &id, &property, &value); + id_prop_update(proxy, id, property, value, client); + } else if (g_strcmp0(signal, "ItemUpdated") == 0) { + gint id; + g_variant_get(params, "(i)", &id); + id_update(proxy, id, client); + } else if (g_strcmp0(signal, "ItemActivationRequested") == 0) { + gint id; guint timestamp; + g_variant_get(params, "(iu)", &id, ×tamp); + item_activated(proxy, id, timestamp, client); + } else { + g_warning("Received signal '%s' from menu proxy that is unknown", signal); + } return; } -- cgit v1.2.3 From a71b34a9103a9a383cff69bfe7b44319f7cb114c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 08:45:02 -0600 Subject: Changing the function prototype for properties callback to be local, and make more sense. --- libdbusmenu-glib/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d2bfc8f..6f31354 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -60,6 +60,8 @@ enum { LAST_SIGNAL }; +typedef void (*properties_func) (DbusmenuClient * client, GVariant * properties); + static guint signals[LAST_SIGNAL] = { 0 }; struct _DbusmenuClientPrivate @@ -100,7 +102,7 @@ struct _newItemPropData typedef struct _properties_listener_t properties_listener_t; struct _properties_listener_t { gint id; - org_ayatana_dbusmenu_get_properties_reply callback; + properties_func callback; gpointer user_data; gboolean replied; }; @@ -135,7 +137,7 @@ static gint parse_layout (DbusmenuClient * client, const gchar * layout); static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); -static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data); +static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, properties_func callback, gpointer user_data); static GQuark error_domain (void); static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -653,7 +655,7 @@ get_properties_flush (DbusmenuClient * client) /* A function to group all the get_properties commands to make them more efficient over dbus. */ static void -get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data) +get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, properties_func callback, gpointer user_data) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); if (find_listener(priv->delayed_property_listeners, 0, id) != NULL) { -- cgit v1.2.3 From fb510a52796e9ff1a5bfc52fad72e94c22efc6e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 08:47:36 -0600 Subject: Blanket replace of DBusGProxy with GDBusProxy --- libdbusmenu-glib/client.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 6f31354..92991b3 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -127,19 +127,19 @@ static void dbusmenu_client_finalize (GObject *object); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); /* Private Funcs */ -static void layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client); -static void id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client); -static void id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client); +static void layout_update (GDBusProxy * proxy, guint revision, gint parent, DbusmenuClient * client); +static void id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GValue * 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, DBusGProxy * proxy); +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 void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); +static void update_layout_cb (GDBusProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); static void update_layout (DbusmenuClient * client); -static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); +static void menuitem_get_properties_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data); static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, properties_func callback, gpointer user_data); static GQuark error_domain (void); -static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); +static void item_activated (GDBusProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data); static void menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data); @@ -494,7 +494,7 @@ find_listener (GArray * listeners, guint index, gint id) /* Call back from getting the group properties, now we need to unwind and call the various functions. */ static void -get_properties_callback (DBusGProxy *proxy, GPtrArray *OUT_properties, GError *error, gpointer userdata) +get_properties_callback (GDBusProxy *proxy, GPtrArray *OUT_properties, GError *error, gpointer userdata) { GArray * listeners = (GArray *)userdata; int i; @@ -701,7 +701,7 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert /* Called when a server item wants to activate the menu */ static void -item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client) +item_activated (GDBusProxy * proxy, gint id, guint timestamp, DbusmenuClient * client) { g_return_if_fail(DBUSMENU_IS_CLIENT(client)); @@ -725,7 +725,7 @@ item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * c /* Annoying little wrapper to make the right function update */ static void -layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client) +layout_update (GDBusProxy * proxy, guint revision, gint parent, DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); priv->current_revision = revision; @@ -738,7 +738,7 @@ layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * /* Signal from the server that a property has changed on one of our menuitems */ static void -id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client) +id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client) { #ifdef MASSIVEDEBUGGING GValue valstr = {0}; @@ -768,7 +768,7 @@ id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, D /* Oh, lots of updates now. That silly server, they want to change all kinds of stuff! */ static void -id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client) +id_update (GDBusProxy * proxy, gint id, DbusmenuClient * client) { #ifdef MASSIVEDEBUGGING g_debug("Client side ID update: %d", id); @@ -788,7 +788,7 @@ id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client) /* Watches to see if our DBus savior comes onto the bus */ static void -dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, DbusmenuClient * client) +dbus_owner_change (GDBusProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); /* g_debug("Owner change: %s %s %s", name, prev, new); */ @@ -815,7 +815,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c it does, then we should build the proxies here. Race condition check. */ static void -name_owner_check (DBusGProxy *proxy, gboolean has_owner, GError *error, gpointer userdata) +name_owner_check (GDBusProxy *proxy, gboolean has_owner, GError *error, gpointer userdata) { if (error != NULL) { return; @@ -1115,7 +1115,7 @@ get_properties_helper (gpointer key, gpointer value, gpointer data) This isn't the most efficient way. We can optimize this by somehow removing the foreach. But that is for later. */ static void -menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) +menuitem_get_properties_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(data)); if (error != NULL) { @@ -1133,7 +1133,7 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError is getting recycled with the update, but we think might have prop changes. */ static void -menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) +menuitem_get_properties_replace_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(data)); gboolean have_error = FALSE; @@ -1164,7 +1164,7 @@ menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, /* This is a different get properites call back that also sends new signals. It basically is a small wrapper around the original. */ static void -menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) +menuitem_get_properties_new_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data) { g_return_if_fail(data != NULL); newItemPropData * propdata = (newItemPropData *)data; @@ -1216,7 +1216,7 @@ menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GEr /* Respond to the call function to make sure that the other side got it, or print a warning. */ static void -menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) +menuitem_call_cb (GDBusProxy * proxy, GError * error, gpointer userdata) { event_data_t * edata = (event_data_t *)userdata; @@ -1285,7 +1285,7 @@ struct _about_to_show_t { /* Reports errors and responds to update request that were a result of sending the about to show signal. */ static void -about_to_show_cb (DBusGProxy * proxy, gboolean need_update, GError * error, gpointer userdata) +about_to_show_cb (GDBusProxy * proxy, gboolean need_update, GError * error, gpointer userdata) { about_to_show_t * data = (about_to_show_t *)userdata; @@ -1369,7 +1369,7 @@ 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, DBusGProxy * proxy) +parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, GDBusProxy * proxy) { /* First verify and figure out what we've got */ gint id = parse_node_get_id(node); @@ -1540,7 +1540,7 @@ parse_layout (DbusmenuClient * client, const gchar * layout) /* When the layout property returns, here's where we take care of that. */ static void -update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * error, void * data) +update_layout_cb (GDBusProxy * proxy, guint rev, gchar * xml, GError * error, void * data) { DbusmenuClient * client = DBUSMENU_CLIENT(data); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); -- cgit v1.2.3 From 5a5e31fd65810bd106f01833c5b66545d936e831 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 08:49:20 -0600 Subject: Adding in the dbusmenu interface --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 92991b3..e24a182 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -118,6 +118,7 @@ struct _event_data_t { #define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) +#define DBUSMENU_INTERFACE "org.ayatana.dbusmenu" /* GObject Stuff */ static void dbusmenu_client_class_init (DbusmenuClientClass *klass); -- cgit v1.2.3 From dbb933c7da1d7ec7d3a40b7f0aead90aafe87911 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 08:54:03 -0600 Subject: Changing the prototype for one call to the callback, need a different approach --- libdbusmenu-glib/client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index e24a182..b80999e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -60,7 +60,7 @@ enum { LAST_SIGNAL }; -typedef void (*properties_func) (DbusmenuClient * client, GVariant * properties); +typedef void (*properties_func) (DbusmenuClient * client, GVariant * properties, GError * error); static guint signals[LAST_SIGNAL] = { 0 }; @@ -318,6 +318,7 @@ dbusmenu_client_init (DbusmenuClient *self) static void dbusmenu_client_dispose (GObject *object) { + DbusmenuClient * client = DBUSMENU_CLIENT(object); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(object); if (priv->delayed_idle != 0) { @@ -347,7 +348,7 @@ dbusmenu_client_dispose (GObject *object) if (localerror == NULL) { g_set_error_literal(&localerror, error_domain(), 0, "DbusmenuClient Shutdown"); } - listener->callback(priv->menuproxy, NULL, localerror, listener->user_data); + listener->callback(client, NULL, localerror); } } if (localerror != NULL) { -- cgit v1.2.3 From 80fe2298aff27d9c10b3fbb8bbab120954e7f2be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 14:24:14 -0600 Subject: Changing the properties callback to use the proper prototype and GVariant --- libdbusmenu-glib/client.c | 57 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b80999e..50b379c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -60,7 +60,7 @@ enum { LAST_SIGNAL }; -typedef void (*properties_func) (DbusmenuClient * client, GVariant * properties, GError * error); +typedef void (*properties_func) (GVariant * properties, GError * error, gpointer user_data); static guint signals[LAST_SIGNAL] = { 0 }; @@ -348,7 +348,7 @@ dbusmenu_client_dispose (GObject *object) if (localerror == NULL) { g_set_error_literal(&localerror, error_domain(), 0, "DbusmenuClient Shutdown"); } - listener->callback(client, NULL, localerror); + listener->callback(NULL, localerror, listener->user_data); } } if (localerror != NULL) { @@ -496,47 +496,37 @@ find_listener (GArray * listeners, guint index, gint id) /* Call back from getting the group properties, now we need to unwind and call the various functions. */ static void -get_properties_callback (GDBusProxy *proxy, GPtrArray *OUT_properties, GError *error, gpointer userdata) +get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) { - GArray * listeners = (GArray *)userdata; + GArray * listeners = (GArray *)user_data; int i; + GError * error = NULL; + GVariant * params = NULL; - #ifdef MASSIVEDEBUGGING - g_debug("Get properties callback: %d", OUT_properties->len); - #endif + params = g_dbus_proxy_call_finish(G_DBUS_PROXY(obj), res, &error); if (error != NULL) { /* If we get an error, all our callbacks need to hear about it. */ g_warning("Group Properties error: %s", error->message); for (i = 0; i < listeners->len; i++) { properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); - listener->callback(proxy, NULL, error, listener->user_data); + listener->callback(NULL, error, listener->user_data); } g_array_free(listeners, TRUE); return; } /* Callback all the folks we can find */ - for (i = 0; i < OUT_properties->len; i++) { - GValueArray * varray = (GValueArray *)g_ptr_array_index(OUT_properties, i); - - if (varray->n_values != 2) { - g_warning("Value Array is %d entries long but we expected 2.", varray->n_values); + GVariantIter * iter = g_variant_iter_new(params); + GVariant * child; + while ((child = g_variant_iter_next_value(iter)) != NULL) { + if (g_strcmp0(g_variant_get_type_string(child), "ia(sv)") != 0) { + g_warning("Properties return signature is not 'ia(sv)' it is '%s'", g_variant_get_type_string(child)); continue; } - GValue * vid = g_value_array_get_nth(varray, 0); - GValue * vproperties = g_value_array_get_nth(varray, 1); - - if (G_VALUE_TYPE(vid) != G_TYPE_INT) { - g_warning("ID Entry not holding an int: %s", G_VALUE_TYPE_NAME(vid)); - } - if (G_VALUE_TYPE(vproperties) != dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) { - g_warning("Properties Entry not holding an a{sv}: %s", G_VALUE_TYPE_NAME(vproperties)); - } - - gint id = g_value_get_int(vid); - GHashTable * properties = g_value_get_boxed(vproperties); + gint id = g_variant_get_int32(g_variant_get_child_value(child, 0)); + GVariant * properties = g_variant_get_child_value(child, 1); properties_listener_t * listener = find_listener(listeners, 0, id); if (listener == NULL) { @@ -545,12 +535,13 @@ get_properties_callback (GDBusProxy *proxy, GPtrArray *OUT_properties, GError *e } if (!listener->replied) { - listener->callback(proxy, properties, NULL, listener->user_data); + listener->callback(properties, NULL, listener->user_data); listener->replied = TRUE; } else { g_warning("Odd, we've already replied to the listener on ID %d", id); } } + g_variant_iter_free(iter); /* Provide errors for those who we can't */ GError * localerror = NULL; @@ -560,7 +551,7 @@ get_properties_callback (GDBusProxy *proxy, GPtrArray *OUT_properties, GError *e if (localerror == NULL) { g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID"); } - listener->callback(proxy, NULL, localerror, listener->user_data); + listener->callback(NULL, localerror, listener->user_data); } } if (localerror != NULL) { @@ -579,7 +570,7 @@ static gboolean get_properties_idle (gpointer user_data) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); - //org_ayatana_dbusmenu_get_properties_async(priv->menuproxy, id, properties, callback, user_data); + g_return_val_if_fail(priv->menuproxy != NULL, TRUE); if (priv->delayed_property_listeners->len == 0) { g_warning("Odd, idle func got no listeners."); @@ -593,7 +584,15 @@ get_properties_idle (gpointer user_data) g_array_append_val(idlist, g_array_index(priv->delayed_property_listeners, properties_listener_t, i).id); } - org_ayatana_dbusmenu_get_group_properties_async(priv->menuproxy, idlist, (const gchar **)priv->delayed_property_list->data, get_properties_callback, priv->delayed_property_listeners); + GVariant * variant_params = g_variant_new("a(s)", (const gchar **)priv->delayed_property_list->data); + g_dbus_proxy_call(priv->menuproxy, + "GetGroupProperties", + variant_params, + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancellable */ + get_properties_callback, + priv->delayed_property_listeners); /* Free ID List */ g_array_free(idlist, TRUE); -- cgit v1.2.3 From 26311e4db0f50c805374a1cf2265e7a5c81dd083 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 14:37:53 -0600 Subject: Fixing the menuitem_get_properties_cb to use Variants and match the right prototype --- libdbusmenu-glib/client.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 50b379c..23981de 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -137,7 +137,7 @@ static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr n static gint parse_layout (DbusmenuClient * client, const gchar * layout); static void update_layout_cb (GDBusProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); static void update_layout (DbusmenuClient * client); -static void menuitem_get_properties_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data); +static void menuitem_get_properties_cb (GVariant * properties, GError * error, gpointer data); static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, properties_func callback, gpointer user_data); static GQuark error_domain (void); static void item_activated (GDBusProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); @@ -542,6 +542,7 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) } } g_variant_iter_free(iter); + g_variant_unref(params); /* Provide errors for those who we can't */ GError * localerror = NULL; @@ -1116,17 +1117,32 @@ get_properties_helper (gpointer key, gpointer value, gpointer data) This isn't the most efficient way. We can optimize this by somehow removing the foreach. But that is for later. */ static void -menuitem_get_properties_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data) +menuitem_get_properties_cb (GVariant * properties, GError * error, gpointer data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(data)); + DbusmenuMenuitem * item = DBUSMENU_MENUITEM(data); + if (error != NULL) { g_warning("Error getting properties on a menuitem: %s", error->message); g_object_unref(data); return; } - g_hash_table_foreach(properties, get_properties_helper, data); - g_hash_table_destroy(properties); + + GVariantIter * iter = g_variant_iter_new(properties); + gchar * key; + GVariant * value; + + while (g_variant_iter_next(iter, "{sv}", &key, &value)) { + dbusmenu_menuitem_property_set_variant(item, key, value); + + g_variant_unref(value); + g_free(key); + } + + g_variant_iter_free(iter); + g_object_unref(data); + return; } @@ -1154,7 +1170,7 @@ menuitem_get_properties_replace_cb (GDBusProxy * proxy, GHashTable * properties, } if (!have_error) { - menuitem_get_properties_cb(proxy, properties, error, data); + menuitem_get_properties_cb(properties, error, data); } else { g_object_unref(data); } @@ -1181,7 +1197,7 @@ menuitem_get_properties_new_cb (GDBusProxy * proxy, GHashTable * properties, GEr /* Extra ref as get_properties will unref once itself */ g_object_ref(propdata->item); - menuitem_get_properties_cb (proxy, properties, error, propdata->item); + menuitem_get_properties_cb (properties, error, propdata->item); gboolean handled = FALSE; -- cgit v1.2.3 From a03c508bbeb1267d2f3e9062f5d75b5fdbee9b05 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 14:39:30 -0600 Subject: Adding prototypes for the variant functions we're going to need in menuitem --- libdbusmenu-glib/menuitem.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index ff8d713..802a8c4 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -189,10 +189,12 @@ DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); +gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, const GVariant * value); gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); +const GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); -- cgit v1.2.3 From cbabf67cabb66079fa89d3972fea2aaee9543b5e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 14:46:12 -0600 Subject: Changing the prototypes for the get_properties wrappers --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 23981de..c206e47 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1150,7 +1150,7 @@ menuitem_get_properties_cb (GVariant * properties, GError * error, gpointer data is getting recycled with the update, but we think might have prop changes. */ static void -menuitem_get_properties_replace_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data) +menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpointer data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(data)); gboolean have_error = FALSE; @@ -1181,7 +1181,7 @@ menuitem_get_properties_replace_cb (GDBusProxy * proxy, GHashTable * properties, /* This is a different get properites call back that also sends new signals. It basically is a small wrapper around the original. */ static void -menuitem_get_properties_new_cb (GDBusProxy * proxy, GHashTable * properties, GError * error, gpointer data) +menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer data) { g_return_if_fail(data != NULL); newItemPropData * propdata = (newItemPropData *)data; -- cgit v1.2.3 From e911ad73aadd6cb2cb58771a750df1e600613c08 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 15:20:38 -0600 Subject: Completely change layoutcall to be a GCancellable --- libdbusmenu-glib/client.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c206e47..51113f0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -360,7 +360,8 @@ dbusmenu_client_dispose (GObject *object) } if (priv->layoutcall != NULL) { - dbus_g_proxy_cancel_call(priv->menuproxy, priv->layoutcall); + g_cancellable_cancel(priv->layoutcall); + g_object_unref(priv->layoutcall); priv->layoutcall = NULL; } @@ -890,7 +891,11 @@ proxy_destroyed (GObject * gobj_proxy, gpointer userdata) } if ((gpointer)priv->menuproxy == (gpointer)gobj_proxy) { - priv->layoutcall = NULL; + if (priv->layoutcall != NULL) { + g_cancellable_cancel(priv->layoutcall); + g_object_unref(priv->layoutcall); + priv->layoutcall = NULL; + } } priv->current_revision = 0; @@ -1574,7 +1579,10 @@ update_layout_cb (GDBusProxy * proxy, guint rev, gchar * xml, GError * error, vo priv->my_revision = rev; /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */ - priv->layoutcall = NULL; + if (priv->layoutcall != NULL) { + g_object_unref(priv->layoutcall); + priv->layoutcall = NULL; + } #ifdef MASSIVEDEBUGGING g_debug("Client signaling layout has changed."); #endif @@ -1604,7 +1612,9 @@ update_layout (DbusmenuClient * client) return; } - priv->layoutcall = org_ayatana_dbusmenu_get_layout_async(priv->menuproxy, + priv->layoutcall = g_cancellable_new(); + + org_ayatana_dbusmenu_get_layout_async(priv->menuproxy, 0, /* Parent is the root */ update_layout_cb, client); -- cgit v1.2.3 From 187694edd077b979c6e19c511b5227791c3cd3f6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 15:21:48 -0600 Subject: A couple of clean ups from the compiler --- libdbusmenu-glib/client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 51113f0..2027e7a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -318,7 +318,6 @@ dbusmenu_client_init (DbusmenuClient *self) static void dbusmenu_client_dispose (GObject *object) { - DbusmenuClient * client = DBUSMENU_CLIENT(object); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(object); if (priv->delayed_idle != 0) { @@ -665,7 +664,7 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert g_warning("Asking for properties from same ID twice: %d", id); GError * localerror = NULL; g_set_error_literal(&localerror, error_domain(), 0, "ID already queued"); - callback(priv->menuproxy, NULL, localerror, user_data); + callback(NULL, localerror, user_data); g_error_free(localerror); return; } -- cgit v1.2.3 From c4882fb11cece780073e56ba186e87b9cc2e90d7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 15:29:34 -0600 Subject: Switching over our call to AboutToShow --- libdbusmenu-glib/client.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 2027e7a..ab3730d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1306,14 +1306,22 @@ struct _about_to_show_t { /* Reports errors and responds to update request that were a result of sending the about to show signal. */ static void -about_to_show_cb (GDBusProxy * proxy, gboolean need_update, GError * error, gpointer userdata) +about_to_show_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) { + gboolean need_update = FALSE; + GError * error = NULL; about_to_show_t * data = (about_to_show_t *)userdata; + GVariant * params = NULL; + + params = g_dbus_proxy_call_finish(G_DBUS_PROXY(proxy), res, &error); if (error != NULL) { g_warning("Unable to send about_to_show: %s", error->message); /* Note: we're just ensuring only the callback gets called */ need_update = FALSE; + } else { + g_variant_get(params, "b", &need_update); + g_variant_unref(params); } /* If we need to update, do that first. */ @@ -1344,7 +1352,14 @@ dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb)( data->cb_data = cb_data; g_object_ref(client); - org_ayatana_dbusmenu_about_to_show_async (priv->menuproxy, id, about_to_show_cb, data); + g_dbus_proxy_call(priv->menuproxy, + "AboutToShow", + g_variant_new("i", id), + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancellable */ + about_to_show_cb, + data); return; } -- cgit v1.2.3 From f60be7e8228a685fadc88e4b41ae707b5c67ec94 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 15:39:00 -0600 Subject: Reshuffling update layout to use GDBus and GVariants --- libdbusmenu-glib/client.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ab3730d..7f6da7b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -135,7 +135,7 @@ 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 void update_layout_cb (GDBusProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); +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); static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, properties_func callback, gpointer user_data); @@ -1576,17 +1576,31 @@ parse_layout (DbusmenuClient * client, const gchar * layout) /* When the layout property returns, here's where we take care of that. */ static void -update_layout_cb (GDBusProxy * proxy, guint rev, gchar * xml, GError * error, void * data) +update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) { - DbusmenuClient * client = DBUSMENU_CLIENT(data); - DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + GError * error = NULL; + GVariant * params = NULL; + + params = g_dbus_proxy_call_finish(G_DBUS_PROXY(proxy), res, &error); if (error != NULL) { - g_warning("Getting layout failed on client %s object %s: %s", priv->dbus_name, priv->dbus_object, error->message); + g_warning("Getting layout failed: %s", error->message); return; } - if (!parse_layout(client, xml)) { + guint rev; + gchar * xml; + + g_variant_get(params, "us", &rev, &xml); + g_variant_unref(params); + + DbusmenuClient * client = DBUSMENU_CLIENT(data); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + + guint parseable = parse_layout(client, xml); + g_free(xml); + + if (parseable == 0) { g_warning("Unable to parse layout!"); return; } @@ -1628,10 +1642,14 @@ update_layout (DbusmenuClient * client) priv->layoutcall = g_cancellable_new(); - org_ayatana_dbusmenu_get_layout_async(priv->menuproxy, - 0, /* Parent is the root */ - update_layout_cb, - client); + g_dbus_proxy_call(priv->menuproxy, + "GetLayout", + g_variant_new("i", 0), /* root */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + priv->layoutcall, /* cancellable */ + update_layout_cb, + client); return; } -- cgit v1.2.3 From 4d1386938c19e6819c3d7ae631336bc8f37bfc48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 15:51:03 -0600 Subject: Changing the 'Event' call to use GDBus and GVariant --- libdbusmenu-glib/client.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7f6da7b..3a47465 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1237,9 +1237,13 @@ menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer /* Respond to the call function to make sure that the other side got it, or print a warning. */ static void -menuitem_call_cb (GDBusProxy * proxy, GError * error, gpointer userdata) +menuitem_call_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) { + GError * error = NULL; event_data_t * edata = (event_data_t *)userdata; + GVariant * params; + + params = g_dbus_proxy_call_finish(G_DBUS_PROXY(proxy), res, &error); if (error != NULL) { g_warning("Unable to call event '%s' on menu item %d: %s", edata->event, dbusmenu_menuitem_get_id(edata->menuitem), error->message); @@ -1252,6 +1256,11 @@ menuitem_call_cb (GDBusProxy * proxy, GError * error, gpointer userdata) g_object_unref(edata->menuitem); g_free(edata); + if (error != NULL) { + g_error_free(error); + } + g_variant_unref(params); + return; } @@ -1287,11 +1296,14 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name g_value_copy(value, &edata->data); edata->timestamp = timestamp; - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (menuitem_call_cb); - stuff->userdata = edata; - dbus_g_proxy_begin_call_with_timeout (priv->menuproxy, "Event", org_ayatana_dbusmenu_event_async_callback, stuff, _dbus_glib_async_data_free, 1000, G_TYPE_INT, id, G_TYPE_STRING, name, G_TYPE_VALUE, value, G_TYPE_UINT, timestamp, G_TYPE_INVALID); + g_dbus_proxy_call(priv->menuproxy, + "Event", + g_variant_new("isvu", id, name, value, timestamp), + G_DBUS_CALL_FLAGS_NONE, + 1000, /* timeout */ + NULL, /* cancellable */ + menuitem_call_cb, + edata); return; } -- cgit v1.2.3 From c5ddb96e4b861edf0d0281942bea99d22296d077 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:00:35 -0600 Subject: Changing how the watcher is setup --- libdbusmenu-glib/client.c | 59 +++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 3a47465..f9584a9 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -82,7 +82,7 @@ struct _DbusmenuClientPrivate gint current_revision; gint my_revision; - GDBusProxy * dbusproxy; + guint dbusproxy; GHashTable * type_handlers; @@ -303,7 +303,7 @@ dbusmenu_client_init (DbusmenuClient *self) priv->current_revision = 0; priv->my_revision = 0; - priv->dbusproxy = NULL; + priv->dbusproxy = 0; priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); @@ -376,9 +376,9 @@ dbusmenu_client_dispose (GObject *object) priv->menuproxy = NULL; } - if (priv->dbusproxy != NULL) { - g_object_unref(G_OBJECT(priv->dbusproxy)); - priv->dbusproxy = NULL; + if (priv->dbusproxy != 0) { + g_bus_unwatch_name(priv->dbusproxy); + priv->dbusproxy = 0; } /* Bring down the session bus, ensure we're not @@ -790,23 +790,11 @@ id_update (GDBusProxy * proxy, gint id, DbusmenuClient * client) /* Watches to see if our DBus savior comes onto the bus */ static void -dbus_owner_change (GDBusProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, DbusmenuClient * client) +dbus_owner_change (GDBusConnection * connection, const gchar * name, const gchar * owner, gpointer user_data) { - DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - /* g_debug("Owner change: %s %s %s", name, prev, new); */ - - if (!(new[0] != '\0' && prev[0] == '\0')) { - /* If it's not someone new getting on the bus, sorry we - simply just don't care. It's not that your service isn't - important to someone, just not us. You'll find the right - process someday, there's lots of processes out there. */ - return; - } + g_return_if_fail(DBUSMENU_IS_CLIENT(user_data)); - if (g_strcmp0(name, priv->dbus_name)) { - /* Again, someone else's service. */ - return; - } + DbusmenuClient * client = DBUSMENU_CLIENT(user_data); /* Woot! A service for us to love and to hold for ever and ever and ever! */ @@ -840,26 +828,17 @@ build_dbus_proxy (DbusmenuClient * client) DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); GError * error = NULL; - if (priv->dbusproxy != NULL) { - return; - } - - priv->dbusproxy = dbus_g_proxy_new_for_name_owner (priv->session_bus, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS, - &error); - if (error != NULL) { - g_debug("Oh, that's bad. That's really bad. We can't get a proxy to DBus itself? Seriously? Here's all I know: %s", error->message); - g_error_free(error); + if (priv->dbusproxy != 0) { return; } - dbus_g_proxy_add_signal(priv->dbusproxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->dbusproxy, "NameOwnerChanged", - G_CALLBACK(dbus_owner_change), client, NULL); + priv->dbusproxy = g_bus_watch_name_on_connection(priv->session_bus, + priv->dbus_name, + G_BUS_NAME_WATCHER_FLAGS_NONE, + dbus_owner_change, + NULL, + client, + NULL); /* Now let's check to make sure we're not in some race condition case. */ @@ -1011,9 +990,9 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) } /* If we get here, we don't need the DBus proxy */ - if (priv->dbusproxy != NULL) { - g_object_unref(G_OBJECT(priv->dbusproxy)); - priv->dbusproxy = NULL; + if (priv->dbusproxy != 0) { + g_bus_unwatch(priv->dbusproxy); + priv->dbusproxy = 0; } g_signal_connect(priv->menuproxy, "g-signal", G_CALLBACK(menuproxy_signal_cb), client); -- cgit v1.2.3 From 7fd7547baeb728c162de08b7278ebbbff81832d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:09:34 -0600 Subject: Dropping the name check, need to figure out another way to do this. --- libdbusmenu-glib/client.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f9584a9..563fbe0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -801,25 +801,6 @@ dbus_owner_change (GDBusConnection * connection, const gchar * name, const gchar return build_proxies(client); } -/* This is the response to see if the name has an owner. If - it does, then we should build the proxies here. Race condition - check. */ -static void -name_owner_check (GDBusProxy *proxy, gboolean has_owner, GError *error, gpointer userdata) -{ - if (error != NULL) { - return; - } - - if (!has_owner) { - return; - } - - DbusmenuClient * client = DBUSMENU_CLIENT(userdata); - build_proxies(client); - return; -} - /* This function builds the DBus proxy which will look out for the service coming up. */ static void @@ -842,10 +823,7 @@ build_dbus_proxy (DbusmenuClient * client) /* Now let's check to make sure we're not in some race condition case. */ - org_freedesktop_DBus_name_has_owner_async(priv->dbusproxy, - priv->dbus_name, - name_owner_check, - client); + /* TODO: Not sure how to check for names in GDBus */ return; } -- cgit v1.2.3 From fb8c8e53f6bcbac9e589e1ee86a364765ce4ec83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:15:04 -0600 Subject: A set of basically typos caught by the compiler --- libdbusmenu-glib/client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 563fbe0..8658104 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -807,7 +807,6 @@ static void build_dbus_proxy (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - GError * error = NULL; if (priv->dbusproxy != 0) { return; @@ -878,6 +877,7 @@ session_bus_cb (GObject * object, GAsyncResult * res, gpointer user_data) } /* If this wasn't cancelled, we should be good */ + DbusmenuClient * client = DBUSMENU_CLIENT(user_data); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); priv->session_bus = bus; @@ -898,7 +898,6 @@ static void build_proxies (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - GError * error = NULL; g_return_if_fail(priv->dbus_object != NULL); g_return_if_fail(priv->dbus_name != NULL); @@ -912,7 +911,7 @@ build_proxies (DbusmenuClient * client) priv->session_bus_cancel = g_cancellable_new(); /* Async get the session bus */ - g_bus_get(G_BUS_SESSION, priv->session_bus_cancel, session_bus_cb, client); + g_bus_get(G_BUS_TYPE_SESSION, priv->session_bus_cancel, session_bus_cb, client); } /* This function exists, it'll be called again when we get @@ -959,7 +958,8 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) } /* If this wasn't cancelled, we should be good */ - DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); + DbusmenuClient * client = DBUSMENU_CLIENT(user_data); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); priv->menuproxy = proxy; if (priv->menuproxy_cancel != NULL) { @@ -969,7 +969,7 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != 0) { - g_bus_unwatch(priv->dbusproxy); + g_bus_unwatch_name(priv->dbusproxy); priv->dbusproxy = 0; } -- cgit v1.2.3 From 1b970b18f1ef93c597ae4d079eba78340eaced20 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:16:29 -0600 Subject: Changing property update to use variants --- libdbusmenu-glib/client.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8658104..18cbfce 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -129,7 +129,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); /* Private Funcs */ static void layout_update (GDBusProxy * proxy, guint revision, gint parent, DbusmenuClient * client); -static void id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client); +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); @@ -740,16 +740,8 @@ layout_update (GDBusProxy * proxy, guint revision, gint parent, DbusmenuClient * /* Signal from the server that a property has changed on one of our menuitems */ static void -id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client) +id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GVariant * value, DbusmenuClient * client) { - #ifdef MASSIVEDEBUGGING - GValue valstr = {0}; - g_value_init(&valstr, G_TYPE_STRING); - g_value_transform(value, &valstr); - g_debug("Property change sent to client for item %d property %s value %s", id, property, g_utf8_strlen(g_value_get_string(&valstr), 50) < 25 ? g_value_get_string(&valstr) : ""); - g_value_unset(&valstr); - #endif - DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); g_return_if_fail(priv->root != NULL); @@ -762,7 +754,7 @@ id_prop_update (GDBusProxy * proxy, gint id, gchar * property, GValue * value, D return; } - dbusmenu_menuitem_property_set_value(menuitem, property, value); + dbusmenu_menuitem_property_set_variant(menuitem, property, value); return; } -- cgit v1.2.3 From ab90d78d2079ac5dbdd8c6ae259e893559307246 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:20:35 -0600 Subject: Removing the lookup in the properties to see if an item should be replaced, since we're calling all of them, I don't think we want any leftovers. --- libdbusmenu-glib/client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 18cbfce..f25ed7d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1116,11 +1116,11 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin GList * current_props = NULL; for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); - current_props != NULL ; current_props = g_list_next(current_props)) { - if (have_error || g_hash_table_lookup(properties, current_props->data) == NULL) { - dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->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); } + g_list_free(current_props); if (!have_error) { menuitem_get_properties_cb(properties, error, data); -- cgit v1.2.3 From 80ab7485e816b687caeee4d6f0395ba010b99d2e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:21:07 -0600 Subject: Oops, unused helper --- libdbusmenu-glib/client.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f25ed7d..ff7d5ec 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1055,15 +1055,6 @@ parse_node_get_id (xmlNodePtr node) return -1; } -/* A small helper that calls _property_set on each hash table - entry in the properties hash. */ -static void -get_properties_helper (gpointer key, gpointer value, gpointer data) -{ - dbusmenu_menuitem_property_set_value((DbusmenuMenuitem *)data, (gchar *)key, (GValue *)value); - return; -} - /* 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. -- cgit v1.2.3 From bf33041c44cc9edd029a2ebe1359a78103f8e9f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:25:49 -0600 Subject: Some stub functions so that we can compile --- libdbusmenu-glib/menuitem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 5e700a5..7497697 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1021,6 +1021,13 @@ dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * prope return TRUE; } +gboolean +dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, const GVariant * value) +{ + + return FALSE; +} + /** dbusmenu_menuitem_property_get: @mi: The #DbusmenuMenuitem to look for the property on. @@ -1065,6 +1072,13 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, property); } +const GVariant * +dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property) +{ + + return NULL; +} + /** dbusmenu_menuitem_property_get_bool: @mi: The #DbusmenuMenuitem to look for the property on. -- cgit v1.2.3 From 080cf37f48dba3dc521167bd3ddc51f45681ea1d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:55:43 -0600 Subject: Cleaning out namespaces from the XML so that GDBus will read it. --- libdbusmenu-glib/Makefile.am | 13 +++++++++---- libdbusmenu-glib/clean-namespaces.xslt | 9 +++++++++ libdbusmenu-glib/client.c | 4 ++-- libdbusmenu-glib/server.c | 4 ++-- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 libdbusmenu-glib/clean-namespaces.xslt diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index be70cfa..4e97428 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -2,6 +2,7 @@ CLEANFILES = EXTRA_DIST = \ + clean-namespaces.xslt \ dbusmenu-glib.pc.in \ dbus-menu.xml \ client-marshal.list \ @@ -20,8 +21,8 @@ libdbusmenu_glibinclude_HEADERS = \ client.h libdbusmenu_glib_la_SOURCES = \ - dbus-menu.xml.h \ - dbus-menu.xml.c \ + dbus-menu-clean.xml.h \ + dbus-menu-clean.xml.c \ menuitem.h \ menuitem.c \ menuitem-marshal.h \ @@ -62,10 +63,14 @@ pkgconfigdir = $(libdir)/pkgconfig sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ echo ";" >> $@ +dbus-menu-clean.xml: dbus-menu.xml + xsltproc $(srcdir)/clean-namespaces.xslt $< > $@ + +CLEANFILES += dbus-menu-clean.xml BUILT_SOURCES = \ - dbus-menu.xml.c \ - dbus-menu.xml.h \ + dbus-menu-clean.xml.c \ + dbus-menu-clean.xml.h \ client-marshal.h \ client-marshal.c \ menuitem-marshal.h \ diff --git a/libdbusmenu-glib/clean-namespaces.xslt b/libdbusmenu-glib/clean-namespaces.xslt new file mode 100644 index 0000000..125a10f --- /dev/null +++ b/libdbusmenu-glib/clean-namespaces.xslt @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ff7d5ec..7c90fa6 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -41,7 +41,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client-menuitem.h" #include "server-marshal.h" #include "client-marshal.h" -#include "dbus-menu.xml.h" +#include "dbus-menu-clean.xml.h" /* Properties */ enum { @@ -262,7 +262,7 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) if (dbusmenu_node_info == NULL) { GError * error = NULL; - dbusmenu_node_info = g_dbus_node_info_new_for_xml(dbus_menu_xml, &error); + dbusmenu_node_info = g_dbus_node_info_new_for_xml(dbus_menu_clean_xml, &error); if (error != NULL) { g_error("Unable to parse DBusmenu Interface description: %s", error->message); g_error_free(error); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 652b2a8..63d237f 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -36,7 +36,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "server.h" #include "server-marshal.h" -#include "dbus-menu.xml.h" +#include "dbus-menu-clean.xml.h" static void layout_update_signal (DbusmenuServer * server); @@ -288,7 +288,7 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) if (dbusmenu_node_info == NULL) { GError * error = NULL; - dbusmenu_node_info = g_dbus_node_info_new_for_xml(dbus_menu_xml, &error); + dbusmenu_node_info = g_dbus_node_info_new_for_xml(dbus_menu_clean_xml, &error); if (error != NULL) { g_error("Unable to parse DBusmenu Interface description: %s", error->message); g_error_free(error); -- cgit v1.2.3 From d40345acf5e69fea2e87f03cc94cc6c29cadd421 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Nov 2010 16:58:01 -0600 Subject: Ignoring the new temp files --- .bzrignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bzrignore b/.bzrignore index c60cc9c..b6ed6f4 100644 --- a/.bzrignore +++ b/.bzrignore @@ -197,3 +197,7 @@ tests/test-glib-events-server libdbusmenu-glib/dbus-menu.xml.c libdbusmenu-glib/dbus-menu.xml.h libdbusmenu-glib/libdbusmenu_glib_la-dbus-menu.xml.lo +libdbusmenu-glib/dbus-menu-clean.xml +libdbusmenu-glib/dbus-menu-clean.xml.c +libdbusmenu-glib/dbus-menu-clean.xml.h +libdbusmenu-glib/libdbusmenu_glib_la-dbus-menu-clean.xml.lo -- cgit v1.2.3 From a8fc233f37e08f52ed7ca80fbd284277ca1bd33e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 11:23:46 -0600 Subject: Taking out the dbus-glib specialized types for now --- tests/json-loader.c | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index aad4295..9e67666 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -20,7 +20,6 @@ with this program. If not, see . */ #include "json-loader.h" -#include static GValue * node2value (JsonNode * node) @@ -74,58 +73,12 @@ node2value (JsonNode * node) } } else { - GValue * subvalue = node2value(first); - GType type = dbus_g_type_get_collection("GPtrArray", G_VALUE_TYPE(subvalue)); - gpointer * wrapper = dbus_g_type_specialized_construct(type); - - g_value_init(value, type); - g_value_take_boxed(value, wrapper); - - DBusGTypeSpecializedAppendContext ctx; - dbus_g_type_specialized_init_append(value, &ctx); - - dbus_g_type_specialized_collection_append(&ctx, subvalue); - int i; - for (i = 1; i < json_array_get_length(array); i++) { - GValue * subvalue = node2value(node); - dbus_g_type_specialized_collection_append(&ctx, subvalue); - } - - dbus_g_type_specialized_collection_end_append(&ctx); + g_warning("Complex array not supported"); } } if (JSON_NODE_TYPE(node) == JSON_NODE_OBJECT) { - JsonObject * obj = json_node_get_object(node); - - GType type = dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE); - GHashTable * hash = (GHashTable *)dbus_g_type_specialized_construct(type); - - g_value_init(value, type); - g_value_take_boxed(value, hash); - - DBusGTypeSpecializedAppendContext ctx; - dbus_g_type_specialized_init_append(value, &ctx); - - GList * members = NULL; - for (members = json_object_get_members(obj); members != NULL; members = g_list_next(members)) { - const gchar * member = members->data; - - JsonNode * lnode = json_object_get_member(obj, member); - GValue * value = node2value(lnode); - - if (value != NULL) { - GValue name = {0}; - g_value_init(&name, G_TYPE_STRING); - g_value_set_static_string(&name, member); - - dbus_g_type_specialized_map_append(&ctx, &name, value); - - g_value_unset(&name); - g_value_unset(value); - g_free(value); - } - } + g_warning("Object nodes are a problem"); } return value; -- cgit v1.2.3 From 5d804e383706aba3c7e8014931d88378a1774c85 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 12:59:06 -0600 Subject: Glib version is using GIO now --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index c8d18b1..e0d4b28 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,7 @@ GLIB_REQUIRED_VERSION=2.18 XML_REQUIRED_VERSION=2.6 PKG_CHECK_MODULES(DBUSMENUGLIB, glib-2.0 >= $GLIB_REQUIRED_VERSION + gio-2.0 >= $GLIB_REQUIRED_VERSION libxml-2.0 >= $XML_REQUIRED_VERSION) AC_SUBST(DBUSMENUGLIB_CFLAGS) -- cgit v1.2.3 From 94d5da983e2d1d64d6cf4249237b6ba009102286 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 13:46:26 -0600 Subject: Switching to GDBus from dbus-glib --- tests/test-glib-events-server.c | 55 +++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/tests/test-glib-events-server.c b/tests/test-glib-events-server.c index 0d1e0b1..ab72c6b 100644 --- a/tests/test-glib-events-server.c +++ b/tests/test-glib-events-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -49,35 +45,40 @@ timer_func (gpointer data) return FALSE; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); - - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - server = dbusmenu_server_new("/org/test"); DbusmenuMenuitem * menuitem = dbusmenu_menuitem_new(); dbusmenu_server_set_root(server, menuitem); g_signal_connect(G_OBJECT(menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(handle_event), NULL); + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); + g_timeout_add_seconds(3, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From 9bdfb119a18873a4c564865fd7b399940f0ad9bb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 14:16:06 -0600 Subject: Fix error handling on the xslt script --- libdbusmenu-glib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 4e97428..3746b49 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -64,7 +64,7 @@ pkgconfigdir = $(libdir)/pkgconfig echo ";" >> $@ dbus-menu-clean.xml: dbus-menu.xml - xsltproc $(srcdir)/clean-namespaces.xslt $< > $@ + xsltproc $(srcdir)/clean-namespaces.xslt $< > $@ || rm -f $@ && /bin/false CLEANFILES += dbus-menu-clean.xml -- cgit v1.2.3 From d16f4ab9fee7ebc3a38631ab8efc4e0464923e8f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 14:29:35 -0600 Subject: Ooops, fix the booleans --- libdbusmenu-glib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 3746b49..db4ed4b 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -64,7 +64,7 @@ pkgconfigdir = $(libdir)/pkgconfig echo ";" >> $@ dbus-menu-clean.xml: dbus-menu.xml - xsltproc $(srcdir)/clean-namespaces.xslt $< > $@ || rm -f $@ && /bin/false + xsltproc $(srcdir)/clean-namespaces.xslt $< > $@ || (rm -f $@ && /bin/false) CLEANFILES += dbus-menu-clean.xml -- cgit v1.2.3 From e53602cd25b7057c02e95a9e49363acb32ae47a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 15:14:33 -0600 Subject: Wow, that blows things out. Nice! --- libdbusmenu-glib/clean-namespaces.xslt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libdbusmenu-glib/clean-namespaces.xslt b/libdbusmenu-glib/clean-namespaces.xslt index 125a10f..8344a71 100644 --- a/libdbusmenu-glib/clean-namespaces.xslt +++ b/libdbusmenu-glib/clean-namespaces.xslt @@ -5,5 +5,10 @@ + + + + + -- cgit v1.2.3 From 6fc56d02acbb80a166837ed226fbe24bd3635fca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 15:30:39 -0600 Subject: Switching to GDBus for getting the name --- tests/test-glib-layout-server.c | 53 +++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index 111e164..e289349 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -72,33 +68,38 @@ timer_func (gpointer data) return TRUE; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + server = dbusmenu_server_new("/org/test"); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; + timer_func(NULL); + g_timeout_add(2500, timer_func, NULL); - if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } + return; +} - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} - server = dbusmenu_server_new("/org/test"); +int +main (int argc, char ** argv) +{ + g_type_init(); - timer_func(NULL); - g_timeout_add(2500, timer_func, NULL); + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From b09ed309175070d38bc4351d02f23b0ef757008c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 15:47:10 -0600 Subject: More name grabbing porting from dbus-glib to GDBus --- tests/test-glib-properties-server.c | 7 +---- tests/test-glib-proxy-proxy.c | 55 +++++++++++++++++++------------------ tests/test-glib-proxy-server.c | 51 +++++++++++++++++----------------- 3 files changed, 55 insertions(+), 58 deletions(-) diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c index 091e550..4248ea2 100644 --- a/tests/test-glib-properties-server.c +++ b/tests/test-glib-properties-server.c @@ -20,10 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include +#include #include #include @@ -91,8 +88,6 @@ main (int argc, char ** argv) { g_type_init(); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); - server = dbusmenu_server_new("/org/test"); timer_func(NULL); diff --git a/tests/test-glib-proxy-proxy.c b/tests/test-glib-proxy-proxy.c index 722cf1f..b9db620 100644 --- a/tests/test-glib-proxy-proxy.c +++ b/tests/test-glib-proxy-proxy.c @@ -1,9 +1,5 @@ #include - -#include -#include -#include -#include +#include #include #include @@ -32,6 +28,25 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer user return; } +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + server = dbusmenu_server_new("/org/test"); + client = dbusmenu_client_new((gchar *)user_data, "/org/test"); + + g_signal_connect(client, DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), server); + + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} + int main (int argc, char ** argv) { @@ -47,28 +62,14 @@ main (int argc, char ** argv) g_debug("I am '%s' and I'm proxying '%s'", whoami, myproxy); - GError * error = NULL; - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(connection))); - - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, whoami, 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - - server = dbusmenu_server_new("/org/test"); - client = dbusmenu_client_new(myproxy, "/org/test"); - - g_signal_connect(client, DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), server); + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + myproxy, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index f32b426..c12a584 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -104,31 +100,36 @@ layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) return; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - g_type_init(); - - GError * error = NULL; - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(connection))); + server = dbusmenu_server_new("/org/test"); + layout_change(NULL, 0, NULL); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; + return; +} - if (!org_freedesktop_DBus_request_name(bus_proxy, "test.proxy.server", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } +int +main (int argc, char ** argv) +{ + g_type_init(); - server = dbusmenu_server_new("/org/test"); - layout_change(NULL, 0, NULL); + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From d2eaaa6de0019da3bb9202dc0cb194ca5ef9d79f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 16:25:24 -0600 Subject: It doesn't really match standard GVariant syntax to have this be a const --- libdbusmenu-glib/menuitem.c | 2 +- libdbusmenu-glib/menuitem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 7497697..80d9df4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1072,7 +1072,7 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, property); } -const GVariant * +GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property) { diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 802a8c4..1dbad9d 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -194,7 +194,7 @@ gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); -const GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property); +GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); -- cgit v1.2.3 From 726e8b11f2938a229b5ff75979031aafdbacf60d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 16:27:53 -0600 Subject: Redoing the handling of shortcuts to use GVariants rather than GValues --- libdbusmenu-gtk/menuitem.c | 128 +++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 87 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 5846aa7..9c1cfd2 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -29,7 +29,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem.h" #include #include -#include /** dbusmenu_menuitem_property_set_image: @@ -201,25 +200,16 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, const gchar * keyname = gdk_keyval_name(key); g_array_append_val(array, keyname); - GType type = dbus_g_type_get_collection("GPtrArray", G_TYPE_STRV); - GPtrArray * wrapper = (GPtrArray *)dbus_g_type_specialized_construct(type); + GVariant * inside = g_variant_new("as", array->data); + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE("av")); + g_variant_builder_add_value(&builder, inside); + GVariant * outsidevariant = g_variant_builder_end(&builder); - GValue value = {0,}; - g_value_init(&value, type); - g_value_take_boxed(&value, wrapper); + dbusmenu_menuitem_property_set_variant(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, outsidevariant); - DBusGTypeSpecializedAppendContext ctx; - dbus_g_type_specialized_init_append(&value, &ctx); - - GValue strval = {0,}; - g_value_init(&strval, G_TYPE_STRV); - g_value_take_boxed(&strval, array->data); - g_array_free(array, FALSE); - - dbus_g_type_specialized_collection_append(&ctx, &strval); - dbus_g_type_specialized_collection_end_append(&ctx); - - dbusmenu_menuitem_property_set_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, &value); + g_variant_unref(outsidevariant); + g_variant_unref(inside); return TRUE; } @@ -279,68 +269,6 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods); } -/* A set of typed data for the interator */ -typedef struct _iter_data_t iter_data_t; -struct _iter_data_t { - guint * key; - GdkModifierType * modifier; -}; - -/* Goes through the wrapper items. In reality we only support one - so it checks to see if a key is set first. But, we could possibly, - support more in the future. */ -static void -_wrapper_iterator (const GValue * value, gpointer user_data) -{ - iter_data_t * iter_data = (iter_data_t *)user_data; - - if (*iter_data->key != 0) { - g_warning("Shortcut is more than one entry. Which we don't currently support. Taking the first."); - return; - } - - if (!G_VALUE_HOLDS(value, G_TYPE_STRV)) { - g_warning("Unexpected shortcut structure. Value array is: %s", G_VALUE_TYPE_NAME(value)); - return; - } - - gchar ** stringarray = (gchar **)g_value_get_boxed(value); - if (stringarray == NULL) { - return; - } - - const gchar * last_string = NULL; - int i; - - for (i = 0; stringarray[i] != NULL; i++) { - last_string = stringarray[i]; - - if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { - *iter_data->modifier |= GDK_CONTROL_MASK; - continue; - } - if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { - *iter_data->modifier |= GDK_MOD1_MASK; - continue; - } - if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { - *iter_data->modifier |= GDK_SHIFT_MASK; - continue; - } - if (g_strcmp0(last_string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { - *iter_data->modifier |= GDK_SUPER_MASK; - continue; - } - } - - if (last_string != NULL) { - GdkModifierType tempmod; - gtk_accelerator_parse(last_string, iter_data->key, &tempmod); - } - - return; -} - /** dbusmenu_menuitem_property_get_shortcut: @menuitem: The #DbusmenuMenuitem to get the shortcut off @@ -358,20 +286,46 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke g_return_if_fail(DBUSMENU_IS_MENUITEM(menuitem)); - const GValue * wrapper = dbusmenu_menuitem_property_get_value(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT); + GVariant * wrapper = dbusmenu_menuitem_property_get_variant(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT); if (wrapper == NULL) { return; } - if (!dbus_g_type_is_collection(G_VALUE_TYPE(wrapper))) { - g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); + + if (g_variant_n_children(wrapper) != 1) { + g_warning("Unable to parse shortcut, too many keys"); + g_variant_unref(wrapper); return; } - iter_data_t iter_data; - iter_data.key = key; - iter_data.modifier = modifier; + GVariantIter outsideiter; + GVariant * inside; + g_variant_iter_init(&outsideiter, wrapper); + + while(g_variant_iter_next(&outsideiter, "v", &inside)) { + GVariantIter insideiter; + g_variant_iter_init(&insideiter, inside); + gchar * string; + + while(g_variant_iter_next(&insideiter, "s", &string)) { + if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + *modifier |= GDK_CONTROL_MASK; + } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + *modifier |= GDK_MOD1_MASK; + } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + *modifier |= GDK_SHIFT_MASK; + } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + *modifier |= GDK_SUPER_MASK; + } else { + GdkModifierType tempmod; + gtk_accelerator_parse(string, key, &tempmod); + } + + g_free(string); + } - dbus_g_type_collection_value_iterate(wrapper, _wrapper_iterator, &iter_data); + g_variant_unref(inside); + } + g_variant_unref(wrapper); return; } -- cgit v1.2.3 From b856f7cd47db470f4369aa28ad87dc1925bf68a5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 16:31:51 -0600 Subject: Switching to getting the name with GDBus --- tools/testapp/main.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/tools/testapp/main.c b/tools/testapp/main.c index f489407..67e962d 100644 --- a/tools/testapp/main.c +++ b/tools/testapp/main.c @@ -26,9 +26,7 @@ License version 3 and version 2.1 along with this program. If not, see */ #include - -#include -#include +#include #include @@ -117,6 +115,24 @@ void init_menu(DbusmenuMenuitem *root, const char *filename) } } +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + DbusmenuServer *server = dbusmenu_server_new("/MenuBar"); + DbusmenuMenuitem *root = dbusmenu_menuitem_new_with_id(0); + init_menu(root, (gchar *)user_data); + dbusmenu_server_set_root(server, root); + + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + return; +} + int main (int argc, char ** argv) { g_type_init(); @@ -127,25 +143,14 @@ int main (int argc, char ** argv) } const char *filename = argv[1]; - GError * error = NULL; - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - - DbusmenuServer *server = dbusmenu_server_new("/MenuBar"); - DbusmenuMenuitem *root = dbusmenu_menuitem_new_with_id(0); - init_menu(root, filename); - dbusmenu_server_set_root(server, root); + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + (gpointer)filename, + NULL); g_main_loop_run(g_main_loop_new(NULL, FALSE)); -- cgit v1.2.3 From b0a7118fc4581f07b42c25ce02bda01fd1604097 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 17:16:45 -0600 Subject: Chaning to get dbus names via GDBus --- tests/test-glib-simple-items.c | 3 --- tests/test-glib-submenu-server.c | 53 +++++++++++++++++++------------------- tests/test-gtk-label-server.c | 52 +++++++++++++++++++------------------ tests/test-gtk-reorder-server.c | 55 ++++++++++++++++++++-------------------- tests/test-gtk-shortcut-server.c | 53 +++++++++++++++++++------------------- 5 files changed, 110 insertions(+), 106 deletions(-) diff --git a/tests/test-glib-simple-items.c b/tests/test-glib-simple-items.c index 5b9f538..3ea5480 100644 --- a/tests/test-glib-simple-items.c +++ b/tests/test-glib-simple-items.c @@ -1,6 +1,3 @@ -#include -#include - #include #include diff --git a/tests/test-glib-submenu-server.c b/tests/test-glib-submenu-server.c index 68f7004..73362c1 100644 --- a/tests/test-glib-submenu-server.c +++ b/tests/test-glib-submenu-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -72,33 +68,38 @@ timer_func (gpointer data) return TRUE; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + server = dbusmenu_server_new("/org/test"); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; + timer_func(NULL); + g_timeout_add(2500, timer_func, NULL); - if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } + return; +} - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} - server = dbusmenu_server_new("/org/test"); +int +main (int argc, char ** argv) +{ + g_type_init(); - timer_func(NULL); - g_timeout_add(2500, timer_func, NULL); + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 32572fc..ddf8fcf 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -53,6 +49,25 @@ timer_func (gpointer data) return TRUE; } +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + server = dbusmenu_server_new("/org/test"); + + timer_func(NULL); + g_timeout_add_seconds(5, timer_func, NULL); + + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} + int main (int argc, char ** argv) { @@ -73,26 +88,15 @@ main (int argc, char ** argv) root_array = json_node_get_array(root_node); g_debug("%d layouts in test description '%s'", json_array_get_length(root_array), argv[1]); - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - - server = dbusmenu_server_new("/org/test"); - - timer_func(NULL); - g_timeout_add_seconds(5, timer_func, NULL); + g_bus_own_name(G_BUS_TYPE_SESSION, + "glib.label.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-gtk-reorder-server.c b/tests/test-gtk-reorder-server.c index eee9bb8..44209f1 100644 --- a/tests/test-gtk-reorder-server.c +++ b/tests/test-gtk-reorder-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -73,29 +69,9 @@ timer_func (gpointer data) return TRUE; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); - - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - server = dbusmenu_server_new("/org/test"); root = dbusmenu_menuitem_new(); dbusmenu_server_set_root(server, root); @@ -109,6 +85,31 @@ main (int argc, char ** argv) timer_func(NULL); g_timeout_add_seconds(5, timer_func, NULL); + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + g_bus_own_name(G_BUS_TYPE_SESSION, + "glib.label.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-gtk-shortcut-server.c b/tests/test-gtk-shortcut-server.c index 3b703a1..b205d03 100644 --- a/tests/test-gtk-shortcut-server.c +++ b/tests/test-gtk-shortcut-server.c @@ -20,13 +20,9 @@ with this program. If not, see . */ #include +#include #include -#include -#include -#include -#include - #include #include #include @@ -61,33 +57,38 @@ build_menu (void) return; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + server = dbusmenu_server_new("/org/test"); + build_menu(); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; + g_timeout_add_seconds(10, timer_func, NULL); - if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } + return; +} - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} - server = dbusmenu_server_new("/org/test"); - build_menu(); +int +main (int argc, char ** argv) +{ + g_type_init(); - g_timeout_add_seconds(10, timer_func, NULL); + g_bus_own_name(G_BUS_TYPE_SESSION, + "glib.label.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From f6108371c958c994b451d9c7c80f530bae4fd7c3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 21:57:32 -0600 Subject: Making a test do a name detection, but kinda making it async at the same time. --- tests/test-json-client.c | 60 ++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/tests/test-json-client.c b/tests/test-json-client.c index f9da55e..d4e782b 100644 --- a/tests/test-json-client.c +++ b/tests/test-json-client.c @@ -21,38 +21,21 @@ with this program. If not, see . #include #include -#include -#include -#include GMainLoop * mainloop = NULL; -int -main (int argc, char ** argv) +gboolean +timeout_func (gpointer user_data) { - g_type_init(); - g_debug("Wait for friends"); - - GError * error = NULL; - DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - if (error != NULL) { - g_error("Unable to get session bus: %s", error->message); - return 1; - } - - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - - gboolean has_owner = FALSE; - gint owner_count = 0; - while (!has_owner && owner_count < 10000) { - org_freedesktop_DBus_name_has_owner(bus_proxy, "org.dbusmenu.test", &has_owner, NULL); - owner_count++; - } + g_warning("Timeout without getting name"); + g_main_loop_quit(mainloop); + return FALSE; +} - if (owner_count == 10000) { - g_error("Unable to get name owner after 10000 tries"); - return 1; - } +void +name_appeared (GDBusConnection * connection, const gchar * name, const gchar * owner, gpointer user_data) +{ + char ** argv = (char **)user_data; g_usleep(500000); @@ -69,7 +52,28 @@ main (int argc, char ** argv) g_file_replace_contents(ofile, output, g_utf8_strlen(output, -1), NULL, FALSE, 0, NULL, NULL, NULL); } - g_debug("Exiting"); + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + g_debug("Wait for friends"); + + g_bus_watch_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_WATCHER_FLAGS_NONE, + name_appeared, + NULL, + argv, + NULL); + + g_timeout_add_seconds(2, timeout_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); return 0; } -- cgit v1.2.3 From 1100e05ca534449b557a1f2993c405f01781bd72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Nov 2010 22:04:47 -0600 Subject: Getting names the GDBus way --- tests/test-gtk-submenu-server.c | 55 +++++++++++++++++++------------------ tests/test-json-server.c | 61 +++++++++++++++++++++++------------------ 2 files changed, 62 insertions(+), 54 deletions(-) diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c index 11cede0..9c4d7d4 100644 --- a/tests/test-gtk-submenu-server.c +++ b/tests/test-gtk-submenu-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -59,29 +55,9 @@ add_item(DbusmenuMenuitem * parent, const char * label) return item; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); - - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - DbusmenuServer * server = dbusmenu_server_new("/org/test"); DbusmenuMenuitem * root = dbusmenu_menuitem_new(); dbusmenu_server_set_root(server, root); @@ -101,6 +77,31 @@ main (int argc, char ** argv) g_timeout_add_seconds(4, show_item, item); + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + g_bus_own_name(G_BUS_TYPE_SESSION, + "glib.label.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); + g_timeout_add_seconds(6, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); diff --git a/tests/test-json-server.c b/tests/test-json-server.c index fe9507a..083de60 100644 --- a/tests/test-json-server.c +++ b/tests/test-json-server.c @@ -20,11 +20,7 @@ with this program. If not, see . */ #include - -#include -#include -#include -#include +#include #include #include @@ -40,38 +36,49 @@ timer_func (gpointer data) return FALSE; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - GError * error = NULL; - - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); - - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } + gchar ** argv = (gchar **)user_data; DbusmenuServer * server = dbusmenu_server_new("/org/test"); DbusmenuMenuitem * root = dbusmenu_json_build_from_file(argv[1]); - g_return_val_if_fail(root!=NULL, 1); + if (root == NULL) { + g_warning("Unable to build root"); + g_main_loop_quit(mainloop); + return; + } dbusmenu_server_set_root(server, root); g_timeout_add(10000, timer_func, NULL); + return; +} + +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + g_bus_own_name(G_BUS_TYPE_SESSION, + "org.dbusmenu.test", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + argv, + NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From e9e8e1c31e0a32e23e2526622d2435f60c24a084 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 11:12:28 -0600 Subject: Porting the dumper to GDBus --- tools/dbusmenu-dumper.c | 154 ++++++++++-------------------------------------- 1 file changed, 30 insertions(+), 124 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 3256f7e..4580e4c 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -21,7 +21,6 @@ with this program. If not, see . */ #include -#include #include #include @@ -30,111 +29,10 @@ with this program. If not, see . #include #include -#include #include static GMainLoop * mainloop = NULL; -static gchar * value2string (const GValue * value, int depth); - -static gchar * -strv_dumper(const GValue * value) -{ - gchar ** strv = (gchar **)g_value_get_boxed(value); - - gchar * joined = g_strjoinv("\", \"", strv); - gchar * retval = g_strdup_printf("[\"%s\"]", joined); - g_free(joined); - return retval; -} - -typedef struct _collection_iterator_t collection_iterator_t; -struct _collection_iterator_t { - gchar * space; - GPtrArray * array; - gboolean first; - int depth; -}; - -static void -collection_iterate (const GValue * value, gpointer user_data) -{ - collection_iterator_t * iter = (collection_iterator_t *)user_data; - - gchar * str = value2string(value, iter->depth); - gchar * retval = NULL; - - if (iter->first) { - iter->first = FALSE; - retval = g_strdup_printf("\n%s%s", iter->space, str); - } else { - retval = g_strdup_printf(",\n%s%s", iter->space, str); - } - - g_ptr_array_add(iter->array, retval); - g_free(str); - - return; -} - -static gchar * -collection_dumper (const GValue * value, int depth) -{ - gchar * space = g_strnfill(depth, ' '); - GPtrArray * array = g_ptr_array_new_with_free_func(g_free); - - g_ptr_array_add(array, g_strdup("[")); - - collection_iterator_t iter; - iter.space = space; - iter.array = array; - iter.first = TRUE; - iter.depth = depth + 2; - - dbus_g_type_collection_value_iterate(value, collection_iterate, &iter); - - g_ptr_array_add(array, g_strdup_printf("\n%s]", space)); - - g_free(space); - - gchar * retstr = NULL; - if (array->len == 3) { - retstr = g_strdup_printf("[%s]", ((gchar *)array->pdata[1]) + depth + 1/*for newline*/); - } else { - retstr = g_strjoinv(NULL, (gchar **)array->pdata); - } - - g_ptr_array_free(array, TRUE); - - return retstr; -} - -static gchar * -value2string (const GValue * value, int depth) -{ - gchar * str = NULL; - - if (value == NULL) { - return g_strdup("(null)"); - } - - if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) { - str = collection_dumper(value, depth); - } else if (G_VALUE_TYPE(value) == G_TYPE_STRV) { - str = strv_dumper(value); - } else if (G_VALUE_TYPE(value) == G_TYPE_BOOLEAN) { - if (g_value_get_boolean(value)) { - str = g_strdup("true"); - } else { - str = g_strdup("false"); - } - } else { - str = g_strdup_value_contents(value); - } - - return str; -} - static gint list_str_cmp (gconstpointer a, gconstpointer b) { @@ -151,10 +49,11 @@ print_menuitem (DbusmenuMenuitem * item, int depth) GList * properties = g_list_sort(properties_raw, list_str_cmp); GList * property; for (property = properties; property != NULL; property = g_list_next(property)) { - const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data); - gchar * str = value2string(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2 /*quotes*/ + 2 /*: */); + GVariant * variant = dbusmenu_menuitem_property_get_variant(item, (gchar *)property->data); + gchar * str = g_variant_print(variant, FALSE); g_print(",\n%s\"%s\": %s", space, (gchar *)property->data, str); g_free(str); + g_variant_unref(variant); } g_list_free(properties); @@ -350,39 +249,46 @@ static gchar * dbusobject = NULL; static gboolean init_dbus_vars_from_window(Window window) { - DBusGConnection *connection; GError *error; - DBusGProxy *proxy; + GDBusProxy *proxy; error = NULL; - connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - if (connection == NULL) { - g_printerr("Failed to open connection to bus: %s\n", error->message); + + proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.ayatana.AppMenu.Registrar", + "/org/ayatana/AppMenu/Registrar", + "org.ayatana.AppMenu.Registrar", + NULL, + &error); + if (error != NULL) { + g_warning("Unable to get registrar proxy: %s", error->message); g_error_free(error); return FALSE; } - proxy = dbus_g_proxy_new_for_name (connection, - "org.ayatana.AppMenu.Registrar", - "/org/ayatana/AppMenu/Registrar", - "org.ayatana.AppMenu.Registrar"); - error = NULL; - if (!dbus_g_proxy_call (proxy, "GetMenuForWindow", &error, - G_TYPE_UINT, window, G_TYPE_INVALID, - G_TYPE_STRING, &dbusname, DBUS_TYPE_G_OBJECT_PATH, &dbusobject, G_TYPE_INVALID)) - { - g_printerr("ERROR: %s\n", error->message); + GVariant * retval; + + retval = g_dbus_proxy_call_sync(proxy, + "GetMenuForWindow", + g_variant_new("u", window), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to call 'GetMenuForWindow' on registrar: %s", error->message); g_error_free(error); - g_object_unref(proxy); return FALSE; } - if (!g_strcmp0(dbusobject, "/")) { - return FALSE; - } + g_variant_get(retval, "so", &dbusname, &dbusobject); - g_object_unref (proxy); + g_variant_unref(retval); + g_object_unref(proxy); return TRUE; } -- cgit v1.2.3 From f39b7fe067855d42dd79300d2d283b02eef48a03 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 16:25:52 -0600 Subject: Switch the internal hash table to be variant and implement the set and get functions. Also TODOs around other needed changes. --- libdbusmenu-glib/menuitem.c | 80 ++++++++++++++++++++++++++++++++++++++------- libdbusmenu-glib/menuitem.h | 2 +- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 80d9df4..28a711a 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -271,15 +271,12 @@ g_value_transform_STRING_INT (const GValue * in, GValue * out) static gint menuitem_next_id = 1; -/* A small little function to both clear the insides of a - value as well as the memory it itself uses. */ +/* Make the unref function match the prototype need for the + hashtable destructor */ static void -_g_value_free (gpointer data) +_g_variant_unref (gpointer data) { - if (data == NULL) return; - GValue * value = (GValue*)data; - g_value_unset(value); - g_free(data); + g_variant_unref((GVariant *)data); return; } @@ -295,7 +292,7 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->id = -1; priv->children = NULL; - priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free); + priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref); priv->root = FALSE; priv->realized = FALSE; @@ -919,6 +916,7 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c GValue val = {0}; g_value_init(&val, G_TYPE_STRING); g_value_set_static_string(&val, value); + /* TODO: Switch to use variant */ return dbusmenu_menuitem_property_set_value(mi, property, &val); } @@ -943,6 +941,7 @@ dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * proper GValue val = {0}; g_value_init(&val, G_TYPE_BOOLEAN); g_value_set_boolean(&val, value); + /* TODO: Switch to use variant */ return dbusmenu_menuitem_property_set_value(mi, property, &val); } @@ -967,11 +966,12 @@ dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * propert GValue val = {0}; g_value_init(&val, G_TYPE_INT); g_value_set_int(&val, value); + /* TODO: Switch to use variant */ return dbusmenu_menuitem_property_set_value(mi, property, &val); } /** - dbusmenu_menuitem_property_set: + dbusmenu_menuitem_property_set_value: @mi: The #DbusmenuMenuitem to set the property on. @property: Name of the property to set. @value: The value of the property. @@ -988,6 +988,7 @@ dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * propert gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value) { + /* TODO: Switch to use variant */ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); g_return_val_if_fail(property != NULL, FALSE); g_return_val_if_fail(G_IS_VALUE(value), FALSE); @@ -1021,9 +1022,46 @@ dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * prope return TRUE; } +/** + 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, const GVariant * value) +dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value) { + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + g_return_val_if_fail(property != NULL, FALSE); + + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + gchar * lprop = g_strdup(property); + g_variant_ref(value); + + gboolean replaced = FALSE; + gpointer currentval = g_hash_table_lookup(priv->properties, lprop); + if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) { + g_hash_table_replace(priv->properties, lprop, value); + replaced = TRUE; + } + + /* NOTE: The actual value is invalid at this point + 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) { + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, value, TRUE); + } return FALSE; } @@ -1044,6 +1082,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) { + /* TODO: Switch to use variant */ const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return NULL; if (G_VALUE_TYPE(value) != G_TYPE_STRING) return NULL; @@ -1064,6 +1103,7 @@ dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property) { + /* TODO: Switch to use variant */ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); g_return_val_if_fail(property != NULL, NULL); @@ -1072,11 +1112,26 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, 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. +*/ GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property) { + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); + g_return_val_if_fail(property != NULL, NULL); - return NULL; + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + return (GVariant *)g_hash_table_lookup(priv->properties, property); } /** @@ -1092,6 +1147,7 @@ dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * pro gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) { + /* TODO: Switch to use variant */ const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return FALSE; if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) { @@ -1120,6 +1176,7 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) { + /* TODO: Switch to use variant */ const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return 0; if (G_VALUE_TYPE(value) != G_TYPE_INT) { @@ -1239,6 +1296,7 @@ dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) static void variant_helper (gpointer in_key, gpointer in_value, gpointer user_data) { + /* TODO: Switch to being a variant */ GValue vval = {0}; g_value_init(&vval, G_TYPE_VARIANT); diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 1dbad9d..438cdd1 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -189,7 +189,7 @@ DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); -gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, const GVariant * value); +gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value); gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); -- cgit v1.2.3 From 7352a7e71fbe842b9429bb5fcc6ab23e6578d4d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 17:22:59 -0600 Subject: Replacing the value based functions with variants instead of values. --- libdbusmenu-glib/menuitem.c | 81 +++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 28a711a..a9036f0 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -913,11 +913,8 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id) gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value) { - GValue val = {0}; - g_value_init(&val, G_TYPE_STRING); - g_value_set_static_string(&val, value); - /* TODO: Switch to use variant */ - return dbusmenu_menuitem_property_set_value(mi, property, &val); + GVariant * variant = g_variant_new("s", value); + return dbusmenu_menuitem_property_set_variant(mi, property, variant); } /** @@ -938,11 +935,8 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value) { - GValue val = {0}; - g_value_init(&val, G_TYPE_BOOLEAN); - g_value_set_boolean(&val, value); - /* TODO: Switch to use variant */ - return dbusmenu_menuitem_property_set_value(mi, property, &val); + GVariant * variant = g_variant_new("b", value); + return dbusmenu_menuitem_property_set_variant(mi, property, variant); } /** @@ -963,11 +957,8 @@ dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * proper gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value) { - GValue val = {0}; - g_value_init(&val, G_TYPE_INT); - g_value_set_int(&val, value); - /* TODO: Switch to use variant */ - return dbusmenu_menuitem_property_set_value(mi, property, &val); + GVariant * variant = g_variant_new("i", value); + return dbusmenu_menuitem_property_set_variant(mi, property, variant); } /** @@ -1082,11 +1073,10 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) { - /* TODO: Switch to use variant */ - const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); - if (value == NULL) return NULL; - if (G_VALUE_TYPE(value) != G_TYPE_STRING) return NULL; - return g_value_get_string(value); + GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property); + if (variant == NULL) return NULL; + if (!g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) return NULL; + return g_variant_get_string(variant, NULL); } /** @@ -1147,20 +1137,25 @@ dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * pro gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) { - /* TODO: Switch to use variant */ - const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); - if (value == NULL) return FALSE; - if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) { - if (g_value_type_transformable(G_VALUE_TYPE(value), G_TYPE_BOOLEAN)) { - GValue boolval = {0}; - g_value_init(&boolval, G_TYPE_BOOLEAN); - g_value_transform(value, &boolval); - return g_value_get_boolean(&boolval); + GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property); + if (variant == NULL) return FALSE; + + if (g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_BOOLEAN)) { + return g_variant_get_boolean(variant); + } + + if (!g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) { + const gchar * string = g_variant_get_string(variant, NULL); + + if (!g_strcmp0(string, "TRUE") || !g_strcmp0(string, "true") || !g_strcmp0(string, "True")) { + return TRUE; } else { return FALSE; } } - return g_value_get_boolean(value); + + g_warning("Property '%s' has been requested as an boolean but is not one.", property); + return FALSE; } /** @@ -1176,20 +1171,20 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) { - /* TODO: Switch to use variant */ - const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); - if (value == NULL) return 0; - if (G_VALUE_TYPE(value) != G_TYPE_INT) { - if (g_value_type_transformable(G_VALUE_TYPE(value), G_TYPE_INT)) { - GValue intval = {0}; - g_value_init(&intval, G_TYPE_INT); - g_value_transform(value, &intval); - return g_value_get_int(&intval); - } else { - return 0; - } + GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property); + if (variant == NULL) return 0; + + if (g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_INT32)) { + return g_variant_get_int32(variant); + } + + if (!g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) { + const gchar * string = g_variant_get_string(variant, NULL); + return atoi(string); } - return g_value_get_int(value); + + g_warning("Property '%s' has been requested as an int but is not one.", property); + return 0; } -- cgit v1.2.3 From 31034648055ad0fc3e022f43b3a3b3033972a008 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 20:06:31 -0600 Subject: Adding some deprectated flags for the value functions. --- libdbusmenu-glib/menuitem.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 438cdd1..77bca4b 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -188,12 +188,16 @@ DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id) DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); +#ifndef DBUSMENU_DISABLE_DEPRECATED gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); +#endif gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value); gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); +#ifndef DBUSMENU_DISABLE_DEPRECATED const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); +#endif GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); -- cgit v1.2.3 From 353802f51c23447bcc905767014dcc37b5b76e20 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 20:08:39 -0600 Subject: Adding deprecation comment to the documentation. --- libdbusmenu-glib/menuitem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index a9036f0..d5d4d26 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -975,6 +975,7 @@ dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * propert emitted by this function. Return value: A boolean representing if the property value was set. + Deprecated: Use dbusmenu_menuitem_property_set_variant() instead */ gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value) @@ -1089,6 +1090,7 @@ dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) exist. Return value: A GValue for the property. + Deprecated: Use dbusmenu_menuitem_property_get_variant() instead */ const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property) -- cgit v1.2.3 From 17af43e09f01979a4ab660bbd2a60d9212a8ef13 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 20:12:53 -0600 Subject: Removing the set_value and get_value functions from being used elsewhere in -glib --- libdbusmenu-glib/menuitem-proxy.c | 6 +++--- libdbusmenu-glib/server.c | 15 +++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/libdbusmenu-glib/menuitem-proxy.c b/libdbusmenu-glib/menuitem-proxy.c index 7acb541..68bdcc6 100644 --- a/libdbusmenu-glib/menuitem-proxy.c +++ b/libdbusmenu-glib/menuitem-proxy.c @@ -173,10 +173,10 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g /* Watches a property change and makes sure to put that value into our property list. */ static void -proxy_item_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, gpointer user_data) +proxy_item_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * variant, gpointer user_data) { DbusmenuMenuitemProxy * pmi = DBUSMENU_MENUITEM_PROXY(user_data); - dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(pmi), property, value); + dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(pmi), property, variant); return; } @@ -273,7 +273,7 @@ add_menuitem (DbusmenuMenuitemProxy * pmi, DbusmenuMenuitem * mi) GList * prop; for (prop = props; prop != NULL; prop = g_list_next(prop)) { gchar * prop_name = (gchar *)prop->data; - dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(pmi), prop_name, dbusmenu_menuitem_property_get_value(priv->mi, prop_name)); + dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(pmi), prop_name, dbusmenu_menuitem_property_get_variant(priv->mi, prop_name)); } g_list_free(props); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 63d237f..4fdd6f8 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -815,8 +815,8 @@ bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat return; } - const GValue * prop = dbusmenu_menuitem_property_get_value(mi, property); - if (prop == NULL) { + GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property); + if (variant == NULL) { g_dbus_method_invocation_return_error(invocation, error_quark(), INVALID_PROPERTY_NAME, @@ -826,16 +826,7 @@ bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat return; } - GValue vval = {0}; - g_value_init(&vval, G_TYPE_VARIANT); - - if (!g_value_transform(prop, &vval)) { - g_warning("Unable to convert property '%s' value from type '%s' to variant", property, G_VALUE_TYPE_NAME(prop)); - } - - g_dbus_method_invocation_return_value(invocation, g_value_get_variant(&vval)); - g_value_unset(&vval); - + g_dbus_method_invocation_return_value(invocation, variant); return; } -- cgit v1.2.3 From 153a249f1029171cfcf40cf34ccc5157ba791c20 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 20:37:01 -0600 Subject: Switching everything to start using variants... even ahead of GLib --- libdbusmenu-gtk/client.c | 71 ++++++++++++++++----------------------- libdbusmenu-gtk/genericmenuitem.c | 2 ++ 2 files changed, 31 insertions(+), 42 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 487971f..9dd18df 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -57,9 +57,9 @@ static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); -static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value); -static void process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value); -static void image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata); +static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); +static void process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); +static void image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant * invalue, gpointer userdata); /* GObject Stuff */ G_DEFINE_TYPE (DbusmenuGtkClient, dbusmenu_gtkclient, DBUSMENU_TYPE_CLIENT); @@ -283,10 +283,8 @@ static gboolean menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) { if (gtk_menu_item_get_submenu(gmi) == NULL) { - GValue value = {0}; - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, 0); - dbusmenu_menuitem_handle_event(mi, "clicked", &value, gtk_get_current_event_time()); + GVariant * variant = g_variant_new("i", 0); + dbusmenu_menuitem_handle_event(mi, "clicked", variant, gtk_get_current_event_time()); } else { /* TODO: We need to stop the display of the submenu until this callback returns. */ @@ -297,7 +295,7 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) /* Process the visible property */ static void -process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) +process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value) { gboolean val = TRUE; if (value != NULL) { @@ -314,7 +312,7 @@ process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) /* Process the sensitive property */ static void -process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) +process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value) { gboolean val = TRUE; if (value != NULL) { @@ -326,26 +324,21 @@ process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * valu /* Process the sensitive property */ static void -process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) +process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant) { if (!IS_GENERICMENUITEM(gmi)) return; - if (value == NULL) return; + if (variant == NULL) return; GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE; - GValue strvalue = {0}; - g_value_init(&strvalue, G_TYPE_STRING); - - if (value != NULL && g_value_transform(value, &strvalue)) { - const gchar * strval = g_value_get_string(&strvalue); + if (variant != NULL) { + const gchar * strval = g_variant_get_string(variant, NULL); if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_CHECK)) { type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_RADIO)) { type = GENERICMENUITEM_CHECK_TYPE_RADIO; } - - g_value_unset(&strvalue); } genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type); @@ -355,17 +348,14 @@ process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * va /* Process the sensitive property */ static void -process_toggle_state (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) +process_toggle_state (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant) { if (!IS_GENERICMENUITEM(gmi)) return; GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED; - GValue intvalue = {0}; - g_value_init(&intvalue, G_TYPE_INT); - - if (value != NULL && g_value_transform(value, &intvalue)) { - int val = g_value_get_int(&intvalue); + if (variant != NULL) { + int val = g_variant_get_int32(variant); if (val == DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED) { state = GENERICMENUITEM_STATE_CHECKED; @@ -381,18 +371,18 @@ process_toggle_state (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * v /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void -menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkMenuItem * gmi) +menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * variant, GtkMenuItem * gmi) { if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_LABEL)) { - gtk_menu_item_set_label(gmi, g_value_get_string(value)); + gtk_menu_item_set_label(gmi, g_variant_get_string(variant, NULL)); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { - process_visible(mi, gmi, value); + process_visible(mi, gmi, variant); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_ENABLED)) { - process_sensitive(mi, gmi, value); + process_sensitive(mi, gmi, variant); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)) { - process_toggle_type(mi, gmi, value); + process_toggle_type(mi, gmi, variant); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)) { - process_toggle_state(mi, gmi, value); + process_toggle_state(mi, gmi, variant); } return; @@ -401,7 +391,7 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkMen /* Special handler for the shortcut changing as we need to have the client for that one to get the accel group. */ static void -menu_shortcut_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, DbusmenuGtkClient * client) +menu_shortcut_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, DbusmenuGtkClient * client) { if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { refresh_shortcut(client, mi); @@ -537,10 +527,10 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * g_object_weak_ref(G_OBJECT(item), destoryed_dbusmenuitem_cb, gmi); /* Check our set of props to see if any are set already */ - process_visible(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); - process_sensitive(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_ENABLED)); - process_toggle_type(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)); - process_toggle_state(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)); + process_visible(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); + process_sensitive(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_ENABLED)); + process_toggle_type(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)); + process_toggle_state(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)); refresh_shortcut(client, item); /* Oh, we're a child, let's deal with that */ @@ -705,11 +695,11 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu image_property_handle(newitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, - dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_NAME), + dbusmenu_menuitem_property_get_variant(newitem, DBUSMENU_MENUITEM_PROP_ICON_NAME), client); image_property_handle(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA, - dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA), + dbusmenu_menuitem_property_get_variant(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA), client); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, @@ -743,7 +733,7 @@ new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* This handler looks at property changes for items that are image menu items. */ static void -image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata) +image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer userdata) { /* We're only looking at these two properties here */ if (g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_NAME) != 0 && @@ -752,11 +742,8 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV } const gchar * value = NULL; + value = g_variant_get_string(variant, NULL); - if (invalue != NULL && G_VALUE_TYPE(invalue) == G_TYPE_STRING) { - value = g_value_get_string(invalue); - } - if (value == NULL || value[0] == '\0') { /* This means that we're unsetting a value. */ /* Try to use the other one */ diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 30b072f..cb76964 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -298,6 +298,8 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType return; } + g_value_unset(&value); + gtk_widget_queue_draw(GTK_WIDGET(item)); return; -- cgit v1.2.3 From 01603a653335b7f4f09120fc5e04f3273c36a8b5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 20:50:45 -0600 Subject: Change all the event handling to use GVariants --- libdbusmenu-glib/client-menuitem.c | 6 +++--- libdbusmenu-glib/client.c | 21 +++++++++------------ libdbusmenu-glib/client.h | 2 +- libdbusmenu-glib/menuitem-proxy.c | 6 +++--- libdbusmenu-glib/menuitem.c | 10 +++++----- libdbusmenu-glib/menuitem.h | 12 +++--------- libdbusmenu-glib/server.c | 11 ++++------- 7 files changed, 28 insertions(+), 40 deletions(-) diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index 9c21065..0f14b85 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -45,7 +45,7 @@ static void dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *kl static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self); static void dbusmenu_client_menuitem_dispose (GObject *object); static void dbusmenu_client_menuitem_finalize (GObject *object); -static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); +static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); static void send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM); @@ -102,10 +102,10 @@ dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client) /* Passes the event signal on through the client. */ static void -handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) +handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp) { DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); - dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, value, timestamp); + dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, variant, timestamp); return; } diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7c90fa6..6f16eb2 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -112,7 +112,7 @@ struct _event_data_t { DbusmenuClient * client; DbusmenuMenuitem * menuitem; gchar * event; - GValue data; + GVariant * variant; guint timestamp; }; @@ -1189,9 +1189,9 @@ menuitem_call_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) g_warning("Unable to call event '%s' on menu item %d: %s", edata->event, dbusmenu_menuitem_get_id(edata->menuitem), error->message); } - g_signal_emit(edata->client, signals[EVENT_RESULT], 0, edata->menuitem, edata->event, &edata->data, edata->timestamp, error, TRUE); + g_signal_emit(edata->client, signals[EVENT_RESULT], 0, edata->menuitem, edata->event, edata->variant, edata->timestamp, error, TRUE); - g_value_unset(&edata->data); + g_variant_unref(edata->variant); g_free(edata->event); g_object_unref(edata->menuitem); g_free(edata); @@ -1207,7 +1207,7 @@ menuitem_call_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) /* Sends the event over DBus to the server on the other side of the bus. */ void -dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp) +dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, GVariant * variant, guint timestamp) { g_return_if_fail(DBUSMENU_IS_CLIENT(client)); g_return_if_fail(id >= 0); @@ -1220,11 +1220,8 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name return; } - if (value == NULL) { - GValue internalval = {0}; - g_value_init(&internalval, G_TYPE_INT); - g_value_set_int(&internalval, 0); - value = &internalval; + if (variant == NULL) { + variant = g_variant_new("i", 0); } event_data_t * edata = g_new0(event_data_t, 1); @@ -1232,13 +1229,13 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name edata->menuitem = mi; g_object_ref(edata->menuitem); edata->event = g_strdup(name); - g_value_init(&edata->data, G_VALUE_TYPE(value)); - g_value_copy(value, &edata->data); edata->timestamp = timestamp; + edata->variant = variant; + g_variant_ref(variant); g_dbus_proxy_call(priv->menuproxy, "Event", - g_variant_new("isvu", id, name, value, timestamp), + g_variant_new("isvu", id, name, variant, timestamp), G_DBUS_CALL_FLAGS_NONE, 1000, /* timeout */ NULL, /* cancellable */ diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 32813d9..3a3a988 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -122,7 +122,7 @@ gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, void dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, - const GValue * value, + GVariant * variant, guint timestamp); void dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, diff --git a/libdbusmenu-glib/menuitem-proxy.c b/libdbusmenu-glib/menuitem-proxy.c index 68bdcc6..1d97c4c 100644 --- a/libdbusmenu-glib/menuitem-proxy.c +++ b/libdbusmenu-glib/menuitem-proxy.c @@ -56,7 +56,7 @@ static void dbusmenu_menuitem_proxy_dispose (GObject *object); static void dbusmenu_menuitem_proxy_finalize (GObject *object); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); -static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); +static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp); static void add_menuitem (DbusmenuMenuitemProxy * pmi, DbusmenuMenuitem * mi); static void remove_menuitem (DbusmenuMenuitemProxy * pmi); @@ -162,12 +162,12 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Takes the event and passes it along to the item that we're playing proxy for. */ static void -handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) +handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp) { g_return_if_fail(DBUSMENU_IS_MENUITEM_PROXY(mi)); DbusmenuMenuitemProxyPrivate * priv = DBUSMENU_MENUITEM_PROXY_GET_PRIVATE(mi); g_return_if_fail(priv->mi != NULL); - return dbusmenu_menuitem_handle_event(priv->mi, name, value, timestamp); + return dbusmenu_menuitem_handle_event(priv->mi, name, variant, timestamp); } /* Watches a property change and makes sure to put that value diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d5d4d26..643321a 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -94,7 +94,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, const GValue * value, guint timestamp); +static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); static void send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); /* GObject stuff */ @@ -377,7 +377,7 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Handles the activate event if it is sent. */ static void -handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) +handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp) { if (g_strcmp0(name, "clicked") == 0) { g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, timestamp, TRUE); @@ -1445,7 +1445,7 @@ 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 - @value: A value that could be set for the event + @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 @@ -1461,7 +1461,7 @@ dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem reason not to. */ void -dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) +dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp) { g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); #ifdef MASSIVEDEBUGGING @@ -1470,7 +1470,7 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); if (class->handle_event != NULL) { - return class->handle_event(mi, name, value, timestamp); + return class->handle_event(mi, name, variant, timestamp); } return; } diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 77bca4b..9158f3e 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -145,7 +145,7 @@ struct _DbusmenuMenuitemClass GObjectClass parent_class; /* Signals */ - void (*property_changed) (gchar * property, GValue * value); + void (*property_changed) (gchar * property, GVariant * value); void (*item_activated) (guint timestamp); void (*child_added) (DbusmenuMenuitem * child, guint position); void (*child_removed) (DbusmenuMenuitem * child); @@ -154,7 +154,7 @@ struct _DbusmenuMenuitemClass /* Virtual functions */ dbusmenu_menuitem_buildxml_slot_t buildxml; - void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); + 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); void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data); @@ -188,16 +188,10 @@ DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id) DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); -#ifndef DBUSMENU_DISABLE_DEPRECATED -gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); -#endif gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value); gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); -#ifndef DBUSMENU_DISABLE_DEPRECATED -const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); -#endif GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); @@ -210,7 +204,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, const GValue * value, guint timestamp); +void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, 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); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4fdd6f8..bd5c2ac 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -935,7 +935,7 @@ typedef struct _idle_event_t idle_event_t; struct _idle_event_t { DbusmenuMenuitem * mi; gchar * eventid; - GValue data; + GVariant * variant; guint timestamp; }; @@ -946,11 +946,11 @@ event_local_handler (gpointer user_data) { idle_event_t * data = (idle_event_t *)user_data; - dbusmenu_menuitem_handle_event(data->mi, data->eventid, &data->data, data->timestamp); + dbusmenu_menuitem_handle_event(data->mi, data->eventid, data->variant, data->timestamp); g_object_unref(data->mi); g_free(data->eventid); - g_value_unset(&data->data); + g_variant_unref(data->variant); g_free(data); return FALSE; } @@ -977,10 +977,7 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i g_object_ref(event_data->mi); event_data->eventid = g_strdup(g_variant_get_string(g_variant_get_child_value(params, 1), NULL)); event_data->timestamp = g_variant_get_uint32(g_variant_get_child_value(params, 3)); - - /* TODO: Need to figure out converting a variant to a value */ - g_value_init(&(event_data->data), G_TYPE_INT); - g_value_set_int(&(event_data->data), 0); + event_data->variant = g_variant_get_child_value(params, 2); g_timeout_add(0, event_local_handler, event_data); -- cgit v1.2.3 From a1c3b2b9d5ad5a8444a972a04faff1e70f9b2ad7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 20:55:15 -0600 Subject: Dropping set and get value --- libdbusmenu-glib/menuitem.c | 77 --------------------------------------------- 1 file changed, 77 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 643321a..47fbdf9 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -961,59 +961,6 @@ dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * propert return dbusmenu_menuitem_property_set_variant(mi, property, variant); } -/** - dbusmenu_menuitem_property_set_value: - @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. - Deprecated: Use dbusmenu_menuitem_property_set_variant() instead -*/ -gboolean -dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value) -{ - /* TODO: Switch to use variant */ - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); - g_return_val_if_fail(property != NULL, FALSE); - g_return_val_if_fail(G_IS_VALUE(value), FALSE); - - DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - /* g_debug("Setting a property. ID: %d Prop: %s Value: %s", priv->id, property, value); */ - - #if 0 - gpointer lookup = g_hash_table_lookup(priv->properties, property); - if (g_strcmp0((gchar *)lookup, value) == 0) { - /* The value is the same as the value currently in the - table so we don't really care. Just say everything's okay */ - return TRUE; - } - #endif - - gchar * lprop = g_strdup(property); - GValue * lval = g_new0(GValue, 1); - g_value_init(lval, G_VALUE_TYPE(value)); - g_value_copy(value, lval); - - g_hash_table_replace(priv->properties, lprop, lval); - #ifdef MASSIVEDEBUGGING - gchar * valstr = g_strdup_value_contents(lval); - g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(valstr, 50) < 25 ? valstr : ""); - g_free(valstr); - #endif - - g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, lval, TRUE); - - return TRUE; -} - /** dbusmenu_menuitem_property_set_variant: @mi: The #DbusmenuMenuitem to set the property on. @@ -1080,30 +1027,6 @@ dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) return g_variant_get_string(variant, NULL); } -/** - dbusmenu_menuitem_property_get_value: - @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 GValue for the property. - Deprecated: Use dbusmenu_menuitem_property_get_variant() instead -*/ -const GValue * -dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property) -{ - /* TODO: Switch to use variant */ - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); - g_return_val_if_fail(property != NULL, NULL); - - DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - - return (const GValue *)g_hash_table_lookup(priv->properties, property); -} - /** dbusmenu_menuitem_property_get_variant: @mi: The #DbusmenuMenuitem to look for the property on. -- cgit v1.2.3 From 050ca49a1179f4c04d6c175e8005e8516fd80654 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 21:07:51 -0600 Subject: Variants in sending over the server connection --- libdbusmenu-glib/client.h | 2 +- libdbusmenu-glib/server.c | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 3a3a988..1ae89fa 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -84,7 +84,7 @@ struct _DbusmenuClientClass { void (*root_changed) (DbusmenuMenuitem * newroot); void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); - void (*event_result) (DbusmenuMenuitem * item, gchar * event, GValue * data, guint timestamp, GError * error); + void (*event_result) (DbusmenuMenuitem * item, gchar * event, GVariant * data, guint timestamp, GError * error); /*< Private >*/ void (*reserved1) (void); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index bd5c2ac..1005e1b 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -141,7 +141,7 @@ static GVariant * bus_get_prop (GDBusConnection * connection, gpointer user_data); static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, - GValue * value, + GVariant * variant, DbusmenuServer * server); static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, @@ -619,21 +619,13 @@ layout_update_signal (DbusmenuServer * server) } static void -menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server) +menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * variant, DbusmenuServer * server) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, value, TRUE); + 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) { - GValue variantval = {0}; - g_value_init(&variantval, G_TYPE_VARIANT); - - if (!g_value_transform(value, &variantval)) { - g_warning("Unable to convert property '%s' of type %s to a variant", property, G_VALUE_TYPE_NAME(value)); - } - GVariant * variant = g_value_get_variant(&variantval); - g_dbus_connection_emit_signal(priv->bus, NULL, priv->dbusobject, @@ -641,8 +633,6 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * val "ItemPropertyUpdated", g_variant_new("(isv)", dbusmenu_menuitem_get_id(mi), property, variant), NULL); - - g_value_unset(&variantval); } return; } -- cgit v1.2.3 From 0dea1bb0779b8cddbf631ee80f76d13aa8920ec5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 21:11:40 -0600 Subject: Fixing our signals and marshallers for them as well --- libdbusmenu-glib/client-marshal.list | 2 +- libdbusmenu-glib/client.c | 4 ++-- libdbusmenu-glib/menuitem-marshal.list | 2 +- libdbusmenu-glib/menuitem.c | 4 ++-- libdbusmenu-glib/server-marshal.list | 2 +- libdbusmenu-glib/server.c | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list index 2e14491..866dfa8 100644 --- a/libdbusmenu-glib/client-marshal.list +++ b/libdbusmenu-glib/client-marshal.list @@ -1,2 +1,2 @@ VOID: OBJECT, UINT -VOID: OBJECT, STRING, POINTER, UINT, POINTER +VOID: OBJECT, STRING, VARIANT, UINT, POINTER diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 6f16eb2..629a1be 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -245,8 +245,8 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (DbusmenuClientClass, event_result), NULL, NULL, - _dbusmenu_client_marshal_VOID__OBJECT_STRING_POINTER_UINT_POINTER, - G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_POINTER); + _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); 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/menuitem-marshal.list b/libdbusmenu-glib/menuitem-marshal.list index 654c91b..e3cb272 100644 --- a/libdbusmenu-glib/menuitem-marshal.list +++ b/libdbusmenu-glib/menuitem-marshal.list @@ -1,4 +1,4 @@ -VOID: STRING, POINTER +VOID: STRING, VARIANT VOID: OBJECT, UINT, UINT VOID: OBJECT, UINT VOID: OBJECT diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 47fbdf9..24196fc 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -129,8 +129,8 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuMenuitemClass, property_changed), NULL, NULL, - _dbusmenu_menuitem_marshal_VOID__STRING_POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER); + _dbusmenu_menuitem_marshal_VOID__STRING_VARIANT, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT); /** DbusmenuMenuitem::item-activated: @arg0: The #DbusmenuMenuitem object. diff --git a/libdbusmenu-glib/server-marshal.list b/libdbusmenu-glib/server-marshal.list index 0d68c4e..08ebf93 100644 --- a/libdbusmenu-glib/server-marshal.list +++ b/libdbusmenu-glib/server-marshal.list @@ -1,3 +1,3 @@ -VOID: INT, STRING, POINTER +VOID: INT, STRING, VARIANT VOID: UINT, INT VOID: INT, UINT diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 1005e1b..8d5c558 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -216,8 +216,8 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuServerClass, id_prop_update), NULL, NULL, - _dbusmenu_server_marshal_VOID__INT_STRING_POINTER, - G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE); + _dbusmenu_server_marshal_VOID__INT_STRING_VARIANT, + G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_VARIANT); /** DbusmenuServer::id-update: @arg0: The #DbusmenuServer emitting the signal. -- cgit v1.2.3 From aabdcffea6b311cda25ad2937466d65fc4e36381 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Nov 2010 21:23:27 -0600 Subject: Moving the GValues over to GVariant --- tests/test-glib-events-client.c | 14 ++++++-------- tests/test-glib-objects.c | 24 ++++++++++++------------ tests/test-glib-proxy-client.c | 7 +++---- tests/test-gtk-objects.c | 4 ++-- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/tests/test-glib-events-client.c b/tests/test-glib-events-client.c index 97d5caf..ee0b821 100644 --- a/tests/test-glib-events-client.c +++ b/tests/test-glib-events-client.c @@ -35,7 +35,7 @@ static gboolean passed = TRUE; static gboolean first = TRUE; static void -event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GValue * data, guint timestamp, GError * error, gpointer user_data) +event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GVariant * data, guint timestamp, GError * error, gpointer user_data) { g_debug("Event status: %s", error == NULL ? "Sent" : "Error"); @@ -46,8 +46,8 @@ event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GV return; } - if (g_value_get_int(data) != DATA_VALUE) { - g_debug("Data value pass fail got: %d", g_value_get_int(data)); + if (g_variant_get_int32(data) != DATA_VALUE) { + g_debug("Data value pass fail got: %d", g_variant_get_int32(data)); passed = FALSE; g_main_loop_quit(mainloop); return; @@ -96,11 +96,9 @@ layout_updated (DbusmenuClient * client, gpointer user_data) return; } - GValue data = {0}; - g_value_init(&data, G_TYPE_INT); - g_value_set_int(&data, DATA_VALUE); - - dbusmenu_menuitem_handle_event(menuroot, "clicked", &data, TIMESTAMP_VALUE); + GVariant * data = g_variant_new("i", DATA_VALUE); + dbusmenu_menuitem_handle_event(menuroot, "clicked", data, TIMESTAMP_VALUE); + g_variant_unref(data); return; } diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 1d4f673..c6a8dc9 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -77,17 +77,17 @@ test_object_menuitem_props_string (void) { /* Build a menu item */ DbusmenuMenuitem * item = dbusmenu_menuitem_new(); - const GValue * out = NULL; + GVariant * out = NULL; /* Test to make sure it's a happy object */ g_assert(item != NULL); /* Setting a string */ dbusmenu_menuitem_property_set(item, "string", "value"); - out = dbusmenu_menuitem_property_get_value(item, "string"); + out = dbusmenu_menuitem_property_get_variant(item, "string"); g_assert(out != NULL); - g_assert(G_VALUE_TYPE(out) == G_TYPE_STRING); - g_assert(!g_strcmp0(g_value_get_string(out), "value")); + g_assert(g_variant_type_equal(g_variant_get_type(out), G_VARIANT_TYPE_STRING)); + g_assert(!g_strcmp0(g_variant_get_string(out, NULL), "value")); g_assert(!g_strcmp0(dbusmenu_menuitem_property_get(item, "string"), "value")); g_object_unref(item); @@ -101,17 +101,17 @@ test_object_menuitem_props_int (void) { /* Build a menu item */ DbusmenuMenuitem * item = dbusmenu_menuitem_new(); - const GValue * out = NULL; + GVariant * out = NULL; /* Test to make sure it's a happy object */ g_assert(item != NULL); /* Setting a string */ dbusmenu_menuitem_property_set_int(item, "int", 12345); - out = dbusmenu_menuitem_property_get_value(item, "int"); + out = dbusmenu_menuitem_property_get_variant(item, "int"); g_assert(out != NULL); - g_assert(G_VALUE_TYPE(out) == G_TYPE_INT); - g_assert(g_value_get_int(out) == 12345); + g_assert(g_variant_type_equal(g_variant_get_type(out), G_VARIANT_TYPE_INT32)); + g_assert(g_variant_get_int32(out) == 12345); g_assert(dbusmenu_menuitem_property_get_int(item, "int") == 12345); g_object_unref(item); @@ -125,17 +125,17 @@ test_object_menuitem_props_bool (void) { /* Build a menu item */ DbusmenuMenuitem * item = dbusmenu_menuitem_new(); - const GValue * out = NULL; + GVariant * out = NULL; /* Test to make sure it's a happy object */ g_assert(item != NULL); /* Setting a string */ dbusmenu_menuitem_property_set_bool(item, "boolean", TRUE); - out = dbusmenu_menuitem_property_get_value(item, "boolean"); + out = dbusmenu_menuitem_property_get_variant(item, "boolean"); g_assert(out != NULL); - g_assert(G_VALUE_TYPE(out) == G_TYPE_BOOLEAN); - g_assert(g_value_get_boolean(out)); + g_assert(g_variant_type_equal(g_variant_get_type(out), G_VARIANT_TYPE_BOOLEAN)); + g_assert(g_variant_get_boolean(out)); g_assert(dbusmenu_menuitem_property_get_int(item, "boolean")); g_object_unref(item); diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index 0ae2e20..2e1e2d2 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -150,10 +150,9 @@ layout_verify_timer (gpointer data) g_main_loop_quit(mainloop); } - GValue value = {0}; - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, 0); - dbusmenu_menuitem_handle_event(menuroot, "clicked", &value, layouton); + GVariant * value = g_variant_new("i", 0); + dbusmenu_menuitem_handle_event(menuroot, "clicked", value, layouton); + g_variant_unref(value); return FALSE; } diff --git a/tests/test-gtk-objects.c b/tests/test-gtk-objects.c index 726f404..30fc022 100644 --- a/tests/test-gtk-objects.c +++ b/tests/test-gtk-objects.c @@ -72,7 +72,7 @@ test_object_prop_pixbuf (void) g_object_unref(pixbuf); /* Check to see if it's set */ - const GValue * val = dbusmenu_menuitem_property_get_value(item, prop_name); + GVariant * val = dbusmenu_menuitem_property_get_variant(item, prop_name); g_assert(val != NULL); /* Get the pixbuf back! */ @@ -105,7 +105,7 @@ test_object_prop_shortcut (void) g_assert(success); /* Check for value */ - const GValue * val = dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SHORTCUT); + GVariant * val = dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_SHORTCUT); g_assert(val != NULL); /* Check to see if we love it */ -- cgit v1.2.3 From cd8988a8dfd03a585860eabfc97c0e0aa8c6e912 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 08:59:50 -0600 Subject: Switching to variants in the property changed signals --- tests/test-glib-objects.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index c6a8dc9..6afbe57 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -177,7 +177,7 @@ test_object_menuitem_props_swap (void) /* A helper to put a value into a pointer for eval. */ static void -test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * property, GValue * value, GValue ** out) +test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * property, GVariant * value, GVariant ** out) { if (!g_strcmp0(property, "swapper")) { *out = value; @@ -194,7 +194,7 @@ test_object_menuitem_props_signals (void) { /* Build a menu item */ DbusmenuMenuitem * item = dbusmenu_menuitem_new(); - GValue * out = NULL; + GVariant * out = NULL; /* Test to make sure it's a happy object */ g_assert(item != NULL); @@ -205,25 +205,25 @@ test_object_menuitem_props_signals (void) /* Setting a boolean */ dbusmenu_menuitem_property_set_bool(item, "swapper", TRUE); g_assert(out != NULL); - g_assert(g_value_get_boolean(out)); + g_assert(g_variant_get_boolean(out)); out = NULL; /* Setting a int */ dbusmenu_menuitem_property_set_int(item, "swapper", 5432); g_assert(out != NULL); - g_assert(g_value_get_int(out) == 5432); + g_assert(g_variant_get_int32(out) == 5432); out = NULL; /* Setting a string */ dbusmenu_menuitem_property_set(item, "swapper", "mystring"); g_assert(out != NULL); - g_assert(!g_strcmp0(g_value_get_string(out), "mystring")); + g_assert(!g_strcmp0(g_variant_get_string(out, NULL), "mystring")); out = NULL; /* Setting a boolean */ dbusmenu_menuitem_property_set_bool(item, "swapper", FALSE); g_assert(out != NULL); - g_assert(!g_value_get_boolean(out)); + g_assert(!g_variant_get_boolean(out)); out = NULL; g_object_unref(item); -- cgit v1.2.3 From 24ecbd99558d2ae2a65ad7407f547c55ffed2e4e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 09:00:45 -0600 Subject: This now generates a warning, but unfortunately gtester fails that. --- tests/test-glib-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 6afbe57..7143814 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -136,7 +136,7 @@ test_object_menuitem_props_bool (void) g_assert(out != NULL); g_assert(g_variant_type_equal(g_variant_get_type(out), G_VARIANT_TYPE_BOOLEAN)); g_assert(g_variant_get_boolean(out)); - g_assert(dbusmenu_menuitem_property_get_int(item, "boolean")); + /* g_assert(dbusmenu_menuitem_property_get_int(item, "boolean") == 0); */ g_object_unref(item); -- cgit v1.2.3 From 1c2d3ea075efd02f8a655c45c89ec132d0e76828 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 09:01:18 -0600 Subject: Eh, bad truth checking here. --- libdbusmenu-glib/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 24196fc..3b5011b 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1069,7 +1069,7 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper return g_variant_get_boolean(variant); } - if (!g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) { + if (g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) { const gchar * string = g_variant_get_string(variant, NULL); if (!g_strcmp0(string, "TRUE") || !g_strcmp0(string, "true") || !g_strcmp0(string, "True")) { @@ -1103,7 +1103,7 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert return g_variant_get_int32(variant); } - if (!g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) { + if (g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE_STRING)) { const gchar * string = g_variant_get_string(variant, NULL); return atoi(string); } -- cgit v1.2.3 From f5227142593335542a62a8c7d3c122b8013cfead Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 09:07:38 -0600 Subject: Fixing signal emition when there are new entries added to the property table. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 3b5011b..d9fbf25 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -998,7 +998,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 (currentval == NULL || replaced) { g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, value, TRUE); } -- cgit v1.2.3 From 72da1b32a6a834de66496fbaa6f3c57cac4d4d7a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 09:13:19 -0600 Subject: Fixing our use of GVariant type strings --- libdbusmenu-glib/client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 629a1be..e0ab2d4 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1221,7 +1221,7 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name } if (variant == NULL) { - variant = g_variant_new("i", 0); + variant = g_variant_new("(i)", 0); } event_data_t * edata = g_new0(event_data_t, 1); @@ -1235,7 +1235,7 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name g_dbus_proxy_call(priv->menuproxy, "Event", - g_variant_new("isvu", id, name, variant, timestamp), + g_variant_new("(isvu)", id, name, variant, timestamp), G_DBUS_CALL_FLAGS_NONE, 1000, /* timeout */ NULL, /* cancellable */ @@ -1303,7 +1303,7 @@ dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb)( g_dbus_proxy_call(priv->menuproxy, "AboutToShow", - g_variant_new("i", id), + g_variant_new("(i)", id), G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ NULL, /* cancellable */ @@ -1540,7 +1540,7 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) guint rev; gchar * xml; - g_variant_get(params, "us", &rev, &xml); + g_variant_get(params, "(us)", &rev, &xml); g_variant_unref(params); DbusmenuClient * client = DBUSMENU_CLIENT(data); @@ -1593,7 +1593,7 @@ update_layout (DbusmenuClient * client) g_dbus_proxy_call(priv->menuproxy, "GetLayout", - g_variant_new("i", 0), /* root */ + g_variant_new("(i)", 0), /* root */ G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ priv->layoutcall, /* cancellable */ -- cgit v1.2.3 From acf4557c9c5b7d87c5b7b0f1df2b535a6dd11671 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 09:22:24 -0600 Subject: Wow, I've learned a lot about better ways to do this :) --- 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 8d5c558..fd507a2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -852,21 +852,21 @@ static void bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); - GVariantIter * ids = NULL; - g_variant_get_child(params, 0, "ai", &ids); + GVariantIter ids; + g_variant_iter_init(&ids, params); - GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("a(ia{sv})")); + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ia{sv})")); - GVariant * id; - while ((id = g_variant_iter_next_value(ids)) != NULL) { - DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, g_variant_get_int32(id)); + guint id; + while (g_variant_iter_next(&ids, "i", &id)) { + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) continue; - g_variant_builder_add(builder, "ia{sv}", g_variant_get_int32(id), dbusmenu_menuitem_properties_variant(mi)); + g_variant_builder_add(&builder, "ia{sv}", id, dbusmenu_menuitem_properties_variant(mi)); } - GVariant * ret = g_variant_builder_end(builder); - g_variant_builder_unref(builder); + GVariant * ret = g_variant_builder_end(&builder); g_dbus_method_invocation_return_value(invocation, ret); -- cgit v1.2.3 From 62a03e300af33f8ad306c08337f33f59fb8511b3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 11:54:41 -0600 Subject: Cleaning up the building of the property requests --- libdbusmenu-glib/client.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index e0ab2d4..1e6e479 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -579,13 +579,26 @@ get_properties_idle (gpointer user_data) } /* Build up an ID list to pass */ - GArray * idlist = g_array_new(FALSE, FALSE, sizeof(gint)); + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); + gint i; for (i = 0; i < priv->delayed_property_listeners->len; i++) { - g_array_append_val(idlist, g_array_index(priv->delayed_property_listeners, properties_listener_t, i).id); + g_variant_builder_add(&builder, "i", g_array_index(priv->delayed_property_listeners, properties_listener_t, i).id); } - GVariant * variant_params = g_variant_new("a(s)", (const gchar **)priv->delayed_property_list->data); + GVariant * variant_ids = g_variant_builder_end(&builder); + + /* Build up a prop list to pass */ + g_variant_builder_init(&builder, g_variant_type_new("as")); + GVariant * variant_props = g_variant_builder_end(&builder); + + /* Combine them into a value for the parameter */ + g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value(&builder, variant_ids); + g_variant_builder_add_value(&builder, variant_props); + GVariant * variant_params = g_variant_builder_end(&builder); + g_dbus_proxy_call(priv->menuproxy, "GetGroupProperties", variant_params, @@ -595,9 +608,6 @@ get_properties_idle (gpointer user_data) get_properties_callback, priv->delayed_property_listeners); - /* Free ID List */ - g_array_free(idlist, TRUE); - /* Free properties */ gchar ** dataregion = (gchar **)g_array_free(priv->delayed_property_list, FALSE); if (dataregion != NULL) { -- cgit v1.2.3 From 233eec5d073b4101b3100598c60e497cf5075586 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 13:21:36 -0600 Subject: Cleaning up the building of a properties variant --- libdbusmenu-glib/menuitem.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d9fbf25..66dfb66 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1216,18 +1216,7 @@ dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) static void variant_helper (gpointer in_key, gpointer in_value, gpointer user_data) { - /* TODO: Switch to being a variant */ - GValue vval = {0}; - g_value_init(&vval, G_TYPE_VARIANT); - - if (!g_value_transform((GValue *)in_value, &vval)) { - g_warning("Unable to convert property '%s' of type '%s'", (gchar *)in_key, G_VALUE_TYPE_NAME(in_value)); - return; - } - - g_variant_builder_add((GVariantBuilder *)user_data, "{sv}", in_key, g_value_get_variant(&vval)); - g_value_unset(&vval); - + g_variant_builder_add((GVariantBuilder *)user_data, "sv", in_key, in_value); return; } @@ -1247,12 +1236,17 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi) DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + GVariant * final_variant = NULL; + + if (g_hash_table_size(priv->properties) > 0) { + GVariantBuilder builder; + g_variant_builder_init(&builder, g_variant_type_new("a{sv}")); - g_hash_table_foreach(priv->properties, variant_helper, builder); + g_hash_table_foreach(priv->properties, variant_helper, &builder); + + final_variant = g_variant_builder_end(&builder); + } - GVariant * final_variant = g_variant_builder_end(builder); - g_variant_builder_unref(builder); return final_variant; } -- cgit v1.2.3 From 9ef52be8a4da1fc981e09079e142d2aea9793567 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 13:49:27 -0600 Subject: Setting up the proper builders and interfaces for group_properties --- libdbusmenu-glib/server.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index fd507a2..b48b28a 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -851,25 +851,43 @@ bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvoc static void bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { + g_debug("Begin group prop: %s", g_variant_print(params, TRUE)); DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); GVariantIter ids; - g_variant_iter_init(&ids, params); + g_variant_iter_init(&ids, g_variant_get_child_value(params, 0)); GVariantBuilder builder; - g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ia{sv})")); + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); - guint id; + gint id; while (g_variant_iter_next(&ids, "i", &id)) { DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) continue; - g_variant_builder_add(&builder, "ia{sv}", id, dbusmenu_menuitem_properties_variant(mi)); + 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); + + if (props == NULL) { + props = g_variant_parse(g_variant_type_new("a{sv}"), "{}", NULL, NULL, NULL); + } + + g_variant_builder_add_value(&wbuilder, props); + GVariant * mi_data = g_variant_builder_end(&wbuilder); + + g_variant_builder_add_value(&builder, mi_data); } GVariant * ret = g_variant_builder_end(&builder); - g_dbus_method_invocation_return_value(invocation, ret); + g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value(&builder, ret); + GVariant * final = g_variant_builder_end(&builder); + g_dbus_method_invocation_return_value(invocation, final); + + g_debug("End group prop"); return; } @@ -907,13 +925,17 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat return; } - GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("a(ia{sv})")); - GList * children = dbusmenu_menuitem_get_children(mi); - g_list_foreach(children, serialize_menuitem, builder); + GVariant * ret = NULL; + + if (children != NULL) { + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); - GVariant * ret = g_variant_builder_end(builder); - g_variant_builder_unref(builder); + g_list_foreach(children, serialize_menuitem, &builder); + + ret = g_variant_builder_end(&builder); + } g_dbus_method_invocation_return_value(invocation, ret); return; -- cgit v1.2.3 From b5e90b0ce320570a1338e84538874a02c5dd5753 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 13:49:50 -0600 Subject: Break out of the tuple --- 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 1e6e479..696f7c5 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -517,7 +517,7 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) } /* Callback all the folks we can find */ - GVariantIter * iter = g_variant_iter_new(params); + GVariantIter * iter = g_variant_iter_new(g_variant_get_child_value(params, 0)); GVariant * child; while ((child = g_variant_iter_next_value(iter)) != NULL) { if (g_strcmp0(g_variant_get_type_string(child), "ia(sv)") != 0) { -- cgit v1.2.3 From c35642d47693feb5dce6fc6b5e3e5f258b255982 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 13:52:24 -0600 Subject: Correcting type check --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 696f7c5..50df570 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -520,8 +520,8 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) GVariantIter * iter = g_variant_iter_new(g_variant_get_child_value(params, 0)); GVariant * child; while ((child = g_variant_iter_next_value(iter)) != NULL) { - if (g_strcmp0(g_variant_get_type_string(child), "ia(sv)") != 0) { - g_warning("Properties return signature is not 'ia(sv)' it is '%s'", g_variant_get_type_string(child)); + if (g_strcmp0(g_variant_get_type_string(child), "(ia{sv})") != 0) { + g_warning("Properties return signature is not '(ia{sv})' it is '%s'", g_variant_get_type_string(child)); continue; } -- cgit v1.2.3 From 9cae52b3bfcb2b86c6be362ddb03afb2ddd78e6d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 13:52:46 -0600 Subject: Oops, drop debug messages --- libdbusmenu-glib/server.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index b48b28a..d9a3c64 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -851,7 +851,6 @@ bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvoc static void bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { - g_debug("Begin group prop: %s", g_variant_print(params, TRUE)); DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); GVariantIter ids; g_variant_iter_init(&ids, g_variant_get_child_value(params, 0)); @@ -887,7 +886,6 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho g_dbus_method_invocation_return_value(invocation, final); - g_debug("End group prop"); return; } -- cgit v1.2.3 From fc235b7eb4e7102b349fb711991e5c121a1c7a7d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 14:40:58 -0600 Subject: Switching to not put into a tuple --- 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 50df570..0479548 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1231,7 +1231,7 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name } if (variant == NULL) { - variant = g_variant_new("(i)", 0); + variant = g_variant_new_int32(0); } event_data_t * edata = g_new0(event_data_t, 1); -- cgit v1.2.3 From c40c70c6cee475ab2bf8d7e6e5804571b25deb9c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 14:41:27 -0600 Subject: Protect against NULL params (which they should be) but not leak just in case --- libdbusmenu-glib/client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 0479548..cb3377a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1206,10 +1206,12 @@ menuitem_call_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) g_object_unref(edata->menuitem); g_free(edata); - if (error != NULL) { + if (G_UNLIKELY(error != NULL)) { g_error_free(error); } - g_variant_unref(params); + if (G_LIKELY(params != NULL)) { + g_variant_unref(params); + } return; } -- cgit v1.2.3 From 7380d970e2187af5e153250565d784abbe469bc8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 14:42:25 -0600 Subject: Don't unref the variant we send and fix up debugging messages. --- tests/test-glib-events-client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-glib-events-client.c b/tests/test-glib-events-client.c index ee0b821..2cc5439 100644 --- a/tests/test-glib-events-client.c +++ b/tests/test-glib-events-client.c @@ -47,7 +47,7 @@ event_status (DbusmenuClient * client, DbusmenuMenuitem * item, gchar * name, GV } if (g_variant_get_int32(data) != DATA_VALUE) { - g_debug("Data value pass fail got: %d", g_variant_get_int32(data)); + g_debug("Data value pass fail got: %d", g_variant_get_int32(g_variant_get_child_value(data, 0))); passed = FALSE; g_main_loop_quit(mainloop); return; @@ -96,9 +96,8 @@ layout_updated (DbusmenuClient * client, gpointer user_data) return; } - GVariant * data = g_variant_new("i", DATA_VALUE); + GVariant * data = g_variant_new_int32(DATA_VALUE); dbusmenu_menuitem_handle_event(menuroot, "clicked", data, TIMESTAMP_VALUE); - g_variant_unref(data); return; } @@ -126,6 +125,7 @@ main (int argc, char ** argv) mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_debug("Main loop complete"); g_object_unref(G_OBJECT(client)); if (passed) { -- cgit v1.2.3 From c80c863e4191fe9b5f20e65887db7c2e278b13fb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 14:45:15 -0600 Subject: Oops, messed up the format here. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 66dfb66..2f42704 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1216,7 +1216,7 @@ 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); + g_variant_builder_add((GVariantBuilder *)user_data, "{sv}", in_key, in_value); return; } -- cgit v1.2.3 From caea84d6056d1ab1dd9744af5be9ac05670be8f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 15:06:29 -0600 Subject: We can't really be autostarting as we don't know enough to make a judgement there. --- 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 cb3377a..f283a78 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -929,7 +929,7 @@ build_proxies (DbusmenuClient * client) priv->menuproxy_cancel = g_cancellable_new(); g_dbus_proxy_new(priv->session_bus, - G_DBUS_PROXY_FLAGS_NONE, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, dbusmenu_interface_info, priv->dbus_name, priv->dbus_object, -- cgit v1.2.3 From c2953a6f3f099db35bc79415f2bb0c767f325c44 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 15:07:00 -0600 Subject: Using the name assigned instead of a default. --- tests/test-glib-proxy-proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-proxy-proxy.c b/tests/test-glib-proxy-proxy.c index b9db620..38c59e2 100644 --- a/tests/test-glib-proxy-proxy.c +++ b/tests/test-glib-proxy-proxy.c @@ -63,7 +63,7 @@ main (int argc, char ** argv) g_debug("I am '%s' and I'm proxying '%s'", whoami, myproxy); g_bus_own_name(G_BUS_TYPE_SESSION, - "org.dbusmenu.test", + whoami, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus, NULL, -- cgit v1.2.3 From a3482b774239b10010fd9d9734333afc09c1beb8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Nov 2010 16:47:30 -0600 Subject: Protecting the invalid root a little bit more and returning a better error. --- libdbusmenu-glib/server.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index d9a3c64..c738537 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -83,6 +83,7 @@ enum { INVALID_PROPERTY_NAME, UNKNOWN_DBUS_ERROR, NOT_IMPLEMENTED, + NO_VALID_LAYOUT, LAST_ERROR }; @@ -756,7 +757,11 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio dbusmenu_menuitem_buildxml(priv->root, xmlarray); } } else { - DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent); + DbusmenuMenuitem * item = NULL; + if (priv->root != NULL) { + item = dbusmenu_menuitem_find_id(priv->root, parent); + } + if (item == NULL) { g_dbus_method_invocation_return_error(invocation, error_quark(), @@ -790,6 +795,14 @@ static void bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + if (priv->root == NULL) { + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NO_VALID_LAYOUT, + "There currently isn't a layout in this server"); + return; + } gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); const gchar * property = g_variant_get_string(g_variant_get_child_value(params, 1), NULL); @@ -826,6 +839,14 @@ bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvoc { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + if (priv->root == NULL) { + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NO_VALID_LAYOUT, + "There currently isn't a layout in this server"); + return; + } + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); @@ -852,6 +873,22 @@ static void bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + if (priv->root == NULL) { + GVariant * idlist = g_variant_get_child_value(params, 0); + if (g_variant_n_children(idlist) == 1 && g_variant_get_int32(g_variant_get_child_value(idlist, 0)) == 0) { + GVariant * final = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, NULL); + g_dbus_method_invocation_return_value(invocation, final); + return; + } + + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NO_VALID_LAYOUT, + "There currently isn't a layout in this server"); + return; + } + GVariantIter ids; g_variant_iter_init(&ids, g_variant_get_child_value(params, 0)); @@ -912,6 +949,15 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); + + if (priv->root == NULL) { + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NO_VALID_LAYOUT, + "There currently isn't a layout in this server"); + return; + } + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { @@ -970,6 +1016,15 @@ static void bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + if (priv->root == NULL) { + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NO_VALID_LAYOUT, + "There currently isn't a layout in this server"); + return; + } + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); @@ -1000,6 +1055,15 @@ static void bus_about_to_show (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + if (priv->root == NULL) { + g_dbus_method_invocation_return_error(invocation, + error_quark(), + NO_VALID_LAYOUT, + "There currently isn't a layout in this server"); + return; + } + gint id = g_variant_get_int32(g_variant_get_child_value(params, 0)); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); -- cgit v1.2.3 From f5cc5d5809ac1bc60ed2f90424e95988f84194db Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Nov 2010 17:08:52 -0600 Subject: Wrong bus name --- tests/test-glib-proxy-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index c12a584..a5dfd4e 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -123,7 +123,7 @@ main (int argc, char ** argv) g_type_init(); g_bus_own_name(G_BUS_TYPE_SESSION, - "org.dbusmenu.test", + "test.proxy.server", G_BUS_NAME_OWNER_FLAGS_NONE, on_bus, NULL, -- cgit v1.2.3 From 92d355c18217c43c358ccda9d6eb74af9eed30d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Nov 2010 13:21:52 -0600 Subject: Protect update_layout from not having an owner yet, and if we get one immediately call update_layout() --- libdbusmenu-glib/client.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f283a78..be35dde 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -978,7 +978,11 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_signal_connect(priv->menuproxy, "g-signal", G_CALLBACK(menuproxy_signal_cb), client); g_signal_connect(priv->menuproxy, "notify::g-name-owner", G_CALLBACK(menuproxy_name_changed_cb), client); - update_layout(client); + gchar * name_owner = g_dbus_proxy_get_name_owner(priv->menuproxy); + if (name_owner != NULL) { + update_layout(client); + g_free(name_owner); + } return; } @@ -996,6 +1000,7 @@ menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_d proxy_destroyed(G_OBJECT(proxy), user_data); } else { g_free(owner); + update_layout(DBUSMENU_CLIENT(user_data)); } return; @@ -1597,6 +1602,12 @@ update_layout (DbusmenuClient * client) return; } + gchar * name_owner = g_dbus_proxy_get_name_owner(priv->menuproxy); + if (name_owner == NULL) { + return; + } + g_free(name_owner); + if (priv->layoutcall != NULL) { return; } -- cgit v1.2.3 From c661b1ec2a71c8e78e72db7f72116a205059e292 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Nov 2010 13:22:40 -0600 Subject: Adding another todo about the properties... need to do that everywhere --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index be35dde..a918f43 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -591,6 +591,7 @@ get_properties_idle (gpointer user_data) /* Build up a prop list to pass */ g_variant_builder_init(&builder, g_variant_type_new("as")); + /* TODO: need to use delayed property list here */ GVariant * variant_props = g_variant_builder_end(&builder); /* Combine them into a value for the parameter */ -- cgit v1.2.3 From e811c4f900545d37aecdf18cbce911ff23e684cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Nov 2010 13:27:13 -0600 Subject: Exporting the server before getting the name --- tests/test-glib-proxy-proxy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test-glib-proxy-proxy.c b/tests/test-glib-proxy-proxy.c index 38c59e2..8a17ead 100644 --- a/tests/test-glib-proxy-proxy.c +++ b/tests/test-glib-proxy-proxy.c @@ -31,7 +31,6 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer user static void on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - server = dbusmenu_server_new("/org/test"); client = dbusmenu_client_new((gchar *)user_data, "/org/test"); g_signal_connect(client, DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), server); @@ -62,6 +61,8 @@ main (int argc, char ** argv) g_debug("I am '%s' and I'm proxying '%s'", whoami, myproxy); + server = dbusmenu_server_new("/org/test"); + g_bus_own_name(G_BUS_TYPE_SESSION, whoami, G_BUS_NAME_OWNER_FLAGS_NONE, -- cgit v1.2.3 From 784522930b3102d044000ef1dd6af1854548e3be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Nov 2010 14:40:11 -0600 Subject: Convert json loader to using variants --- tests/json-loader.c | 107 ++++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index 9e67666..4d3e6aa 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -21,67 +21,75 @@ with this program. If not, see . #include "json-loader.h" -static GValue * -node2value (JsonNode * node) +static GVariant * node2variant (JsonNode * node); + +static void +array_foreach (JsonArray * array, guint index, JsonNode * node, gpointer user_data) +{ + GVariantBuilder * builder = (GVariantBuilder *)user_data; + GVariant * variant = node2variant(node); + if (variant != NULL) { + g_variant_builder_add_value(builder, variant); + } + return; +} + +static void +object_foreach (JsonObject * array, const gchar * member, JsonNode * node, gpointer user_data) +{ + GVariantBuilder * builder = (GVariantBuilder *)user_data; + GVariant * variant = node2variant(node); + if (variant != NULL) { + g_variant_builder_add(builder, "{sv}", member, variant); + } + return; +} + +static GVariant * +node2variant (JsonNode * node) { if (node == NULL) { return NULL; } - GValue * value = g_new0(GValue, 1); - if (JSON_NODE_TYPE(node) == JSON_NODE_VALUE) { - json_node_get_value(node, value); - return value; + switch (json_node_get_value_type(node)) { + case G_TYPE_INT: + case G_TYPE_INT64: + return g_variant_new_int64(json_node_get_int(node)); + case G_TYPE_DOUBLE: + case G_TYPE_FLOAT: + return g_variant_new_double(json_node_get_double(node)); + case G_TYPE_BOOLEAN: + return g_variant_new_boolean(json_node_get_boolean(node)); + case G_TYPE_STRING: + return g_variant_new_string(json_node_get_string(node)); + default: + g_assert_not_reached(); + } } if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) { + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); + JsonArray * array = json_node_get_array(node); - JsonNode * first = json_array_get_element(array, 0); - - if (JSON_NODE_TYPE(first) == JSON_NODE_VALUE) { - GValue subvalue = {0}; - json_node_get_value(first, &subvalue); - - if (G_VALUE_TYPE(&subvalue) == G_TYPE_STRING) { - GArray * garray = g_array_sized_new(TRUE, TRUE, sizeof(gchar *), json_array_get_length(array)); - g_value_init(value, G_TYPE_STRV); - g_value_take_boxed(value, garray->data); - - int i; - for (i = 0; i < json_array_get_length(array); i++) { - const gchar * str = json_node_get_string(json_array_get_element(array, i)); - gchar * dupstr = g_strdup(str); - g_array_append_val(garray, dupstr); - } - - g_array_free(garray, FALSE); - } else { - GValueArray * varray = g_value_array_new(json_array_get_length(array)); - g_value_init(value, G_TYPE_VALUE_ARRAY); - g_value_take_boxed(value, varray); - - g_value_array_append(varray, &subvalue); - g_value_unset(&subvalue); - - int i; - for (i = 1; i < json_array_get_length(array); i++) { - json_node_get_value(first, &subvalue); - g_value_array_append(varray, &subvalue); - g_value_unset(&subvalue); - } - } + json_array_foreach_element(array, array_foreach, &builder); - } else { - g_warning("Complex array not supported"); - } + return g_variant_builder_end(&builder); } if (JSON_NODE_TYPE(node) == JSON_NODE_OBJECT) { - g_warning("Object nodes are a problem"); + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE_DICTIONARY); + + JsonObject * array = json_node_get_object(node); + json_object_foreach_member(array, object_foreach, &builder); + + return g_variant_builder_end(&builder); } - return value; + return NULL; } static void @@ -97,12 +105,11 @@ set_props (DbusmenuMenuitem * mi, JsonObject * node) if (!g_strcmp0(member, "submenu")) { continue; } JsonNode * lnode = json_object_get_member(node, member); - GValue * value = node2value(lnode); + GVariant * variant = node2variant(lnode); - if (value != NULL) { - dbusmenu_menuitem_property_set_value(mi, member, value); - g_value_unset(value); - g_free(value); + if (variant != NULL) { + dbusmenu_menuitem_property_set_variant(mi, member, variant); + g_variant_unref(variant); } } -- cgit v1.2.3 From a7a7326946d7dd13c0ef5027d460662dfd04b1e7 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Tue, 23 Nov 2010 15:53:10 -0500 Subject: Set more scanner flags to get the namespace right --- libdbusmenu-glib/Makefile.am | 12 +++++++++--- libdbusmenu-gtk/Makefile.am | 14 ++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 0a6513f..3d031dd 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -114,9 +114,13 @@ menuitem-marshal.c: $(srcdir)/menuitem-marshal.list -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = \ - --add-include-path=$(srcdir) \ - $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ + --add-include-path=$(srcdir) \ + $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) \ + --symbol-prefix=dbusmenu \ + --identifier-prefix=Dbusmenu \ + --pkg-export=dbusmenu-glib + INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) if HAVE_INTROSPECTION @@ -131,6 +135,8 @@ Dbusmenu_Glib_0_2_gir_LIBS = libdbusmenu-glib.la Dbusmenu_Glib_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) Dbusmenu_Glib_0_2_gir_NAMESPACE = Dbusmenu Dbusmenu_Glib_0_2_gir_VERSION = Glib-0.2 +Dbusmenu_Glib_0_2_gir_PACKAGES = dbusmenu-glib +Dbusmenu_Glib_0_2_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) INTROSPECTION_GIRS += Dbusmenu-Glib-0.2.gir diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b30cac9..bb3890e 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -66,10 +66,12 @@ pkgconfigdir = $(libdir)/pkgconfig -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = \ - --add-include-path=$(srcdir) \ +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ - $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) + $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) \ + --symbol-prefix=dbusmenu \ + --identifier-prefix=DbusmenuGtk \ + --pkg-export=dbusmenu-gtk$(VER) INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_builddir)/libdbusmenu-glib if HAVE_INTROSPECTION @@ -80,16 +82,20 @@ DbusmenuGtk$(VER)-0.2.gir: libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_INCLUDES = \ GObject-2.0 \ $(GTKGIR) \ - Dbusmenu-Glib-0.2 + Dbusmenu-Glib-0.2 DbusmenuGtk_0_2_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) +DbusmenuGtk_0_2_gir_NAMESPACE = DbusmenuGtk$(VER) +DbusmenuGtk_0_2_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS) # We duplicate these for the same reason as libdbusmenu_gtk3includedir above DbusmenuGtk3_0_2_gir_INCLUDES = $(DbusmenuGtk_0_2_gir_INCLUDES) DbusmenuGtk3_0_2_gir_CFLAGS = $(DbusmenuGtk_0_2_gir_CFLAGS) DbusmenuGtk3_0_2_gir_LIBS = $(DbusmenuGtk_0_2_gir_LIBS) DbusmenuGtk3_0_2_gir_FILES = $(DbusmenuGtk_0_2_gir_FILES) +DbusmenuGtk3_0_2_gir_NAMESPACE = $(DbusmenuGtk_0_2_gir_NAMESPACE) +DbusmenuGtk3_0_2_gir_SCANNERFLAGS = $(DbusmenuGtk_0_2_gir_SCANNERFLAGS) INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.2.gir -- cgit v1.2.3 From d9d3f22c4240b7b1479299167e8ce184fd0c5f3a Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Tue, 23 Nov 2010 16:06:30 -0500 Subject: Cleaned up the scanner flags some --- libdbusmenu-glib/Makefile.am | 3 +-- libdbusmenu-gtk/Makefile.am | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 3d031dd..adf4607 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -118,8 +118,7 @@ INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --add-include-path=$(srcdir) \ $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) \ --symbol-prefix=dbusmenu \ - --identifier-prefix=Dbusmenu \ - --pkg-export=dbusmenu-glib + --identifier-prefix=Dbusmenu INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index bb3890e..e539aa6 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -70,8 +70,7 @@ INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) \ --symbol-prefix=dbusmenu \ - --identifier-prefix=DbusmenuGtk \ - --pkg-export=dbusmenu-gtk$(VER) + --identifier-prefix=DbusmenuGtk INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_builddir)/libdbusmenu-glib if HAVE_INTROSPECTION @@ -88,6 +87,7 @@ DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) DbusmenuGtk_0_2_gir_NAMESPACE = DbusmenuGtk$(VER) DbusmenuGtk_0_2_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS) +DbusmenuGtk_0_2_gir_PACKAGES = dbusmenu-gtk$(VER) # We duplicate these for the same reason as libdbusmenu_gtk3includedir above DbusmenuGtk3_0_2_gir_INCLUDES = $(DbusmenuGtk_0_2_gir_INCLUDES) @@ -96,6 +96,7 @@ DbusmenuGtk3_0_2_gir_LIBS = $(DbusmenuGtk_0_2_gir_LIBS) DbusmenuGtk3_0_2_gir_FILES = $(DbusmenuGtk_0_2_gir_FILES) DbusmenuGtk3_0_2_gir_NAMESPACE = $(DbusmenuGtk_0_2_gir_NAMESPACE) DbusmenuGtk3_0_2_gir_SCANNERFLAGS = $(DbusmenuGtk_0_2_gir_SCANNERFLAGS) +DbusmenuGtk3_0_2_gir_PACKAGES = $(DbusmenuGtk_0_2_gir_PACKAGES) INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.2.gir -- cgit v1.2.3 From 12cc39d7e2b62a279377448338a0e8af384494f2 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Tue, 23 Nov 2010 16:19:52 -0500 Subject: Make gtk-doc building gtk3 friendly --- docs/libdbusmenu-gtk/reference/Makefile.am | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/libdbusmenu-gtk/reference/Makefile.am b/docs/libdbusmenu-gtk/reference/Makefile.am index ec1bd28..6e44a23 100644 --- a/docs/libdbusmenu-gtk/reference/Makefile.am +++ b/docs/libdbusmenu-gtk/reference/Makefile.am @@ -1,5 +1,12 @@ + ## Process this file with automake to produce Makefile.in +if USE_GTK3 +VER=3 +else +VER= +endif + # We require automake 1.6 at least. AUTOMAKE_OPTIONS = 1.6 @@ -9,7 +16,7 @@ AUTOMAKE_OPTIONS = 1.6 # of using the various options. # The name of the module, e.g. 'glib'. -DOC_MODULE=libdbusmenu-gtk +DOC_MODULE=libdbusmenu-gtk$(VER) # The top-level SGML file. You can change this if you want to. DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml @@ -68,7 +75,7 @@ expand_content_files= # e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) INCLUDES=-I$(top_srcdir) $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUGTK_CFLAGS) -GTKDOC_LIBS=$(top_builddir)/libdbusmenu-gtk/libdbusmenu-gtk.la +GTKDOC_LIBS=$(top_builddir)/libdbusmenu-gtk/libdbusmenu-gtk$(VER).la $(DBUSMENUGLIB_LIBS) $(DBUSMENUGTK_LIBS) # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.local.make -- cgit v1.2.3 From a25b09998a7b9a5a1e012b8648fdf135fdc59d33 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Nov 2010 16:55:43 -0600 Subject: Uhm, there's no explaination for this one. Duh. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 2f42704..ad6472b 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1002,7 +1002,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, value, TRUE); } - return FALSE; + return TRUE; } /** -- cgit v1.2.3 From 02be403c32b2228b33d3cb122750889f165419d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Nov 2010 17:00:14 -0600 Subject: Fixing up variant usage --- libdbusmenu-gtk/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 9c1cfd2..64913be 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -200,9 +200,9 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, const gchar * keyname = gdk_keyval_name(key); g_array_append_val(array, keyname); - GVariant * inside = g_variant_new("as", array->data); + GVariant * inside = g_variant_new_strv((const gchar * const *)array->data, -1); GVariantBuilder builder; - g_variant_builder_init(&builder, G_VARIANT_TYPE("av")); + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); g_variant_builder_add_value(&builder, inside); GVariant * outsidevariant = g_variant_builder_end(&builder); -- cgit v1.2.3 From 938856dbb01aa4e583ce637a0cd34846f8a940fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 12:32:35 -0600 Subject: Switching shortcut parsing code to more directly use the variant iterator --- libdbusmenu-gtk/menuitem.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 64913be..872142b 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -297,35 +297,28 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke return; } - GVariantIter outsideiter; - GVariant * inside; - g_variant_iter_init(&outsideiter, wrapper); - - while(g_variant_iter_next(&outsideiter, "v", &inside)) { - GVariantIter insideiter; - g_variant_iter_init(&insideiter, inside); - gchar * string; - - while(g_variant_iter_next(&insideiter, "s", &string)) { - if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { - *modifier |= GDK_CONTROL_MASK; - } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { - *modifier |= GDK_MOD1_MASK; - } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { - *modifier |= GDK_SHIFT_MASK; - } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { - *modifier |= GDK_SUPER_MASK; - } else { - GdkModifierType tempmod; - gtk_accelerator_parse(string, key, &tempmod); - } - - g_free(string); + g_debug("Data: %s", g_variant_print(wrapper, TRUE)); + + GVariantIter iter; + g_variant_iter_init(&iter, g_variant_get_child_value(wrapper, 0)); + gchar * string; + + while(g_variant_iter_next(&iter, "s", &string)) { + if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { + *modifier |= GDK_CONTROL_MASK; + } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { + *modifier |= GDK_MOD1_MASK; + } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SHIFT) == 0) { + *modifier |= GDK_SHIFT_MASK; + } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_SUPER) == 0) { + *modifier |= GDK_SUPER_MASK; + } else { + GdkModifierType tempmod; + gtk_accelerator_parse(string, key, &tempmod); } - g_variant_unref(inside); + g_free(string); } - g_variant_unref(wrapper); return; } -- cgit v1.2.3 From de467d6d1231f6490b79ddc5a4966b9521fe8536 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 13:40:07 -0600 Subject: Wrong signal name --- 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 c738537..a2e0849 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -694,7 +694,7 @@ menuitem_shown (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server) NULL, priv->dbusobject, DBUSMENU_INTERFACE, - "ItemPropertyUpdated", + "ItemActivationRequested", g_variant_new("(iu)", dbusmenu_menuitem_get_id(mi), timestamp), NULL); } -- cgit v1.2.3 From 611103533121afca614b2e531c5e113a1a6122f4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 14:21:03 -0600 Subject: Protect against NULL variants to remove warnings --- libdbusmenu-gtk/client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 9dd18df..77935c5 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -374,7 +374,7 @@ static void menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * variant, GtkMenuItem * gmi) { if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_LABEL)) { - gtk_menu_item_set_label(gmi, g_variant_get_string(variant, NULL)); + gtk_menu_item_set_label(gmi, variant == NULL ? NULL : g_variant_get_string(variant, NULL)); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { process_visible(mi, gmi, variant); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_ENABLED)) { @@ -742,7 +742,9 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant } const gchar * value = NULL; - value = g_variant_get_string(variant, NULL); + if (variant != NULL) { + value = g_variant_get_string(variant, NULL); + } if (value == NULL || value[0] == '\0') { /* This means that we're unsetting a value. */ -- cgit v1.2.3 From 7a12cdc4cff4546e911bd49fd38b6fed9511d506 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 15:19:31 -0600 Subject: Fixing the return values from AboutToShow --- libdbusmenu-glib/client.c | 2 +- libdbusmenu-glib/server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a918f43..7a6d87c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1287,7 +1287,7 @@ about_to_show_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) /* Note: we're just ensuring only the callback gets called */ need_update = FALSE; } else { - g_variant_get(params, "b", &need_update); + g_variant_get(params, "(b)", &need_update); g_variant_unref(params); } diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index a2e0849..4202299 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1078,7 +1078,7 @@ bus_about_to_show (DbusmenuServer * server, GVariant * params, GDBusMethodInvoca /* GTK+ does not support about-to-show concept for now */ g_dbus_method_invocation_return_value(invocation, - g_variant_new_boolean(FALSE)); + g_variant_new("(b)", FALSE)); return; } -- cgit v1.2.3 From d3c6ef0dd116d888e3415b2566d7bf14cb6ee0b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 15:19:52 -0600 Subject: Ensuring all returns are protected by tuples for GDBus --- libdbusmenu-glib/server.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4202299..8a10715 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -551,6 +551,7 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar return dbusmenu_method_table[i].func(DBUSMENU_SERVER(user_data), params, invocation); } else { /* If we have a null function we're responding but nothing else. */ + g_warning("Invalid function call for '%s' with parameters: %s", method, g_variant_print(params, TRUE)); g_dbus_method_invocation_return_value(invocation, NULL); return; } @@ -829,7 +830,7 @@ bus_get_property (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat return; } - g_dbus_method_invocation_return_value(invocation, variant); + g_dbus_method_invocation_return_value(invocation, g_variant_new("(v)", variant)); return; } @@ -862,7 +863,7 @@ bus_get_properties (DbusmenuServer * server, GVariant * params, GDBusMethodInvoc GVariant * dict = dbusmenu_menuitem_properties_variant(mi); - g_dbus_method_invocation_return_value(invocation, dict); + g_dbus_method_invocation_return_value(invocation, g_variant_new("(a{sv})", dict)); return; } @@ -978,7 +979,9 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat g_list_foreach(children, serialize_menuitem, &builder); - ret = g_variant_builder_end(&builder); + ret = g_variant_new("(a(ia{svg}))", g_variant_builder_end(&builder)); + } else { + ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, NULL); } g_dbus_method_invocation_return_value(invocation, ret); -- cgit v1.2.3 From e3097b569710d3cb8466f229571dc632decd1671 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 15:38:21 -0600 Subject: Switching to use the builder all the way for the strings instead of the GArray --- libdbusmenu-gtk/menuitem.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 872142b..1b8cab1 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -177,31 +177,26 @@ 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); - GArray * array = g_array_sized_new(TRUE, TRUE, sizeof(gchar *), 4); /* Four seems like the max we'd need, plus it's still small */ - - const gchar * control_val = DBUSMENU_MENUITEM_SHORTCUT_CONTROL; - const gchar * alt_val = DBUSMENU_MENUITEM_SHORTCUT_ALT; - const gchar * shift_val = DBUSMENU_MENUITEM_SHORTCUT_SHIFT; - const gchar * super_val = DBUSMENU_MENUITEM_SHORTCUT_SUPER; + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); if (modifier & GDK_CONTROL_MASK) { - g_array_append_val(array, control_val); + g_variant_builder_add(&builder, "s", DBUSMENU_MENUITEM_SHORTCUT_CONTROL); } if (modifier & GDK_MOD1_MASK) { - g_array_append_val(array, alt_val); + g_variant_builder_add(&builder, "s", DBUSMENU_MENUITEM_SHORTCUT_ALT); } if (modifier & GDK_SHIFT_MASK) { - g_array_append_val(array, shift_val); + g_variant_builder_add(&builder, "s", DBUSMENU_MENUITEM_SHORTCUT_SHIFT); } if (modifier & GDK_SUPER_MASK) { - g_array_append_val(array, super_val); + g_variant_builder_add(&builder, "s", DBUSMENU_MENUITEM_SHORTCUT_SUPER); } const gchar * keyname = gdk_keyval_name(key); - g_array_append_val(array, keyname); + g_variant_builder_add(&builder, "s", keyname); - GVariant * inside = g_variant_new_strv((const gchar * const *)array->data, -1); - GVariantBuilder builder; + GVariant * inside = g_variant_builder_end(&builder); g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); g_variant_builder_add_value(&builder, inside); GVariant * outsidevariant = g_variant_builder_end(&builder); -- cgit v1.2.3 From 675693fe90c242c4dc9d54d7d3ed34be49d931cc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 15:50:38 -0600 Subject: Ah, oops, we shouldn't unref these variants as they're kept in the hashtable, we have them as floating. --- libdbusmenu-gtk/menuitem.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 1b8cab1..2251efc 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -201,12 +201,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, g_variant_builder_add_value(&builder, inside); GVariant * outsidevariant = g_variant_builder_end(&builder); - dbusmenu_menuitem_property_set_variant(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, outsidevariant); - - g_variant_unref(outsidevariant); - g_variant_unref(inside); - - return TRUE; + return dbusmenu_menuitem_property_set_variant(menuitem, DBUSMENU_MENUITEM_PROP_SHORTCUT, outsidevariant); } /* Look at the closures in an accel group and find -- cgit v1.2.3 From 9231081151c71846010c1be75277a4cc0afc29e3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 29 Nov 2010 15:51:57 -0600 Subject: oops, forgot a debug message --- libdbusmenu-gtk/menuitem.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 2251efc..e27e6ff 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -287,8 +287,6 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke return; } - g_debug("Data: %s", g_variant_print(wrapper, TRUE)); - GVariantIter iter; g_variant_iter_init(&iter, g_variant_get_child_value(wrapper, 0)); gchar * string; -- cgit v1.2.3 From b953ca847127fcc9698b83dbfcb8f760b7b62b30 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 14:40:30 -0600 Subject: Removing the flush. It seems to be broken in GDBus and I can't fix it. --- libdbusmenu-glib/client.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7a6d87c..454e8bb 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -549,6 +549,7 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) for (i = 0; i < listeners->len; i++) { properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); if (!listener->replied) { + g_warning("Generating properties error for: %d", listener->id); if (localerror == NULL) { g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID"); } @@ -625,21 +626,6 @@ get_properties_idle (gpointer user_data) return FALSE; } -/* Report and error if we're unable to flush the connection, likely - to be a cause of some other issues. */ -static void -connection_flush_cb (GObject * object, GAsyncResult * result, gpointer user_data) -{ - GError * error = NULL; - - if (!g_dbus_connection_flush_finish(G_DBUS_CONNECTION(object), result, &error)) { - g_warning("Unable to flush DBus connection: %s", error->message); - g_error_free(error); - } - - return; -} - /* Forces a call out to start getting properties with the menu items that we have queued up already. */ static void @@ -656,12 +642,6 @@ get_properties_flush (DbusmenuClient * client) get_properties_idle(client); - /* I'm not sure this flush is necissary with GDBus running the - DBus connection in another thread. But, I don't think that - it'll hurt anything either, so I'm leaving it in. */ - g_return_if_fail(priv->session_bus != NULL); - g_dbus_connection_flush(priv->session_bus, NULL, connection_flush_cb, NULL); - return; } -- cgit v1.2.3 From cd6960896d1f3b6143737eadd53ba69561eba2a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 15:48:08 -0600 Subject: Changing the quoting so that the test passes --- tests/test-json-01.json | 1644 +++++++++++++++++++++++------------------------ 1 file changed, 822 insertions(+), 822 deletions(-) diff --git a/tests/test-json-01.json b/tests/test-json-01.json index 08e9112..b626d20 100644 --- a/tests/test-json-01.json +++ b/tests/test-json-01.json @@ -1,127 +1,127 @@ { "id": 0, - "children-display": "submenu", + "children-display": 'submenu', "submenu": [ { "id": 5, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "File", + "label": 'File', "visible": true, "submenu": [ { "id": 6, "enabled": true, - "label": "Quit", - "shortcut": [["Control", "q"]], + "label": 'Quit', + "shortcut": [['Control', 'q']], "visible": true }, { "id": 7, "enabled": true, - "label": "Close all", - "shortcut": [["Control", "Shift", "w"]], + "label": 'Close all', + "shortcut": [['Control', 'Shift', 'w']], "visible": true }, { "id": 8, "enabled": true, - "label": "Close", - "shortcut": [["Control", "w"]], + "label": 'Close', + "shortcut": [['Control', 'w']], "visible": true }, { "id": 9, - "type": "separator" + "type": 'separator' }, { "id": 10, "enabled": true, - "label": "Send by Email...", + "label": 'Send by Email...', "visible": true }, { "id": 11, "enabled": true, - "label": "Print...", - "shortcut": [["Control", "p"]], + "label": 'Print...', + "shortcut": [['Control', 'p']], "visible": true }, { "id": 12, "enabled": true, - "label": "Page Setup", + "label": 'Page Setup', "visible": true }, { "id": 13, - "type": "separator" + "type": 'separator' }, { "id": 14, "enabled": true, - "label": "Revert", + "label": 'Revert', "visible": true }, { "id": 15, "enabled": true, - "label": "Save as Template...", + "label": 'Save as Template...', "visible": true }, { "id": 16, "enabled": true, - "label": "Save a Copy...", + "label": 'Save a Copy...', "visible": true }, { "id": 17, "enabled": true, - "label": "Save As...", - "shortcut": [["Control", "Shift", "s"]], + "label": 'Save As...', + "shortcut": [['Control', 'Shift', 's']], "visible": true }, { "id": 18, "enabled": true, - "label": "Save", - "shortcut": [["Control", "s"]], + "label": 'Save', + "shortcut": [['Control', 's']], "visible": true }, { "id": 19, - "type": "separator" + "type": 'separator' }, { "id": 20, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Open Recent", + "label": 'Open Recent', "visible": true, "submenu": [ { "id": 21, "enabled": true, - "label": "Document History", + "label": 'Document History', "visible": true }, { "id": 22, - "type": "separator" + "type": 'separator' }, { "id": 23, "enabled": true, - "label": "giggity.jpg", - "shortcut": [["Control", "2"]], + "label": 'giggity.jpg', + "shortcut": [['Control', '2']], "visible": true }, { "id": 24, "enabled": true, - "label": "Icon Height.svg", - "shortcut": [["Control", "1"]], + "label": 'Icon Height.svg', + "shortcut": [['Control', '1']], "visible": true } ] @@ -129,150 +129,150 @@ { "id": 25, "enabled": true, - "label": "Open Location...", + "label": 'Open Location...', "visible": true }, { "id": 26, "enabled": true, - "label": "Open as Layers...", - "shortcut": [["Control", "Alt", "o"]], + "label": 'Open as Layers...', + "shortcut": [['Control', 'Alt', 'o']], "visible": true }, { "id": 27, "enabled": true, - "label": "Open...", - "shortcut": [["Control", "o"]], + "label": 'Open...', + "shortcut": [['Control', 'o']], "visible": true }, { "id": 28, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Create", + "label": 'Create', "visible": true, "submenu": [ { "id": 29, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Web Page Themes", + "label": 'Web Page Themes', "visible": true, "submenu": [ { "id": 30, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Classic.Gimp.Org", + "label": 'Classic.Gimp.Org', "visible": true, "submenu": [ { "id": 31, "enabled": true, - "label": "Tube Sub-Sub-Button Label...", + "label": 'Tube Sub-Sub-Button Label...', "visible": true }, { "id": 32, "enabled": true, - "label": "Tube Sub-Button Label...", + "label": 'Tube Sub-Button Label...', "visible": true }, { "id": 33, "enabled": true, - "label": "Tube Button Label...", + "label": 'Tube Button Label...', "visible": true }, { "id": 34, "enabled": true, - "label": "Small Header...", + "label": 'Small Header...', "visible": true }, { "id": 35, "enabled": true, - "label": "General Tube Labels...", + "label": 'General Tube Labels...', "visible": true }, { "id": 36, "enabled": true, - "label": "Big Header...", + "label": 'Big Header...', "visible": true } ] }, { "id": 37, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Beveled Pattern", + "label": 'Beveled Pattern', "visible": true, "submenu": [ { "id": 38, "enabled": true, - "label": "Hrule...", + "label": 'Hrule...', "visible": true }, { "id": 39, "enabled": true, - "label": "Heading...", + "label": 'Heading...', "visible": true }, { "id": 40, "enabled": true, - "label": "Button...", + "label": 'Button...', "visible": true }, { "id": 41, "enabled": true, - "label": "Bullet...", + "label": 'Bullet...', "visible": true }, { "id": 42, "enabled": true, - "label": "Arrow...", + "label": 'Arrow...', "visible": true } ] }, { "id": 43, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Alien Glow", + "label": 'Alien Glow', "visible": true, "submenu": [ { "id": 44, "enabled": true, - "label": "Hrule...", + "label": 'Hrule...', "visible": true }, { "id": 45, "enabled": true, - "label": "Button...", + "label": 'Button...', "visible": true }, { "id": 46, "enabled": true, - "label": "Bullet...", + "label": 'Bullet...', "visible": true }, { "id": 47, "enabled": true, - "label": "Arrow...", + "label": 'Arrow...', "visible": true } ] @@ -281,274 +281,274 @@ }, { "id": 48, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Patterns", + "label": 'Patterns', "visible": true, "submenu": [ { "id": 49, "enabled": true, - "label": "Truchet...", + "label": 'Truchet...', "visible": true }, { "id": 50, "enabled": true, - "label": "Swirly...", + "label": 'Swirly...', "visible": true }, { "id": 51, "enabled": true, - "label": "Swirl-Tile...", + "label": 'Swirl-Tile...', "visible": true }, { "id": 52, "enabled": true, - "label": "Render Map...", + "label": 'Render Map...', "visible": true }, { "id": 53, "enabled": true, - "label": "Land...", + "label": 'Land...', "visible": true }, { "id": 54, "enabled": true, - "label": "Flatland...", + "label": 'Flatland...', "visible": true }, { "id": 55, "enabled": true, - "label": "Camouflage...", + "label": 'Camouflage...', "visible": true }, { "id": 56, "enabled": true, - "label": "3D Truchet...", + "label": '3D Truchet...', "visible": true } ] }, { "id": 57, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Logos", + "label": 'Logos', "visible": true, "submenu": [ { "id": 58, "enabled": true, - "label": "Web Title Header...", + "label": 'Web Title Header...', "visible": true }, { "id": 59, "enabled": true, - "label": "Textured...", + "label": 'Textured...', "visible": true }, { "id": 60, "enabled": true, - "label": "Text Circle...", + "label": 'Text Circle...', "visible": true }, { "id": 61, "enabled": true, - "label": "Starscape...", + "label": 'Starscape...', "visible": true }, { "id": 62, "enabled": true, - "label": "Speed Text...", + "label": 'Speed Text...', "visible": true }, { "id": 63, "enabled": true, - "label": "SOTA Chrome...", + "label": 'SOTA Chrome...', "visible": true }, { "id": 64, "enabled": true, - "label": "Particle Trace...", + "label": 'Particle Trace...', "visible": true }, { "id": 65, "enabled": true, - "label": "Newsprint Text...", + "label": 'Newsprint Text...', "visible": true }, { "id": 66, "enabled": true, - "label": "Neon...", + "label": 'Neon...', "visible": true }, { "id": 67, "enabled": true, - "label": "Imigre-26...", + "label": 'Imigre-26...', "visible": true }, { "id": 68, "enabled": true, - "label": "Gradient Bevel...", + "label": 'Gradient Bevel...', "visible": true }, { "id": 69, "enabled": true, - "label": "Glowing Hot...", + "label": 'Glowing Hot...', "visible": true }, { "id": 70, "enabled": true, - "label": "Glossy...", + "label": 'Glossy...', "visible": true }, { "id": 71, "enabled": true, - "label": "Frosty...", + "label": 'Frosty...', "visible": true }, { "id": 72, "enabled": true, - "label": "Crystal...", + "label": 'Crystal...', "visible": true }, { "id": 73, "enabled": true, - "label": "Cool Metal...", + "label": 'Cool Metal...', "visible": true }, { "id": 74, "enabled": true, - "label": "Comic Book...", + "label": 'Comic Book...', "visible": true }, { "id": 75, "enabled": true, - "label": "Chrome...", + "label": 'Chrome...', "visible": true }, { "id": 76, "enabled": true, - "label": "Chip Away...", + "label": 'Chip Away...', "visible": true }, { "id": 77, "enabled": true, - "label": "Chalk...", + "label": 'Chalk...', "visible": true }, { "id": 78, "enabled": true, - "label": "Carved...", + "label": 'Carved...', "visible": true }, { "id": 79, "enabled": true, - "label": "Bovination...", + "label": 'Bovination...', "visible": true }, { "id": 80, "enabled": true, - "label": "Blended...", + "label": 'Blended...', "visible": true }, { "id": 81, "enabled": true, - "label": "Basic I...", + "label": 'Basic I...', "visible": true }, { "id": 82, "enabled": true, - "label": "Basic II...", + "label": 'Basic II...', "visible": true }, { "id": 83, "enabled": true, - "label": "Alien Neon...", + "label": 'Alien Neon...', "visible": true }, { "id": 84, "enabled": true, - "label": "Alien Glow...", + "label": 'Alien Glow...', "visible": true }, { "id": 85, "enabled": true, - "label": "3D Outline...", + "label": '3D Outline...', "visible": true } ] }, { "id": 86, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Buttons", + "label": 'Buttons', "visible": true, "submenu": [ { "id": 87, "enabled": true, - "label": "Simple Beveled Button...", + "label": 'Simple Beveled Button...', "visible": true }, { "id": 88, "enabled": true, - "label": "Round Button...", + "label": 'Round Button...', "visible": true } ] }, { "id": 89, - "type": "separator" + "type": 'separator' }, { "id": 90, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "xscanimage", + "label": 'xscanimage', "visible": true, "submenu": [ { "id": 91, "enabled": false, - "label": "Device dialog...", + "label": 'Device dialog...', "visible": true } ] @@ -556,14 +556,14 @@ { "id": 92, "enabled": true, - "label": "Screenshot...", + "label": 'Screenshot...', "visible": true }, { "id": 93, "enabled": true, - "label": "From Clipboard", - "shortcut": [["Control", "Shift", "v"]], + "label": 'From Clipboard', + "shortcut": [['Control', 'Shift', 'v']], "visible": true } ] @@ -571,154 +571,154 @@ { "id": 94, "enabled": true, - "label": "New...", - "shortcut": [["Control", "n"]], + "label": 'New...', + "shortcut": [['Control', 'n']], "visible": true } ] }, { "id": 95, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Edit", + "label": 'Edit', "visible": true, "submenu": [ { "id": 96, "enabled": true, - "label": "Units", + "label": 'Units', "visible": true }, { "id": 97, "enabled": true, - "label": "Modules", + "label": 'Modules', "visible": true }, { "id": 98, "enabled": true, - "label": "Keyboard Shortcuts", + "label": 'Keyboard Shortcuts', "visible": true }, { "id": 99, "enabled": true, - "label": "Preferences", + "label": 'Preferences', "visible": true }, { "id": 100, - "type": "separator" + "type": 'separator' }, { "id": 101, "enabled": false, - "label": "Stroke Path...", + "label": 'Stroke Path...', "visible": true }, { "id": 102, "enabled": false, - "label": "Stroke Selection...", + "label": 'Stroke Selection...', "visible": true }, { "id": 103, "enabled": true, - "label": "Fill with Pattern", - "shortcut": [["Control", "semicolon"]], + "label": 'Fill with Pattern', + "shortcut": [['Control', 'semicolon']], "visible": true }, { "id": 104, "enabled": true, - "label": "Fill with BG Color", - "shortcut": [["Control", "period"]], + "label": 'Fill with BG Color', + "shortcut": [['Control', 'period']], "visible": true }, { "id": 105, "enabled": true, - "label": "Fill with FG Color", - "shortcut": [["Control", "comma"]], + "label": 'Fill with FG Color', + "shortcut": [['Control', 'comma']], "visible": true }, { "id": 106, "enabled": true, - "label": "Clear", - "shortcut": [["Delete"]], + "label": 'Clear', + "shortcut": [['Delete']], "visible": true }, { "id": 107, - "type": "separator" + "type": 'separator' }, { "id": 108, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Buffer", + "label": 'Buffer', "visible": true, "submenu": [ { "id": 109, "enabled": true, - "label": "Paste Named...", + "label": 'Paste Named...', "visible": true }, { "id": 110, "enabled": true, - "label": "Copy Visible Named...", + "label": 'Copy Visible Named...', "visible": true }, { "id": 111, "enabled": true, - "label": "Copy Named...", + "label": 'Copy Named...', "visible": true }, { "id": 112, "enabled": true, - "label": "Cut Named...", + "label": 'Cut Named...', "visible": true } ] }, { "id": 113, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Paste as", + "label": 'Paste as', "visible": true, "submenu": [ { "id": 114, "enabled": true, - "label": "New Pattern...", + "label": 'New Pattern...', "visible": true }, { "id": 115, "enabled": true, - "label": "New Brush...", + "label": 'New Brush...', "visible": true }, { "id": 116, "enabled": true, - "label": "New Layer", + "label": 'New Layer', "visible": true }, { "id": 117, "enabled": true, - "label": "New Image", - "shortcut": [["Control", "Shift", "v"]], + "label": 'New Image', + "shortcut": [['Control', 'Shift', 'v']], "visible": true } ] @@ -726,390 +726,390 @@ { "id": 118, "enabled": true, - "label": "Paste Into", + "label": 'Paste Into', "visible": true }, { "id": 119, "enabled": true, - "label": "Paste", - "shortcut": [["Control", "v"]], + "label": 'Paste', + "shortcut": [['Control', 'v']], "visible": true }, { "id": 120, "enabled": true, - "label": "Copy Visible", - "shortcut": [["Control", "Shift", "c"]], + "label": 'Copy Visible', + "shortcut": [['Control', 'Shift', 'c']], "visible": true }, { "id": 121, "enabled": true, - "label": "Copy", - "shortcut": [["Control", "c"]], + "label": 'Copy', + "shortcut": [['Control', 'c']], "visible": true }, { "id": 122, "enabled": true, - "label": "Cut", - "shortcut": [["Control", "x"]], + "label": 'Cut', + "shortcut": [['Control', 'x']], "visible": true }, { "id": 123, - "type": "separator" + "type": 'separator' }, { "id": 124, "enabled": true, - "label": "Undo History", + "label": 'Undo History', "visible": true }, { "id": 3, "enabled": false, - "label": "_Fade...", + "label": '_Fade...', "visible": true }, { "id": 2, "enabled": false, - "label": "_Redo", - "shortcut": [["Control", "y"]], + "label": '_Redo', + "shortcut": [['Control', 'y']], "visible": true }, { "id": 1, "enabled": false, - "label": "_Undo", - "shortcut": [["Control", "z"]], + "label": '_Undo', + "shortcut": [['Control', 'z']], "visible": true } ] }, { "id": 125, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Select", + "label": 'Select', "visible": true, "submenu": [ { "id": 126, "enabled": false, - "label": "To Path", + "label": 'To Path', "visible": true }, { "id": 127, "enabled": true, - "label": "Save to Channel", + "label": 'Save to Channel', "visible": true }, { "id": 128, "enabled": true, - "label": "Toggle Quick Mask", - "shortcut": [["Shift", "q"]], + "label": 'Toggle Quick Mask', + "shortcut": [['Shift', 'q']], "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 129, - "type": "separator" + "type": 'separator' }, { "id": 130, "enabled": true, - "label": "Distort...", + "label": 'Distort...', "visible": true }, { "id": 131, "enabled": false, - "label": "Border...", + "label": 'Border...', "visible": true }, { "id": 132, "enabled": false, - "label": "Grow...", + "label": 'Grow...', "visible": true }, { "id": 133, "enabled": false, - "label": "Shrink...", + "label": 'Shrink...', "visible": true }, { "id": 134, "enabled": false, - "label": "Sharpen", + "label": 'Sharpen', "visible": true }, { "id": 135, "enabled": false, - "label": "Feather...", + "label": 'Feather...', "visible": true }, { "id": 136, - "type": "separator" + "type": 'separator' }, { "id": 137, "enabled": true, - "label": "Selection Editor", + "label": 'Selection Editor', "visible": true }, { "id": 138, "enabled": false, - "label": "From Path", - "shortcut": [["Shift", "v"]], + "label": 'From Path', + "shortcut": [['Shift', 'v']], "visible": true }, { "id": 139, "enabled": true, - "label": "By Color", - "shortcut": [["Shift", "o"]], + "label": 'By Color', + "shortcut": [['Shift', 'o']], "visible": true }, { "id": 140, "enabled": false, - "label": "Float", - "shortcut": [["Control", "Shift", "l"]], + "label": 'Float', + "shortcut": [['Control', 'Shift', 'l']], "visible": true }, { "id": 141, "enabled": true, - "label": "Invert", - "shortcut": [["Control", "i"]], + "label": 'Invert', + "shortcut": [['Control', 'i']], "visible": true }, { "id": 142, "enabled": false, - "label": "None", - "shortcut": [["Control", "Shift", "a"]], + "label": 'None', + "shortcut": [['Control', 'Shift', 'a']], "visible": true }, { "id": 143, "enabled": true, - "label": "All", - "shortcut": [["Control", "a"]], + "label": 'All', + "shortcut": [['Control', 'a']], "visible": true } ] }, { "id": 144, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "View", + "label": 'View', "visible": true, "submenu": [ { "id": 145, "enabled": true, - "label": "Show Statusbar", + "label": 'Show Statusbar', "toggle-state": 1, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 146, "enabled": true, - "label": "Show Scrollbars", + "label": 'Show Scrollbars', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 147, "enabled": true, - "label": "Show Rulers", - "shortcut": [["Control", "Shift", "r"]], + "label": 'Show Rulers', + "shortcut": [['Control', 'Shift', 'r']], "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 148, "enabled": true, - "label": "Show Menubar", + "label": 'Show Menubar', "toggle-state": 1, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 149, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Padding Color", + "label": 'Padding Color', "visible": true, "submenu": [ { "id": 150, "enabled": true, - "label": "As in Preferences", + "label": 'As in Preferences', "visible": true }, { "id": 151, - "type": "separator" + "type": 'separator' }, { "id": 152, "enabled": true, - "label": "Select Custom Color...", + "label": 'Select Custom Color...', "visible": true }, { "id": 153, "enabled": true, - "label": "Dark Check Color", + "label": 'Dark Check Color', "visible": true }, { "id": 154, "enabled": true, - "label": "Light Check Color", + "label": 'Light Check Color', "visible": true }, { "id": 155, "enabled": true, - "label": "From Theme", + "label": 'From Theme', "visible": true } ] }, { "id": 156, - "type": "separator" + "type": 'separator' }, { "id": 157, "enabled": true, - "label": "Snap to Active Path", + "label": 'Snap to Active Path', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 158, "enabled": true, - "label": "Snap to Canvas Edges", + "label": 'Snap to Canvas Edges', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 159, "enabled": true, - "label": "Snap to Grid", + "label": 'Snap to Grid', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 160, "enabled": true, - "label": "Snap to Guides", + "label": 'Snap to Guides', "toggle-state": 1, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 161, - "type": "separator" + "type": 'separator' }, { "id": 162, "enabled": true, - "label": "Show Sample Points", + "label": 'Show Sample Points', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 163, "enabled": true, - "label": "Show Grid", + "label": 'Show Grid', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 164, "enabled": true, - "label": "Show Guides", - "shortcut": [["Control", "Shift", "t"]], + "label": 'Show Guides', + "shortcut": [['Control', 'Shift', 't']], "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 165, "enabled": true, - "label": "Show Layer Boundary", + "label": 'Show Layer Boundary', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 166, "enabled": true, - "label": "Show Selection", - "shortcut": [["Control", "t"]], + "label": 'Show Selection', + "shortcut": [['Control', 't']], "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 167, - "type": "separator" + "type": 'separator' }, { "id": 168, "enabled": true, - "label": "Display Filters...", + "label": 'Display Filters...', "visible": true }, { "id": 169, "enabled": true, - "label": "Navigation Window", + "label": 'Navigation Window', "visible": true }, { "id": 170, - "type": "separator" + "type": 'separator' }, { "id": 171, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Fullscreen", - "shortcut": [["F11"]], + "label": 'Fullscreen', + "shortcut": [['F11']], "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true, "submenu": [ { "id": 172, "enabled": true, - "label": "Open Display...", + "label": 'Open Display...', "visible": true } ] @@ -1117,142 +1117,142 @@ { "id": 173, "enabled": true, - "label": "Shrink Wrap", - "shortcut": [["Control", "e"]], + "label": 'Shrink Wrap', + "shortcut": [['Control', 'e']], "visible": true }, { "id": 174, - "type": "separator" + "type": 'separator' }, { "id": 175, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "_Zoom (67%)", + "label": '_Zoom (67%)', "visible": true, "submenu": [ { "id": 176, "enabled": true, - "label": "Othe_r (67%)...", + "label": 'Othe_r (67%)...', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 177, - "type": "separator" + "type": 'separator' }, { "id": 178, "enabled": true, - "label": "1:16 (6.25%)", + "label": '1:16 (6.25%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 179, "enabled": true, - "label": "1:8 (12.5%)", + "label": '1:8 (12.5%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 180, "enabled": true, - "label": "1:4 (25%)", + "label": '1:4 (25%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 181, "enabled": true, - "label": "1:2 (50%)", + "label": '1:2 (50%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 182, "enabled": true, - "label": "1:1 (100%)", - "shortcut": [["1"]], + "label": '1:1 (100%)', + "shortcut": [['1']], "toggle-state": 1, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 183, "enabled": true, - "label": "2:1 (200%)", + "label": '2:1 (200%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 184, "enabled": true, - "label": "4:1 (400%)", + "label": '4:1 (400%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 185, "enabled": true, - "label": "8:1 (800%)", + "label": '8:1 (800%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 186, "enabled": true, - "label": "16:1 (1600%)", + "label": '16:1 (1600%)', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 187, - "type": "separator" + "type": 'separator' }, { "id": 188, "enabled": true, - "label": "Fill Window", + "label": 'Fill Window', "visible": true }, { "id": 189, "enabled": true, - "label": "Fit Image in Window", - "shortcut": [["Control", "Shift", "e"]], + "label": 'Fit Image in Window', + "shortcut": [['Control', 'Shift', 'e']], "visible": true }, { "id": 190, "enabled": true, - "label": "Zoom In", - "shortcut": [["plus"]], + "label": 'Zoom In', + "shortcut": [['plus']], "visible": true }, { "id": 191, "enabled": true, - "label": "Zoom Out", - "shortcut": [["minus"]], + "label": 'Zoom Out', + "shortcut": [['minus']], "visible": true }, { "id": 4, "enabled": true, - "label": "Re_vert Zoom (67%)", - "shortcut": [["grave"]], + "label": 'Re_vert Zoom (67%)', + "shortcut": [['grave']], "visible": true } ] @@ -1260,253 +1260,253 @@ { "id": 192, "enabled": true, - "label": "Dot for Dot", + "label": 'Dot for Dot', "toggle-state": 1, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 193, "enabled": true, - "label": "New View", + "label": 'New View', "visible": true } ] }, { "id": 194, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Image", + "label": 'Image', "visible": true, "submenu": [ { "id": 195, "enabled": true, - "label": "Image Properties", - "shortcut": [["Alt", "Return"]], + "label": 'Image Properties', + "shortcut": [['Alt', 'Return']], "visible": true }, { "id": 196, "enabled": true, - "label": "Configure Grid...", + "label": 'Configure Grid...', "visible": true }, { "id": 197, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Guides", + "label": 'Guides', "visible": true, "submenu": [ { "id": 198, "enabled": true, - "label": "Remove all Guides", + "label": 'Remove all Guides', "visible": true }, { "id": 199, "enabled": true, - "label": "New Guides from Selection", + "label": 'New Guides from Selection', "visible": true }, { "id": 200, "enabled": true, - "label": "New Guide...", + "label": 'New Guide...', "visible": true }, { "id": 201, "enabled": true, - "label": "New Guide (by Percent)...", + "label": 'New Guide (by Percent)...', "visible": true } ] }, { "id": 202, - "type": "separator" + "type": 'separator' }, { "id": 203, "enabled": true, - "label": "Align Visible Layers...", + "label": 'Align Visible Layers...', "visible": true }, { "id": 204, "enabled": true, - "label": "Flatten Image", + "label": 'Flatten Image', "visible": true }, { "id": 205, "enabled": true, - "label": "Merge Visible Layers...", - "shortcut": [["Control", "m"]], + "label": 'Merge Visible Layers...', + "shortcut": [['Control', 'm']], "visible": true }, { "id": 206, - "type": "separator" + "type": 'separator' }, { "id": 207, "enabled": true, - "label": "Zealous Crop", + "label": 'Zealous Crop', "visible": true }, { "id": 208, "enabled": true, - "label": "Autocrop Image", + "label": 'Autocrop Image', "visible": true }, { "id": 209, "enabled": false, - "label": "Crop to Selection", + "label": 'Crop to Selection', "visible": true }, { "id": 210, - "type": "separator" + "type": 'separator' }, { "id": 211, "enabled": true, - "label": "Scale Image...", + "label": 'Scale Image...', "visible": true }, { "id": 212, "enabled": true, - "label": "Print Size...", + "label": 'Print Size...', "visible": true }, { "id": 213, "enabled": false, - "label": "Fit Canvas to Selection", + "label": 'Fit Canvas to Selection', "visible": true }, { "id": 214, "enabled": true, - "label": "Fit Canvas to Layers", + "label": 'Fit Canvas to Layers', "visible": true }, { "id": 215, "enabled": true, - "label": "Canvas Size...", + "label": 'Canvas Size...', "visible": true }, { "id": 216, - "type": "separator" + "type": 'separator' }, { "id": 217, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Transform", + "label": 'Transform', "visible": true, "submenu": [ { "id": 218, "enabled": true, - "label": "Guillotine", + "label": 'Guillotine', "visible": true }, { "id": 219, - "type": "separator" + "type": 'separator' }, { "id": 220, "enabled": true, - "label": "Rotate 180\302\260", + "label": 'Rotate 180?', "visible": true }, { "id": 221, "enabled": true, - "label": "Rotate 90\302\260 counter-clockwise", + "label": 'Rotate 90? counter-clockwise', "visible": true }, { "id": 222, "enabled": true, - "label": "Rotate 90\302\260 clockwise", + "label": 'Rotate 90? clockwise', "visible": true }, { "id": 223, - "type": "separator" + "type": 'separator' }, { "id": 224, "enabled": true, - "label": "Flip Vertically", + "label": 'Flip Vertically', "visible": true }, { "id": 225, "enabled": true, - "label": "Flip Horizontally", + "label": 'Flip Horizontally', "visible": true } ] }, { "id": 226, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Mode", + "label": 'Mode', "visible": true, "submenu": [ { "id": 227, "enabled": true, - "label": "Convert to Color Profile...", + "label": 'Convert to Color Profile...', "visible": true }, { "id": 228, "enabled": true, - "label": "Assign Color Profile...", + "label": 'Assign Color Profile...', "visible": true }, { "id": 229, - "type": "separator" + "type": 'separator' }, { "id": 230, "enabled": true, - "label": "Indexed...", + "label": 'Indexed...', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 231, "enabled": true, - "label": "Grayscale", + "label": 'Grayscale', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 232, "enabled": true, - "label": "RGB", + "label": 'RGB', "toggle-state": 1, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true } ] @@ -1514,347 +1514,347 @@ { "id": 233, "enabled": true, - "label": "Duplicate", - "shortcut": [["Control", "d"]], + "label": 'Duplicate', + "shortcut": [['Control', 'd']], "visible": true } ] }, { "id": 234, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Layer", + "label": 'Layer', "visible": true, "submenu": [ { "id": 235, "enabled": true, - "label": "Autocrop Layer", + "label": 'Autocrop Layer', "visible": true }, { "id": 236, "enabled": false, - "label": "Crop to Selection", + "label": 'Crop to Selection', "visible": true }, { "id": 237, "enabled": true, - "label": "Scale Layer...", + "label": 'Scale Layer...', "visible": true }, { "id": 238, "enabled": true, - "label": "Layer to Image Size", + "label": 'Layer to Image Size', "visible": true }, { "id": 239, "enabled": true, - "label": "Layer Boundary Size...", + "label": 'Layer Boundary Size...', "visible": true }, { "id": 240, - "type": "separator" + "type": 'separator' }, { "id": 241, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Transform", + "label": 'Transform', "visible": true, "submenu": [ { "id": 242, "enabled": true, - "label": "Offset...", - "shortcut": [["Control", "Shift", "o"]], + "label": 'Offset...', + "shortcut": [['Control', 'Shift', 'o']], "visible": true }, { "id": 243, - "type": "separator" + "type": 'separator' }, { "id": 244, "enabled": true, - "label": "Arbitrary Rotation...", + "label": 'Arbitrary Rotation...', "visible": true }, { "id": 245, "enabled": true, - "label": "Rotate 180\302\260", + "label": 'Rotate 180?', "visible": true }, { "id": 246, "enabled": true, - "label": "Rotate 90\302\260 counter-clockwise", + "label": 'Rotate 90? counter-clockwise', "visible": true }, { "id": 247, "enabled": true, - "label": "Rotate 90\302\260 clockwise", + "label": 'Rotate 90? clockwise', "visible": true }, { "id": 248, - "type": "separator" + "type": 'separator' }, { "id": 249, "enabled": true, - "label": "Flip Vertically", + "label": 'Flip Vertically', "visible": true }, { "id": 250, "enabled": true, - "label": "Flip Horizontally", + "label": 'Flip Horizontally', "visible": true } ] }, { "id": 251, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Transparency", + "label": 'Transparency', "visible": true, "submenu": [ { "id": 252, "enabled": true, - "label": "Intersect with Selection", + "label": 'Intersect with Selection', "visible": true }, { "id": 253, "enabled": true, - "label": "Subtract from Selection", + "label": 'Subtract from Selection', "visible": true }, { "id": 254, "enabled": true, - "label": "Add to Selection", + "label": 'Add to Selection', "visible": true }, { "id": 255, "enabled": true, - "label": "Alpha to Selection", + "label": 'Alpha to Selection', "visible": true }, { "id": 256, - "type": "separator" + "type": 'separator' }, { "id": 257, "enabled": true, - "label": "Threshold Alpha...", + "label": 'Threshold Alpha...', "visible": true }, { "id": 258, "enabled": true, - "label": "Semi-Flatten", + "label": 'Semi-Flatten', "visible": true }, { "id": 259, "enabled": true, - "label": "Color to Alpha...", + "label": 'Color to Alpha...', "visible": true }, { "id": 260, "enabled": true, - "label": "Remove Alpha Channel", + "label": 'Remove Alpha Channel', "visible": true }, { "id": 261, "enabled": false, - "label": "Add Alpha Channel", + "label": 'Add Alpha Channel', "visible": true } ] }, { "id": 262, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Mask", + "label": 'Mask', "visible": true, "submenu": [ { "id": 263, "enabled": false, - "label": "Intersect with Selection", + "label": 'Intersect with Selection', "visible": true }, { "id": 264, "enabled": false, - "label": "Subtract from Selection", + "label": 'Subtract from Selection', "visible": true }, { "id": 265, "enabled": false, - "label": "Add to Selection", + "label": 'Add to Selection', "visible": true }, { "id": 266, "enabled": false, - "label": "Mask to Selection", + "label": 'Mask to Selection', "visible": true }, { "id": 267, - "type": "separator" + "type": 'separator' }, { "id": 268, "enabled": false, - "label": "Disable Layer Mask", + "label": 'Disable Layer Mask', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 269, "enabled": false, - "label": "Edit Layer Mask", + "label": 'Edit Layer Mask', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 270, "enabled": false, - "label": "Show Layer Mask", + "label": 'Show Layer Mask', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 271, - "type": "separator" + "type": 'separator' }, { "id": 272, "enabled": false, - "label": "Delete Layer Mask", + "label": 'Delete Layer Mask', "visible": true }, { "id": 273, "enabled": false, - "label": "Apply Layer Mask", + "label": 'Apply Layer Mask', "visible": true }, { "id": 274, "enabled": true, - "label": "Add Layer Mask...", + "label": 'Add Layer Mask...', "visible": true } ] }, { "id": 275, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Stack", + "label": 'Stack', "visible": true, "submenu": [ { "id": 276, "enabled": true, - "label": "Reverse Layer Order", + "label": 'Reverse Layer Order', "visible": true }, { "id": 277, - "type": "separator" + "type": 'separator' }, { "id": 278, "enabled": false, - "label": "Layer to Bottom", + "label": 'Layer to Bottom', "visible": true }, { "id": 279, "enabled": false, - "label": "Layer to Top", + "label": 'Layer to Top', "visible": true }, { "id": 280, "enabled": false, - "label": "Lower Layer", + "label": 'Lower Layer', "visible": true }, { "id": 281, "enabled": false, - "label": "Raise Layer", + "label": 'Raise Layer', "visible": true }, { "id": 282, - "type": "separator" + "type": 'separator' }, { "id": 283, "enabled": false, - "label": "Select Bottom Layer", - "shortcut": [["End"]], + "label": 'Select Bottom Layer', + "shortcut": [['End']], "visible": true }, { "id": 284, "enabled": false, - "label": "Select Top Layer", - "shortcut": [["Home"]], + "label": 'Select Top Layer', + "shortcut": [['Home']], "visible": true }, { "id": 285, "enabled": false, - "label": "Select Next Layer", - "shortcut": [["Page_Down"]], + "label": 'Select Next Layer', + "shortcut": [['Page_Down']], "visible": true }, { "id": 286, "enabled": false, - "label": "Select Previous Layer", - "shortcut": [["Page_Up"]], + "label": 'Select Previous Layer', + "shortcut": [['Page_Up']], "visible": true } ] }, { "id": 287, - "children-display": "submenu", - "type": "separator", + "children-display": 'submenu', + "type": 'separator', "submenu": [ { "id": 288, "enabled": false, - "label": "Empty", + "label": 'Empty', "visible": true } ] @@ -1862,704 +1862,704 @@ { "id": 289, "enabled": true, - "label": "Delete Layer", + "label": 'Delete Layer', "visible": true }, { "id": 290, "enabled": false, - "label": "Merge Down", + "label": 'Merge Down', "visible": true }, { "id": 291, "enabled": false, - "label": "Anchor Layer", - "shortcut": [["Control", "h"]], + "label": 'Anchor Layer', + "shortcut": [['Control', 'h']], "visible": true }, { "id": 292, "enabled": true, - "label": "Duplicate Layer", - "shortcut": [["Control", "Shift", "d"]], + "label": 'Duplicate Layer', + "shortcut": [['Control', 'Shift', 'd']], "visible": true }, { "id": 293, "enabled": true, - "label": "New from Visible", + "label": 'New from Visible', "visible": true }, { "id": 294, "enabled": true, - "label": "New Layer...", - "shortcut": [["Control", "Shift", "n"]], + "label": 'New Layer...', + "shortcut": [['Control', 'Shift', 'n']], "visible": true } ] }, { "id": 295, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Colors", + "label": 'Colors', "visible": true, "submenu": [ { "id": 296, "enabled": true, - "label": "Retinex...", + "label": 'Retinex...', "visible": true }, { "id": 297, "enabled": true, - "label": "Maximum RGB...", + "label": 'Maximum RGB...', "visible": true }, { "id": 298, "enabled": false, - "label": "Hot...", + "label": 'Hot...', "visible": true }, { "id": 299, "enabled": true, - "label": "Filter Pack...", + "label": 'Filter Pack...', "visible": true }, { "id": 300, "enabled": true, - "label": "Color to Alpha...", + "label": 'Color to Alpha...', "visible": true }, { "id": 301, "enabled": true, - "label": "Colorify...", + "label": 'Colorify...', "visible": true }, { "id": 302, - "type": "separator" + "type": 'separator' }, { "id": 303, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Info", + "label": 'Info', "visible": true, "submenu": [ { "id": 304, "enabled": true, - "label": "Smooth Palette...", + "label": 'Smooth Palette...', "visible": true }, { "id": 305, "enabled": true, - "label": "Colorcube Analysis...", + "label": 'Colorcube Analysis...', "visible": true }, { "id": 306, "enabled": true, - "label": "Border Average...", + "label": 'Border Average...', "visible": true }, { "id": 307, "enabled": true, - "label": "Histogram", + "label": 'Histogram', "visible": true } ] }, { "id": 308, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Map", + "label": 'Map', "visible": true, "submenu": [ { "id": 309, "enabled": true, - "label": "Sample Colorize...", + "label": 'Sample Colorize...', "visible": true }, { "id": 310, "enabled": true, - "label": "Rotate Colors...", + "label": 'Rotate Colors...', "visible": true }, { "id": 311, "enabled": true, - "label": "Palette Map", + "label": 'Palette Map', "visible": true }, { "id": 312, "enabled": true, - "label": "Gradient Map", + "label": 'Gradient Map', "visible": true }, { "id": 313, "enabled": true, - "label": "Color Exchange...", + "label": 'Color Exchange...', "visible": true }, { "id": 314, "enabled": true, - "label": "Alien Map...", + "label": 'Alien Map...', "visible": true }, { "id": 315, - "type": "separator" + "type": 'separator' }, { "id": 316, "enabled": false, - "label": "Set Colormap...", + "label": 'Set Colormap...', "visible": true }, { "id": 317, "enabled": false, - "label": "Rearrange Colormap...", + "label": 'Rearrange Colormap...', "visible": true } ] }, { "id": 318, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Components", + "label": 'Components', "visible": true, "submenu": [ { "id": 319, "enabled": false, - "label": "Recompose", + "label": 'Recompose', "visible": true }, { "id": 320, "enabled": true, - "label": "Decompose...", + "label": 'Decompose...', "visible": true }, { "id": 321, "enabled": false, - "label": "Compose...", + "label": 'Compose...', "visible": true }, { "id": 322, "enabled": true, - "label": "Channel Mixer...", + "label": 'Channel Mixer...', "visible": true } ] }, { "id": 323, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Auto", + "label": 'Auto', "visible": true, "submenu": [ { "id": 324, "enabled": true, - "label": "Stretch HSV", + "label": 'Stretch HSV', "visible": true }, { "id": 325, "enabled": true, - "label": "Stretch Contrast", + "label": 'Stretch Contrast', "visible": true }, { "id": 326, "enabled": true, - "label": "Normalize", + "label": 'Normalize', "visible": true }, { "id": 327, "enabled": true, - "label": "Color Enhance", + "label": 'Color Enhance', "visible": true }, { "id": 328, "enabled": true, - "label": "White Balance", + "label": 'White Balance', "visible": true }, { "id": 329, "enabled": true, - "label": "Equalize", + "label": 'Equalize', "visible": true } ] }, { "id": 330, - "type": "separator" + "type": 'separator' }, { "id": 331, "enabled": true, - "label": "Use GEGL", + "label": 'Use GEGL', "toggle-state": 0, - "toggle-type": "checkmark", + "toggle-type": 'checkmark', "visible": true }, { "id": 332, - "type": "separator" + "type": 'separator' }, { "id": 333, "enabled": true, - "label": "Value Invert", + "label": 'Value Invert', "visible": true }, { "id": 334, "enabled": true, - "label": "Invert", + "label": 'Invert', "visible": true }, { "id": 335, - "type": "separator" + "type": 'separator' }, { "id": 336, "enabled": true, - "label": "Desaturate...", + "label": 'Desaturate...', "visible": true }, { "id": 337, "enabled": true, - "label": "Posterize...", + "label": 'Posterize...', "visible": true }, { "id": 338, "enabled": true, - "label": "Curves...", + "label": 'Curves...', "visible": true }, { "id": 339, "enabled": true, - "label": "Levels...", + "label": 'Levels...', "visible": true }, { "id": 340, "enabled": true, - "label": "Threshold...", + "label": 'Threshold...', "visible": true }, { "id": 341, "enabled": true, - "label": "Brightness-Contrast...", + "label": 'Brightness-Contrast...', "visible": true }, { "id": 342, "enabled": true, - "label": "Colorize...", + "label": 'Colorize...', "visible": true }, { "id": 343, "enabled": true, - "label": "Hue-Saturation...", + "label": 'Hue-Saturation...', "visible": true }, { "id": 344, "enabled": true, - "label": "Color Balance...", + "label": 'Color Balance...', "visible": true } ] }, { "id": 345, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Tools", + "label": 'Tools', "visible": true, "submenu": [ { "id": 346, "enabled": true, - "label": "Swap Colors", - "shortcut": [["x"]], + "label": 'Swap Colors', + "shortcut": [['x']], "visible": true }, { "id": 347, "enabled": true, - "label": "Default Colors", - "shortcut": [["d"]], + "label": 'Default Colors', + "shortcut": [['d']], "visible": true }, { "id": 348, "enabled": true, - "label": "Toolbox", - "shortcut": [["Control", "b"]], + "label": 'Toolbox', + "shortcut": [['Control', 'b']], "visible": true }, { "id": 349, - "type": "separator" + "type": 'separator' }, { "id": 350, "enabled": true, - "label": "GEGL Operation...", + "label": 'GEGL Operation...', "visible": true }, { "id": 351, "enabled": true, - "label": "Text", - "shortcut": [["t"]], + "label": 'Text', + "shortcut": [['t']], "visible": true }, { "id": 352, "enabled": true, - "label": "Measure", - "shortcut": [["Shift", "m"]], + "label": 'Measure', + "shortcut": [['Shift', 'm']], "visible": true }, { "id": 353, "enabled": true, - "label": "Zoom", - "shortcut": [["z"]], + "label": 'Zoom', + "shortcut": [['z']], "visible": true }, { "id": 354, "enabled": true, - "label": "Color Picker", - "shortcut": [["o"]], + "label": 'Color Picker', + "shortcut": [['o']], "visible": true }, { "id": 355, "enabled": true, - "label": "Paths", - "shortcut": [["b"]], + "label": 'Paths', + "shortcut": [['b']], "visible": true }, { "id": 356, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Color Tools", + "label": 'Color Tools', "visible": true, "submenu": [ { "id": 357, "enabled": true, - "label": "Desaturate...", + "label": 'Desaturate...', "visible": true }, { "id": 358, "enabled": true, - "label": "Posterize...", + "label": 'Posterize...', "visible": true }, { "id": 359, "enabled": true, - "label": "Curves...", + "label": 'Curves...', "visible": true }, { "id": 360, "enabled": true, - "label": "Levels...", + "label": 'Levels...', "visible": true }, { "id": 361, "enabled": true, - "label": "Threshold...", + "label": 'Threshold...', "visible": true }, { "id": 362, "enabled": true, - "label": "Brightness-Contrast...", + "label": 'Brightness-Contrast...', "visible": true }, { "id": 363, "enabled": true, - "label": "Colorize...", + "label": 'Colorize...', "visible": true }, { "id": 364, "enabled": true, - "label": "Hue-Saturation...", + "label": 'Hue-Saturation...', "visible": true }, { "id": 365, "enabled": true, - "label": "Color Balance...", + "label": 'Color Balance...', "visible": true } ] }, { "id": 366, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Transform Tools", + "label": 'Transform Tools', "visible": true, "submenu": [ { "id": 367, "enabled": true, - "label": "Flip", - "shortcut": [["Shift", "f"]], + "label": 'Flip', + "shortcut": [['Shift', 'f']], "visible": true }, { "id": 368, "enabled": true, - "label": "Perspective", - "shortcut": [["Shift", "p"]], + "label": 'Perspective', + "shortcut": [['Shift', 'p']], "visible": true }, { "id": 369, "enabled": true, - "label": "Shear", - "shortcut": [["Shift", "s"]], + "label": 'Shear', + "shortcut": [['Shift', 's']], "visible": true }, { "id": 370, "enabled": true, - "label": "Scale", - "shortcut": [["Shift", "t"]], + "label": 'Scale', + "shortcut": [['Shift', 't']], "visible": true }, { "id": 371, "enabled": true, - "label": "Rotate", - "shortcut": [["Shift", "r"]], + "label": 'Rotate', + "shortcut": [['Shift', 'r']], "visible": true }, { "id": 372, "enabled": true, - "label": "Crop", - "shortcut": [["Shift", "c"]], + "label": 'Crop', + "shortcut": [['Shift', 'c']], "visible": true }, { "id": 373, "enabled": true, - "label": "Move", - "shortcut": [["m"]], + "label": 'Move', + "shortcut": [['m']], "visible": true }, { "id": 374, "enabled": true, - "label": "Align", - "shortcut": [["q"]], + "label": 'Align', + "shortcut": [['q']], "visible": true } ] }, { "id": 375, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Paint Tools", + "label": 'Paint Tools', "visible": true, "submenu": [ { "id": 376, "enabled": true, - "label": "Dodge / Burn", - "shortcut": [["Shift", "d"]], + "label": 'Dodge / Burn', + "shortcut": [['Shift', 'd']], "visible": true }, { "id": 377, "enabled": true, - "label": "Smudge", - "shortcut": [["s"]], + "label": 'Smudge', + "shortcut": [['s']], "visible": true }, { "id": 378, "enabled": true, - "label": "Blur / Sharpen", - "shortcut": [["Shift", "u"]], + "label": 'Blur / Sharpen', + "shortcut": [['Shift', 'u']], "visible": true }, { "id": 379, "enabled": true, - "label": "Perspective Clone", + "label": 'Perspective Clone', "visible": true }, { "id": 380, "enabled": true, - "label": "Heal", - "shortcut": [["h"]], + "label": 'Heal', + "shortcut": [['h']], "visible": true }, { "id": 381, "enabled": true, - "label": "Clone", - "shortcut": [["c"]], + "label": 'Clone', + "shortcut": [['c']], "visible": true }, { "id": 382, "enabled": true, - "label": "Ink", - "shortcut": [["k"]], + "label": 'Ink', + "shortcut": [['k']], "visible": true }, { "id": 383, "enabled": true, - "label": "Airbrush", - "shortcut": [["a"]], + "label": 'Airbrush', + "shortcut": [['a']], "visible": true }, { "id": 384, "enabled": true, - "label": "Eraser", - "shortcut": [["Shift", "e"]], + "label": 'Eraser', + "shortcut": [['Shift', 'e']], "visible": true }, { "id": 385, "enabled": true, - "label": "Paintbrush", - "shortcut": [["p"]], + "label": 'Paintbrush', + "shortcut": [['p']], "visible": true }, { "id": 386, "enabled": true, - "label": "Pencil", - "shortcut": [["n"]], + "label": 'Pencil', + "shortcut": [['n']], "visible": true }, { "id": 387, "enabled": true, - "label": "Blend", - "shortcut": [["l"]], + "label": 'Blend', + "shortcut": [['l']], "visible": true }, { "id": 388, "enabled": true, - "label": "Bucket Fill", - "shortcut": [["Shift", "b"]], + "label": 'Bucket Fill', + "shortcut": [['Shift', 'b']], "visible": true } ] }, { "id": 389, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Selection Tools", + "label": 'Selection Tools', "visible": true, "submenu": [ { "id": 390, "enabled": true, - "label": "Intelligent Scissors", - "shortcut": [["i"]], + "label": 'Intelligent Scissors', + "shortcut": [['i']], "visible": true }, { "id": 391, "enabled": true, - "label": "By Color Select", - "shortcut": [["Shift", "o"]], + "label": 'By Color Select', + "shortcut": [['Shift', 'o']], "visible": true }, { "id": 392, "enabled": true, - "label": "Fuzzy Select", - "shortcut": [["u"]], + "label": 'Fuzzy Select', + "shortcut": [['u']], "visible": true }, { "id": 393, "enabled": true, - "label": "Foreground Select", + "label": 'Foreground Select', "visible": true }, { "id": 394, "enabled": true, - "label": "Free Select", - "shortcut": [["f"]], + "label": 'Free Select', + "shortcut": [['f']], "visible": true }, { "id": 395, "enabled": true, - "label": "Ellipse Select", - "shortcut": [["e"]], + "label": 'Ellipse Select', + "shortcut": [['e']], "visible": true }, { "id": 396, "enabled": true, - "label": "Rectangle Select", - "shortcut": [["r"]], + "label": 'Rectangle Select', + "shortcut": [['r']], "visible": true } ] @@ -2568,438 +2568,438 @@ }, { "id": 397, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Filters", + "label": 'Filters', "visible": true, "submenu": [ { "id": 398, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Script-Fu", + "label": 'Script-Fu', "visible": true, "submenu": [ { "id": 399, "enabled": true, - "label": "Start Server...", + "label": 'Start Server...', "visible": true }, { "id": 400, "enabled": true, - "label": "Refresh Scripts", + "label": 'Refresh Scripts', "visible": true }, { "id": 401, "enabled": true, - "label": "Console", + "label": 'Console', "visible": true } ] }, { "id": 402, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Python-Fu", + "label": 'Python-Fu', "visible": true, "submenu": [ { "id": 403, "enabled": true, - "label": "Console", + "label": 'Console', "visible": true } ] }, { "id": 404, - "type": "separator" + "type": 'separator' }, { "id": 405, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Alpha to Logo", + "label": 'Alpha to Logo', "visible": true, "submenu": [ { "id": 406, "enabled": true, - "label": "Textured...", + "label": 'Textured...', "visible": true }, { "id": 407, "enabled": true, - "label": "Particle Trace...", + "label": 'Particle Trace...', "visible": true }, { "id": 408, "enabled": true, - "label": "Neon...", + "label": 'Neon...', "visible": true }, { "id": 409, "enabled": true, - "label": "Gradient Bevel...", + "label": 'Gradient Bevel...', "visible": true }, { "id": 410, "enabled": true, - "label": "Glowing Hot...", + "label": 'Glowing Hot...', "visible": true }, { "id": 411, "enabled": true, - "label": "Glossy...", + "label": 'Glossy...', "visible": true }, { "id": 412, "enabled": true, - "label": "Frosty...", + "label": 'Frosty...', "visible": true }, { "id": 413, "enabled": true, - "label": "Cool Metal...", + "label": 'Cool Metal...', "visible": true }, { "id": 414, "enabled": true, - "label": "Comic Book...", + "label": 'Comic Book...', "visible": true }, { "id": 415, "enabled": true, - "label": "Chrome...", + "label": 'Chrome...', "visible": true }, { "id": 416, "enabled": true, - "label": "Chip Away...", + "label": 'Chip Away...', "visible": true }, { "id": 417, "enabled": true, - "label": "Chalk...", + "label": 'Chalk...', "visible": true }, { "id": 418, "enabled": true, - "label": "Bovination...", + "label": 'Bovination...', "visible": true }, { "id": 419, "enabled": true, - "label": "Blended...", + "label": 'Blended...', "visible": true }, { "id": 420, "enabled": true, - "label": "Basic I...", + "label": 'Basic I...', "visible": true }, { "id": 421, "enabled": true, - "label": "Basic II...", + "label": 'Basic II...', "visible": true }, { "id": 422, "enabled": true, - "label": "Alien Neon...", + "label": 'Alien Neon...', "visible": true }, { "id": 423, "enabled": true, - "label": "Alien Glow...", + "label": 'Alien Glow...', "visible": true }, { "id": 424, "enabled": true, - "label": "3D Outline...", + "label": '3D Outline...', "visible": true } ] }, { "id": 425, - "type": "separator" + "type": 'separator' }, { "id": 426, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Animation", + "label": 'Animation', "visible": true, "submenu": [ { "id": 427, "enabled": true, - "label": "Unoptimize", + "label": 'Unoptimize', "visible": true }, { "id": 428, "enabled": true, - "label": "Playback...", + "label": 'Playback...', "visible": true }, { "id": 429, "enabled": true, - "label": "Optimize (for GIF)", + "label": 'Optimize (for GIF)', "visible": true }, { "id": 430, "enabled": true, - "label": "Optimize (Difference)", + "label": 'Optimize (Difference)', "visible": true }, { "id": 431, - "type": "separator" + "type": 'separator' }, { "id": 432, "enabled": true, - "label": "Waves...", + "label": 'Waves...', "visible": true }, { "id": 433, "enabled": true, - "label": "Spinning Globe...", + "label": 'Spinning Globe...', "visible": true }, { "id": 434, "enabled": true, - "label": "Rippling...", + "label": 'Rippling...', "visible": true }, { "id": 435, "enabled": true, - "label": "Burn-In...", + "label": 'Burn-In...', "visible": true }, { "id": 436, "enabled": true, - "label": "Blend...", + "label": 'Blend...', "visible": true } ] }, { "id": 437, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Web", + "label": 'Web', "visible": true, "submenu": [ { "id": 438, "enabled": true, - "label": "Slice...", + "label": 'Slice...', "visible": true }, { "id": 439, "enabled": true, - "label": "Semi-Flatten", + "label": 'Semi-Flatten', "visible": true }, { "id": 440, "enabled": true, - "label": "Image Map...", + "label": 'Image Map...', "visible": true } ] }, { "id": 441, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Render", + "label": 'Render', "visible": true, "submenu": [ { "id": 442, "enabled": true, - "label": "Spyrogimp...", + "label": 'Spyrogimp...', "visible": true }, { "id": 443, "enabled": true, - "label": "Sphere Designer...", + "label": 'Sphere Designer...', "visible": true }, { "id": 444, "enabled": true, - "label": "Line Nova...", + "label": 'Line Nova...', "visible": true }, { "id": 445, "enabled": true, - "label": "Lava...", + "label": 'Lava...', "visible": true }, { "id": 446, "enabled": true, - "label": "Gfig...", + "label": 'Gfig...', "visible": true }, { "id": 447, "enabled": true, - "label": "Fractal Explorer...", + "label": 'Fractal Explorer...', "visible": true }, { "id": 448, "enabled": true, - "label": "Circuit...", + "label": 'Circuit...', "visible": true }, { "id": 449, - "type": "separator" + "type": 'separator' }, { "id": 450, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Pattern", + "label": 'Pattern', "visible": true, "submenu": [ { "id": 451, "enabled": true, - "label": "Sinus...", + "label": 'Sinus...', "visible": true }, { "id": 452, "enabled": true, - "label": "Qbist...", + "label": 'Qbist...', "visible": true }, { "id": 453, "enabled": true, - "label": "Maze...", + "label": 'Maze...', "visible": true }, { "id": 454, "enabled": true, - "label": "Jigsaw...", + "label": 'Jigsaw...', "visible": true }, { "id": 455, "enabled": true, - "label": "Grid...", + "label": 'Grid...', "visible": true }, { "id": 456, "enabled": true, - "label": "Diffraction Patterns...", + "label": 'Diffraction Patterns...', "visible": true }, { "id": 457, "enabled": true, - "label": "CML Explorer...", + "label": 'CML Explorer...', "visible": true }, { "id": 458, "enabled": true, - "label": "Checkerboard...", + "label": 'Checkerboard...', "visible": true } ] }, { "id": 459, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Nature", + "label": 'Nature', "visible": true, "submenu": [ { "id": 460, "enabled": true, - "label": "IFS Fractal...", + "label": 'IFS Fractal...', "visible": true }, { "id": 461, "enabled": true, - "label": "Flame...", + "label": 'Flame...', "visible": true } ] }, { "id": 462, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Clouds", + "label": 'Clouds', "visible": true, "submenu": [ { "id": 463, "enabled": true, - "label": "Solid Noise...", + "label": 'Solid Noise...', "visible": true }, { "id": 464, "enabled": true, - "label": "Plasma...", + "label": 'Plasma...', "visible": true }, { "id": 465, "enabled": true, - "label": "Fog...", + "label": 'Fog...', "visible": true }, { "id": 466, "enabled": true, - "label": "Difference Clouds...", + "label": 'Difference Clouds...', "visible": true } ] @@ -3008,661 +3008,661 @@ }, { "id": 467, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Map", + "label": 'Map', "visible": true, "submenu": [ { "id": 468, "enabled": true, - "label": "Warp...", + "label": 'Warp...', "visible": true }, { "id": 469, "enabled": true, - "label": "Tile...", + "label": 'Tile...', "visible": true }, { "id": 470, "enabled": true, - "label": "Small Tiles...", + "label": 'Small Tiles...', "visible": true }, { "id": 471, "enabled": true, - "label": "Paper Tile...", + "label": 'Paper Tile...', "visible": true }, { "id": 472, "enabled": true, - "label": "Map Object...", + "label": 'Map Object...', "visible": true }, { "id": 473, "enabled": true, - "label": "Make Seamless", + "label": 'Make Seamless', "visible": true }, { "id": 474, "enabled": true, - "label": "Illusion...", + "label": 'Illusion...', "visible": true }, { "id": 475, "enabled": true, - "label": "Fractal Trace...", + "label": 'Fractal Trace...', "visible": true }, { "id": 476, "enabled": true, - "label": "Displace...", + "label": 'Displace...', "visible": true }, { "id": 477, "enabled": true, - "label": "Bump Map...", + "label": 'Bump Map...', "visible": true } ] }, { "id": 478, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Decor", + "label": 'Decor', "visible": true, "submenu": [ { "id": 479, "enabled": false, - "label": "Stencil Chrome...", + "label": 'Stencil Chrome...', "visible": true }, { "id": 480, "enabled": false, - "label": "Stencil Carve...", + "label": 'Stencil Carve...', "visible": true }, { "id": 481, "enabled": false, - "label": "Slide...", + "label": 'Slide...', "visible": true }, { "id": 482, "enabled": false, - "label": "Round Corners...", + "label": 'Round Corners...', "visible": true }, { "id": 483, "enabled": true, - "label": "Old Photo...", + "label": 'Old Photo...', "visible": true }, { "id": 484, "enabled": true, - "label": "Fuzzy Border...", + "label": 'Fuzzy Border...', "visible": true }, { "id": 485, "enabled": true, - "label": "Coffee Stain...", + "label": 'Coffee Stain...', "visible": true }, { "id": 486, "enabled": true, - "label": "Add Border...", + "label": 'Add Border...', "visible": true }, { "id": 487, "enabled": true, - "label": "Add Bevel...", + "label": 'Add Bevel...', "visible": true } ] }, { "id": 488, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Artistic", + "label": 'Artistic', "visible": true, "submenu": [ { "id": 489, "enabled": true, - "label": "Weave...", + "label": 'Weave...', "visible": true }, { "id": 490, "enabled": true, - "label": "Van Gogh (LIC)...", + "label": 'Van Gogh (LIC)...', "visible": true }, { "id": 491, "enabled": true, - "label": "Softglow...", + "label": 'Softglow...', "visible": true }, { "id": 492, "enabled": true, - "label": "Predator...", + "label": 'Predator...', "visible": true }, { "id": 493, "enabled": true, - "label": "Photocopy...", + "label": 'Photocopy...', "visible": true }, { "id": 494, "enabled": true, - "label": "Oilify...", + "label": 'Oilify...', "visible": true }, { "id": 495, "enabled": true, - "label": "GIMPressionist...", + "label": 'GIMPressionist...', "visible": true }, { "id": 496, "enabled": true, - "label": "Cubism...", + "label": 'Cubism...', "visible": true }, { "id": 497, "enabled": true, - "label": "Clothify...", + "label": 'Clothify...', "visible": true }, { "id": 498, "enabled": true, - "label": "Cartoon...", + "label": 'Cartoon...', "visible": true }, { "id": 499, "enabled": true, - "label": "Apply Canvas...", + "label": 'Apply Canvas...', "visible": true } ] }, { "id": 500, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Combine", + "label": 'Combine', "visible": true, "submenu": [ { "id": 501, "enabled": true, - "label": "Filmstrip...", + "label": 'Filmstrip...', "visible": true }, { "id": 502, "enabled": true, - "label": "Depth Merge...", + "label": 'Depth Merge...', "visible": true } ] }, { "id": 503, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Generic", + "label": 'Generic', "visible": true, "submenu": [ { "id": 504, "enabled": true, - "label": "Erode", + "label": 'Erode', "visible": true }, { "id": 505, "enabled": true, - "label": "Dilate", + "label": 'Dilate', "visible": true }, { "id": 506, "enabled": true, - "label": "Convolution Matrix...", + "label": 'Convolution Matrix...', "visible": true } ] }, { "id": 507, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Edge-Detect", + "label": 'Edge-Detect', "visible": true, "submenu": [ { "id": 508, "enabled": true, - "label": "Sobel...", + "label": 'Sobel...', "visible": true }, { "id": 509, "enabled": true, - "label": "Neon...", + "label": 'Neon...', "visible": true }, { "id": 510, "enabled": true, - "label": "Laplace", + "label": 'Laplace', "visible": true }, { "id": 511, "enabled": true, - "label": "Edge...", + "label": 'Edge...', "visible": true }, { "id": 512, "enabled": true, - "label": "Difference of Gaussians...", + "label": 'Difference of Gaussians...', "visible": true } ] }, { "id": 513, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Noise", + "label": 'Noise', "visible": true, "submenu": [ { "id": 514, "enabled": true, - "label": "Spread...", + "label": 'Spread...', "visible": true }, { "id": 515, "enabled": true, - "label": "Slur...", + "label": 'Slur...', "visible": true }, { "id": 516, "enabled": true, - "label": "RGB Noise...", + "label": 'RGB Noise...', "visible": true }, { "id": 517, "enabled": true, - "label": "Pick...", + "label": 'Pick...', "visible": true }, { "id": 518, "enabled": true, - "label": "Hurl...", + "label": 'Hurl...', "visible": true }, { "id": 519, "enabled": true, - "label": "HSV Noise...", + "label": 'HSV Noise...', "visible": true } ] }, { "id": 520, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Light and Shadow", + "label": 'Light and Shadow', "visible": true, "submenu": [ { "id": 521, "enabled": true, - "label": "Glass Tile...", + "label": 'Glass Tile...', "visible": true }, { "id": 522, "enabled": true, - "label": "Apply Lens...", + "label": 'Apply Lens...', "visible": true }, { "id": 523, - "type": "separator" + "type": 'separator' }, { "id": 524, "enabled": true, - "label": "Xach-Effect...", + "label": 'Xach-Effect...', "visible": true }, { "id": 525, "enabled": true, - "label": "Perspective...", + "label": 'Perspective...', "visible": true }, { "id": 526, "enabled": true, - "label": "Drop Shadow...", + "label": 'Drop Shadow...', "visible": true }, { "id": 527, - "type": "separator" + "type": 'separator' }, { "id": 528, "enabled": true, - "label": "Supernova...", + "label": 'Supernova...', "visible": true }, { "id": 529, "enabled": true, - "label": "Sparkle...", + "label": 'Sparkle...', "visible": true }, { "id": 530, "enabled": true, - "label": "Lighting Effects...", + "label": 'Lighting Effects...', "visible": true }, { "id": 531, "enabled": true, - "label": "Lens Flare...", + "label": 'Lens Flare...', "visible": true }, { "id": 532, "enabled": true, - "label": "Gradient Flare...", + "label": 'Gradient Flare...', "visible": true } ] }, { "id": 533, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Distorts", + "label": 'Distorts', "visible": true, "submenu": [ { "id": 534, "enabled": true, - "label": "Wind...", + "label": 'Wind...', "visible": true }, { "id": 535, "enabled": true, - "label": "Whirl and Pinch...", + "label": 'Whirl and Pinch...', "visible": true }, { "id": 536, "enabled": true, - "label": "Waves...", + "label": 'Waves...', "visible": true }, { "id": 537, "enabled": true, - "label": "Video...", + "label": 'Video...', "visible": true }, { "id": 538, "enabled": true, - "label": "Value Propagate...", + "label": 'Value Propagate...', "visible": true }, { "id": 539, "enabled": true, - "label": "Shift...", + "label": 'Shift...', "visible": true }, { "id": 540, "enabled": true, - "label": "Ripple...", + "label": 'Ripple...', "visible": true }, { "id": 541, "enabled": true, - "label": "Polar Coordinates...", + "label": 'Polar Coordinates...', "visible": true }, { "id": 542, "enabled": true, - "label": "Pagecurl...", + "label": 'Pagecurl...', "visible": true }, { "id": 543, "enabled": true, - "label": "Newsprint...", + "label": 'Newsprint...', "visible": true }, { "id": 544, "enabled": true, - "label": "Mosaic...", + "label": 'Mosaic...', "visible": true }, { "id": 545, "enabled": true, - "label": "Lens Distortion...", + "label": 'Lens Distortion...', "visible": true }, { "id": 546, "enabled": true, - "label": "IWarp...", + "label": 'IWarp...', "visible": true }, { "id": 547, "enabled": true, - "label": "Erase Every Other Row...", + "label": 'Erase Every Other Row...', "visible": true }, { "id": 548, "enabled": true, - "label": "Engrave...", + "label": 'Engrave...', "visible": true }, { "id": 549, "enabled": true, - "label": "Emboss...", + "label": 'Emboss...', "visible": true }, { "id": 550, "enabled": true, - "label": "Curve Bend...", + "label": 'Curve Bend...', "visible": true }, { "id": 551, "enabled": true, - "label": "Blinds...", + "label": 'Blinds...', "visible": true } ] }, { "id": 552, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Enhance", + "label": 'Enhance', "visible": true, "submenu": [ { "id": 553, "enabled": true, - "label": "Unsharp Mask...", + "label": 'Unsharp Mask...', "visible": true }, { "id": 554, "enabled": true, - "label": "Sharpen...", + "label": 'Sharpen...', "visible": true }, { "id": 555, "enabled": true, - "label": "Red Eye Removal...", + "label": 'Red Eye Removal...', "visible": true }, { "id": 556, "enabled": false, - "label": "NL Filter...", + "label": 'NL Filter...', "visible": true }, { "id": 557, "enabled": true, - "label": "Destripe...", + "label": 'Destripe...', "visible": true }, { "id": 558, "enabled": true, - "label": "Despeckle...", + "label": 'Despeckle...', "visible": true }, { "id": 559, "enabled": true, - "label": "Deinterlace...", + "label": 'Deinterlace...', "visible": true }, { "id": 560, "enabled": true, - "label": "Antialias", + "label": 'Antialias', "visible": true } ] }, { "id": 561, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Blur", + "label": 'Blur', "visible": true, "submenu": [ { "id": 562, "enabled": true, - "label": "Tileable Blur...", + "label": 'Tileable Blur...', "visible": true }, { "id": 563, "enabled": true, - "label": "Selective Gaussian Blur...", + "label": 'Selective Gaussian Blur...', "visible": true }, { "id": 564, "enabled": true, - "label": "Pixelize...", + "label": 'Pixelize...', "visible": true }, { "id": 565, "enabled": true, - "label": "Motion Blur...", + "label": 'Motion Blur...', "visible": true }, { "id": 566, "enabled": true, - "label": "Gaussian Blur...", + "label": 'Gaussian Blur...', "visible": true }, { "id": 567, "enabled": true, - "label": "Blur", + "label": 'Blur', "visible": true } ] }, { "id": 568, - "type": "separator" + "type": 'separator' }, { "id": 569, "enabled": true, - "label": "Reset all Filters", + "label": 'Reset all Filters', "visible": true }, { "id": 570, - "children-display": "submenu", + "children-display": 'submenu', "enabled": false, - "label": "Re-Show Last", - "shortcut": [["Control", "Shift", "f"]], + "label": 'Re-Show Last', + "shortcut": [['Control', 'Shift', 'f']], "visible": true, "submenu": [ { "id": 571, "enabled": false, - "label": "Empty", + "label": 'Empty', "visible": true } ] @@ -3670,210 +3670,210 @@ { "id": 572, "enabled": false, - "label": "Repeat Last", - "shortcut": [["Control", "f"]], + "label": 'Repeat Last', + "shortcut": [['Control', 'f']], "visible": true } ] }, { "id": 573, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Windows", + "label": 'Windows', "visible": true, "submenu": [ { "id": 574, "enabled": true, - "label": "Toolbox", - "shortcut": [["Control", "b"]], + "label": 'Toolbox', + "shortcut": [['Control', 'b']], "visible": true }, { "id": 575, - "type": "separator" + "type": 'separator' }, { "id": 576, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Dockable Dialogs", + "label": 'Dockable Dialogs', "visible": true, "submenu": [ { "id": 577, "enabled": true, - "label": "Error Console", + "label": 'Error Console', "visible": true }, { "id": 578, "enabled": true, - "label": "Tools", + "label": 'Tools', "visible": true }, { "id": 579, "enabled": true, - "label": "Templates", + "label": 'Templates', "visible": true }, { "id": 580, "enabled": true, - "label": "Document History", + "label": 'Document History', "visible": true }, { "id": 581, "enabled": true, - "label": "Images", + "label": 'Images', "visible": true }, { "id": 582, - "type": "separator" + "type": 'separator' }, { "id": 583, "enabled": true, - "label": "Buffers", + "label": 'Buffers', "visible": true }, { "id": 584, "enabled": true, - "label": "Fonts", + "label": 'Fonts', "visible": true }, { "id": 585, "enabled": true, - "label": "Palettes", + "label": 'Palettes', "visible": true }, { "id": 586, "enabled": true, - "label": "Gradients", - "shortcut": [["Control", "g"]], + "label": 'Gradients', + "shortcut": [['Control', 'g']], "visible": true }, { "id": 587, "enabled": true, - "label": "Patterns", - "shortcut": [["Control", "Shift", "p"]], + "label": 'Patterns', + "shortcut": [['Control', 'Shift', 'p']], "visible": true }, { "id": 588, "enabled": true, - "label": "Brushes", - "shortcut": [["Control", "Shift", "b"]], + "label": 'Brushes', + "shortcut": [['Control', 'Shift', 'b']], "visible": true }, { "id": 589, "enabled": true, - "label": "Colors", + "label": 'Colors', "visible": true }, { "id": 590, - "type": "separator" + "type": 'separator' }, { "id": 591, "enabled": true, - "label": "Sample Points", + "label": 'Sample Points', "visible": true }, { "id": 592, "enabled": true, - "label": "Pointer", + "label": 'Pointer', "visible": true }, { "id": 593, "enabled": true, - "label": "Undo History", + "label": 'Undo History', "visible": true }, { "id": 594, "enabled": true, - "label": "Navigation", + "label": 'Navigation', "visible": true }, { "id": 595, "enabled": true, - "label": "Selection Editor", + "label": 'Selection Editor', "visible": true }, { "id": 596, "enabled": true, - "label": "Histogram", + "label": 'Histogram', "visible": true }, { "id": 597, "enabled": true, - "label": "Colormap", + "label": 'Colormap', "visible": true }, { "id": 598, "enabled": true, - "label": "Paths", + "label": 'Paths', "visible": true }, { "id": 599, "enabled": true, - "label": "Channels", + "label": 'Channels', "visible": true }, { "id": 600, "enabled": true, - "label": "Layers", - "shortcut": [["Control", "l"]], + "label": 'Layers', + "shortcut": [['Control', 'l']], "visible": true }, { "id": 601, - "type": "separator" + "type": 'separator' }, { "id": 602, "enabled": true, - "label": "Device Status", + "label": 'Device Status', "visible": true }, { "id": 603, "enabled": true, - "label": "Tool Options", + "label": 'Tool Options', "visible": true } ] }, { "id": 604, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Recently Closed Docks", + "label": 'Recently Closed Docks', "visible": true, "submenu": [ { "id": 605, "enabled": false, - "label": "Empty", + "label": 'Empty', "visible": true } ] @@ -3882,139 +3882,139 @@ }, { "id": 606, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "Help", + "label": 'Help', "visible": true, "submenu": [ { "id": 607, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "User Manual", + "label": 'User Manual', "visible": true, "submenu": [ { "id": 608, "enabled": true, - "label": "Working with Digital Camera Photos", + "label": 'Working with Digital Camera Photos', "visible": true }, { "id": 609, "enabled": true, - "label": "Using Paths", + "label": 'Using Paths', "visible": true }, { "id": 610, "enabled": true, - "label": "Preparing your Images for the Web", + "label": 'Preparing your Images for the Web', "visible": true }, { "id": 611, "enabled": true, - "label": "How to Use Dialogs", + "label": 'How to Use Dialogs', "visible": true }, { "id": 612, "enabled": true, - "label": "Drawing Simple Objects", + "label": 'Drawing Simple Objects', "visible": true }, { "id": 613, "enabled": true, - "label": "Create, Open and Save Files", + "label": 'Create, Open and Save Files', "visible": true }, { "id": 614, "enabled": true, - "label": "Basic Concepts", + "label": 'Basic Concepts', "visible": true } ] }, { "id": 615, - "children-display": "submenu", + "children-display": 'submenu', "enabled": true, - "label": "GIMP Online", + "label": 'GIMP Online', "visible": true, "submenu": [ { "id": 616, "enabled": true, - "label": "User Manual Web Site", + "label": 'User Manual Web Site', "visible": true }, { "id": 617, "enabled": true, - "label": "Plug-in Registry", + "label": 'Plug-in Registry', "visible": true }, { "id": 618, "enabled": true, - "label": "Main Web Site", + "label": 'Main Web Site', "visible": true }, { "id": 619, "enabled": true, - "label": "Developer Web Site", + "label": 'Developer Web Site', "visible": true } ] }, { "id": 620, - "type": "separator" + "type": 'separator' }, { "id": 621, "enabled": true, - "label": "Procedure Browser", + "label": 'Procedure Browser', "visible": true }, { "id": 622, "enabled": true, - "label": "Plug-In Browser", + "label": 'Plug-In Browser', "visible": true }, { "id": 623, - "type": "separator" + "type": 'separator' }, { "id": 624, "enabled": true, - "label": "About", + "label": 'About', "visible": true }, { "id": 625, "enabled": true, - "label": "Tip of the Day", + "label": 'Tip of the Day', "visible": true }, { "id": 626, "enabled": true, - "label": "Context Help", - "shortcut": [["Shift", "F1"]], + "label": 'Context Help', + "shortcut": [['Shift', 'F1']], "visible": true }, { "id": 627, "enabled": true, - "label": "Help", - "shortcut": [["F1"]], + "label": 'Help', + "shortcut": [['F1']], "visible": true } ] -- cgit v1.2.3 From c0423dad5e66f491a7da1f19d472100af5e1afe7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 15:51:34 -0600 Subject: Switching API over to 0.4 --- libdbusmenu-glib/Makefile.am | 24 ++++++++++++------------ libdbusmenu-glib/dbusmenu-glib.pc.in | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index db4ed4b..6db7e5d 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -12,7 +12,7 @@ EXTRA_DIST = \ lib_LTLIBRARIES = \ libdbusmenu-glib.la -libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-glib/ +libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-glib/ libdbusmenu_glibinclude_HEADERS = \ menuitem.h \ @@ -125,16 +125,16 @@ if HAVE_INTROSPECTION introspection_sources = $(libdbusmenu_glibinclude_HEADERS) -Dbusmenu_Glib-0.2.gir: libdbusmenu-glib.la -Dbusmenu_Glib_0_2_gir_INCLUDES = \ +Dbusmenu_Glib-0.4.gir: libdbusmenu-glib.la +Dbusmenu_Glib_0_4_gir_INCLUDES = \ GObject-2.0 -Dbusmenu_Glib_0_2_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) -Dbusmenu_Glib_0_2_gir_LIBS = libdbusmenu-glib.la -Dbusmenu_Glib_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -Dbusmenu_Glib_0_2_gir_NAMESPACE = Dbusmenu -Dbusmenu_Glib_0_2_gir_VERSION = Glib-0.2 +Dbusmenu_Glib_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) +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.2 -INTROSPECTION_GIRS += Dbusmenu-Glib-0.2.gir +INTROSPECTION_GIRS += Dbusmenu-Glib-0.4.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -153,10 +153,10 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = Dbusmenu-Glib-0.2.vapi +vapi_DATA = Dbusmenu-Glib-0.4.vapi -Dbusmenu-Glib-0.2.vapi: Dbusmenu-Glib-0.2.gir - $(VALA_API_GEN) --library=Dbusmenu-Glib-0.2 $< +Dbusmenu-Glib-0.4.vapi: Dbusmenu-Glib-0.4.gir + $(VALA_API_GEN) --library=Dbusmenu-Glib-0.4 $< CLEANFILES += $(vapi_DATA) diff --git a/libdbusmenu-glib/dbusmenu-glib.pc.in b/libdbusmenu-glib/dbusmenu-glib.pc.in index dacd903..3f31664 100644 --- a/libdbusmenu-glib/dbusmenu-glib.pc.in +++ b/libdbusmenu-glib/dbusmenu-glib.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.1 +Cflags: -I${includedir}/libdbusmenu-0.4 Requires: dbus-glib-1 Libs: -L${libdir} -ldbusmenu-glib -- cgit v1.2.3 From 0ac0a85f42be1aa1c93cfc42a0b4d455f594ba2c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 15:53:09 -0600 Subject: Changing API to 0.4 --- libdbusmenu-gtk/Makefile.am | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 2be63b7..3a65b03 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -7,7 +7,7 @@ EXTRA_DIST = \ lib_LTLIBRARIES = \ libdbusmenu-gtk.la -libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/ +libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ client.h \ @@ -55,16 +55,16 @@ if HAVE_INTROSPECTION introspection_sources = $(libdbusmenu_gtkinclude_HEADERS) -DbusmenuGtk-0.2.gir: libdbusmenu-gtk.la -DbusmenuGtk_0_2_gir_INCLUDES = \ +DbusmenuGtk-0.4.gir: libdbusmenu-gtk.la +DbusmenuGtk_0_4_gir_INCLUDES = \ GObject-2.0 \ Gtk-2.0 \ - Dbusmenu-Glib-0.2 -DbusmenuGtk_0_2_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -DbusmenuGtk_0_2_gir_LIBS = libdbusmenu-gtk.la -DbusmenuGtk_0_2_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) + Dbusmenu-Glib-0.4 +DbusmenuGtk_0_4_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) +DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk.la +DbusmenuGtk_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) -INTROSPECTION_GIRS += DbusmenuGtk-0.2.gir +INTROSPECTION_GIRS += DbusmenuGtk-0.4.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) @@ -83,24 +83,24 @@ endif if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = DbusmenuGtk-0.2.vapi +vapi_DATA = DbusmenuGtk-0.4.vapi -DbusmenuGtk-0.2.vapi: DbusmenuGtk-0.2.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk-0.2 \ +DbusmenuGtk-0.4.vapi: DbusmenuGtk-0.4.tmp.gir Makefile.am + $(VALA_API_GEN) --library=DbusmenuGtk-0.4 \ --pkg gdk-pixbuf-2.0 \ --pkg gtk+-2.0 \ --pkg atk \ - --pkg Dbusmenu-Glib-0.2 \ + --pkg Dbusmenu-Glib-0.4 \ --vapidir=$(top_builddir)/libdbusmenu-glib \ $< -DbusmenuGtk-0.2.tmp.gir: DbusmenuGtk-0.2.gir +DbusmenuGtk-0.4.tmp.gir: DbusmenuGtk-0.4.gir $(SED) \ -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \ -e "s|Atk.ImplementorIface|Atk.Implementor|g" \ $< > $@ -CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.2.tmp.gir +CLEANFILES += $(vapi_DATA) DbusmenuGtk-0.4.tmp.gir endif -- cgit v1.2.3 From 2a3d4ac52d20ea99e77b44749aaccb07a135fe25 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 20:42:13 -0600 Subject: Changing the include directory to be the correct changed one. --- libdbusmenu-gtk/dbusmenu-gtk.pc.in | 2 +- libdbusmenu-gtk/dbusmenu-gtk3.pc.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/dbusmenu-gtk.pc.in b/libdbusmenu-gtk/dbusmenu-gtk.pc.in index df4cb36..f35c621 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.1 +Cflags: -I${includedir}/libdbusmenu-0.4 Requires: dbus-glib-1 dbusmenu-glib Libs: -L${libdir} -ldbusmenu-gtk diff --git a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in index 1a3410e..033c390 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.1 +Cflags: -I${includedir}/libdbusmenu-0.4 Requires: dbus-glib-1 dbusmenu-glib Libs: -L${libdir} -ldbusmenu-gtk3 -- cgit v1.2.3 From 7c45578e1fbaa08088d4f2d43bc3533e6b9112e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 20:46:40 -0600 Subject: Moving the pc files to be parallel installable. --- configure.ac | 6 +++--- libdbusmenu-glib/Makefile.am | 4 ++-- libdbusmenu-glib/dbusmenu-glib-0.4.pc.in | 14 ++++++++++++++ libdbusmenu-glib/dbusmenu-glib.pc.in | 14 -------------- libdbusmenu-gtk/Makefile.am | 6 +++--- libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in | 14 ++++++++++++++ libdbusmenu-gtk/dbusmenu-gtk.pc.in | 14 -------------- libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in | 14 ++++++++++++++ libdbusmenu-gtk/dbusmenu-gtk3.pc.in | 14 -------------- 9 files changed, 50 insertions(+), 50 deletions(-) create mode 100644 libdbusmenu-glib/dbusmenu-glib-0.4.pc.in delete mode 100644 libdbusmenu-glib/dbusmenu-glib.pc.in create mode 100644 libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in delete mode 100644 libdbusmenu-gtk/dbusmenu-gtk.pc.in create mode 100644 libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in delete mode 100644 libdbusmenu-gtk/dbusmenu-gtk3.pc.in diff --git a/configure.ac b/configure.ac index bbc1aad..80519e8 100644 --- a/configure.ac +++ b/configure.ac @@ -159,10 +159,10 @@ AC_OUTPUT([ Makefile po/Makefile.in libdbusmenu-glib/Makefile -libdbusmenu-glib/dbusmenu-glib.pc +libdbusmenu-glib/dbusmenu-glib-0.4.pc libdbusmenu-gtk/Makefile -libdbusmenu-gtk/dbusmenu-gtk.pc -libdbusmenu-gtk/dbusmenu-gtk3.pc +libdbusmenu-gtk/dbusmenu-gtk-0.4.pc +libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc tools/Makefile tools/testapp/Makefile tests/Makefile diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 6db7e5d..e5a99a2 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -3,7 +3,7 @@ CLEANFILES = EXTRA_DIST = \ clean-namespaces.xslt \ - dbusmenu-glib.pc.in \ + dbusmenu-glib-0.4.pc.in \ dbus-menu.xml \ client-marshal.list \ menuitem-marshal.list \ @@ -52,7 +52,7 @@ libdbusmenu_glib_la_CFLAGS = \ libdbusmenu_glib_la_LIBADD = \ $(DBUSMENUGLIB_LIBS) -pkgconfig_DATA = dbusmenu-glib.pc +pkgconfig_DATA = dbusmenu-glib-0.4.pc pkgconfigdir = $(libdir)/pkgconfig %.xml.h: %.xml diff --git a/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in b/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in new file mode 100644 index 0000000..3f31664 --- /dev/null +++ b/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libdbusmenu-0.4 +Requires: dbus-glib-1 +Libs: -L${libdir} -ldbusmenu-glib + +Name: libdbusmenu-glib +Description: libdbusmenu-glib. +Version: @VERSION@ + diff --git a/libdbusmenu-glib/dbusmenu-glib.pc.in b/libdbusmenu-glib/dbusmenu-glib.pc.in deleted file mode 100644 index 3f31664..0000000 --- a/libdbusmenu-glib/dbusmenu-glib.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -bindir=@bindir@ -includedir=@includedir@ - -Cflags: -I${includedir}/libdbusmenu-0.4 -Requires: dbus-glib-1 -Libs: -L${libdir} -ldbusmenu-glib - -Name: libdbusmenu-glib -Description: libdbusmenu-glib. -Version: @VERSION@ - diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index e512c4d..7eb725a 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -14,8 +14,8 @@ lib_LTLIBRARIES = libdbusmenu-gtk.la endif EXTRA_DIST = \ - dbusmenu-gtk.pc.in \ - dbusmenu-gtk3.pc.in + dbusmenu-gtk-0.4.pc.in \ + dbusmenu-gtk3-0.4.pc.in libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-gtk$(VER)/ @@ -57,7 +57,7 @@ libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) libdbusmenu_gtk3_la_LIBADD = $(libdbusmenu_gtk_la_LIBADD) -pkgconfig_DATA = dbusmenu-gtk$(VER).pc +pkgconfig_DATA = dbusmenu-gtk$(VER)-0.4.pc pkgconfigdir = $(libdir)/pkgconfig ######################### diff --git a/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in new file mode 100644 index 0000000..f35c621 --- /dev/null +++ b/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libdbusmenu-0.4 +Requires: dbus-glib-1 dbusmenu-glib +Libs: -L${libdir} -ldbusmenu-gtk + +Name: libdbusmenu-gtk +Description: libdbusmenu-gtk. +Version: @VERSION@ + diff --git a/libdbusmenu-gtk/dbusmenu-gtk.pc.in b/libdbusmenu-gtk/dbusmenu-gtk.pc.in deleted file mode 100644 index f35c621..0000000 --- a/libdbusmenu-gtk/dbusmenu-gtk.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -bindir=@bindir@ -includedir=@includedir@ - -Cflags: -I${includedir}/libdbusmenu-0.4 -Requires: dbus-glib-1 dbusmenu-glib -Libs: -L${libdir} -ldbusmenu-gtk - -Name: libdbusmenu-gtk -Description: libdbusmenu-gtk. -Version: @VERSION@ - diff --git a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in new file mode 100644 index 0000000..033c390 --- /dev/null +++ b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libdbusmenu-0.4 +Requires: dbus-glib-1 dbusmenu-glib +Libs: -L${libdir} -ldbusmenu-gtk3 + +Name: libdbusmenu-gtk3 +Description: libdbusmenu-gtk3. +Version: @VERSION@ + diff --git a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3.pc.in deleted file mode 100644 index 033c390..0000000 --- a/libdbusmenu-gtk/dbusmenu-gtk3.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -bindir=@bindir@ -includedir=@includedir@ - -Cflags: -I${includedir}/libdbusmenu-0.4 -Requires: dbus-glib-1 dbusmenu-glib -Libs: -L${libdir} -ldbusmenu-gtk3 - -Name: libdbusmenu-gtk3 -Description: libdbusmenu-gtk3. -Version: @VERSION@ - -- cgit v1.2.3 From 8d13b4941e5a520d9dbfffb87a03996c8cb38c98 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 20:49:47 -0600 Subject: Ignore a bunch of new files. --- .bzrignore | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.bzrignore b/.bzrignore index 84b179c..d23b2d9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -210,3 +210,13 @@ libdbusmenu-gtk/libdbusmenu_gtk3_la-client.lo libdbusmenu-gtk/libdbusmenu_gtk3_la-genericmenuitem.lo libdbusmenu-gtk/libdbusmenu_gtk3_la-menu.lo libdbusmenu-gtk/libdbusmenu_gtk3_la-menuitem.lo +libdbusmenu-glib/Dbusmenu-Glib-0.4.gir +libdbusmenu-glib/Dbusmenu-Glib-0.4.typelib +libdbusmenu-glib/Dbusmenu-Glib-0.4.vapi +libdbusmenu-glib/dbusmenu-glib-0.4.pc +libdbusmenu-gtk/DbusmenuGtk-0.4.gir +libdbusmenu-gtk/DbusmenuGtk-0.4.tmp.gir +libdbusmenu-gtk/DbusmenuGtk-0.4.typelib +libdbusmenu-gtk/DbusmenuGtk-0.4.vapi +libdbusmenu-gtk/dbusmenu-gtk-0.4.pc +libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc -- cgit v1.2.3 From e3582434262f474412ac40b864f5bbc128973c40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 21:01:36 -0600 Subject: Putting the XSLT Processor into the configuration file. --- configure.ac | 6 ++++++ libdbusmenu-glib/Makefile.am | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 80519e8..c17b293 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,12 @@ GOBJECT_INTROSPECTION_CHECK([0.6.7]) AC_PATH_PROG([VALA_API_GEN], [vapigen]) +########################### +# XSLT Processor +########################### + +AC_PATH_PROG([XSLT_PROC], [xsltproc]) + ########################### # Lib versioning ########################### diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index e5a99a2..0020d59 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -64,7 +64,7 @@ pkgconfigdir = $(libdir)/pkgconfig echo ";" >> $@ dbus-menu-clean.xml: dbus-menu.xml - xsltproc $(srcdir)/clean-namespaces.xslt $< > $@ || (rm -f $@ && /bin/false) + $(XSLT_PROC) $(srcdir)/clean-namespaces.xslt $< > $@ || (rm -f $@ && /bin/false) CLEANFILES += dbus-menu-clean.xml -- cgit v1.2.3 From 4bf64d184cb6eb7ac89d91705e947aedd2aa981a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Dec 2010 21:35:46 -0600 Subject: Making the ints from the JSON file int32s --- tests/json-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index 4d3e6aa..14e90e0 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -56,7 +56,7 @@ node2variant (JsonNode * node) switch (json_node_get_value_type(node)) { case G_TYPE_INT: case G_TYPE_INT64: - return g_variant_new_int64(json_node_get_int(node)); + return g_variant_new_int32(json_node_get_int(node)); case G_TYPE_DOUBLE: case G_TYPE_FLOAT: return g_variant_new_double(json_node_get_double(node)); -- cgit v1.2.3 From 9dba82584abf181777b7bed4cca8202cf6652ff6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Dec 2010 13:52:54 -0600 Subject: Removing a GValue to use the direct functions --- libdbusmenu-gtk/genericmenuitem.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 990ca82..61881ef 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -291,7 +291,6 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType } item->priv->check_type = check_type; - GValue value = {0}; switch (item->priv->check_type) { case GENERICMENUITEM_CHECK_TYPE_NONE: @@ -300,22 +299,16 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType check on the item. */ break; case GENERICMENUITEM_CHECK_TYPE_CHECKBOX: - g_value_init(&value, G_TYPE_BOOLEAN); - g_value_set_boolean(&value, FALSE); - g_object_set_property(G_OBJECT(item), "draw-as-radio", &value); + gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), FALSE); break; case GENERICMENUITEM_CHECK_TYPE_RADIO: - g_value_init(&value, G_TYPE_BOOLEAN); - g_value_set_boolean(&value, TRUE); - g_object_set_property(G_OBJECT(item), "draw-as-radio", &value); + gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE); break; default: g_warning("Generic Menuitem invalid check type: %d", check_type); return; } - g_value_unset(&value); - gtk_widget_queue_draw(GTK_WIDGET(item)); return; -- cgit v1.2.3 From 837d3645ef5860c92dd5c1c82420c60a581b341f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Dec 2010 14:01:47 -0600 Subject: Renaming the jsonloader pc file --- configure.ac | 2 +- tests/Makefile.am | 2 +- tests/dbusmenu-jsonloader-0.4.pc.in | 14 ++++++++++++++ tests/dbusmenu-jsonloader.pc.in | 14 -------------- 4 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 tests/dbusmenu-jsonloader-0.4.pc.in delete mode 100644 tests/dbusmenu-jsonloader.pc.in diff --git a/configure.ac b/configure.ac index c17b293..9aff3ce 100644 --- a/configure.ac +++ b/configure.ac @@ -172,7 +172,7 @@ libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc tools/Makefile tools/testapp/Makefile tests/Makefile -tests/dbusmenu-jsonloader.pc +tests/dbusmenu-jsonloader-0.4.pc docs/Makefile docs/libdbusmenu-glib/Makefile docs/libdbusmenu-glib/reference/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index aa79c8f..df2a364 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -80,7 +80,7 @@ libdbusmenu_jsonloader_la_LIBADD = \ $(DBUSMENUGLIB_LIBS) \ $(DBUSMENUTESTS_LIBS) -pkgconfig_DATA = dbusmenu-jsonloader.pc +pkgconfig_DATA = dbusmenu-jsonloader-0.4.pc pkgconfigdir = $(libdir)/pkgconfig ###################### diff --git a/tests/dbusmenu-jsonloader-0.4.pc.in b/tests/dbusmenu-jsonloader-0.4.pc.in new file mode 100644 index 0000000..d042132 --- /dev/null +++ b/tests/dbusmenu-jsonloader-0.4.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libdbusmenu-0.1 +Requires: dbus-glib-1,dbusmenu-glib,json-glib-1.0 +Libs: -L${libdir} -ldbusmenu-jsonloader + +Name: libdbusmenu-jsonloader +Description: A small library to load JSON descriptions of menus. Mostly for testing. +Version: @VERSION@ + diff --git a/tests/dbusmenu-jsonloader.pc.in b/tests/dbusmenu-jsonloader.pc.in deleted file mode 100644 index d042132..0000000 --- a/tests/dbusmenu-jsonloader.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -bindir=@bindir@ -includedir=@includedir@ - -Cflags: -I${includedir}/libdbusmenu-0.1 -Requires: dbus-glib-1,dbusmenu-glib,json-glib-1.0 -Libs: -L${libdir} -ldbusmenu-jsonloader - -Name: libdbusmenu-jsonloader -Description: A small library to load JSON descriptions of menus. Mostly for testing. -Version: @VERSION@ - -- cgit v1.2.3 From ffb9d313cf4f588fc6958eb7e4e30b272b00d10e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Dec 2010 14:13:09 -0600 Subject: Ignoring the new PC file --- .bzrignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index d23b2d9..44c6edb 100644 --- a/.bzrignore +++ b/.bzrignore @@ -182,7 +182,7 @@ docs/libdbusmenu-gtk/reference/tmpl/menuitem.sgml docs/libdbusmenu-gtk/reference/tmpl/menuitem.sgml.bak gtk-doc.make m4/gtk-doc.m4 -tests/dbusmenu-jsonloader.pc +tests/dbusmenu-jsonloader-0.4.pc tests/libdbusmenu-jsonloader.la tests/libdbusmenu_jsonloader_la-json-loader.lo tests/test-json-server -- cgit v1.2.3 From 5f1c15b654a09bf8d5ad04b8d8ff046cdf7068fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 10:50:24 -0600 Subject: Add a check for GIR version less that 10 --- configure.ac | 6 ++++++ libdbusmenu-glib/Makefile.am | 7 +++++++ libdbusmenu-gtk/Makefile.am | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 4a7bc86..a285ad9 100644 --- a/configure.ac +++ b/configure.ac @@ -116,6 +116,12 @@ AC_SUBST(DBUSMENUTESTS_LIBS) GOBJECT_INTROSPECTION_CHECK([0.6.7]) +PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 0.10], + introspection_ten=yes, + introspection_ten=no) + +AM_CONDITIONAL(INTROSPECTION_TEN, [test "x$introspection_ten" = "xyes"]) + ########################### # Vala API Generation ########################### diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index adf4607..d33bc9b 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -114,11 +114,18 @@ menuitem-marshal.c: $(srcdir)/menuitem-marshal.list -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = + +if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --add-include-path=$(srcdir) \ $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) \ --symbol-prefix=dbusmenu \ --identifier-prefix=Dbusmenu +else +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ + --add-include-path=$(srcdir) \ + $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) +endif INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index e539aa6..19765d5 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -66,11 +66,19 @@ pkgconfigdir = $(libdir)/pkgconfig -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = + +if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) \ --symbol-prefix=dbusmenu \ --identifier-prefix=DbusmenuGtk +else +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ + --add-include-path=$(top_builddir)/libdbusmenu-glib \ + $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) +endif + INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_builddir)/libdbusmenu-glib if HAVE_INTROSPECTION -- cgit v1.2.3 From 55ed277c86f90c7d31c6ab1cfd59f049ade329eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Dec 2010 09:41:00 -0600 Subject: Oops, wrong version -- fixed --- libdbusmenu-glib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index e6aecd6..e45f700 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -142,7 +142,7 @@ Dbusmenu_Glib_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) 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.2 +Dbusmenu_Glib_0_4_gir_VERSION = Glib-0.4 Dbusmenu_Glib_0_4_gir_PACKAGES = dbusmenu-glib Dbusmenu_Glib_0_4_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) -- cgit v1.2.3 From 58c157738e5aae7a01422b21a3b1f0a6e3ca2ed9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Dec 2010 21:17:43 -0600 Subject: Wrong directory for jsonloader header files. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index df2a364..17b44d1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,7 +52,7 @@ XVFB_RUN=". $(srcdir)/run-xvfb.sh" lib_LTLIBRARIES = libdbusmenu-jsonloader.la -libdbusmenu_jsonloaderincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-jsonloader/ +libdbusmenu_jsonloaderincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-jsonloader/ libdbusmenu_jsonloaderinclude_HEADERS = \ json-loader.h -- cgit v1.2.3 From 1a73825600508b5d7f027641b05a682a8ac81f5e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 09:27:48 -0600 Subject: Fixing the requires in the pc files --- libdbusmenu-glib/dbusmenu-glib-0.4.pc.in | 2 +- libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in | 2 +- libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in | 2 +- tests/dbusmenu-jsonloader-0.4.pc.in | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in b/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in index 3f31664..31a1eac 100644 --- a/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in +++ b/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in @@ -5,7 +5,7 @@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libdbusmenu-0.4 -Requires: dbus-glib-1 +Requires: Libs: -L${libdir} -ldbusmenu-glib Name: libdbusmenu-glib diff --git a/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in index f35c621..8784556 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in @@ -5,7 +5,7 @@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libdbusmenu-0.4 -Requires: dbus-glib-1 dbusmenu-glib +Requires: dbusmenu-glib-0.4 Libs: -L${libdir} -ldbusmenu-gtk Name: libdbusmenu-gtk diff --git a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in index 033c390..804b13e 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in @@ -5,7 +5,7 @@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libdbusmenu-0.4 -Requires: dbus-glib-1 dbusmenu-glib +Requires: dbusmenu-glib-0.4 Libs: -L${libdir} -ldbusmenu-gtk3 Name: libdbusmenu-gtk3 diff --git a/tests/dbusmenu-jsonloader-0.4.pc.in b/tests/dbusmenu-jsonloader-0.4.pc.in index d042132..62bfeb2 100644 --- a/tests/dbusmenu-jsonloader-0.4.pc.in +++ b/tests/dbusmenu-jsonloader-0.4.pc.in @@ -5,7 +5,7 @@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libdbusmenu-0.1 -Requires: dbus-glib-1,dbusmenu-glib,json-glib-1.0 +Requires: dbusmenu-glib-0.4 json-glib-1.0 Libs: -L${libdir} -ldbusmenu-jsonloader Name: libdbusmenu-jsonloader -- cgit v1.2.3 From b29bfd7c365a6b768dcf4530c40e9220d9e8abd1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Dec 2010 10:18:26 -0600 Subject: Upping the library version as we're different ABI than 0.3.90 even :-/ --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e18452b..cab1c42 100644 --- a/configure.ac +++ b/configure.ac @@ -135,7 +135,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) # Lib versioning ########################### -LIBDBUSMENU_CURRENT=2 +LIBDBUSMENU_CURRENT=3 LIBDBUSMENU_REVISION=0 LIBDBUSMENU_AGE=0 -- cgit v1.2.3 From 1574d58e111bd80cbeb770ab3f603dca88a90341 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Dec 2010 16:36:48 -0600 Subject: Switching away from using set_activate as that doesn't actually set the value, it just signals, but we're sucking up that signal already so we need to manually create it if we need it, which is the only way to set the active property. Goofy. --- libdbusmenu-gtk/genericmenuitem.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index d507487..d3023ad 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -65,6 +65,7 @@ static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, cairo_t static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) = NULL; #endif +static void (*parent_menuitem_activate) (GtkMenuItem * mi) = NULL; /* Initializing all of the classes. Most notably we're disabling the drawing of the check early. */ @@ -86,6 +87,7 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) GtkMenuItemClass * menuitem_class = GTK_MENU_ITEM_CLASS (klass); menuitem_class->set_label = set_label; menuitem_class->get_label = get_label; + parent_menuitem_activate = menuitem_class->activate; menuitem_class->activate = activate; return; @@ -338,21 +340,19 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) item->priv->state = state; GtkCheckMenuItem * check = GTK_CHECK_MENU_ITEM(item); - - gboolean old_active = gtk_check_menu_item_get_active (check); - gboolean old_inconsist = gtk_check_menu_item_get_inconsistent (check); + gboolean goal_active = FALSE; switch (item->priv->state) { case GENERICMENUITEM_STATE_UNCHECKED: - gtk_check_menu_item_set_active (check, FALSE); + goal_active = FALSE; gtk_check_menu_item_set_inconsistent (check, FALSE); break; case GENERICMENUITEM_STATE_CHECKED: - gtk_check_menu_item_set_active (check, TRUE); + goal_active = TRUE; gtk_check_menu_item_set_inconsistent (check, FALSE); break; case GENERICMENUITEM_STATE_INDETERMINATE: - gtk_check_menu_item_set_active (check, TRUE); + goal_active = TRUE; gtk_check_menu_item_set_inconsistent (check, TRUE); break; default: @@ -360,16 +360,12 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) return; } - if (old_active != gtk_check_menu_item_get_active (check)) { - g_object_notify(G_OBJECT(item), "active"); - } - - if (old_inconsist != gtk_check_menu_item_get_inconsistent (check)) { - g_object_notify(G_OBJECT(item), "inconsistent"); + if (goal_active != gtk_check_menu_item_get_active(check)) { + if (parent_menuitem_activate != NULL) { + parent_menuitem_activate(GTK_MENU_ITEM(check)); + } } - gtk_widget_queue_draw(GTK_WIDGET(item)); - return; } -- cgit v1.2.3 From 9ca2114ba780c0d7976e66fbc6e4ae750a7522c4 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 13 Dec 2010 13:40:01 +0000 Subject: Bracked public libdbusmenu-gtk/menuitem.h header with G_{BEGIN/END}_DECLS, so it can be used from C++ consumers --- libdbusmenu-gtk/menuitem.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h index 6960f76..a2b6652 100644 --- a/libdbusmenu-gtk/menuitem.h +++ b/libdbusmenu-gtk/menuitem.h @@ -35,6 +35,8 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +G_BEGIN_DECLS + gboolean dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * property, const GdkPixbuf * data); GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * property); @@ -43,4 +45,6 @@ gboolean dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menu gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi); void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifiers); +G_END_DECLS + #endif -- cgit v1.2.3 From 84969770f06f78f92f8e587c779e148d1d240f99 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 13 Dec 2010 13:45:05 +0000 Subject: * Hook in AboutToShow to the menu items --- libdbusmenu-glib/server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 8a10715..d1d82bd 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1079,6 +1079,8 @@ bus_about_to_show (DbusmenuServer * server, GVariant * params, GDBusMethodInvoca return; } + dbusmenu_menuitem_send_about_to_show(mi, NULL, NULL); + /* GTK+ does not support about-to-show concept for now */ g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", FALSE)); -- cgit v1.2.3 From 09cb60267e5a4773ec5965e7e1a2ff92a690d7f0 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 13 Dec 2010 16:51:45 +0000 Subject: Add an about-to-show signal to the menu items and hook this up to be emitted when someone calls dbusmenu_menuitem_send_about_to_show --- libdbusmenu-glib/menuitem.c | 19 ++++++++++++++++++- libdbusmenu-glib/menuitem.h | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ad6472b..747cc01 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -70,6 +70,7 @@ enum { CHILD_MOVED, REALIZED, SHOW_TO_USER, + ABOUT_TO_SHOW, LAST_SIGNAL }; @@ -229,6 +230,21 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT, G_TYPE_NONE); + /** + DbusmenuMenuitem::about-to-show: + @arg0: The #DbusmenuMenuitem object. + + Emitted when the submenu for this item + is about to be shown + */ + signals[ABOUT_TO_SHOW] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(DbusmenuMenuitemClass, about_to_show), + NULL, NULL, + _dbusmenu_menuitem_marshal_VOID__VOID, + G_TYPE_BOOLEAN, 0, G_TYPE_NONE); + g_object_class_install_property (object_class, PROP_ID, g_param_spec_int(PROP_ID_S, "ID for the menu item", "This is a unique indentifier for the menu item.", @@ -398,7 +414,8 @@ send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gp if (dbusmenu_menuitem_get_children(mi) == NULL) { g_warning("About to Show called on an item wihtout submenus. We're ignoring it."); } else { - g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, 0 /* timestamp */, TRUE); + gboolean dummy; + g_signal_emit(G_OBJECT(mi), signals[ABOUT_TO_SHOW], 0, &dummy); } if (cb != NULL) { diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 9158f3e..0058ded 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -50,6 +50,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_SIGNAL_REALIZED "realized" #define DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID (g_signal_lookup(DBUSMENU_MENUITEM_SIGNAL_REALIZED, DBUSMENU_TYPE_MENUITEM)) #define DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER "show-to-user" +#define DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW "about-to-show" #define DBUSMENU_MENUITEM_PROP_TYPE "type" #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" @@ -158,6 +159,7 @@ struct _DbusmenuMenuitemClass 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); + gboolean (*about_to_show) (void); /*< Private >*/ void (*reserved1) (void); @@ -165,7 +167,6 @@ struct _DbusmenuMenuitemClass void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); - void (*reserved6) (void); }; GType dbusmenu_menuitem_get_type (void); -- cgit v1.2.3 From a02639a8849df82b563331783f5d571622d65208 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 5 Jan 2011 16:58:37 -0600 Subject: Handling the case of a NULL variant by making it clear the hashtable of that property. --- libdbusmenu-glib/menuitem.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ad6472b..50354ee 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -984,14 +984,22 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - gchar * lprop = g_strdup(property); - g_variant_ref(value); - gboolean replaced = FALSE; - gpointer currentval = g_hash_table_lookup(priv->properties, lprop); - if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) { - g_hash_table_replace(priv->properties, lprop, value); - replaced = TRUE; + gpointer currentval = g_hash_table_lookup(priv->properties, property); + + if (value != NULL) { + gchar * lprop = g_strdup(property); + g_variant_ref(value); + + if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) { + g_hash_table_replace(priv->properties, lprop, value); + replaced = TRUE; + } + } else { + if (currentval != NULL) { + g_hash_table_remove(priv->properties, property); + replaced = TRUE; + } } /* NOTE: The actual value is invalid at this point @@ -999,7 +1007,7 @@ 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, lprop, value, TRUE); + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE); } return TRUE; -- cgit v1.2.3 From e5f53f91d929c46914b4a02336e31724fb54ec95 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 5 Jan 2011 20:47:09 -0600 Subject: Adding a test to test removing of properties --- tests/test-glib-objects.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 7143814..2c8eda9 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -274,6 +274,29 @@ test_object_menuitem_props_boolstr (void) return; } +/* Set and then remove a prop */ +static void +test_object_menuitem_props_removal (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + + /* Set the property and ensure that it's set */ + dbusmenu_menuitem_property_set_variant(item, "myprop", g_variant_new_int32(34)); + g_assert(dbusmenu_menuitem_property_get_variant(item, "myprop") != NULL); + + /* Remove the property and ensure it goes away */ + dbusmenu_menuitem_property_set_variant(item, "myprop", NULL); + g_assert(dbusmenu_menuitem_property_get_variant(item, "myprop") == NULL); + + g_object_unref(item); + + return; +} + /* Build the test suite */ static void test_glib_objects_suite (void) @@ -286,6 +309,7 @@ test_glib_objects_suite (void) g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_swap", test_object_menuitem_props_swap); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_signals", test_object_menuitem_props_signals); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_boolstr", test_object_menuitem_props_boolstr); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_removal", test_object_menuitem_props_removal); return; } -- cgit v1.2.3 From 0c50ae11cafdd7ca04ae6d2a69390903d16daedd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 5 Jan 2011 20:49:47 -0600 Subject: Adding a test for removal by string being NULL --- tests/test-glib-objects.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 2c8eda9..9c99280 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -292,6 +292,14 @@ test_object_menuitem_props_removal (void) dbusmenu_menuitem_property_set_variant(item, "myprop", NULL); g_assert(dbusmenu_menuitem_property_get_variant(item, "myprop") == NULL); + /* Set the property again */ + dbusmenu_menuitem_property_set_variant(item, "myprop", g_variant_new_int32(34)); + g_assert(dbusmenu_menuitem_property_get_variant(item, "myprop") != NULL); + + /* Remove the property with a NULL string */ + dbusmenu_menuitem_property_set(item, "myprop", NULL); + g_assert(dbusmenu_menuitem_property_get_variant(item, "myprop") == NULL); + g_object_unref(item); return; -- cgit v1.2.3 From 47263d9b6c912d013a77ce2efda27df9c7571920 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 5 Jan 2011 20:51:51 -0600 Subject: Testing for the string being NULL before g_variant aborts on it. --- libdbusmenu-glib/menuitem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 50354ee..31c23f4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -913,7 +913,10 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id) gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value) { - GVariant * variant = g_variant_new("s", value); + GVariant * variant = NULL; + if (value != NULL) { + g_variant_new_string(value); + } return dbusmenu_menuitem_property_set_variant(mi, property, variant); } -- cgit v1.2.3 From 1b77b621285fe681ca030bf3f548ad04b50dd242 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 5 Jan 2011 20:53:27 -0600 Subject: Oops, need to actually assign that return. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 31c23f4..1e892c3 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -915,7 +915,7 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c { GVariant * variant = NULL; if (value != NULL) { - g_variant_new_string(value); + variant = g_variant_new_string(value); } return dbusmenu_menuitem_property_set_variant(mi, property, variant); } -- cgit v1.2.3 From a8b425c5868c73739f60997ebc2013df3b3d6d4b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 13 Jan 2011 09:53:15 -0600 Subject: Ayatana purge --- libdbusmenu-glib/clean-namespaces.xslt | 2 +- libdbusmenu-glib/client.c | 2 +- libdbusmenu-glib/dbus-menu.xml | 6 +++--- libdbusmenu-glib/server.c | 8 ++++---- tools/dbusmenu-bench | 2 +- tools/dbusmenu-dumper.c | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-glib/clean-namespaces.xslt b/libdbusmenu-glib/clean-namespaces.xslt index 8344a71..8c0c521 100644 --- a/libdbusmenu-glib/clean-namespaces.xslt +++ b/libdbusmenu-glib/clean-namespaces.xslt @@ -1,4 +1,4 @@ - + diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a15469b..58d6360 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -122,7 +122,7 @@ struct _event_data_t { #define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) -#define DBUSMENU_INTERFACE "org.ayatana.dbusmenu" +#define DBUSMENU_INTERFACE "com.canonical.dbusmenu" /* GObject Stuff */ static void dbusmenu_client_class_init (DbusmenuClientClass *klass); diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 9e8013c..042a24c 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -28,15 +28,15 @@ 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 --> - + - + Date: Thu, 13 Jan 2011 09:57:37 -0600 Subject: Fixing packages names for the gir scanner --- libdbusmenu-glib/Makefile.am | 2 +- libdbusmenu-gtk/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index e45f700..4a65ac0 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -143,7 +143,7 @@ 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_PACKAGES = dbusmenu-glib +Dbusmenu_Glib_0_4_gir_PACKAGES = dbusmenu-glib-0.4 Dbusmenu_Glib_0_4_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) INTROSPECTION_GIRS += Dbusmenu-Glib-0.4.gir diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index ac2eee9..1957820 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -95,7 +95,7 @@ DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) DbusmenuGtk_0_4_gir_NAMESPACE = DbusmenuGtk$(VER) DbusmenuGtk_0_4_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS) -DbusmenuGtk_0_4_gir_PACKAGES = dbusmenu-gtk$(VER) +DbusmenuGtk_0_4_gir_PACKAGES = dbusmenu-gtk$(VER)-0.4 # We duplicate these for the same reason as libdbusmenu_gtk3includedir above DbusmenuGtk3_0_4_gir_INCLUDES = $(DbusmenuGtk_0_4_gir_INCLUDES) -- cgit v1.2.3 From 2cfbfcab8a2c73227619eb3cd7a79e1fe17a8b43 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 13 Jan 2011 10:03:21 -0600 Subject: 0.3.91 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index cab1c42..f1920b9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.90, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.91, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.90, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.91, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 8545febdaac50ee3c741f20141c20c27911a5b96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 09:56:07 -0600 Subject: Unboxing variants if they're in events. --- libdbusmenu-glib/server.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 373cc05..100eb14 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1047,6 +1047,12 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i event_data->timestamp = g_variant_get_uint32(g_variant_get_child_value(params, 3)); event_data->variant = g_variant_get_child_value(params, 2); + if (g_variant_is_of_type(event_data->variant, G_VARIANT_TYPE_VARIANT)) { + event_data->variant = g_variant_get_variant(event_data->variant); + } + + g_variant_ref(event_data->variant); + g_timeout_add(0, event_local_handler, event_data); g_dbus_method_invocation_return_value(invocation, NULL); -- cgit v1.2.3 From c6d2783146648f2c80635b693608fb20704b25bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 10:30:30 -0600 Subject: Adding the notdir on the build --- libdbusmenu-glib/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 4a65ac0..a1247a3 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -56,10 +56,10 @@ pkgconfig_DATA = dbusmenu-glib-0.4.pc pkgconfigdir = $(libdir)/pkgconfig %.xml.h: %.xml - echo "extern const char * $(subst -,_,$(subst .,_,$(basename $@)));" > $@ + echo "extern const char * $(subst -,_,$(subst .,_,$(basename $(notdir $@))));" > $@ %.xml.c: %.xml - echo "const char * $(subst -,_,$(subst .,_,$(basename $@))) = " > $@ + echo "const char * $(subst -,_,$(subst .,_,$(basename $(notdir $@)))) = " > $@ sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ echo ";" >> $@ -- cgit v1.2.3 From 499e96b9384305466173d986ddb9c53f8b01640b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 10:30:40 -0600 Subject: 0.3.92 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index f1920b9..5c85da8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.91, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.92, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.91, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.92, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 66cfbe695f21345bb0cf84824f4b2d9183067a25 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Tue, 18 Jan 2011 10:02:47 -0500 Subject: Use EXPORT_PACKAGES instead of PACKAGES to prevent circular build depends --- libdbusmenu-glib/Makefile.am | 2 +- libdbusmenu-gtk/Makefile.am | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index a1247a3..f502fb3 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -143,7 +143,7 @@ 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_PACKAGES = dbusmenu-glib-0.4 +Dbusmenu_Glib_0_4_gir_EXPORT_PACKAGES = dbusmenu-glib-0.4 Dbusmenu_Glib_0_4_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) INTROSPECTION_GIRS += Dbusmenu-Glib-0.4.gir diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 1957820..0b939c0 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -95,7 +95,7 @@ DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) DbusmenuGtk_0_4_gir_NAMESPACE = DbusmenuGtk$(VER) DbusmenuGtk_0_4_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS) -DbusmenuGtk_0_4_gir_PACKAGES = dbusmenu-gtk$(VER)-0.4 +DbusmenuGtk_0_4_gir_EXPORT_PACKAGES = dbusmenu-gtk$(VER)-0.4 # We duplicate these for the same reason as libdbusmenu_gtk3includedir above DbusmenuGtk3_0_4_gir_INCLUDES = $(DbusmenuGtk_0_4_gir_INCLUDES) @@ -104,7 +104,7 @@ DbusmenuGtk3_0_4_gir_LIBS = $(DbusmenuGtk_0_4_gir_LIBS) DbusmenuGtk3_0_4_gir_FILES = $(DbusmenuGtk_0_4_gir_FILES) DbusmenuGtk3_0_4_gir_NAMESPACE = $(DbusmenuGtk_0_4_gir_NAMESPACE) DbusmenuGtk3_0_4_gir_SCANNERFLAGS = $(DbusmenuGtk_0_4_gir_SCANNERFLAGS) -DbusmenuGtk3_0_4_gir_PACKAGES = $(DbusmenuGtk_0_4_gir_PACKAGES) +DbusmenuGtk3_0_4_gir_EXPORT_PACKAGES = $(DbusmenuGtk_0_4_gir_EXPORT_PACKAGES) INTROSPECTION_GIRS += DbusmenuGtk$(VER)-0.4.gir -- cgit v1.2.3 From 31d28c2b7f818749973aa528fca53632a129f83d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 10:32:29 -0600 Subject: Fixing builder to only init/finish if there are entries we get. --- libdbusmenu-glib/server.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 100eb14..03886bb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -894,13 +894,18 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho g_variant_iter_init(&ids, g_variant_get_child_value(params, 0)); GVariantBuilder builder; - g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); + gboolean builder_init = FALSE; gint id; while (g_variant_iter_next(&ids, "i", &id)) { DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) continue; + if (!builder_init) { + g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); + builder_init = TRUE; + } + GVariantBuilder wbuilder; g_variant_builder_init(&wbuilder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add(&wbuilder, "i", id); @@ -916,7 +921,13 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho g_variant_builder_add_value(&builder, mi_data); } - GVariant * ret = g_variant_builder_end(&builder); + GVariant * ret = NULL; + + if (builder_init) { + ret = g_variant_builder_end(&builder); + } else { + ret = g_variant_parse(g_variant_type_new("a(ia(sv))"), "[]", NULL, NULL, NULL); + } g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value(&builder, ret); -- cgit v1.2.3 From 4c8f8ca605bb7e2780c089c42ca58e8c0c7aa7dd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 10:34:22 -0600 Subject: Protecting the final tuple from errors. --- libdbusmenu-glib/server.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 03886bb..39176c2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -929,9 +929,14 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho ret = g_variant_parse(g_variant_type_new("a(ia(sv))"), "[]", NULL, NULL, NULL); } - g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add_value(&builder, ret); - GVariant * final = g_variant_builder_end(&builder); + GVariant * final = NULL; + if (ret != NULL) { + g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value(&builder, ret); + final = g_variant_builder_end(&builder); + } else { + g_warning("Error building property list, final variant is NULL"); + } g_dbus_method_invocation_return_value(invocation, final); -- cgit v1.2.3 From 72a77bdfbe9dd9925648b2cfa8b11804758def40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 10:38:27 -0600 Subject: Adding warnings on g_variant_parse errors --- libdbusmenu-glib/server.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 39176c2..8d18feb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -912,7 +912,13 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho GVariant * props = dbusmenu_menuitem_properties_variant(mi); if (props == NULL) { - props = g_variant_parse(g_variant_type_new("a{sv}"), "{}", NULL, NULL, NULL); + GError * error = NULL; + props = g_variant_parse(g_variant_type_new("a{sv}"), "{}", NULL, NULL, &error); + if (error != NULL) { + g_warning("Unable to parse '{}' as a 'a{sv}'"); + g_error_free(error); + props = NULL; + } } g_variant_builder_add_value(&wbuilder, props); @@ -926,7 +932,13 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho if (builder_init) { ret = g_variant_builder_end(&builder); } else { + GError * error = 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))'"); + g_error_free(error); + ret = NULL; + } } GVariant * final = NULL; -- cgit v1.2.3 From 74ccb9b179c63ae79719b480247bb844326ab675 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 10:39:09 -0600 Subject: Use the message string. --- 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 8d18feb..75a305c 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -915,7 +915,7 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho GError * error = NULL; props = g_variant_parse(g_variant_type_new("a{sv}"), "{}", NULL, NULL, &error); if (error != NULL) { - g_warning("Unable to parse '{}' as a 'a{sv}'"); + g_warning("Unable to parse '{}' as a 'a{sv}': %s", error->message); g_error_free(error); props = NULL; } @@ -935,7 +935,7 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho GError * error = 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))'"); + g_warning("Unable to parse '[]' as a 'a(ia(sv))': %s", error->message); g_error_free(error); ret = NULL; } -- cgit v1.2.3 From 6cb4e78579f4d202ca797dfbc9a998e1cc58186a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 10:47:32 -0600 Subject: Warn when can't parse. --- libdbusmenu-glib/server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 75a305c..6be2a60 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1009,7 +1009,13 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat ret = g_variant_new("(a(ia{svg}))", g_variant_builder_end(&builder)); } else { - ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, NULL); + GError * error = NULL; + ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, &error); + if (error != NULL) { + g_warning("Unable to parse '([(0, {})],)' as a '(a(ia{sv}))': %s", error->message); + g_error_free(error); + ret = NULL; + } } g_dbus_method_invocation_return_value(invocation, ret); -- cgit v1.2.3 -- cgit v1.2.3 From 88a9ad428716c028fc8de094b814623af07adec6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 12:39:57 -0600 Subject: Send a LayoutUpdated when we register the object. --- libdbusmenu-glib/server.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 100eb14..51a47b2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -506,6 +506,19 @@ register_object (DbusmenuServer * server) if (error != NULL) { g_warning("Unable to register object on bus: %s", error->message); g_error_free(error); + return; + } + + /* If we've got it registered let's tell everyone about it */ + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); + if (priv->dbusobject != NULL && priv->bus != NULL) { + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + DBUSMENU_INTERFACE, + "LayoutUpdated", + g_variant_new("(ui)", priv->layout_revision, 0), + NULL); } return; -- cgit v1.2.3 From cedc4584f11e6fa90ae73db5ecc3019868a6323e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 15:59:36 -0600 Subject: Set the use-fallback property to TRUE on all our Images --- libdbusmenu-gtk/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index b01156f..18a2cdd 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -789,6 +789,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant gtkimage = NULL; } else if (g_strcmp0(iconname, DBUSMENU_MENUITEM_ICON_NAME_BLANK) == 0) { gtkimage = gtk_image_new(); + g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL); } else { /* Look to see if we want to have an icon with the 'ltr' or 'rtl' depending on what we're doing. */ @@ -807,6 +808,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant can just convert it to this name. */ if (gtkimage == NULL) { gtkimage = gtk_image_new_from_icon_name(finaliconname, GTK_ICON_SIZE_MENU); + g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL); } else { gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), finaliconname, GTK_ICON_SIZE_MENU); } -- cgit v1.2.3 From e319b07fba9a47a15aae9ef7c85da464b75874ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 16:02:48 -0600 Subject: Steal the serializable menuitem from IDO --- libdbusmenu-gtk/serializablemenuitem.c | 99 ++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/serializablemenuitem.h | 58 ++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 libdbusmenu-gtk/serializablemenuitem.c create mode 100644 libdbusmenu-gtk/serializablemenuitem.h diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c new file mode 100644 index 0000000..2c166d8 --- /dev/null +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -0,0 +1,99 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "idoserializablemenuitem.h" + +struct _IdoSerializableMenuItemPrivate { + int dummy; +}; + +#define IDO_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItemPrivate)) + +static void ido_serializable_menu_item_class_init (IdoSerializableMenuItemClass *klass); +static void ido_serializable_menu_item_init (IdoSerializableMenuItem *self); +static void ido_serializable_menu_item_dispose (GObject *object); +static void ido_serializable_menu_item_finalize (GObject *object); + +G_DEFINE_TYPE (IdoSerializableMenuItem, ido_serializable_menu_item, GTK_TYPE_MENU_ITEM); + +static void +ido_serializable_menu_item_class_init (IdoSerializableMenuItemClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (IdoSerializableMenuItemPrivate)); + + object_class->dispose = ido_serializable_menu_item_dispose; + object_class->finalize = ido_serializable_menu_item_finalize; + + return; +} + +static void +ido_serializable_menu_item_init (IdoSerializableMenuItem *self) +{ + self->priv = IDO_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(self); + + self->priv->dummy = 5; + + return; +} + +static void +ido_serializable_menu_item_dispose (GObject *object) +{ + + + G_OBJECT_CLASS (ido_serializable_menu_item_parent_class)->dispose (object); + return; +} + +static void +ido_serializable_menu_item_finalize (GObject *object) +{ + + + + G_OBJECT_CLASS (ido_serializable_menu_item_parent_class)->finalize (object); + return; +} + +DbusmenuMenuitem * +ido_serializable_menu_item_get_dbusmenu_menuitem (IdoSerializableMenuItem * smi) +{ + g_return_val_if_fail(IDO_IS_SERIALIZABLE_MENU_ITEM(smi), NULL); + + IdoSerializableMenuItemClass * klass = IDO_SERIALIZABLE_MENU_ITEM_GET_CLASS(smi); + if (klass->get_dbusmenu_menuitem != NULL) { + return klass->get_dbusmenu_menuitem(smi); + } + + return NULL; +} + +void +ido_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) +{ + g_return_if_fail(g_type_is_a(item_type, IDO_TYPE_SERIALIZABLE_MENU_ITEM)); + + gpointer type_class = g_type_class_ref(item_type); + g_return_if_fail(type_class != NULL); + + IdoSerializableMenuItemClass * class = IDO_SERIALIZABLE_MENU_ITEM_CLASS(type_class); + + if (class->get_type_string == NULL) { + g_type_class_unref(type_class); + g_error("No 'get_type_string' in subclass of IdoSerializableMenuItem"); + return; + } + + /* Register type */ + + + /* Register defaults */ + + + return; +} diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h new file mode 100644 index 0000000..48fdb49 --- /dev/null +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -0,0 +1,58 @@ +#ifndef __IDO_SERIALIZABLE_MENU_ITEM_H__ +#define __IDO_SERIALIZABLE_MENU_ITEM_H__ + +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define IDO_TYPE_SERIALIZABLE_MENU_ITEM (ido_serializable_menu_item_get_type ()) +#define IDO_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItem)) +#define IDO_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItemClass)) +#define IDO_IS_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDO_TYPE_SERIALIZABLE_MENU_ITEM)) +#define IDO_IS_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDO_TYPE_SERIALIZABLE_MENU_ITEM)) +#define IDO_SERIALIZABLE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItemClass)) + +typedef struct _IdoSerializableMenuItem IdoSerializableMenuItem; +typedef struct _IdoSerializableMenuItemClass IdoSerializableMenuItemClass; +typedef struct _IdoSerializableMenuItemPrivate IdoSerializableMenuItemPrivate; + +struct _IdoSerializableMenuItemClass { + GtkMenuItemClass parent_class; + + /* Subclassable functions */ + const gchar * (*get_type_string) (void); + GHashTable * (*get_default_properties) (void); + + DbusmenuMenuitem * (*get_dbusmenu_menuitem) (IdoSerializableMenuItem * smi); + + /* Signals */ + + + + /* Empty Space */ + void (*_ido_serializable_menu_item_reserved1) (void); + void (*_ido_serializable_menu_item_reserved2) (void); + void (*_ido_serializable_menu_item_reserved3) (void); + void (*_ido_serializable_menu_item_reserved4) (void); + void (*_ido_serializable_menu_item_reserved5) (void); + void (*_ido_serializable_menu_item_reserved6) (void); +}; + +struct _IdoSerializableMenuItem { + GtkMenuItem parent; + + IdoSerializableMenuItemPrivate * priv; +}; + +GType ido_serializable_menu_item_get_type (void); + +DbusmenuMenuitem * ido_serializable_menu_item_get_dbusmenu_menuitem (IdoSerializableMenuItem * smi); +void ido_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); + +G_END_DECLS + +#endif -- cgit v1.2.3 From d43d544702665d2653f7dbb9c73493733ff2fae6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 16:27:12 -0600 Subject: Adding the files to the build --- libdbusmenu-gtk/Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 0b939c0..a424d4a 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -22,7 +22,8 @@ libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-gtk$(VER)/ libdbusmenu_gtkinclude_HEADERS = \ client.h \ menu.h \ - menuitem.h + menuitem.h \ + serializablemenuitem.h libdbusmenu_gtk_la_SOURCES = \ client.h \ @@ -32,7 +33,9 @@ libdbusmenu_gtk_la_SOURCES = \ menu.h \ menu.c \ menuitem.h \ - menuitem.c + menuitem.c \ + serializablemenuitem.h \ + serializablemenuitem.c libdbusmenu_gtk_la_LDFLAGS = \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ -- cgit v1.2.3 From 8122074a5e67cf69f147a8b10b31c1fefaf64486 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 16:32:02 -0600 Subject: Changing namespace from IDO to DBusMenu GTK --- libdbusmenu-gtk/serializablemenuitem.c | 52 +++++++++++++++++----------------- libdbusmenu-gtk/serializablemenuitem.h | 48 +++++++++++++++---------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 2c166d8..c9eb416 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -2,39 +2,39 @@ #include "config.h" #endif -#include "idoserializablemenuitem.h" +#include "serializablemenuitem.h" -struct _IdoSerializableMenuItemPrivate { +struct _DbusmenuGtkSerializableMenuItemPrivate { int dummy; }; -#define IDO_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItemPrivate)) +#define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemPrivate)) -static void ido_serializable_menu_item_class_init (IdoSerializableMenuItemClass *klass); -static void ido_serializable_menu_item_init (IdoSerializableMenuItem *self); -static void ido_serializable_menu_item_dispose (GObject *object); -static void ido_serializable_menu_item_finalize (GObject *object); +static void dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemClass *klass); +static void dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self); +static void dbusmenu_gtk_serializable_menu_item_dispose (GObject *object); +static void dbusmenu_gtk_serializable_menu_item_finalize (GObject *object); -G_DEFINE_TYPE (IdoSerializableMenuItem, ido_serializable_menu_item, GTK_TYPE_MENU_ITEM); +G_DEFINE_TYPE (DbusmenuGtkSerializableMenuItem, dbusmenu_gtk_serializable_menu_item, GTK_TYPE_MENU_ITEM); static void -ido_serializable_menu_item_class_init (IdoSerializableMenuItemClass *klass) +dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (IdoSerializableMenuItemPrivate)); + g_type_class_add_private (klass, sizeof (DbusmenuGtkSerializableMenuItemPrivate)); - object_class->dispose = ido_serializable_menu_item_dispose; - object_class->finalize = ido_serializable_menu_item_finalize; + object_class->dispose = dbusmenu_gtk_serializable_menu_item_dispose; + object_class->finalize = dbusmenu_gtk_serializable_menu_item_finalize; return; } static void -ido_serializable_menu_item_init (IdoSerializableMenuItem *self) +dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self) { - self->priv = IDO_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(self); + self->priv = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(self); self->priv->dummy = 5; @@ -42,30 +42,30 @@ ido_serializable_menu_item_init (IdoSerializableMenuItem *self) } static void -ido_serializable_menu_item_dispose (GObject *object) +dbusmenu_gtk_serializable_menu_item_dispose (GObject *object) { - G_OBJECT_CLASS (ido_serializable_menu_item_parent_class)->dispose (object); + G_OBJECT_CLASS (dbusmenu_gtk_serializable_menu_item_parent_class)->dispose (object); return; } static void -ido_serializable_menu_item_finalize (GObject *object) +dbusmenu_gtk_serializable_menu_item_finalize (GObject *object) { - G_OBJECT_CLASS (ido_serializable_menu_item_parent_class)->finalize (object); + G_OBJECT_CLASS (dbusmenu_gtk_serializable_menu_item_parent_class)->finalize (object); return; } DbusmenuMenuitem * -ido_serializable_menu_item_get_dbusmenu_menuitem (IdoSerializableMenuItem * smi) +dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) { - g_return_val_if_fail(IDO_IS_SERIALIZABLE_MENU_ITEM(smi), NULL); + g_return_val_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi), NULL); - IdoSerializableMenuItemClass * klass = IDO_SERIALIZABLE_MENU_ITEM_GET_CLASS(smi); + DbusmenuGtkSerializableMenuItemClass * klass = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_CLASS(smi); if (klass->get_dbusmenu_menuitem != NULL) { return klass->get_dbusmenu_menuitem(smi); } @@ -74,18 +74,18 @@ ido_serializable_menu_item_get_dbusmenu_menuitem (IdoSerializableMenuItem * smi) } void -ido_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) +dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) { - g_return_if_fail(g_type_is_a(item_type, IDO_TYPE_SERIALIZABLE_MENU_ITEM)); + g_return_if_fail(g_type_is_a(item_type, DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)); gpointer type_class = g_type_class_ref(item_type); g_return_if_fail(type_class != NULL); - IdoSerializableMenuItemClass * class = IDO_SERIALIZABLE_MENU_ITEM_CLASS(type_class); + DbusmenuGtkSerializableMenuItemClass * class = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_CLASS(type_class); if (class->get_type_string == NULL) { g_type_class_unref(type_class); - g_error("No 'get_type_string' in subclass of IdoSerializableMenuItem"); + g_error("No 'get_type_string' in subclass of DbusmenuGtkSerializableMenuItem"); return; } diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index 48fdb49..e99d329 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -1,5 +1,5 @@ -#ifndef __IDO_SERIALIZABLE_MENU_ITEM_H__ -#define __IDO_SERIALIZABLE_MENU_ITEM_H__ +#ifndef __DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ +#define __DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ #include #include @@ -9,49 +9,49 @@ G_BEGIN_DECLS -#define IDO_TYPE_SERIALIZABLE_MENU_ITEM (ido_serializable_menu_item_get_type ()) -#define IDO_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItem)) -#define IDO_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItemClass)) -#define IDO_IS_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDO_TYPE_SERIALIZABLE_MENU_ITEM)) -#define IDO_IS_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDO_TYPE_SERIALIZABLE_MENU_ITEM)) -#define IDO_SERIALIZABLE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDO_TYPE_SERIALIZABLE_MENU_ITEM, IdoSerializableMenuItemClass)) +#define DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM (dbusmenu_gtk_serializable_menu_item_get_type ()) +#define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItem)) +#define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemClass)) +#define DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)) +#define DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)) +#define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemClass)) -typedef struct _IdoSerializableMenuItem IdoSerializableMenuItem; -typedef struct _IdoSerializableMenuItemClass IdoSerializableMenuItemClass; -typedef struct _IdoSerializableMenuItemPrivate IdoSerializableMenuItemPrivate; +typedef struct _DbusmenuGtkSerializableMenuItem DbusmenuGtkSerializableMenuItem; +typedef struct _DbusmenuGtkSerializableMenuItemClass DbusmenuGtkSerializableMenuItemClass; +typedef struct _DbusmenuGtkSerializableMenuItemPrivate DbusmenuGtkSerializableMenuItemPrivate; -struct _IdoSerializableMenuItemClass { +struct _DbusmenuGtkSerializableMenuItemClass { GtkMenuItemClass parent_class; /* Subclassable functions */ const gchar * (*get_type_string) (void); GHashTable * (*get_default_properties) (void); - DbusmenuMenuitem * (*get_dbusmenu_menuitem) (IdoSerializableMenuItem * smi); + DbusmenuMenuitem * (*get_dbusmenu_menuitem) (DbusmenuGtkSerializableMenuItem * smi); /* Signals */ /* Empty Space */ - void (*_ido_serializable_menu_item_reserved1) (void); - void (*_ido_serializable_menu_item_reserved2) (void); - void (*_ido_serializable_menu_item_reserved3) (void); - void (*_ido_serializable_menu_item_reserved4) (void); - void (*_ido_serializable_menu_item_reserved5) (void); - void (*_ido_serializable_menu_item_reserved6) (void); + void (*_dbusmenu_gtk_serializable_menu_item_reserved1) (void); + void (*_dbusmenu_gtk_serializable_menu_item_reserved2) (void); + void (*_dbusmenu_gtk_serializable_menu_item_reserved3) (void); + void (*_dbusmenu_gtk_serializable_menu_item_reserved4) (void); + void (*_dbusmenu_gtk_serializable_menu_item_reserved5) (void); + void (*_dbusmenu_gtk_serializable_menu_item_reserved6) (void); }; -struct _IdoSerializableMenuItem { +struct _DbusmenuGtkSerializableMenuItem { GtkMenuItem parent; - IdoSerializableMenuItemPrivate * priv; + DbusmenuGtkSerializableMenuItemPrivate * priv; }; -GType ido_serializable_menu_item_get_type (void); +GType dbusmenu_gtk_serializable_menu_item_get_type (void); -DbusmenuMenuitem * ido_serializable_menu_item_get_dbusmenu_menuitem (IdoSerializableMenuItem * smi); -void ido_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); +DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); +void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); G_END_DECLS -- cgit v1.2.3 From 6ec53854067f149492c18d35d680c2dad01d0a41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 16:45:44 -0600 Subject: Setting up the type handler, need more API --- libdbusmenu-gtk/serializablemenuitem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index c9eb416..4d23635 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -73,6 +73,14 @@ dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializab return NULL; } +/* Handle the type with this item. */ +static gboolean +type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + + return TRUE; +} + void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) { @@ -90,10 +98,10 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, } /* Register type */ - + dbusmenu_client_add_type_handler(client, class->get_type_string(), type_handler); /* need type */ /* Register defaults */ - + /* TODO: Need API on another branch */ return; } -- cgit v1.2.3 From 17632d1272a0741e5f5a11abcc4e8f758bc9e98c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 16:56:14 -0600 Subject: Adding in a 'full' function to deal with user data and destruction. --- libdbusmenu-glib/client.c | 9 ++++++++- libdbusmenu-glib/client.h | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 58d6360..a57b7ba 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1163,7 +1163,7 @@ menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer } if (newfunc != NULL) { - handled = newfunc(propdata->item, propdata->parent, propdata->client); + handled = newfunc(propdata->item, propdata->parent, propdata->client, NULL); } #ifdef MASSIVEDEBUGGING @@ -1698,6 +1698,12 @@ dbusmenu_client_get_root (DbusmenuClient * client) */ gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc) +{ + return dbusmenu_client_add_type_handler_full(client, type, newfunc, NULL, NULL); +} + +gboolean +dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, DbusmenuClientTypeDestroyHandler destory_func) { g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), FALSE); g_return_val_if_fail(type != NULL, FALSE); @@ -1722,3 +1728,4 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D g_hash_table_insert(priv->type_handlers, g_strdup(type), newfunc); return TRUE; } + diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 1ae89fa..323e142 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -110,7 +110,8 @@ struct _DbusmenuClient { DbusmenuClientPrivate * priv; }; -typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +typedef gboolean (*DbusmenuClientTypeDestroyHandler) (DbusmenuClient * client, const gchar * type, gpointer user_data); GType dbusmenu_client_get_type (void); DbusmenuClient * dbusmenu_client_new (const gchar * name, @@ -119,6 +120,11 @@ DbusmenuMenuitem * dbusmenu_client_get_root (DbusmenuClient * client) gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc); +gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * client, + const gchar * type, + DbusmenuClientTypeHandler newfunc, + gpointer user_data, + DbusmenuClientTypeDestroyHandler destory_func); void dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, -- cgit v1.2.3 From 3d8ec9ae0b07cbe287aaeda633621ac8c81b5925 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 16:59:57 -0600 Subject: Fixing callback prototypes --- libdbusmenu-gtk/client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index b01156f..af7768a 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -54,8 +54,8 @@ static void delete_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, Dbusm static void move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint old, DbusmenuGtkClient * gtkclient); static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); -static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); -static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); static void process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); @@ -684,7 +684,7 @@ dbusmenu_gtkclient_menuitem_get_submenu (DbusmenuGtkClient * client, DbusmenuMen /* The base type handler that builds a plain ol' GtkMenuItem to represent, well, the GtkMenuItem */ static gboolean -new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); @@ -719,7 +719,7 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu /* Type handler for the seperators where it builds a GtkSeparator to act as the GtkMenuItem */ static gboolean -new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); -- cgit v1.2.3 From 61fd5050b6319de6b948cdb0cd36e1b985d7b2a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 17:02:00 -0600 Subject: Setup to the use the full type handler --- libdbusmenu-glib/client.h | 2 +- libdbusmenu-gtk/serializablemenuitem.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 323e142..f371792 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -111,7 +111,7 @@ struct _DbusmenuClient { }; typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -typedef gboolean (*DbusmenuClientTypeDestroyHandler) (DbusmenuClient * client, const gchar * type, gpointer 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, diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 4d23635..42d79b2 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -75,12 +75,20 @@ dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializab /* Handle the type with this item. */ static gboolean -type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { return TRUE; } +/* Destruction is inevitable */ +static void +type_destroy_handler (DbusmenuClient * client, const gchar * type, gpointer user_data) +{ + + return; +} + void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) { @@ -98,7 +106,7 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, } /* Register type */ - dbusmenu_client_add_type_handler(client, class->get_type_string(), type_handler); /* need type */ + dbusmenu_client_add_type_handler_full(client, class->get_type_string(), type_handler, NULL, type_destroy_handler); /* need type */ /* Register defaults */ /* TODO: Need API on another branch */ -- cgit v1.2.3 From 5d6f408aad06b27f8d29b52df9bd8d76155eabe4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 17:05:31 -0600 Subject: Build a type handler structure to handle the class struct --- libdbusmenu-gtk/serializablemenuitem.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 42d79b2..16b3910 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -73,6 +73,12 @@ dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializab return NULL; } +typedef struct _type_handler_t type_handler_t; +struct _type_handler_t { + DbusmenuGtkSerializableMenuItemClass * class; + GType type; +}; + /* Handle the type with this item. */ static gboolean type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) @@ -85,7 +91,10 @@ type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCli static void type_destroy_handler (DbusmenuClient * client, const gchar * type, gpointer user_data) { - + g_return_if_fail(user_data != NULL); + type_handler_t * th = (type_handler_t *)user_data; + g_type_class_unref(th->class); + g_free(user_data); return; } @@ -106,7 +115,10 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, } /* Register type */ - dbusmenu_client_add_type_handler_full(client, class->get_type_string(), type_handler, NULL, type_destroy_handler); /* need type */ + type_handler_t * th = g_new0(type_handler_t, 1); + th->class = class; + th->type = item_type; + dbusmenu_client_add_type_handler_full(client, class->get_type_string(), type_handler, th, type_destroy_handler); /* need type */ /* Register defaults */ /* TODO: Need API on another branch */ -- cgit v1.2.3 From 43b377b84c868f652e8ea0db989b985cf20a3304 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 Jan 2011 17:06:28 -0600 Subject: Clean up on failure --- libdbusmenu-gtk/serializablemenuitem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 16b3910..1d4703f 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -118,7 +118,9 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, type_handler_t * th = g_new0(type_handler_t, 1); th->class = class; th->type = item_type; - dbusmenu_client_add_type_handler_full(client, class->get_type_string(), type_handler, th, type_destroy_handler); /* need 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); + } /* Register defaults */ /* TODO: Need API on another branch */ -- cgit v1.2.3 From be239149b9b3b875f9c52137e6bdc19a78724f72 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Wed, 19 Jan 2011 14:55:37 +0000 Subject: Ensure that we can recover from GetLayout failing --- libdbusmenu-glib/client.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 58d6360..29ed4a0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1538,6 +1538,14 @@ parse_layout (DbusmenuClient * client, const gchar * layout) static void 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; @@ -1554,9 +1562,6 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) g_variant_get(params, "(us)", &rev, &xml); g_variant_unref(params); - DbusmenuClient * client = DBUSMENU_CLIENT(data); - DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - guint parseable = parse_layout(client, xml); g_free(xml); @@ -1567,10 +1572,6 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data) priv->my_revision = rev; /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */ - if (priv->layoutcall != NULL) { - g_object_unref(priv->layoutcall); - priv->layoutcall = NULL; - } #ifdef MASSIVEDEBUGGING g_debug("Client signaling layout has changed."); #endif -- cgit v1.2.3 From 5b1a61d4e8623533d6e96e79984b3aa503248dcf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Jan 2011 10:50:05 -0600 Subject: Ignoring the generated file --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 44c6edb..854c275 100644 --- a/.bzrignore +++ b/.bzrignore @@ -220,3 +220,4 @@ libdbusmenu-gtk/DbusmenuGtk-0.4.typelib libdbusmenu-gtk/DbusmenuGtk-0.4.vapi libdbusmenu-gtk/dbusmenu-gtk-0.4.pc libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc +libdbusmenu-gtk/libdbusmenu_gtk_la-serializablemenuitem.lo -- cgit v1.2.3 From 4d6b2a232814fc61e7652199a142d5af39c4f78f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Jan 2011 10:52:33 -0600 Subject: License headers --- libdbusmenu-gtk/serializablemenuitem.c | 28 ++++++++++++++++++++++++++++ libdbusmenu-gtk/serializablemenuitem.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 1d4703f..e8ad22b 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -1,3 +1,31 @@ +/* +An object to act as a base class for easy GTK widgets that can be +transfered over dbusmenu. + +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-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index e99d329..bb67192 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -1,3 +1,31 @@ +/* +An object to act as a base class for easy GTK widgets that can be +transfered over dbusmenu. + +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_GTK_SERIALIZABLE_MENU_ITEM_H__ #define __DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ -- cgit v1.2.3 From d3e03f289c5d04e36686ea758f523758ea0a783f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Jan 2011 11:29:19 -0600 Subject: Adding in some documentation --- libdbusmenu-glib/client.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a57b7ba..f102dee 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1702,8 +1702,33 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D return dbusmenu_client_add_type_handler_full(client, type, newfunc, NULL, NULL); } +/** + 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 destory_func) +dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, DbusmenuClientTypeDestroyHandler destroy_func) { g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), FALSE); g_return_val_if_fail(type != NULL, FALSE); -- cgit v1.2.3 From e58df7a09fb28a4ae38888f54edf09d937bf70b2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Jan 2011 16:05:08 -0600 Subject: Switch to having the type handlers have a small structure of all their data and clean themselves up. Woot! --- libdbusmenu-glib/client.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f102dee..f84d6e0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -120,6 +120,15 @@ struct _event_data_t { guint timestamp; }; +typedef struct _type_handler_t type_handler_t; +struct _type_handler_t { + DbusmenuClient * client; + DbusmenuClientTypeHandler cb; + DbusmenuClientTypeDestroyHandler destroy_cb; + gpointer user_data; + gchar * type; +}; + #define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) #define DBUSMENU_INTERFACE "com.canonical.dbusmenu" @@ -148,6 +157,7 @@ static void item_activated (GDBusProxy * proxy, gint id, guint timestamp, Dbusme static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data); static void menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data); +static void type_handler_destroy (gpointer user_data); /* Globals */ static GDBusNodeInfo * dbusmenu_node_info = NULL; @@ -310,7 +320,7 @@ dbusmenu_client_init (DbusmenuClient *self) priv->dbusproxy = 0; priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, NULL); + g_free, type_handler_destroy); priv->delayed_idle = 0; priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); @@ -1153,17 +1163,17 @@ menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer gboolean handled = FALSE; const gchar * type; - DbusmenuClientTypeHandler newfunc = NULL; + type_handler_t * th = NULL; type = dbusmenu_menuitem_property_get(propdata->item, DBUSMENU_MENUITEM_PROP_TYPE); if (type != NULL) { - newfunc = g_hash_table_lookup(priv->type_handlers, type); + th = (type_handler_t *)g_hash_table_lookup(priv->type_handlers, type); } else { - newfunc = g_hash_table_lookup(priv->type_handlers, DBUSMENU_CLIENT_TYPES_DEFAULT); + th = (type_handler_t *)g_hash_table_lookup(priv->type_handlers, DBUSMENU_CLIENT_TYPES_DEFAULT); } - if (newfunc != NULL) { - handled = newfunc(propdata->item, propdata->parent, propdata->client, NULL); + if (th != NULL && th->cb != NULL) { + handled = th->cb(propdata->item, propdata->parent, propdata->client, th->user_data); } #ifdef MASSIVEDEBUGGING @@ -1675,6 +1685,19 @@ dbusmenu_client_get_root (DbusmenuClient * client) return priv->root; } +/* Remove the type handler when we're all done with it */ +static void +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); + } + g_free(th->type); + g_free(th); + return; +} + /** dbusmenu_client_add_type_handler: @client: Client where we're getting types coming in @@ -1750,7 +1773,14 @@ dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * ty return FALSE; } - g_hash_table_insert(priv->type_handlers, g_strdup(type), newfunc); + type_handler_t * th = g_new0(type_handler_t, 1); + th->client = client; + th->cb = newfunc; + th->destroy_cb = destroy_func; + th->user_data = user_data; + th->type = g_strdup(type); + + g_hash_table_insert(priv->type_handlers, g_strdup(type), th); return TRUE; } -- cgit v1.2.3 From c0990d9fa4889042ae255ed1358c0686d5dec241 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Jan 2011 16:50:34 -0600 Subject: Filling out the type handler --- libdbusmenu-gtk/serializablemenuitem.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index e8ad22b..de7bb04 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -30,6 +30,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#include "client.h" #include "serializablemenuitem.h" struct _DbusmenuGtkSerializableMenuItemPrivate { @@ -111,6 +112,13 @@ struct _type_handler_t { static gboolean type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { + type_handler_t * th = (type_handler_t *)user_data; + + DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(g_object_new(th->type, NULL)); + g_return_val_if_fail(smi != NULL, FALSE); + + dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem(smi, newitem); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(smi), parent); return TRUE; } -- cgit v1.2.3 From 5dc7f70d50ba5cf9cdc86693e7b759f567fb862c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Jan 2011 17:00:50 -0600 Subject: Adding a function to tell the menu item about where it's properties are coming from. --- libdbusmenu-gtk/serializablemenuitem.c | 7 +++++++ libdbusmenu-gtk/serializablemenuitem.h | 1 + 2 files changed, 8 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index de7bb04..74e0bec 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -163,3 +163,10 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, return; } + +void +dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) +{ + + return; +} diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index bb67192..487b08b 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -80,6 +80,7 @@ GType dbusmenu_gtk_serializable_menu_item_get_type (void); DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); +void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); G_END_DECLS -- cgit v1.2.3 From 58677931dde065b11f7010ad1443c6d4d1b20d7d Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Wed, 19 Jan 2011 22:50:25 -0500 Subject: added --warn-all to scanner flags so the build log will warn us about missing annotations --- libdbusmenu-glib/Makefile.am | 2 ++ libdbusmenu-gtk/Makefile.am | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index f502fb3..8ab36f7 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -119,12 +119,14 @@ INTROSPECTION_GIRS = if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ + --warn-all \ --add-include-path=$(srcdir) \ $(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) \ --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)) endif diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 0b939c0..b8e1170 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -69,12 +69,14 @@ INTROSPECTION_GIRS = if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ + --warn-all \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) \ --symbol-prefix=dbusmenu \ --identifier-prefix=DbusmenuGtk else INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ + --warn-all \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) endif -- cgit v1.2.3 From 97fe110d8f5b65fb39737b7d525db47becd27971 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Jan 2011 08:33:53 -0600 Subject: 0.3.93 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5c85da8..c46afe0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.92, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.93, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.92, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.93, [-Wno-portability]) AM_MAINTAINER_MODE @@ -136,7 +136,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=0 +LIBDBUSMENU_REVISION=1 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From abe1a8b281bf08217367666fbac41eb812708d33 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Jan 2011 19:56:14 -0600 Subject: Switching the name to build so that we realize what's going on there. --- libdbusmenu-gtk/serializablemenuitem.c | 6 +++--- libdbusmenu-gtk/serializablemenuitem.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 74e0bec..32be773 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -90,13 +90,13 @@ dbusmenu_gtk_serializable_menu_item_finalize (GObject *object) } DbusmenuMenuitem * -dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) +dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) { g_return_val_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi), NULL); DbusmenuGtkSerializableMenuItemClass * klass = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_CLASS(smi); - if (klass->get_dbusmenu_menuitem != NULL) { - return klass->get_dbusmenu_menuitem(smi); + if (klass->build_dbusmenu_menuitem != NULL) { + return klass->build_dbusmenu_menuitem(smi); } return NULL; diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index 487b08b..30e1157 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -55,7 +55,7 @@ struct _DbusmenuGtkSerializableMenuItemClass { const gchar * (*get_type_string) (void); GHashTable * (*get_default_properties) (void); - DbusmenuMenuitem * (*get_dbusmenu_menuitem) (DbusmenuGtkSerializableMenuItem * smi); + DbusmenuMenuitem * (*build_dbusmenu_menuitem) (DbusmenuGtkSerializableMenuItem * smi); /* Signals */ @@ -78,7 +78,7 @@ struct _DbusmenuGtkSerializableMenuItem { GType dbusmenu_gtk_serializable_menu_item_get_type (void); -DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_get_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); +DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); -- cgit v1.2.3 From aea42d14c645517cc32611ab0e8580223948aad3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Jan 2011 20:09:39 -0600 Subject: Installing a property for the menuitem in the super-class --- libdbusmenu-gtk/serializablemenuitem.c | 23 +++++++++++++++++++++-- libdbusmenu-gtk/serializablemenuitem.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 32be773..5089af0 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -34,7 +34,13 @@ License version 3 and version 2.1 along with this program. If not, see #include "serializablemenuitem.h" struct _DbusmenuGtkSerializableMenuItemPrivate { - int dummy; + DbusmenuMenuitem * mi; +}; + +/* Properties */ +enum { + PROP_0, + PROP_MENUITEM }; #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(o) \ @@ -57,6 +63,12 @@ dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemC object_class->dispose = dbusmenu_gtk_serializable_menu_item_dispose; object_class->finalize = dbusmenu_gtk_serializable_menu_item_finalize; + g_object_class_install_property (object_class, PROP_MENUITEM, + g_param_spec_object(DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM, "DBusmenu Menuitem attached to item", + "A menuitem who's properties are being watched and where changes should be watched for updates. It is the responsibility of subclasses to set up the signal handlers for those property changes.", + DBUSMENU_TYPE_MENUITEM, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + return; } @@ -65,7 +77,7 @@ dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self) { self->priv = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(self); - self->priv->dummy = 5; + self->priv->mi = NULL; return; } @@ -73,6 +85,13 @@ dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self) static void dbusmenu_gtk_serializable_menu_item_dispose (GObject *object) { + DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(object); + g_return_if_fail(smi != NULL); + + if (smi->priv->mi != NULL) { + g_object_unref(G_OBJECT(smi->priv->mi)); + smi->priv->mi = NULL; + } G_OBJECT_CLASS (dbusmenu_gtk_serializable_menu_item_parent_class)->dispose (object); diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index 30e1157..0dc92e0 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -44,6 +44,8 @@ G_BEGIN_DECLS #define DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)) #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemClass)) +#define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM "dbusmenu-menuitem" + typedef struct _DbusmenuGtkSerializableMenuItem DbusmenuGtkSerializableMenuItem; typedef struct _DbusmenuGtkSerializableMenuItemClass DbusmenuGtkSerializableMenuItemClass; typedef struct _DbusmenuGtkSerializableMenuItemPrivate DbusmenuGtkSerializableMenuItemPrivate; -- cgit v1.2.3 From 64baf8e0dafe24dc1be97cca5b8838e784f6c181 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 10:31:25 -0600 Subject: Add a single include file for dbus-glib --- libdbusmenu-glib/Makefile.am | 1 + libdbusmenu-glib/dbusmenu-glib.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 libdbusmenu-glib/dbusmenu-glib.h diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 8ab36f7..7dd69de 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -15,6 +15,7 @@ lib_LTLIBRARIES = \ libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-glib/ libdbusmenu_glibinclude_HEADERS = \ + dbusmenu-glib.h \ menuitem.h \ menuitem-proxy.h \ server.h \ diff --git a/libdbusmenu-glib/dbusmenu-glib.h b/libdbusmenu-glib/dbusmenu-glib.h new file mode 100644 index 0000000..9c377ca --- /dev/null +++ b/libdbusmenu-glib/dbusmenu-glib.h @@ -0,0 +1,37 @@ +/* +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_GLIB_H__ +#define __DBUSMENU_GLIB_H__ + +#include +#include +#include +#include + +#endif /* __DBUSMENU_GLIB_H__ */ -- cgit v1.2.3 From 1a4efa01c312cf8c54d7d158385b5208f1cdb841 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 10:35:55 -0600 Subject: Add a single include for dbusmenu-gtk --- libdbusmenu-gtk/Makefile.am | 1 + libdbusmenu-gtk/dbusmenu-gtk.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 libdbusmenu-gtk/dbusmenu-gtk.h diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b8e1170..e5df6b1 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -20,6 +20,7 @@ EXTRA_DIST = \ libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-gtk$(VER)/ libdbusmenu_gtkinclude_HEADERS = \ + dbusmenu-gtk.h \ client.h \ menu.h \ menuitem.h diff --git a/libdbusmenu-gtk/dbusmenu-gtk.h b/libdbusmenu-gtk/dbusmenu-gtk.h new file mode 100644 index 0000000..de63c61 --- /dev/null +++ b/libdbusmenu-gtk/dbusmenu-gtk.h @@ -0,0 +1,40 @@ +/* +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_GTK_H__ +#define __DBUSMENU_GTK_H__ + +/* Start with the glib stuff */ +#include + +/* Now get the GTK stuff */ +#include +#include +#include + +#endif /* __DBUSMENU_GLIB_H__ */ -- cgit v1.2.3 From 30063701c33d46754ac528f35c70bed08cd11cd3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 10:38:05 -0600 Subject: Add an include directory for the headers --- libdbusmenu-glib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 7dd69de..a139f7c 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -141,7 +141,7 @@ introspection_sources = $(libdbusmenu_glibinclude_HEADERS) Dbusmenu_Glib-0.4.gir: libdbusmenu-glib.la Dbusmenu_Glib_0_4_gir_INCLUDES = \ GObject-2.0 -Dbusmenu_Glib_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) +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 -- cgit v1.2.3 From 0ea5e726b97d9080b4300d007f002da247dbf0b2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 11:59:06 -0600 Subject: Add serializable menuitem to the single include --- libdbusmenu-gtk/dbusmenu-gtk.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/dbusmenu-gtk.h b/libdbusmenu-gtk/dbusmenu-gtk.h index de63c61..f2fe5be 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk.h +++ b/libdbusmenu-gtk/dbusmenu-gtk.h @@ -36,5 +36,6 @@ License version 3 and version 2.1 along with this program. If not, see #include #include #include +#include #endif /* __DBUSMENU_GLIB_H__ */ -- cgit v1.2.3 From ffce14168e30c5b34d24ee7ee5199a61bb4a30f3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 12:02:57 -0600 Subject: Add some documentation of the class and object structures. --- libdbusmenu-gtk/serializablemenuitem.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index 0dc92e0..aae2f96 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -50,6 +50,19 @@ typedef struct _DbusmenuGtkSerializableMenuItem DbusmenuGtkSerializableMe typedef struct _DbusmenuGtkSerializableMenuItemClass DbusmenuGtkSerializableMenuItemClass; typedef struct _DbusmenuGtkSerializableMenuItemPrivate DbusmenuGtkSerializableMenuItemPrivate; +/** + DbusmenuGtkSerializableMenuItemClass: + @parent_class: Inherit from GtkMenuItem + @get_type_string: Static function to get a string describing this type + @get_default_properties: Return a hashtable of defaults for the menu item type + @build_dbusmenu_menuitem: Build a menuitem that can be sent over dbus + @_dbusmenu_gtk_serializable_menu_item_reserved1: Reserved for future use. + @_dbusmenu_gtk_serializable_menu_item_reserved2: Reserved for future use. + @_dbusmenu_gtk_serializable_menu_item_reserved3: Reserved for future use. + @_dbusmenu_gtk_serializable_menu_item_reserved4: Reserved for future use. + @_dbusmenu_gtk_serializable_menu_item_reserved5: Reserved for future use. + @_dbusmenu_gtk_serializable_menu_item_reserved6: Reserved for future use. +*/ struct _DbusmenuGtkSerializableMenuItemClass { GtkMenuItemClass parent_class; @@ -64,6 +77,7 @@ struct _DbusmenuGtkSerializableMenuItemClass { /* Empty Space */ + /*< Private >*/ void (*_dbusmenu_gtk_serializable_menu_item_reserved1) (void); void (*_dbusmenu_gtk_serializable_menu_item_reserved2) (void); void (*_dbusmenu_gtk_serializable_menu_item_reserved3) (void); @@ -72,6 +86,11 @@ struct _DbusmenuGtkSerializableMenuItemClass { void (*_dbusmenu_gtk_serializable_menu_item_reserved6) (void); }; +/** + DbusmenuGtkSerializableMenuItem: + @parent: Inherit from GtkMenuItem + @priv: Blind structure of private variables +*/ struct _DbusmenuGtkSerializableMenuItem { GtkMenuItem parent; -- cgit v1.2.3 From 48e68b4411e70f0526fca90d3d714f10aea566bb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 13:27:26 -0600 Subject: Making the hashtable have a full copy and free itself appropriately. --- libdbusmenu-glib/menuitem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 827d6c5..b40195c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1204,11 +1204,17 @@ dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) return g_hash_table_get_keys(priv->properties); } +/* Copy the keys and make references to the variants that are + in the new table. They'll be free'd and unref'd when the + Hashtable gets destroyed. */ static void copy_helper (gpointer in_key, gpointer in_value, gpointer in_data) { GHashTable * table = (GHashTable *)in_data; - g_hash_table_insert(table, in_key, in_value); + gchar * key = (gchar *)in_key; + GVariant * value = (GVariant *)in_value; + g_variant_ref(value); + g_hash_table_insert(table, g_strdup(key), value); return; } @@ -1229,7 +1235,7 @@ copy_helper (gpointer in_key, gpointer in_value, gpointer in_data) GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) { - GHashTable * ret = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable * ret = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), ret); -- cgit v1.2.3 From 59b8be494e5fbccdbed59b49fa4f190fbbb55343 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 13:33:01 -0600 Subject: Ensuring that all the errors are free'd correctly. --- libdbusmenu-glib/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 29ed4a0..86b023d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -517,6 +517,7 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) listener->callback(NULL, error, listener->user_data); } g_array_free(listeners, TRUE); + g_error_free(error); return; } @@ -1140,7 +1141,6 @@ menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer if (error != NULL) { g_warning("Error getting properties on a new menuitem: %s", error->message); g_object_unref(propdata->item); - g_free(data); return; } @@ -1277,6 +1277,8 @@ about_to_show_cb (GObject * proxy, GAsyncResult * res, gpointer userdata) g_warning("Unable to send about_to_show: %s", error->message); /* Note: we're just ensuring only the callback gets called */ need_update = FALSE; + g_error_free(error); + error = NULL; } else { g_variant_get(params, "(b)", &need_update); g_variant_unref(params); @@ -1553,6 +1555,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; } -- cgit v1.2.3 From efd5c63d09eed1230bb0bb822f3040f55d30638d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 16:01:20 -0600 Subject: More documentation --- libdbusmenu-gtk/serializablemenuitem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 5089af0..01b20b2 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -33,6 +33,10 @@ License version 3 and version 2.1 along with this program. If not, see #include "client.h" #include "serializablemenuitem.h" +/** + DbusmenuGtkSerializableMenuItemPrivate: + @mi: Menuitem to watch the property changes from +*/ struct _DbusmenuGtkSerializableMenuItemPrivate { DbusmenuMenuitem * mi; }; @@ -43,16 +47,20 @@ enum { PROP_MENUITEM }; +/* Private macro, only used in object init */ #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemPrivate)) +/* Function prototypes */ static void dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemClass *klass); static void dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self); static void dbusmenu_gtk_serializable_menu_item_dispose (GObject *object); static void dbusmenu_gtk_serializable_menu_item_finalize (GObject *object); +/* GObject boiler plate */ G_DEFINE_TYPE (DbusmenuGtkSerializableMenuItem, dbusmenu_gtk_serializable_menu_item, GTK_TYPE_MENU_ITEM); +/* Initialize the stuff in the class structure */ static void dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemClass *klass) { @@ -72,6 +80,7 @@ dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemC return; } +/* Initialize the object structures and private structure */ static void dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self) { @@ -82,6 +91,7 @@ dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self) return; } +/* Free all references to objects */ static void dbusmenu_gtk_serializable_menu_item_dispose (GObject *object) { @@ -98,6 +108,7 @@ dbusmenu_gtk_serializable_menu_item_dispose (GObject *object) return; } +/* Free memory */ static void dbusmenu_gtk_serializable_menu_item_finalize (GObject *object) { @@ -121,6 +132,7 @@ dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializ return NULL; } +/* Callback to the generic type handler */ typedef struct _type_handler_t type_handler_t; struct _type_handler_t { DbusmenuGtkSerializableMenuItemClass * class; -- cgit v1.2.3 From 91544bb4a5ae2bc6eea3e930da6c7ebbb32216d0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 16:37:44 -0600 Subject: gtk-doc documentation for public API functions --- libdbusmenu-gtk/serializablemenuitem.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 01b20b2..06dfa59 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -119,6 +119,19 @@ dbusmenu_gtk_serializable_menu_item_finalize (GObject *object) return; } +/** + dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem: + @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring + + This function is for menu items that are instanciated from + GTK and have their properites set using GTK functions. This + builds a #DbusmenuMenuitem that then has the properties that + should be sent over the bus to create a new item of this + type on the other side. + + Return value: A #DbusmenuMenuitem who's values will be set by + this object. +*/ DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) { @@ -165,6 +178,16 @@ type_destroy_handler (DbusmenuClient * client, const gchar * type, gpointer user return; } +/** + dbusmenu_gtk_serializable_menu_item_register_to_client: + @client: #DbusmenuClient that we should register a type at. + @item_type: The #GType of a class that is a subclass of #DbusmenuGtkSerializableMenuItem + + Registers a generic handler for dealing with all subclasses of + #DbusmenuGtkSerializableMenuItem. This handler responds to the callback, + creates a new object and attaches it to the appropriate #DbusmenuMenuitem + object. +*/ void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) { @@ -195,6 +218,17 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, return; } +/** + dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem: + @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of + @mi: Menuitem to get the properties from + + This function is used on the server side to signal to the object + that it should get its' property change events from @mi instead + of expecting calls to its' API. A call to this function sets the + property and subclasses should listen to the notify signal to + pick up this property being set. +*/ void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) { -- cgit v1.2.3 From 97083dc0b396d91c68fe9f439024cc048333e87b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 16:43:44 -0600 Subject: Adding in set and get property functions. --- libdbusmenu-gtk/serializablemenuitem.c | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 06dfa59..99bc585 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -56,6 +56,14 @@ static void dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializa static void dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self); static void dbusmenu_gtk_serializable_menu_item_dispose (GObject *object); static void dbusmenu_gtk_serializable_menu_item_finalize (GObject *object); +static void set_property (GObject * obj, + guint id, + const GValue * value, + GParamSpec * pspec); +static void get_property (GObject * obj, + guint id, + GValue * value, + GParamSpec * pspec); /* GObject boiler plate */ G_DEFINE_TYPE (DbusmenuGtkSerializableMenuItem, dbusmenu_gtk_serializable_menu_item, GTK_TYPE_MENU_ITEM); @@ -70,6 +78,8 @@ dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemC object_class->dispose = dbusmenu_gtk_serializable_menu_item_dispose; object_class->finalize = dbusmenu_gtk_serializable_menu_item_finalize; + object_class->set_property = set_property; + object_class->get_property = get_property; g_object_class_install_property (object_class, PROP_MENUITEM, g_param_spec_object(DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM, "DBusmenu Menuitem attached to item", @@ -119,6 +129,42 @@ dbusmenu_gtk_serializable_menu_item_finalize (GObject *object) return; } +/* Set an object property */ +static void +set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) +{ + DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(obj); + + switch (id) { + case PROP_MENUITEM: + smi->priv->mi = g_value_get_object(value); + break; + default: + g_return_if_reached(); + break; + } + + return; +} + +/* Get an object property */ +static void +get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) +{ + DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(obj); + + switch (id) { + case PROP_MENUITEM: + g_value_set_object(value, smi->priv->mi); + break; + default: + g_return_if_reached(); + break; + } + + return; +} + /** dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem: @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring -- cgit v1.2.3 From 555f085168fac50cf55c910c746363f8ce268823 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 16:46:27 -0600 Subject: Fleshing out setting the property --- libdbusmenu-gtk/serializablemenuitem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index 99bc585..6bc3695 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -278,6 +278,11 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) { + g_return_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi)); + g_return_if_fail(mi != NULL); + + smi->priv->mi = mi; + g_object_notify(G_OBJECT(smi), DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM); return; } -- cgit v1.2.3 From 539290124d737754b20dd69e6d3033175ca37e12 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 16:48:41 -0600 Subject: Ensuring our double include protectors make g-ir-scanner happy. --- libdbusmenu-gtk/menuitem.h | 4 ++-- libdbusmenu-gtk/serializablemenuitem.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h index a2b6652..4fc42f9 100644 --- a/libdbusmenu-gtk/menuitem.h +++ b/libdbusmenu-gtk/menuitem.h @@ -26,8 +26,8 @@ License version 3 and version 2.1 along with this program. If not, see */ -#ifndef __DBUSMENU_GTKMENUITEM_H__ -#define __DBUSMENU_GTKMENUITEM_H__ 1 +#ifndef DBUSMENU_GTK_MENUITEM_H__ +#define DBUSMENU_GTK_MENUITEM_H__ 1 #include #include diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index aae2f96..1ca3ef8 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -26,8 +26,8 @@ License version 3 and version 2.1 along with this program. If not, see */ -#ifndef __DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ -#define __DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ +#ifndef DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ +#define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ 1 #include #include -- cgit v1.2.3 From edef8613dd3e78e5d11a2754e6175dd8e55ff87e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 16:59:35 -0600 Subject: Adding a transfer annotation --- 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 6bc3695..f67434e 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -175,8 +175,8 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) should be sent over the bus to create a new item of this type on the other side. - Return value: A #DbusmenuMenuitem who's values will be set by - this object. + Return value: (transfer full) A #DbusmenuMenuitem who's values will be + set by this object. */ DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) -- cgit v1.2.3 From b8d297276d4e8598c5509413b40001a0cd514786 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 17:01:41 -0600 Subject: Removing generic menu item (it's not public) and adding serializable menu item --- docs/libdbusmenu-gtk/reference/Makefile.am | 2 +- docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/libdbusmenu-gtk/reference/Makefile.am b/docs/libdbusmenu-gtk/reference/Makefile.am index 6e44a23..191d68e 100644 --- a/docs/libdbusmenu-gtk/reference/Makefile.am +++ b/docs/libdbusmenu-gtk/reference/Makefile.am @@ -54,7 +54,7 @@ CFILE_GLOB=$(top_srcdir)/libdbusmenu-gtk/*.c # Header files to ignore when scanning. # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h -IGNORE_HFILES= +IGNORE_HFILES=genericmenuitem.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png diff --git a/docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml b/docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml index ae9ab07..ec6b82f 100644 --- a/docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml +++ b/docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml @@ -13,8 +13,8 @@ API - + -- cgit v1.2.3 From bddd7634e8055cab7a7ebcff8a2fa130e751f6ec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Jan 2011 21:11:52 -0600 Subject: Ignoring our new doc files --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index 854c275..c7cd2fc 100644 --- a/.bzrignore +++ b/.bzrignore @@ -221,3 +221,5 @@ libdbusmenu-gtk/DbusmenuGtk-0.4.vapi libdbusmenu-gtk/dbusmenu-gtk-0.4.pc libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc libdbusmenu-gtk/libdbusmenu_gtk_la-serializablemenuitem.lo +docs/libdbusmenu-gtk/reference/html/DbusmenuGtkSerializableMenuItem.html +docs/libdbusmenu-gtk/reference/tmpl/serializablemenuitem.sgml -- cgit v1.2.3 From c644e10c9da09e443a00422df00a6ba9df7a7e83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 12:45:05 -0600 Subject: Adding the base files for the parser --- .bzrignore | 1 + libdbusmenu-gtk/Makefile.am | 7 +++++-- libdbusmenu-gtk/parser.c | 9 +++++++++ libdbusmenu-gtk/parser.h | 6 ++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 libdbusmenu-gtk/parser.c create mode 100644 libdbusmenu-gtk/parser.h diff --git a/.bzrignore b/.bzrignore index 44c6edb..e0fd93e 100644 --- a/.bzrignore +++ b/.bzrignore @@ -220,3 +220,4 @@ libdbusmenu-gtk/DbusmenuGtk-0.4.typelib libdbusmenu-gtk/DbusmenuGtk-0.4.vapi libdbusmenu-gtk/dbusmenu-gtk-0.4.pc libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc +libdbusmenu-gtk/libdbusmenu_gtk_la-parser.lo diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index e5df6b1..201a631 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -23,7 +23,8 @@ libdbusmenu_gtkinclude_HEADERS = \ dbusmenu-gtk.h \ client.h \ menu.h \ - menuitem.h + menuitem.h \ + parser.h libdbusmenu_gtk_la_SOURCES = \ client.h \ @@ -33,7 +34,9 @@ libdbusmenu_gtk_la_SOURCES = \ menu.h \ menu.c \ menuitem.h \ - menuitem.c + menuitem.c \ + parser.h \ + parser.c libdbusmenu_gtk_la_LDFLAGS = \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c new file mode 100644 index 0000000..98b3f7d --- /dev/null +++ b/libdbusmenu-gtk/parser.c @@ -0,0 +1,9 @@ + +#include "parser.h" + +DbusmenuMenuitem * +dbusmenu_gtk_parse_menu_structure (GtkMenuItem * mi) +{ + + return NULL; +} diff --git a/libdbusmenu-gtk/parser.h b/libdbusmenu-gtk/parser.h new file mode 100644 index 0000000..222d9f4 --- /dev/null +++ b/libdbusmenu-gtk/parser.h @@ -0,0 +1,6 @@ + +#include +#include + +DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkMenuItem * mi); + -- cgit v1.2.3 From b39a625defde44aa345253237d4f186abedf7196 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Sun, 23 Jan 2011 13:05:28 -0600 Subject: Taking the menu parsing code from appmenu-gtk --- libdbusmenu-gtk/parser.c | 426 ++++++++++++++++++++++++++++++++++++++++++++++- libdbusmenu-gtk/parser.h | 2 +- 2 files changed, 426 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 98b3f7d..8fd0d12 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -1,9 +1,433 @@ #include "parser.h" +#include "menuitem.h" + +static void accel_changed (GtkWidget *widget, gpointer data); +static gboolean update_stock_item (DbusmenuMenuitem *menuitem, GtkWidget *widget); +static void checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi); +static void update_icon_name (DbusmenuMenuitem *menuitem, GtkWidget *widget); +static GtkWidget * find_menu_label (GtkWidget *widget); +static void label_notify_cb (GtkWidget *widget, GParamSpec *pspec, gpointer data); +static void action_notify_cb (GtkAction *action, GParamSpec *pspec, gpointer data); +static void item_activated (DbusmenuMenuitem *item, guint timestamp, gpointer user_data); +static gboolean item_about_to_show (DbusmenuMenuitem *item, gpointer user_data); +static void widget_notify_cb (GtkWidget *widget, GParamSpec *pspec, gpointer data); +static gboolean should_show_image (GtkImage *image); DbusmenuMenuitem * -dbusmenu_gtk_parse_menu_structure (GtkMenuItem * mi) +dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) { + DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); + + if (GTK_IS_MENU_ITEM (widget)) + { + gboolean visible = FALSE; + gboolean sensitive = FALSE; + if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) + { + dbusmenu_menuitem_property_set (mi, + "type", + "separator"); + + visible = gtk_widget_get_visible (widget); + sensitive = gtk_widget_get_sensitive (widget); + } + else + { + gboolean label_set = FALSE; + + g_signal_connect (widget, + "accel-closures-changed", + G_CALLBACK (accel_changed), + mi); + + if (GTK_IS_CHECK_MENU_ITEM (widget)) + { + dbusmenu_menuitem_property_set (mi, + DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, + gtk_check_menu_item_get_draw_as_radio (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_RADIO : DBUSMENU_MENUITEM_TOGGLE_CHECK); + + dbusmenu_menuitem_property_set_int (mi, + DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, + gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); + + g_signal_connect (widget, + "activate", + G_CALLBACK (checkbox_toggled), + mi); + } + + if (GTK_IS_IMAGE_MENU_ITEM (widget)) + { + GtkWidget *image; + GtkImageType image_type; + + image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); + + if (GTK_IS_IMAGE (image)) + { + image_type = gtk_image_get_storage_type (GTK_IMAGE (image)); + + if (image_type == GTK_IMAGE_STOCK) + { + label_set = update_stock_item (mi, image); + } + else if (image_type == GTK_IMAGE_ICON_NAME) + { + update_icon_name (mi, image); + } + else if (image_type == GTK_IMAGE_PIXBUF) + { + dbusmenu_menuitem_property_set_image (mi, + DBUSMENU_MENUITEM_PROP_ICON_DATA, + gtk_image_get_pixbuf (GTK_IMAGE (image))); + } + } + } + + GtkWidget *label = find_menu_label (widget); + + dbusmenu_menuitem_property_set (mi, + "label", + label ? gtk_label_get_text (GTK_LABEL (label)) : NULL); + + if (label) + { + // Sometimes, an app will directly find and modify the label + // (like empathy), so watch the label especially for that. + g_signal_connect (G_OBJECT (label), + "notify", + G_CALLBACK (label_notify_cb), + mi); + } + + if (GTK_IS_ACTIVATABLE (widget)) + { + GtkActivatable *activatable = GTK_ACTIVATABLE (widget); + + if (gtk_activatable_get_use_action_appearance (activatable)) + { + GtkAction *action = gtk_activatable_get_related_action (activatable); + + if (action) + { + visible = gtk_action_is_visible (action); + sensitive = gtk_action_is_sensitive (action); + + g_signal_connect_object (action, "notify", + G_CALLBACK (action_notify_cb), + mi, + G_CONNECT_AFTER); + } + } + } + + if (!g_object_get_data (G_OBJECT (widget), "gtk-empty-menu-item") && !GTK_IS_TEAROFF_MENU_ITEM (widget)) + { + visible = gtk_widget_get_visible (widget); + sensitive = gtk_widget_get_sensitive (widget); + } + + dbusmenu_menuitem_property_set_shortcut_menuitem (mi, GTK_MENU_ITEM (widget)); + + g_signal_connect (G_OBJECT (mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (item_activated), + widget); + + g_signal_connect (G_OBJECT (mi), + DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW, + G_CALLBACK (item_about_to_show), + widget); + } + + dbusmenu_menuitem_property_set_bool (mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + visible); + + dbusmenu_menuitem_property_set_bool (mi, + DBUSMENU_MENUITEM_PROP_ENABLED, + sensitive); + + g_signal_connect (widget, + "notify", + G_CALLBACK (widget_notify_cb), + mi); + } + + return mi; return NULL; } + +static void +accel_changed (GtkWidget *widget, + gpointer data) +{ + DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; + dbusmenu_menuitem_property_set_shortcut_menuitem (mi, GTK_MENU_ITEM (widget)); +} + +static gboolean +update_stock_item (DbusmenuMenuitem *menuitem, + GtkWidget *widget) +{ + GtkStockItem stock; + GtkImage *image; + + g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE); + + image = GTK_IMAGE (widget); + + if (gtk_image_get_storage_type (image) != GTK_IMAGE_STOCK) + return FALSE; + + gtk_stock_lookup (image->data.stock.stock_id, &stock); + + if (should_show_image (image)) + dbusmenu_menuitem_property_set (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_NAME, + image->data.stock.stock_id); + else + dbusmenu_menuitem_property_remove (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_NAME); + + const gchar *label = dbusmenu_menuitem_property_get (menuitem, + DBUSMENU_MENUITEM_PROP_LABEL); + + if (stock.label != NULL && label != NULL) + { + dbusmenu_menuitem_property_set (menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + stock.label); + + return TRUE; + } + + return FALSE; +} + +static void +checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi) +{ + dbusmenu_menuitem_property_set_int (mi, + DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, + gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); +} + +static void +update_icon_name (DbusmenuMenuitem *menuitem, + GtkWidget *widget) +{ + GtkImage *image; + + g_return_if_fail (GTK_IS_IMAGE (widget)); + + image = GTK_IMAGE (widget); + + if (gtk_image_get_storage_type (image) != GTK_IMAGE_ICON_NAME) + return; + + if (should_show_image (image)) + dbusmenu_menuitem_property_set (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_NAME, + image->data.name.icon_name); + else + dbusmenu_menuitem_property_remove (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_NAME); +} + +static GtkWidget * +find_menu_label (GtkWidget *widget) +{ + GtkWidget *label = NULL; + + if (GTK_IS_LABEL (widget)) + return widget; + + if (GTK_IS_CONTAINER (widget)) + { + GList *children; + GList *l; + + children = gtk_container_get_children (GTK_CONTAINER (widget)); + + for (l = children; l; l = l->next) + { + label = find_menu_label (l->data); + + if (label) + break; + } + + g_list_free (children); + } + + return label; +} + +static void +label_notify_cb (GtkWidget *widget, + GParamSpec *pspec, + gpointer data) +{ + DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; + + if (pspec->name == g_intern_static_string ("label")) + { + dbusmenu_menuitem_property_set (child, + DBUSMENU_MENUITEM_PROP_LABEL, + gtk_label_get_text (GTK_LABEL (widget))); + } +} + +static void +action_notify_cb (GtkAction *action, + GParamSpec *pspec, + gpointer data) +{ + DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; + + if (pspec->name == g_intern_static_string ("sensitive")) + { + dbusmenu_menuitem_property_set_bool (mi, + DBUSMENU_MENUITEM_PROP_ENABLED, + gtk_action_is_sensitive (action)); + } + else if (pspec->name == g_intern_static_string ("visible")) + { + dbusmenu_menuitem_property_set_bool (mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + gtk_action_is_visible (action)); + } + else if (pspec->name == g_intern_static_string ("active")) + { + dbusmenu_menuitem_property_set_bool (mi, + DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, + gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); + } + else if (pspec->name == g_intern_static_string ("label")) + { + dbusmenu_menuitem_property_set (mi, + DBUSMENU_MENUITEM_PROP_LABEL, + gtk_action_get_label (action)); + } +} + +static void +item_activated (DbusmenuMenuitem *item, guint timestamp, gpointer user_data) +{ + GtkWidget *child; + + if (user_data != NULL) + { + child = (GtkWidget *)user_data; + + if (GTK_IS_MENU_ITEM (child)) + { + gtk_menu_item_activate (GTK_MENU_ITEM (child)); + } + } +} + +static gboolean +item_about_to_show (DbusmenuMenuitem *item, gpointer user_data) +{ + GtkWidget *child; + + if (user_data != NULL) + { + child = (GtkWidget *)user_data; + + if (GTK_IS_MENU_ITEM (child)) + { + // Only called for items with submens. So we activate it here in + // case the program dynamically creates menus (like empathy does) + gtk_menu_item_activate (GTK_MENU_ITEM (child)); + } + } + + return TRUE; +} + +static void +widget_notify_cb (GtkWidget *widget, + GParamSpec *pspec, + gpointer data) +{ + DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; + + if (pspec->name == g_intern_static_string ("sensitive")) + { + dbusmenu_menuitem_property_set_bool (child, + DBUSMENU_MENUITEM_PROP_ENABLED, + gtk_widget_get_sensitive (widget)); + } + else if (pspec->name == g_intern_static_string ("label")) + { + dbusmenu_menuitem_property_set (child, + DBUSMENU_MENUITEM_PROP_LABEL, + gtk_menu_item_get_label (GTK_MENU_ITEM (widget))); + } + else if (pspec->name == g_intern_static_string ("visible")) + { + dbusmenu_menuitem_property_set_bool (child, + DBUSMENU_MENUITEM_PROP_VISIBLE, + gtk_widget_get_visible (widget)); + } + else if (pspec->name == g_intern_static_string ("stock")) + { + update_stock_item (child, widget); + } + else if (pspec->name == g_intern_static_string ("icon-name")) + { + update_icon_name (child, widget); + } + else if (pspec->name == g_intern_static_string ("parent")) + { + /* + * We probably should have added a 'remove' method to the + * UbuntuMenuProxy early on, but it's late in the cycle now. + */ + if (gtk_widget_get_parent (widget) == NULL) + { + g_signal_handlers_disconnect_by_func (widget, + G_CALLBACK (widget_notify_cb), + child); + + DbusmenuMenuitem *parent = g_object_get_data (G_OBJECT (child), "dbusmenu-parent"); + + if (DBUSMENU_IS_MENUITEM (parent) && DBUSMENU_IS_MENUITEM (child)) + { + dbusmenu_menuitem_child_delete (parent, child); + } + } + } +} + +static gboolean +should_show_image (GtkImage *image) +{ + GtkWidget *item; + + item = gtk_widget_get_ancestor (GTK_WIDGET (image), + GTK_TYPE_IMAGE_MENU_ITEM); + + if (item) + { + GtkSettings *settings; + gboolean gtk_menu_images; + + settings = gtk_widget_get_settings (item); + + g_object_get (settings, "gtk-menu-images", >k_menu_images, NULL); + + if (gtk_menu_images) + return TRUE; + + return gtk_image_menu_item_get_always_show_image (GTK_IMAGE_MENU_ITEM (item)); + } + + return FALSE; +} + diff --git a/libdbusmenu-gtk/parser.h b/libdbusmenu-gtk/parser.h index 222d9f4..3cffb9c 100644 --- a/libdbusmenu-gtk/parser.h +++ b/libdbusmenu-gtk/parser.h @@ -2,5 +2,5 @@ #include #include -DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkMenuItem * mi); +DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget); -- cgit v1.2.3 From 708ccab44c2c88b43ad35048dc0aee81023e61f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 13:11:46 -0600 Subject: Reformating prototypes because it makes the code run faster. --- libdbusmenu-gtk/parser.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 8fd0d12..f0c22be 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -2,17 +2,30 @@ #include "parser.h" #include "menuitem.h" -static void accel_changed (GtkWidget *widget, gpointer data); -static gboolean update_stock_item (DbusmenuMenuitem *menuitem, GtkWidget *widget); -static void checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi); -static void update_icon_name (DbusmenuMenuitem *menuitem, GtkWidget *widget); -static GtkWidget * find_menu_label (GtkWidget *widget); -static void label_notify_cb (GtkWidget *widget, GParamSpec *pspec, gpointer data); -static void action_notify_cb (GtkAction *action, GParamSpec *pspec, gpointer data); -static void item_activated (DbusmenuMenuitem *item, guint timestamp, gpointer user_data); -static gboolean item_about_to_show (DbusmenuMenuitem *item, gpointer user_data); -static void widget_notify_cb (GtkWidget *widget, GParamSpec *pspec, gpointer data); -static gboolean should_show_image (GtkImage *image); +static void accel_changed (GtkWidget * widget, + gpointer data); +static gboolean update_stock_item (DbusmenuMenuitem * menuitem, + GtkWidget * widget); +static void checkbox_toggled (GtkWidget * widget, + DbusmenuMenuitem * mi); +static void update_icon_name (DbusmenuMenuitem * menuitem, + GtkWidget * widget); +static GtkWidget * find_menu_label (GtkWidget * widget); +static void label_notify_cb (GtkWidget * widget, + GParamSpec * pspec, + gpointer data); +static void action_notify_cb (GtkAction * action, + GParamSpec * pspec, + gpointer data); +static void item_activated (DbusmenuMenuitem * item, + guint timestamp, + gpointer user_data); +static gboolean item_about_to_show (DbusmenuMenuitem * item, + gpointer user_data); +static void widget_notify_cb (GtkWidget * widget, + GParamSpec * pspec, + gpointer data); +static gboolean should_show_image (GtkImage * image); DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) -- cgit v1.2.3 From 401bc7c326c518ad01c1edd38155d89d9e35fd49 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 13:16:20 -0600 Subject: Adding copyright headers --- libdbusmenu-gtk/parser.c | 27 +++++++++++++++++++++++++++ libdbusmenu-gtk/parser.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index f0c22be..cba6b42 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -1,3 +1,30 @@ +/* +Parse to take a set of GTK Menus and turn them into something that can +be sent over the wire. + +Copyright 2011 Canonical Ltd. + +Authors: + Numerous (check Bazaar) + +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 + +*/ #include "parser.h" #include "menuitem.h" diff --git a/libdbusmenu-gtk/parser.h b/libdbusmenu-gtk/parser.h index 3cffb9c..a40d709 100644 --- a/libdbusmenu-gtk/parser.h +++ b/libdbusmenu-gtk/parser.h @@ -1,6 +1,37 @@ +/* +Parse to take a set of GTK Menus and turn them into something that can +be sent over the wire. + +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_GTK_PARSER_H__ +#define DBUSMENU_GTK_PARSER_H__ #include #include DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget); +#endif /* DBUSMENU_GTK_PARSER_H__ */ -- cgit v1.2.3 From fda2b25645a35ec7b3baddc366e483a8a9b83e58 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 13:30:00 -0600 Subject: Adding in a basic test that just ensures the parser isn't entirely broken --- .bzrignore | 3 +++ tests/Makefile.am | 35 +++++++++++++++++++++++++++-- tests/test-gtk-parser.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 tests/test-gtk-parser.c diff --git a/.bzrignore b/.bzrignore index e0fd93e..df33247 100644 --- a/.bzrignore +++ b/.bzrignore @@ -221,3 +221,6 @@ libdbusmenu-gtk/DbusmenuGtk-0.4.vapi libdbusmenu-gtk/dbusmenu-gtk-0.4.pc libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc libdbusmenu-gtk/libdbusmenu_gtk_la-parser.lo +test-gtk-parser +test-gtk-parser-test +test-gtk-parser.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 17b44d1..62142dc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,7 +16,8 @@ TESTS = \ test-gtk-label \ test-gtk-shortcut \ test-gtk-reorder \ - test-gtk-submenu + test-gtk-submenu \ + test-gtk-parser-test check_PROGRAMS = \ glib-server-nomenu \ @@ -42,7 +43,8 @@ check_PROGRAMS = \ test-json-client \ test-json-server \ test-gtk-submenu-server \ - test-gtk-submenu-client + test-gtk-submenu-client \ + test-gtk-parser XVFB_RUN=". $(srcdir)/run-xvfb.sh" @@ -384,6 +386,35 @@ test_gtk_objects_LDADD = \ $(DBUSMENUGLIB_LIBS) \ $(DBUSMENUGTK_LIBS) +###################### +# Test GTK Parser +###################### + +GTK_PARSER_XML_REPORT = test-gtk-parser.xml + +test-gtk-parser-test: test-gtk-parser Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo gtester --verbose -k -o $(GTK_PARSER_XML_REPORT) ./test-gtk-parser >> $@ + @chmod +x $@ + +test_gtk_parser_SOURCES = \ + test-gtk-parser.c + +test_gtk_parser_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) \ + $(DBUSMENUGTK_CFLAGS) \ + -DSRCDIR="\"$(srcdir)\"" \ + -Wall -Werror + +test_gtk_parser_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGLIB_LIBS) \ + $(DBUSMENUGTK_LIBS) + + ######################### # Test GTK Label ######################### diff --git a/tests/test-gtk-parser.c b/tests/test-gtk-parser.c new file mode 100644 index 0000000..74ff9b8 --- /dev/null +++ b/tests/test-gtk-parser.c @@ -0,0 +1,58 @@ +/* +Testing for the various objects just by themselves. + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, 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 GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +/* Just makes sure we can connect here people */ +static void +test_parser_runs (void) +{ + GtkWidget * gmi = gtk_menu_item_new_with_label("Test Item"); + g_assert(gmi != NULL); + DbusmenuMenuitem * mi = dbusmenu_gtk_parse_menu_structure(gmi); + g_assert(mi != NULL); + + g_object_unref(gmi); + g_object_unref(mi); + + return; +} + +/* Build the test suite */ +static void +test_gtk_parser_suite (void) +{ + g_test_add_func ("/dbusmenu/gtk/parser/base", test_parser_runs); + return; +} + +gint +main (gint argc, gchar * argv[]) +{ + gtk_init(&argc, &argv); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + test_gtk_parser_suite(); + + + return g_test_run (); +} -- cgit v1.2.3 From 0ab1ae08ad882569f301b00b174d1c823adb9674 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 14:00:19 -0600 Subject: Adding a child test, but it's failing to make the children. --- tests/test-gtk-parser.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/test-gtk-parser.c b/tests/test-gtk-parser.c index 74ff9b8..e6d5385 100644 --- a/tests/test-gtk-parser.c +++ b/tests/test-gtk-parser.c @@ -36,11 +36,62 @@ test_parser_runs (void) return; } +const gchar * test_parser_children_builder = +"" +"" +"" +/* Start menu bar */ +"True" +/* Child 1 */ +"TrueChild One" +/* Child 2 */ +"TrueChild Two" +/* Child 3 */ +"TrueChild Three" +/* Child 4 */ +"TrueChild Four" +/* Stop menubar */ +"" +""; + +/* Ensure the parser can find children */ +static void +test_parser_children (void) { + GtkBuilder * builder = gtk_builder_new(); + g_assert(builder != NULL); + + GError * error = NULL; + gtk_builder_add_from_string(builder, test_parser_children_builder, -1, &error); + if (error != NULL) { + g_error("Unable to parse UI definition: %s", error->message); + g_error_free(error); + error = NULL; + } + + GtkWidget * menu = GTK_WIDGET(gtk_builder_get_object(builder, "menubar")); + g_assert(menu != NULL); + + DbusmenuMenuitem * mi = dbusmenu_gtk_parse_menu_structure(menu); + g_assert(mi != NULL); + + GList * children = dbusmenu_menuitem_get_children(mi); + g_assert(children != NULL); + + g_assert(g_list_length(children) == 4); + + g_object_unref(mi); + g_object_unref(menu); + g_object_unref(builder); + + return; +} + /* Build the test suite */ static void test_gtk_parser_suite (void) { g_test_add_func ("/dbusmenu/gtk/parser/base", test_parser_runs); + g_test_add_func ("/dbusmenu/gtk/parser/children", test_parser_children); return; } -- cgit v1.2.3 From 90cc7e167c0fc9c709379afa1f22e0a2c494c347 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 14:10:43 -0600 Subject: Adding some debug code, commented out. --- tests/test-gtk-parser.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test-gtk-parser.c b/tests/test-gtk-parser.c index e6d5385..ee608ae 100644 --- a/tests/test-gtk-parser.c +++ b/tests/test-gtk-parser.c @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include #include /* Just makes sure we can connect here people */ @@ -74,6 +75,12 @@ test_parser_children (void) { DbusmenuMenuitem * mi = dbusmenu_gtk_parse_menu_structure(menu); g_assert(mi != NULL); +/* + GPtrArray * xmlarray = g_ptr_array_new(); + dbusmenu_menuitem_buildxml(mi, xmlarray); + g_debug("XML: %s", g_strjoinv("", (gchar **)xmlarray->pdata)); +*/ + GList * children = dbusmenu_menuitem_get_children(mi); g_assert(children != NULL); -- cgit v1.2.3 From 32a7eb938893bcc1bc5644aa95c63041e9d4db01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 15:09:51 -0600 Subject: Needed to go up a level to get recursion code. --- libdbusmenu-gtk/parser.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index cba6b42..08613ac 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -29,6 +29,14 @@ License version 3 and version 2.1 along with this program. If not, see #include "parser.h" #include "menuitem.h" +typedef struct _RecurseContext +{ + gint count; + DbusmenuMenuitem *stack[30]; +} RecurseContext; + +static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse); +static DbusmenuMenuitem * construct_dbusmenu_for_widget (GtkWidget * widget); static void accel_changed (GtkWidget * widget, gpointer data); static gboolean update_stock_item (DbusmenuMenuitem * menuitem, @@ -56,6 +64,156 @@ static gboolean should_show_image (GtkImage * image); DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) +{ + RecurseContext recurse = {0}; + recurse.count = -1; + + parse_menu_structure_helper(widget, &recurse); + + if (recurse.stack[0] != NULL && DBUSMENU_IS_MENUITEM(recurse.stack[0])) { + return recurse.stack[0]; + } + + return NULL; +} + +static void +parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) +{ + if (GTK_IS_CONTAINER (widget)) + { + gboolean increment = GTK_IS_MENU_BAR (widget) || GTK_IS_MENU_ITEM (widget); + + if (increment) + recurse->count++; + + /* Okay, this is a little janky and all.. but some applications update some + * menuitem properties such as sensitivity on the activate callback. This + * seems a little weird, but it's not our place to judge when all this code + * is so crazy. So we're going to get ever crazier and activate all the + * menus that are directly below the menubar and force the applications to + * update their sensitivity. The menus won't actually popup in the app + * window due to our gtk+ patches. + * + * Note that this will not force menuitems in submenus to be updated as well. + */ + if (recurse->count == 0 && GTK_IS_MENU_BAR (widget)) + { + GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); + + for (; children != NULL; children = children->next) + { + gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), + children->data, + TRUE); + } + + g_list_free (children); + } + + if (recurse->count > -1 && increment) + { + DbusmenuMenuitem *dmi = NULL; //g_hash_table_lookup (recurse->context->lookup, widget); + if (dmi != NULL) + { + if (increment) + recurse->count--; + + return; + } + else + { + recurse->stack[recurse->count] = construct_dbusmenu_for_widget (widget); + //g_hash_table_insert (recurse->context->lookup, widget, recurse->stack[recurse->count]); + } + + if (!gtk_widget_get_visible (widget)) + { + /*g_signal_connect (G_OBJECT (widget), + "notify", + G_CALLBACK (menuitem_notify_cb), + recurse->context); */ + } + + if (GTK_IS_TEAROFF_MENU_ITEM (widget)) + { + dbusmenu_menuitem_property_set_bool (recurse->stack[recurse->count], + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + } + + if (recurse->count > 0) + { + GList *children = NULL; + GList *peek = NULL; + + if (recurse->stack[recurse->count - 1]) + { + children = dbusmenu_menuitem_get_children (recurse->stack[recurse->count - 1]); + + if (children) + { + peek = g_list_find (children, recurse->stack[recurse->count]); + } + + if (!peek) + { + /* Should we set a weak ref on the parent? */ + g_object_set_data (G_OBJECT (recurse->stack[recurse->count]), + "dbusmenu-parent", + recurse->stack[recurse->count - 1]); + dbusmenu_menuitem_child_append (recurse->stack[recurse->count - 1], + recurse->stack[recurse->count]); + } + } + else + { + DbusmenuMenuitem *item = NULL; /* g_hash_table_lookup (recurse->context->lookup, + gtk_widget_get_parent (widget)); */ + + if (item) + { + children = dbusmenu_menuitem_get_children (item); + + if (children) + { + peek = g_list_find (children, recurse->stack[recurse->count]); + } + + if (!peek) + { + g_object_set_data (G_OBJECT (recurse->stack[recurse->count]), + "dbusmenu-parent", + recurse->stack[recurse->count - 1]); + + dbusmenu_menuitem_child_append (item, recurse->stack[recurse->count]); + } + } + } + } + } + + gtk_container_foreach (GTK_CONTAINER (widget), + (GtkCallback)parse_menu_structure_helper, + recurse); + + if (GTK_IS_MENU_ITEM (widget)) + { + GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); + + if (menu != NULL) + { + parse_menu_structure_helper (menu, recurse); + } + } + + if (increment) + recurse->count--; + } +} + +static DbusmenuMenuitem * +construct_dbusmenu_for_widget (GtkWidget * widget) { DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); -- cgit v1.2.3 From f9cca3a5b9f42963b43b78670720f0cecd7843ea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 15:10:08 -0600 Subject: For some reason this isn't an object, seems like a builder error, but we're not checking for those really. --- tests/test-gtk-parser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-gtk-parser.c b/tests/test-gtk-parser.c index ee608ae..b66b46a 100644 --- a/tests/test-gtk-parser.c +++ b/tests/test-gtk-parser.c @@ -88,7 +88,6 @@ test_parser_children (void) { g_object_unref(mi); g_object_unref(menu); - g_object_unref(builder); return; } -- cgit v1.2.3 From 65b9cda89a5bef2c541f5ed2624e6e199f136435 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 15:40:26 -0600 Subject: Trying to put back in the visibility notifier to force the rebuild, but I'm not quite sure how to do that yet. --- libdbusmenu-gtk/parser.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 08613ac..9d0f9b4 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -31,6 +31,7 @@ License version 3 and version 2.1 along with this program. If not, see typedef struct _RecurseContext { + GtkWidget * toplevel; gint count; DbusmenuMenuitem *stack[30]; } RecurseContext; @@ -61,12 +62,17 @@ static void widget_notify_cb (GtkWidget * widget, GParamSpec * pspec, gpointer data); static gboolean should_show_image (GtkImage * image); +static void menuitem_notify_cb (GtkWidget * widget, + GParamSpec * pspec, + gpointer data); DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) { RecurseContext recurse = {0}; + recurse.count = -1; + recurse.toplevel = gtk_widget_get_toplevel(widget); parse_menu_structure_helper(widget, &recurse); @@ -129,10 +135,10 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) if (!gtk_widget_get_visible (widget)) { - /*g_signal_connect (G_OBJECT (widget), - "notify", + g_signal_connect (G_OBJECT (widget), + "notify::visible", G_CALLBACK (menuitem_notify_cb), - recurse->context); */ + recurse->toplevel); } if (GTK_IS_TEAROFF_MENU_ITEM (widget)) @@ -358,6 +364,27 @@ construct_dbusmenu_for_widget (GtkWidget * widget) return NULL; } +static void +menuitem_notify_cb (GtkWidget *widget, + GParamSpec *pspec, + gpointer data) +{ + if (pspec->name == g_intern_static_string ("visible")) + { + GtkWidget * new_toplevel = gtk_widget_get_toplevel (widget); + GtkWidget * old_toplevel = GTK_WIDGET(data); + + if (new_toplevel == old_toplevel) { + /* TODO: Figure this out -> rebuild (context->bridge, window); */ + } + + /* We only care about this once, so let's disconnect now. */ + g_signal_handlers_disconnect_by_func (widget, + G_CALLBACK (menuitem_notify_cb), + data); + } +} + static void accel_changed (GtkWidget *widget, gpointer data) -- cgit v1.2.3 From a439aeb8fd08d9858055bbb2ae1326a1335600d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 15:53:27 -0600 Subject: Reimplementing the cache based on object data with signals to cleanup --- libdbusmenu-gtk/parser.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 9d0f9b4..f1c46ba 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -29,6 +29,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "parser.h" #include "menuitem.h" +#define CACHED_MENUITEM "dbusmenu-gtk-parser-cached-item" + typedef struct _RecurseContext { GtkWidget * toplevel; @@ -83,6 +85,20 @@ dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) return NULL; } +static void +dbusmenu_cache_freed (gpointer data, GObject * obj) +{ + g_object_set_data(G_OBJECT(data), CACHED_MENUITEM, NULL); + return; +} + +static void +object_cache_freed (gpointer data) +{ + g_object_weak_unref(G_OBJECT(data), dbusmenu_cache_freed, data); + return; +} + static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) { @@ -119,7 +135,10 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) if (recurse->count > -1 && increment) { - DbusmenuMenuitem *dmi = NULL; //g_hash_table_lookup (recurse->context->lookup, widget); + gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM); + DbusmenuMenuitem *dmi = NULL; + if (pmi != NULL) dmi = DBUSMENU_MENUITEM(pmi); + if (dmi != NULL) { if (increment) @@ -130,7 +149,8 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) else { recurse->stack[recurse->count] = construct_dbusmenu_for_widget (widget); - //g_hash_table_insert (recurse->context->lookup, widget, recurse->stack[recurse->count]); + g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, recurse->stack[recurse->count], object_cache_freed); + g_object_weak_ref(G_OBJECT(recurse->stack[recurse->count]), dbusmenu_cache_freed, widget); } if (!gtk_widget_get_visible (widget)) -- cgit v1.2.3 From fc096ca12b152461dfddbfdf74720b98691448ce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 23 Jan 2011 16:08:39 -0600 Subject: Stop using the data field in gtk image for GTK3 --- libdbusmenu-gtk/parser.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index f1c46ba..cfce42a 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -427,12 +427,15 @@ update_stock_item (DbusmenuMenuitem *menuitem, if (gtk_image_get_storage_type (image) != GTK_IMAGE_STOCK) return FALSE; - gtk_stock_lookup (image->data.stock.stock_id, &stock); + gchar * stock_id = NULL; + gtk_image_get_stock(image, &stock_id, NULL); + + gtk_stock_lookup (stock_id, &stock); if (should_show_image (image)) dbusmenu_menuitem_property_set (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, - image->data.stock.stock_id); + stock_id); else dbusmenu_menuitem_property_remove (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME); @@ -473,13 +476,16 @@ update_icon_name (DbusmenuMenuitem *menuitem, if (gtk_image_get_storage_type (image) != GTK_IMAGE_ICON_NAME) return; - if (should_show_image (image)) + if (should_show_image (image)) { + const gchar * icon_name = NULL; + gtk_image_get_icon_name(image, &icon_name, NULL); dbusmenu_menuitem_property_set (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, - image->data.name.icon_name); - else + icon_name); + } else { dbusmenu_menuitem_property_remove (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME); + } } static GtkWidget * -- cgit v1.2.3 From 25ab785826d59d8ca7860b0d0bc39d6187a3a1ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 24 Jan 2011 14:56:07 -0600 Subject: Fixing referencing warnings on destruction. --- libdbusmenu-gtk/parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index cfce42a..52bd8a8 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -88,7 +88,9 @@ dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) static void dbusmenu_cache_freed (gpointer data, GObject * obj) { - g_object_set_data(G_OBJECT(data), CACHED_MENUITEM, NULL); + /* If the dbusmenu item is killed we don't need to remove + the weak ref as well. */ + g_object_steal_data(G_OBJECT(data), CACHED_MENUITEM); return; } -- cgit v1.2.3 From 32def89e3191d994a43d222c1e81c746922b688d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Jan 2011 11:50:46 -0600 Subject: Moving one up the stack so GtkMenu works as well --- 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 52bd8a8..d26f8fb 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -106,7 +106,7 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) { if (GTK_IS_CONTAINER (widget)) { - gboolean increment = GTK_IS_MENU_BAR (widget) || GTK_IS_MENU_ITEM (widget); + gboolean increment = GTK_IS_MENU_SHELL (widget) || GTK_IS_MENU_ITEM (widget); if (increment) recurse->count++; -- cgit v1.2.3 From 0cdd25e225a88a67fedeae4ddb9686213820ac2c Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 25 Jan 2011 13:18:05 -0500 Subject: avoid critical warning from calling a function on a NULL pointer --- 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 29ed4a0..a5fb1dd 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1441,7 +1441,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* We've got everything built up at this node and reconcilled */ /* Flush the properties requests if this is the first level */ - if (dbusmenu_menuitem_get_id(parent) == 0) { + if (parent != NULL && dbusmenu_menuitem_get_id(parent) == 0) { get_properties_flush(client); } -- cgit v1.2.3 From 275bd0eec2e28b708ff6cda14531f63a8aa16e8e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Jan 2011 16:51:31 -0600 Subject: Looking for the serializable menu item and using it's build function if it is one. --- libdbusmenu-gtk/parser.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index d26f8fb..6d95f10 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -28,6 +28,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "parser.h" #include "menuitem.h" +#include "serializablemenuitem.h" #define CACHED_MENUITEM "dbusmenu-gtk-parser-cached-item" @@ -240,13 +241,23 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) } } +/* Turn a widget into a dbusmenu item depending on the type of GTK + object that it is. */ static DbusmenuMenuitem * construct_dbusmenu_for_widget (GtkWidget * widget) { - DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); - + /* If it's a subclass of our serializable menu item then we can + use its own build function */ + if (DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(widget)) { + DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(widget); + return dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem(smi); + } + + /* If it's a standard GTK Menu Item we need to do some of our own work */ if (GTK_IS_MENU_ITEM (widget)) { + DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); + gboolean visible = FALSE; gboolean sensitive = FALSE; if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) @@ -379,11 +390,12 @@ construct_dbusmenu_for_widget (GtkWidget * widget) "notify", G_CALLBACK (widget_notify_cb), mi); + return mi; } - return mi; - - return NULL; + /* If it's none of those we're going to just create a + generic menuitem as a place holder for it. */ + return dbusmenu_menuitem_new(); } static void -- cgit v1.2.3 From d5a160e04dfd351cefb70ac5f6955cb2913e2ad5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Jan 2011 17:04:23 -0600 Subject: Adding a little helper to reduce the number of warnings if the property is missing. --- libdbusmenu-gtk/client.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 18a2cdd..ff2b3a7 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -42,6 +42,7 @@ struct _DbusmenuGtkClientPrivate { }; #define DBUSMENU_GTKCLIENT_GET_PRIVATE(o) (DBUSMENU_GTKCLIENT(o)->priv) +#define USE_FALLBACK_PROP "use-fallback" /* Prototypes */ static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass); @@ -737,6 +738,28 @@ new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm return TRUE; } +/* A little helper so we don't generate a bunch of warnings + about being able to set use-fallback */ +static void +set_use_fallback (GtkWidget * widget) +{ + static gboolean checked = FALSE; + static gboolean available = FALSE; + + if (!checked) { + available = (g_object_class_find_property(G_OBJECT_CLASS(GTK_IMAGE_GET_CLASS(widget)), USE_FALLBACK_PROP) != NULL); + if (!available) { + g_warning("The '" USE_FALLBACK_PROP "' is not available on GtkImage so icons may not show correctly."); + } + } + + if (available) { + g_object_set(G_OBJECT(widget), USE_FALLBACK_PROP, TRUE, NULL); + } + + return; +} + /* This handler looks at property changes for items that are image menu items. */ static void @@ -789,7 +812,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant gtkimage = NULL; } else if (g_strcmp0(iconname, DBUSMENU_MENUITEM_ICON_NAME_BLANK) == 0) { gtkimage = gtk_image_new(); - g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL); + set_use_fallback(gtkimage); } else { /* Look to see if we want to have an icon with the 'ltr' or 'rtl' depending on what we're doing. */ @@ -808,7 +831,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant can just convert it to this name. */ if (gtkimage == NULL) { gtkimage = gtk_image_new_from_icon_name(finaliconname, GTK_ICON_SIZE_MENU); - g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL); + set_use_fallback(gtkimage); } else { gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), finaliconname, GTK_ICON_SIZE_MENU); } -- cgit v1.2.3 From 936836ea02eb7c0825e93b0a3b8be3a3fb9b2ee0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 09:56:44 -0600 Subject: Even though we all love SVG, it's not a valid signature --- 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 095f333..821d3cb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1020,7 +1020,7 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat g_list_foreach(children, serialize_menuitem, &builder); - ret = g_variant_new("(a(ia{svg}))", g_variant_builder_end(&builder)); + ret = g_variant_new("(a(ia{sv}))", g_variant_builder_end(&builder)); } else { GError * error = NULL; ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, &error); -- cgit v1.2.3 From 248c7a0428b8e05048d1e9891242db82c82f067a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 10:07:20 -0600 Subject: Changing the builder add call --- 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 821d3cb..dda0c09 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -979,7 +979,7 @@ serialize_menuitem(gpointer data, gpointer user_data) gint id = dbusmenu_menuitem_get_id(mi); GVariant * props = dbusmenu_menuitem_properties_variant(mi); - g_variant_builder_add(builder, "ia{sv}", id, props); + g_variant_builder_add(builder, "(ia{sv})", id, props); return; } -- cgit v1.2.3 From ea502b22c0b3d34e58e0db774d5edfd28b7f2d41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 10:55:54 -0600 Subject: Switching to use an internal builder for the tuple to make things more explicit. --- libdbusmenu-glib/server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index dda0c09..b6e5fa1 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -975,11 +975,17 @@ serialize_menuitem(gpointer data, gpointer user_data) { DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); GVariantBuilder * builder = (GVariantBuilder *)(user_data); + GVariantBuilder tuple; + + g_variant_builder_init(&tuple, G_VARIANT_TYPE_TUPLE); 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); + g_variant_builder_add_value(&tuple, props); - g_variant_builder_add(builder, "(ia{sv})", id, props); + g_variant_builder_add_value(builder, g_variant_builder_end(&tuple)); return; } -- cgit v1.2.3 From 025b5f2dfad9c8bd65d1c6b055bea2d8fd1ab33d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 11:12:04 -0600 Subject: Make the tuple without specifying the type so we don't need to build a new one. --- libdbusmenu-glib/server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index b6e5fa1..adb9f91 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1026,7 +1026,8 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat g_list_foreach(children, serialize_menuitem, &builder); - ret = g_variant_new("(a(ia{sv}))", g_variant_builder_end(&builder)); + GVariant * end = g_variant_builder_end(&builder); + ret = g_variant_new_tuple(&end, 1); } else { GError * error = NULL; ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, &error); -- cgit v1.2.3 From 1039a4dd88243938e8871c307c20841c375b78d2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 15:11:16 -0600 Subject: Adding comments and a check to ensure the item is valid. --- libdbusmenu-gtk/parser.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index d26f8fb..1936d2d 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -85,6 +85,8 @@ dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) return NULL; } +/* Called when the dbusmenu item that we're keeping around + is finalized */ static void dbusmenu_cache_freed (gpointer data, GObject * obj) { @@ -94,9 +96,12 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) return; } +/* Called if we replace the cache on the object with a new + dbusmenu menuitem */ static void object_cache_freed (gpointer data) { + if (!G_IS_OBJECT(data)) return; g_object_weak_unref(G_OBJECT(data), dbusmenu_cache_freed, data); return; } -- cgit v1.2.3 From 81032fae461250e5e73aaa49896fd92dd58ad674 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 16:09:41 -0600 Subject: Factoring out the stack and just tracking the parent as that's all we were using it for really. --- libdbusmenu-gtk/parser.c | 236 ++++++++++++++++++++--------------------------- 1 file changed, 99 insertions(+), 137 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 1936d2d..5f0ef48 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -34,8 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see typedef struct _RecurseContext { GtkWidget * toplevel; - gint count; - DbusmenuMenuitem *stack[30]; + DbusmenuMenuitem * parent; } RecurseContext; static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse); @@ -68,21 +67,17 @@ static void menuitem_notify_cb (GtkWidget * widget, GParamSpec * pspec, gpointer data); + DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) { RecurseContext recurse = {0}; - recurse.count = -1; recurse.toplevel = gtk_widget_get_toplevel(widget); parse_menu_structure_helper(widget, &recurse); - if (recurse.stack[0] != NULL && DBUSMENU_IS_MENUITEM(recurse.stack[0])) { - return recurse.stack[0]; - } - - return NULL; + return recurse.parent; } /* Called when the dbusmenu item that we're keeping around @@ -93,6 +88,7 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) /* If the dbusmenu item is killed we don't need to remove the weak ref as well. */ g_object_steal_data(G_OBJECT(data), CACHED_MENUITEM); + g_signal_handlers_disconnect_by_func(data, G_CALLBACK(widget_notify_cb), obj); return; } @@ -109,140 +105,106 @@ object_cache_freed (gpointer data) static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) { - if (GTK_IS_CONTAINER (widget)) - { - gboolean increment = GTK_IS_MENU_SHELL (widget) || GTK_IS_MENU_ITEM (widget); - - if (increment) - recurse->count++; - - /* Okay, this is a little janky and all.. but some applications update some - * menuitem properties such as sensitivity on the activate callback. This - * seems a little weird, but it's not our place to judge when all this code - * is so crazy. So we're going to get ever crazier and activate all the - * menus that are directly below the menubar and force the applications to - * update their sensitivity. The menus won't actually popup in the app - * window due to our gtk+ patches. - * - * Note that this will not force menuitems in submenus to be updated as well. - */ - if (recurse->count == 0 && GTK_IS_MENU_BAR (widget)) - { - GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); - - for (; children != NULL; children = children->next) - { - gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), - children->data, - TRUE); - } - - g_list_free (children); - } - - if (recurse->count > -1 && increment) - { - gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM); - DbusmenuMenuitem *dmi = NULL; - if (pmi != NULL) dmi = DBUSMENU_MENUITEM(pmi); - if (dmi != NULL) - { - if (increment) - recurse->count--; - - return; - } - else - { - recurse->stack[recurse->count] = construct_dbusmenu_for_widget (widget); - g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, recurse->stack[recurse->count], object_cache_freed); - g_object_weak_ref(G_OBJECT(recurse->stack[recurse->count]), dbusmenu_cache_freed, widget); + /* If this is a shell, then let's handle the items in it. */ + if (GTK_IS_MENU_SHELL (widget)) { + /* Okay, this is a little janky and all.. but some applications update some + * menuitem properties such as sensitivity on the activate callback. This + * seems a little weird, but it's not our place to judge when all this code + * is so crazy. So we're going to get ever crazier and activate all the + * menus that are directly below the menubar and force the applications to + * update their sensitivity. The menus won't actually popup in the app + * window due to our gtk+ patches. + * + * Note that this will not force menuitems in submenus to be updated as well. + */ + GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); + + for (; children != NULL; children = children->next) { + gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), + children->data, + TRUE); + } + + g_list_free (children); + + if (recurse->parent == NULL) { + recurse->parent = dbusmenu_menuitem_new(); + } + + gtk_container_foreach (GTK_CONTAINER (widget), + (GtkCallback)parse_menu_structure_helper, + recurse); + return; + } + + if (GTK_IS_MENU_ITEM(widget)) { + DbusmenuMenuitem * thisitem = NULL; + + /* Check to see if we're cached already */ + gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM); + if (pmi != NULL) { + thisitem = DBUSMENU_MENUITEM(pmi); + g_object_ref(G_OBJECT(thisitem)); + } + + /* We don't have one, so we'll need to build it */ + if (thisitem == NULL) { + thisitem = construct_dbusmenu_for_widget (widget); + g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, thisitem, object_cache_freed); + g_object_weak_ref(G_OBJECT(thisitem), dbusmenu_cache_freed, widget); + + if (!gtk_widget_get_visible (widget)) { + g_signal_connect (G_OBJECT (widget), + "notify::visible", + G_CALLBACK (menuitem_notify_cb), + recurse->toplevel); } - if (!gtk_widget_get_visible (widget)) - { - g_signal_connect (G_OBJECT (widget), - "notify::visible", - G_CALLBACK (menuitem_notify_cb), - recurse->toplevel); + if (GTK_IS_TEAROFF_MENU_ITEM (widget)) { + dbusmenu_menuitem_property_set_bool (thisitem, + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); } + } + + /* Check to see if we're in our parents list of children, if we have + a parent. */ + if (recurse->parent != NULL) { + GList * children = dbusmenu_menuitem_get_children (recurse->parent); + GList * peek = NULL; + + if (children != NULL) { + peek = g_list_find (children, thisitem); + } + + /* Oops, let's tell our parents about us */ + if (peek == NULL) { + /* TODO: Should we set a weak ref on the parent? */ + g_object_set_data (G_OBJECT (thisitem), + "dbusmenu-parent", + recurse->parent); + dbusmenu_menuitem_child_append (recurse->parent, + thisitem); + } + } + + GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); + if (menu != NULL) { + DbusmenuMenuitem * parent_save = recurse->parent; + recurse->parent = thisitem; + parse_menu_structure_helper (menu, recurse); + recurse->parent = parent_save; + } + + if (recurse->parent == NULL) { + recurse->parent = thisitem; + } else { + g_object_unref(thisitem); + } + } - if (GTK_IS_TEAROFF_MENU_ITEM (widget)) - { - dbusmenu_menuitem_property_set_bool (recurse->stack[recurse->count], - DBUSMENU_MENUITEM_PROP_VISIBLE, - FALSE); - } - - if (recurse->count > 0) - { - GList *children = NULL; - GList *peek = NULL; - - if (recurse->stack[recurse->count - 1]) - { - children = dbusmenu_menuitem_get_children (recurse->stack[recurse->count - 1]); - - if (children) - { - peek = g_list_find (children, recurse->stack[recurse->count]); - } - - if (!peek) - { - /* Should we set a weak ref on the parent? */ - g_object_set_data (G_OBJECT (recurse->stack[recurse->count]), - "dbusmenu-parent", - recurse->stack[recurse->count - 1]); - dbusmenu_menuitem_child_append (recurse->stack[recurse->count - 1], - recurse->stack[recurse->count]); - } - } - else - { - DbusmenuMenuitem *item = NULL; /* g_hash_table_lookup (recurse->context->lookup, - gtk_widget_get_parent (widget)); */ - - if (item) - { - children = dbusmenu_menuitem_get_children (item); - - if (children) - { - peek = g_list_find (children, recurse->stack[recurse->count]); - } - - if (!peek) - { - g_object_set_data (G_OBJECT (recurse->stack[recurse->count]), - "dbusmenu-parent", - recurse->stack[recurse->count - 1]); - - dbusmenu_menuitem_child_append (item, recurse->stack[recurse->count]); - } - } - } - } - } - - gtk_container_foreach (GTK_CONTAINER (widget), - (GtkCallback)parse_menu_structure_helper, - recurse); - - if (GTK_IS_MENU_ITEM (widget)) - { - GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); - - if (menu != NULL) - { - parse_menu_structure_helper (menu, recurse); - } - } - - if (increment) - recurse->count--; - } + return; } static DbusmenuMenuitem * -- cgit v1.2.3 From fe464dc002ed3e2e713f64145e689f66ad51f275 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 26 Jan 2011 16:13:56 -0600 Subject: Fix to the type of toggle-state to int --- libdbusmenu-gtk/parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 5f0ef48..b1e7e01 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -522,9 +522,9 @@ action_notify_cb (GtkAction *action, } else if (pspec->name == g_intern_static_string ("active")) { - dbusmenu_menuitem_property_set_bool (mi, - DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, - gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); + dbusmenu_menuitem_property_set_int (mi, + DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, + gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); } else if (pspec->name == g_intern_static_string ("label")) { -- cgit v1.2.3 From e5078ed1027e8c466d081183eeee6888b10ef510 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 16:27:50 -0600 Subject: No really, read the comment and make sure that only happens on the highest level --- libdbusmenu-gtk/parser.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index b1e7e01..27ac926 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -118,15 +118,17 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) * * Note that this will not force menuitems in submenus to be updated as well. */ - GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); + if (recurse->parent == NULL) { + GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); - for (; children != NULL; children = children->next) { - gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), - children->data, - TRUE); - } + for (; children != NULL; children = children->next) { + gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), + children->data, + TRUE); + } - g_list_free (children); + g_list_free (children); + } if (recurse->parent == NULL) { recurse->parent = dbusmenu_menuitem_new(); -- cgit v1.2.3 From c6da3667cae61d1606eb66e6b7be01c2cbf9cbff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 16:53:54 -0600 Subject: Only activating on menu bars. --- 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 27ac926..5dea9de 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -118,7 +118,7 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) * * Note that this will not force menuitems in submenus to be updated as well. */ - if (recurse->parent == NULL) { + if (recurse->parent == NULL && GTK_IS_MENU_BAR(widget)) { GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); for (; children != NULL; children = children->next) { -- cgit v1.2.3 From 1555d242f4e0214dd39dbd56e5cc6ddcf426e19b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Jan 2011 22:42:30 -0600 Subject: Actually setting the 'checked' value --- libdbusmenu-gtk/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index ff2b3a7..00b2b90 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -751,6 +751,7 @@ set_use_fallback (GtkWidget * widget) if (!available) { g_warning("The '" USE_FALLBACK_PROP "' is not available on GtkImage so icons may not show correctly."); } + checked = TRUE; } if (available) { -- cgit v1.2.3 From 7e55758aa584a9e4080411cbd663d1fa30725a57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 08:48:37 -0600 Subject: Adding documentation of the public API. --- libdbusmenu-gtk/parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 5dea9de..8537a07 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -67,7 +67,17 @@ static void menuitem_notify_cb (GtkWidget * widget, GParamSpec * pspec, gpointer data); +/** + dbusmenu_gtk_parse_menu_structure: + @widget: A #GtkMenuItem or #GtkMenuShell to turn into a #DbusmenuMenuitem + Goes through the GTK structures and turns them into the appropraite + Dbusmenu structures along with setting up all the relationships + between the objects. It also stores the dbusmenu items as a cache + on the GTK items so that they'll be reused if necissary. + + Return value: A dbusmenu item representing the menu structure +*/ DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) { -- cgit v1.2.3 From 321935e1678923454a97bcb41f9ddc6714e4ac88 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 08:50:24 -0600 Subject: Adding an early check on the type of widget coming into the function. --- libdbusmenu-gtk/parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 8537a07..ead653a 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -81,6 +81,8 @@ static void menuitem_notify_cb (GtkWidget * widget, DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) { + g_return_val_if_fail(GTK_IS_MENU_ITEM(widget) || GTK_IS_MENU_SHELL(widget), NULL); + RecurseContext recurse = {0}; recurse.toplevel = gtk_widget_get_toplevel(widget); -- cgit v1.2.3 From 49ecfc8c84d543491031aecbe64037e3fd76d366 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 09:28:44 -0600 Subject: Shortening function names to be more reasonable. --- libdbusmenu-gtk/serializablemenuitem.c | 10 +++++----- libdbusmenu-gtk/serializablemenuitem.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index f67434e..cfd864d 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -166,7 +166,7 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) } /** - dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem: + dbusmenu_gtk_serializable_menu_item_build_menuitem: @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring This function is for menu items that are instanciated from @@ -179,7 +179,7 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) set by this object. */ DbusmenuMenuitem * -dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) +dbusmenu_gtk_serializable_menu_item_build_menuitem (DbusmenuGtkSerializableMenuItem * smi) { g_return_val_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi), NULL); @@ -207,7 +207,7 @@ type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCli DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(g_object_new(th->type, NULL)); g_return_val_if_fail(smi != NULL, FALSE); - dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem(smi, newitem); + dbusmenu_gtk_serializable_menu_item_set_menuitem(smi, newitem); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(smi), parent); return TRUE; @@ -265,7 +265,7 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, } /** - dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem: + dbusmenu_gtk_serializable_menu_item_set_menuitem: @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of @mi: Menuitem to get the properties from @@ -276,7 +276,7 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, pick up this property being set. */ void -dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) +dbusmenu_gtk_serializable_menu_item_set_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) { g_return_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi)); g_return_if_fail(mi != NULL); diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index 1ca3ef8..1d12dd4 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -99,9 +99,9 @@ struct _DbusmenuGtkSerializableMenuItem { GType dbusmenu_gtk_serializable_menu_item_get_type (void); -DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); +DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_menuitem (DbusmenuGtkSerializableMenuItem * smi); void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); -void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); +void dbusmenu_gtk_serializable_menu_item_set_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); G_END_DECLS -- cgit v1.2.3 From f0722fc3e8842ec8047d104119117f036da1b99f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 09:35:14 -0600 Subject: Adding documentation for the handler functions. --- libdbusmenu-glib/client.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index f371792..6d78edf 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -110,7 +110,28 @@ struct _DbusmenuClient { DbusmenuClientPrivate * priv; }; +/** + DbusmenuClientTypeHandler: + @newitem: The #DbusmenuMenuitem that was created + @parent: The parent of @newitem or #NULL if none + @client: A pointer to the #DbusmenuClient + @user_data: The data you gave us + + The type handler is called when a dbusmenu item is created + with a matching type as setup in #dbusmenu_client_add_type_handler +*/ 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); -- cgit v1.2.3 From 717e9a319cd430428c297d0777b45c64e4d7f5fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 09:40:30 -0600 Subject: Adding some naritive text describing the purpose --- libdbusmenu-gtk/serializablemenuitem.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libdbusmenu-gtk/serializablemenuitem.h b/libdbusmenu-gtk/serializablemenuitem.h index 1d12dd4..db28a24 100644 --- a/libdbusmenu-gtk/serializablemenuitem.h +++ b/libdbusmenu-gtk/serializablemenuitem.h @@ -90,6 +90,13 @@ struct _DbusmenuGtkSerializableMenuItemClass { DbusmenuGtkSerializableMenuItem: @parent: Inherit from GtkMenuItem @priv: Blind structure of private variables + + The Serializable Menuitem provides a way for menu items to be created + that can easily be picked up by the Dbusmenu GTK Parser. This way + you can create custom items, and transport them across dbusmenu to + your menus or the appmenu on the other side of the bus. By providing + these function the parser has enough information to both serialize, and + deserialize on the other side, the menuitem you've so carefully created. */ struct _DbusmenuGtkSerializableMenuItem { GtkMenuItem parent; -- cgit v1.2.3 From 07666d7543bfce7fe925c15d3350519fd711a8f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 09:44:11 -0600 Subject: Fix changing prototypes. --- 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 6d95f10..cdbc001 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -250,7 +250,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget) use its own build function */ if (DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(widget)) { DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(widget); - return dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem(smi); + return dbusmenu_gtk_serializable_menu_item_build_menuitem(smi); } /* If it's a standard GTK Menu Item we need to do some of our own work */ -- cgit v1.2.3 From 35265154f7d70dc31837ff8fe4e45a810c393c2b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 14:14:33 -0600 Subject: 0.3.94 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index c46afe0..619cb17 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.93, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.94, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.93, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.94, [-Wno-portability]) AM_MAINTAINER_MODE @@ -136,7 +136,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=1 +LIBDBUSMENU_REVISION=2 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 7be86c5778e58bbe231655ed58b7597ad61f5310 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 28 Jan 2011 14:35:36 -0500 Subject: notice new submenus --- libdbusmenu-gtk/parser.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 5d71585..5f42ed5 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -649,6 +649,27 @@ widget_notify_cb (GtkWidget *widget, } } } + else if (pspec->name == g_intern_static_string ("submenu")) + { + /* The underlying submenu got swapped out. Let's see what it is now. */ + /* First, delete any children that may exist currently. */ + DbusmenuMenuitem * item = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM)); + if (item != NULL) + { + GList * children = dbusmenu_menuitem_get_children (item); + while (children != NULL) { + dbusmenu_menuitem_child_delete (item, DBUSMENU_MENUITEM(children->data)); + children = children->next; + } + } + + /* Now parse new submenu. */ + GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); + RecurseContext recurse = {0}; + recurse.toplevel = gtk_widget_get_toplevel(widget); + recurse.parent = item; + parse_menu_structure_helper(menu, &recurse); + } } static gboolean -- 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(-) 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(-) 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 db2d419d34f98cf8067bc97cda27b8687ce1be6c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 10:01:59 -0600 Subject: Disconnect realized handler when we don't care about the item anymore. --- libdbusmenu-gtk/menu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 9c4f7f8..5231d0f 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -271,6 +271,10 @@ root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGt #ifdef MASSIVEDEBUGGING g_debug("Root child deleted"); #endif + + /* Remove signal for realized */ + g_signal_handlers_disconnect_by_func(G_OBJECT(child), child_realized, menu); + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); GtkWidget * item = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)); if (item != NULL) { -- cgit v1.2.3 From d9b81a0645e15f03c89cae3466a3928d2b75c4ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 10:12:20 -0600 Subject: Keeping the root so that we can remove the signal handlers. --- libdbusmenu-gtk/menu.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 5231d0f..2a27fe2 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -46,6 +46,7 @@ enum { /* Private */ struct _DbusmenuGtkMenuPrivate { DbusmenuGtkClient * client; + DbusmenuMenuitem * root; gchar * dbus_object; gchar * dbus_name; @@ -63,6 +64,8 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * /* Internal */ static void build_client (DbusmenuGtkMenu * self); static void child_realized (DbusmenuMenuitem * child, gpointer userdata); +static void remove_child_signals (gpointer data, gpointer user_data); +static void root_changed (DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, DbusmenuGtkMenu * menu); /* GObject Stuff */ G_DEFINE_TYPE (DbusmenuGtkMenu, dbusmenu_gtkmenu, GTK_TYPE_MENU); @@ -127,6 +130,12 @@ dbusmenu_gtkmenu_dispose (GObject *object) { DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(object); + /* Remove signals from the root */ + if (priv->root != NULL) { + /* This will clear the root */ + root_changed(priv->client, NULL, DBUSMENU_GTKMENU(object)); + } + if (priv->client != NULL) { g_object_unref(G_OBJECT(priv->client)); priv->client = NULL; @@ -273,7 +282,7 @@ root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGt #endif /* Remove signal for realized */ - g_signal_handlers_disconnect_by_func(G_OBJECT(child), child_realized, menu); + remove_child_signals(child, menu); DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); GtkWidget * item = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)); @@ -312,15 +321,41 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata) return; } +/* Remove any signals we attached to children -- just realized right now */ +static void +remove_child_signals (gpointer data, gpointer user_data) +{ + g_signal_handlers_disconnect_by_func(G_OBJECT(data), child_realized, user_data); + return; +} + /* When the root menuitem changes we need to resetup things so that we're back in the game. */ static void root_changed (DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, DbusmenuGtkMenu * menu) { + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); + + /* Clear out our interest in the old root */ + if (priv->root != NULL) { + GList * children = dbusmenu_menuitem_get_children(priv->root); + g_list_foreach(children, remove_child_signals, menu); + + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), root_child_added, menu); + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), root_child_moved, menu); + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), root_child_delete, menu); + + g_object_unref(priv->root); + priv->root = NULL; + } + if (newroot == NULL) { gtk_widget_hide(GTK_WIDGET(menu)); return; } + priv->root = newroot; + g_object_ref(priv->root); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(root_child_added), menu); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(root_child_moved), menu); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(root_child_delete), menu); -- 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(-) 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 -- cgit v1.2.3 From 591583b6e602b93399fd125da1f658146e5d717d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 11:55:39 -0600 Subject: Switching to take_children() so that we can ensure all the data remains valid --- libdbusmenu-gtk/parser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 5f42ed5..4941bf4 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -656,11 +656,13 @@ widget_notify_cb (GtkWidget *widget, DbusmenuMenuitem * item = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM)); if (item != NULL) { - GList * children = dbusmenu_menuitem_get_children (item); - while (children != NULL) { - dbusmenu_menuitem_child_delete (item, DBUSMENU_MENUITEM(children->data)); - children = children->next; + GList * children = dbusmenu_menuitem_take_children (item); + GList * child = children; + while (child != NULL) { + g_object_unref (G_OBJECT(child->data)); + child = child->next; } + g_list_free(children); } /* Now parse new submenu. */ -- cgit v1.2.3 From 74a0afebe8d3c1fa28d969739ea5c718f00e8c0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 12:08:57 -0600 Subject: Handle the case where we don't have a cached item. Not sure how that'd be, but we shouldn't let it drop. --- libdbusmenu-gtk/parser.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 4941bf4..7e5e7e1 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -666,11 +666,19 @@ widget_notify_cb (GtkWidget *widget, } /* Now parse new submenu. */ - GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); RecurseContext recurse = {0}; recurse.toplevel = gtk_widget_get_toplevel(widget); recurse.parent = item; - parse_menu_structure_helper(menu, &recurse); + + if (item != NULL) { + GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); + parse_menu_structure_helper(menu, &recurse); + } else { + /* Note: it would be really odd that we wouldn't have a cached + item, but we should handle that appropriately. */ + parse_menu_structure_helper(widget, &recurse); + g_object_unref(G_OBJECT(recurse.parent)); + } } } -- cgit v1.2.3 From cd7a287de9d00f258d720a745ebdb840d3b31b67 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jan 2011 15:43:13 -0600 Subject: 0.3.95 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 619cb17..b479fce 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.94, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.95, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.94, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.95, [-Wno-portability]) AM_MAINTAINER_MODE @@ -136,7 +136,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=2 +LIBDBUSMENU_REVISION=3 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From a3da704b473f3ab75786501a6ec20d7b735fe8d9 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 2 Feb 2011 13:44:53 -0500 Subject: disconnect signals when done with menuitem --- libdbusmenu-gtk/parser.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 7e5e7e1..317dba2 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -102,6 +102,21 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) the weak ref as well. */ g_object_steal_data(G_OBJECT(data), CACHED_MENUITEM); g_signal_handlers_disconnect_by_func(data, G_CALLBACK(widget_notify_cb), obj); + + GtkWidget *widget = GTK_WIDGET(data); + GtkWidget *label = find_menu_label (widget); + if (label != NULL) { + g_signal_handlers_disconnect_by_func(label, G_CALLBACK(label_notify_cb), obj); + } + + if (GTK_IS_ACTIVATABLE (widget)) { + GtkAction *action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget)); + + if (action) { + g_signal_handlers_disconnect_by_func(action, G_CALLBACK(action_notify_cb), obj); + } + } + return; } -- cgit v1.2.3 From 51e68e1efe0eff4de283d2a0095357115ae514f4 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 3 Feb 2011 08:43:56 -0500 Subject: keep track of objects that we set notifies for --- libdbusmenu-gtk/parser.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 317dba2..db1d8dd 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -31,6 +31,14 @@ License version 3 and version 2.1 along with this program. If not, see #include "serializablemenuitem.h" #define CACHED_MENUITEM "dbusmenu-gtk-parser-cached-item" +#define PARSER_DATA "dbusmenu-gtk-parser-data" + +typedef struct _ParserData +{ + GtkWidget *label; + GtkAction *action; + GtkWidget *widget; +} ParserData; typedef struct _RecurseContext { @@ -103,18 +111,21 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) g_object_steal_data(G_OBJECT(data), CACHED_MENUITEM); g_signal_handlers_disconnect_by_func(data, G_CALLBACK(widget_notify_cb), obj); - GtkWidget *widget = GTK_WIDGET(data); - GtkWidget *label = find_menu_label (widget); - if (label != NULL) { - g_signal_handlers_disconnect_by_func(label, G_CALLBACK(label_notify_cb), obj); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(obj), PARSER_DATA); + + if (pdata != NULL && pdata->label != NULL) { + g_signal_handlers_disconnect_by_func(pdata->label, G_CALLBACK(label_notify_cb), obj); + g_object_remove_weak_pointer(G_OBJECT(pdata->label), (gpointer*)&pdata->label); } - if (GTK_IS_ACTIVATABLE (widget)) { - GtkAction *action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget)); + if (pdata != NULL && pdata->action != NULL) { + g_signal_handlers_disconnect_by_func(pdata->action, G_CALLBACK(action_notify_cb), obj); + g_object_remove_weak_pointer(G_OBJECT(pdata->action), (gpointer*)&pdata->action); + } - if (action) { - g_signal_handlers_disconnect_by_func(action, G_CALLBACK(action_notify_cb), obj); - } + if (pdata != NULL && pdata->widget != NULL) { + g_signal_handlers_disconnect_by_func(pdata->widget, G_CALLBACK(widget_notify_cb), obj); + g_object_remove_weak_pointer(G_OBJECT(pdata->widget), (gpointer*)&pdata->widget); } return; @@ -125,8 +136,10 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) static void object_cache_freed (gpointer data) { - if (!G_IS_OBJECT(data)) return; - g_object_weak_unref(G_OBJECT(data), dbusmenu_cache_freed, data); + // TODO: make this have access to both data and obj so we can call these + //if (!G_IS_OBJECT(obj)) return; + //g_object_weak_unref(G_OBJECT(obj), dbusmenu_cache_freed, data); + //dbusmenu_cache_freed(data, obj); return; } @@ -254,6 +267,9 @@ construct_dbusmenu_for_widget (GtkWidget * widget) { DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); + ParserData *pdata = g_new0 (ParserData, 1); + g_object_set_data_full (G_OBJECT (mi), PARSER_DATA, pdata, g_free); + gboolean visible = FALSE; gboolean sensitive = FALSE; if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) @@ -328,10 +344,12 @@ construct_dbusmenu_for_widget (GtkWidget * widget) { // Sometimes, an app will directly find and modify the label // (like empathy), so watch the label especially for that. + pdata->label = label; g_signal_connect (G_OBJECT (label), "notify", G_CALLBACK (label_notify_cb), mi); + g_object_add_weak_pointer(G_OBJECT (label), (gpointer*)&pdata->label); } if (GTK_IS_ACTIVATABLE (widget)) @@ -347,10 +365,12 @@ construct_dbusmenu_for_widget (GtkWidget * widget) visible = gtk_action_is_visible (action); sensitive = gtk_action_is_sensitive (action); + pdata->action = action; g_signal_connect_object (action, "notify", G_CALLBACK (action_notify_cb), mi, G_CONNECT_AFTER); + g_object_add_weak_pointer(G_OBJECT (action), (gpointer*)&pdata->action); } } } @@ -382,10 +402,13 @@ construct_dbusmenu_for_widget (GtkWidget * widget) DBUSMENU_MENUITEM_PROP_ENABLED, sensitive); + pdata->widget = widget; g_signal_connect (widget, "notify", G_CALLBACK (widget_notify_cb), mi); + g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget); + return mi; } -- cgit v1.2.3 From ffeede1b23ea70ef789217ef24c3d3182bf27350 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Feb 2011 13:50:55 -0600 Subject: 0.3.96 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b479fce..381df76 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.95, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.96, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.95, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.96, [-Wno-portability]) AM_MAINTAINER_MODE @@ -136,7 +136,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=3 +LIBDBUSMENU_REVISION=4 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- 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(-) 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 4da7e99010b1dbf2a6f28660570e9ad79f538136 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 4 Feb 2011 14:05:52 -0500 Subject: watch for new menu items being added to existing menu shells --- libdbusmenu-gtk/parser.c | 97 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index db1d8dd..96418b3 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -38,6 +38,7 @@ typedef struct _ParserData GtkWidget *label; GtkAction *action; GtkWidget *widget; + GtkWidget *shell; } ParserData; typedef struct _RecurseContext @@ -63,6 +64,9 @@ static void label_notify_cb (GtkWidget * widget, static void action_notify_cb (GtkAction * action, GParamSpec * pspec, gpointer data); +static void child_added_cb (GtkContainer * menu, + GtkWidget * widget, + gpointer data); static void item_activated (DbusmenuMenuitem * item, guint timestamp, gpointer user_data); @@ -109,7 +113,6 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) /* If the dbusmenu item is killed we don't need to remove the weak ref as well. */ g_object_steal_data(G_OBJECT(data), CACHED_MENUITEM); - g_signal_handlers_disconnect_by_func(data, G_CALLBACK(widget_notify_cb), obj); ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(obj), PARSER_DATA); @@ -128,6 +131,11 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) g_object_remove_weak_pointer(G_OBJECT(pdata->widget), (gpointer*)&pdata->widget); } + if (pdata != NULL && pdata->shell != NULL) { + g_signal_handlers_disconnect_by_func(pdata->shell, G_CALLBACK(child_added_cb), obj); + g_object_remove_weak_pointer(G_OBJECT(pdata->shell), (gpointer*)&pdata->shell); + } + return; } @@ -143,6 +151,45 @@ object_cache_freed (gpointer data) return; } +static gint +get_child_position (GtkWidget * child) +{ + GtkWidget * parent = gtk_widget_get_parent (child); + if (parent == NULL || !GTK_IS_CONTAINER (parent)) + return -1; + + GList * children = gtk_container_get_children (GTK_CONTAINER (parent)); + GList * iter; + gint position = 0; + + for (iter = children; iter != NULL; iter = iter->next) { + if (iter->data == child) + break; + ++position; + } + + g_list_free (children); + + if (iter == NULL) + return -1; + else + return position; +} + +static DbusmenuMenuitem * +new_menuitem (GtkWidget * widget) +{ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + ParserData *pdata = g_new0 (ParserData, 1); + g_object_set_data_full(G_OBJECT(item), PARSER_DATA, pdata, g_free); + + g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, item, object_cache_freed); + g_object_weak_ref(G_OBJECT(item), dbusmenu_cache_freed, widget); + + return item; +} + static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) { @@ -161,10 +208,11 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) */ if (recurse->parent == NULL && GTK_IS_MENU_BAR(widget)) { GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); + GList *iter; - for (; children != NULL; children = children->next) { + for (iter = children; iter != NULL; iter = iter->next) { gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), - children->data, + iter->data, TRUE); } @@ -172,9 +220,18 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) } if (recurse->parent == NULL) { - recurse->parent = dbusmenu_menuitem_new(); + recurse->parent = new_menuitem(widget); } + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(recurse->parent), PARSER_DATA); + + pdata->shell = widget; + g_signal_connect (G_OBJECT (widget), + "child-added", + G_CALLBACK (child_added_cb), + recurse->parent); + g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->shell); + gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback)parse_menu_structure_helper, recurse); @@ -194,8 +251,6 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) /* We don't have one, so we'll need to build it */ if (thisitem == NULL) { thisitem = construct_dbusmenu_for_widget (widget); - g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, thisitem, object_cache_freed); - g_object_weak_ref(G_OBJECT(thisitem), dbusmenu_cache_freed, widget); if (!gtk_widget_get_visible (widget)) { g_signal_connect (G_OBJECT (widget), @@ -227,8 +282,14 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) g_object_set_data (G_OBJECT (thisitem), "dbusmenu-parent", recurse->parent); - dbusmenu_menuitem_child_append (recurse->parent, - thisitem); + gint pos = get_child_position (widget); + if (pos >= 0) + dbusmenu_menuitem_child_add_position (recurse->parent, + thisitem, + pos); + else + dbusmenu_menuitem_child_append (recurse->parent, + thisitem); } } @@ -265,10 +326,9 @@ construct_dbusmenu_for_widget (GtkWidget * widget) /* If it's a standard GTK Menu Item we need to do some of our own work */ if (GTK_IS_MENU_ITEM (widget)) { - DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); + DbusmenuMenuitem *mi = new_menuitem(widget); - ParserData *pdata = g_new0 (ParserData, 1); - g_object_set_data_full (G_OBJECT (mi), PARSER_DATA, pdata, g_free); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA); gboolean visible = FALSE; gboolean sensitive = FALSE; @@ -414,7 +474,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget) /* If it's none of those we're going to just create a generic menuitem as a place holder for it. */ - return dbusmenu_menuitem_new(); + return new_menuitem(widget); } static void @@ -720,6 +780,19 @@ widget_notify_cb (GtkWidget *widget, } } +/* A child item was added to a menu we're watching. Let's try to integrate it. */ +static void +child_added_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) +{ + DbusmenuMenuitem *menuitem = (DbusmenuMenuitem *)data; + + RecurseContext recurse = {0}; + recurse.toplevel = gtk_widget_get_toplevel(GTK_WIDGET(menu)); + recurse.parent = menuitem; + + parse_menu_structure_helper(widget, &recurse); +} + static gboolean should_show_image (GtkImage *image) { -- 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(-) 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(-) 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(+) 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(-) 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(+) 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(-) 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(-) 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 +++++++++++++------------- libdbusmenu-gtk/Makefile.am | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) 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) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index f3556e9..f66f1f5 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -98,7 +98,7 @@ DbusmenuGtk$(VER)-0.4.gir: libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_INCLUDES = \ GObject-2.0 \ $(GTKGIR) \ - Dbusmenu-Glib-0.4 + Dbusmenu-0.4 DbusmenuGtk_0_4_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) @@ -141,7 +141,7 @@ DbusmenuGtk$(VER)-0.4.vapi: DbusmenuGtk$(VER)-0.4.tmp.gir Makefile.am --pkg gdk-pixbuf-2.0 \ --pkg $(GTKVALA) \ --pkg atk \ - --pkg Dbusmenu-Glib-0.4 \ + --pkg Dbusmenu-0.4 \ --vapidir=$(top_builddir)/libdbusmenu-glib \ $< -- cgit v1.2.3 From 5c1bbec8381af0246b813a095f816b55e2f8dc06 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Feb 2011 14:15:31 -0600 Subject: 0.3.97 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 381df76..4510b6d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.96, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.97, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.96, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.97, [-Wno-portability]) AM_MAINTAINER_MODE @@ -136,7 +136,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=4 +LIBDBUSMENU_REVISION=5 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From e342bd662608d2557bb79d6d6cea5947a58fb09f Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 10 Feb 2011 18:27:40 -0500 Subject: fix icon usage -- watch more signals, handle gicons, respect always-show-image better --- libdbusmenu-gtk/parser.c | 234 +++++++++++++++++++++++++++++------------------ 1 file changed, 146 insertions(+), 88 deletions(-) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 70cde53..38528d8 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -39,6 +39,7 @@ typedef struct _ParserData GtkAction *action; GtkWidget *widget; GtkWidget *shell; + GtkWidget *image; } ParserData; typedef struct _RecurseContext @@ -51,22 +52,25 @@ static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * re static DbusmenuMenuitem * construct_dbusmenu_for_widget (GtkWidget * widget); static void accel_changed (GtkWidget * widget, gpointer data); -static gboolean update_stock_item (DbusmenuMenuitem * menuitem, - GtkWidget * widget); static void checkbox_toggled (GtkWidget * widget, DbusmenuMenuitem * mi); -static void update_icon_name (DbusmenuMenuitem * menuitem, - GtkWidget * widget); +static void update_icon (DbusmenuMenuitem * menuitem, + GtkImage * image); static GtkWidget * find_menu_label (GtkWidget * widget); static void label_notify_cb (GtkWidget * widget, GParamSpec * pspec, gpointer data); +static void image_notify_cb (GtkWidget * widget, + GParamSpec * pspec, + gpointer data); static void action_notify_cb (GtkAction * action, GParamSpec * pspec, gpointer data); static void child_added_cb (GtkContainer * menu, GtkWidget * widget, gpointer data); +static void theme_changed_cb (GtkIconTheme * theme, + gpointer data); static void item_activated (DbusmenuMenuitem * item, guint timestamp, gpointer user_data); @@ -136,6 +140,11 @@ dbusmenu_cache_freed (gpointer data, GObject * obj) g_object_remove_weak_pointer(G_OBJECT(pdata->shell), (gpointer*)&pdata->shell); } + if (pdata != NULL && pdata->image != NULL) { + g_signal_handlers_disconnect_by_func(pdata->image, G_CALLBACK(image_notify_cb), obj); + g_object_remove_weak_pointer(G_OBJECT(pdata->image), (gpointer*)&pdata->image); + } + return; } @@ -148,6 +157,9 @@ object_cache_freed (gpointer data) //if (!G_IS_OBJECT(obj)) return; //g_object_weak_unref(G_OBJECT(obj), dbusmenu_cache_freed, data); //dbusmenu_cache_freed(data, obj); + + g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), data); + return; } @@ -347,8 +359,6 @@ construct_dbusmenu_for_widget (GtkWidget * widget) } else { - gboolean label_set = FALSE; - g_signal_connect (widget, "accel-closures-changed", G_CALLBACK (accel_changed), @@ -373,41 +383,37 @@ construct_dbusmenu_for_widget (GtkWidget * widget) if (GTK_IS_IMAGE_MENU_ITEM (widget)) { GtkWidget *image; - GtkImageType image_type; image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); if (GTK_IS_IMAGE (image)) { - image_type = gtk_image_get_storage_type (GTK_IMAGE (image)); - - if (image_type == GTK_IMAGE_STOCK) - { - label_set = update_stock_item (mi, image); - } - else if (image_type == GTK_IMAGE_ICON_NAME) - { - update_icon_name (mi, image); - } - else if (image_type == GTK_IMAGE_PIXBUF) - { - dbusmenu_menuitem_property_set_image (mi, - DBUSMENU_MENUITEM_PROP_ICON_DATA, - gtk_image_get_pixbuf (GTK_IMAGE (image))); - } + update_icon (mi, GTK_IMAGE (image)); + + /* Watch for theme changes because if gicon changes, we want to send a + different pixbuf. */ + g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + "changed", G_CALLBACK(theme_changed_cb), widget); + + pdata->image = image; + g_signal_connect (G_OBJECT (image), + "notify", + G_CALLBACK (image_notify_cb), + mi); + g_object_add_weak_pointer(G_OBJECT (image), (gpointer*)&pdata->image); } } GtkWidget *label = find_menu_label (widget); - dbusmenu_menuitem_property_set (mi, - "label", - label ? gtk_label_get_text (GTK_LABEL (label)) : NULL); - if (label) { // Sometimes, an app will directly find and modify the label // (like empathy), so watch the label especially for that. + dbusmenu_menuitem_property_set (mi, + "label", + gtk_label_get_text (GTK_LABEL (label))); + pdata->label = label; g_signal_connect (G_OBJECT (label), "notify", @@ -510,48 +516,6 @@ accel_changed (GtkWidget *widget, dbusmenu_menuitem_property_set_shortcut_menuitem (mi, GTK_MENU_ITEM (widget)); } -static gboolean -update_stock_item (DbusmenuMenuitem *menuitem, - GtkWidget *widget) -{ - GtkStockItem stock; - GtkImage *image; - - g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE); - - image = GTK_IMAGE (widget); - - if (gtk_image_get_storage_type (image) != GTK_IMAGE_STOCK) - return FALSE; - - gchar * stock_id = NULL; - gtk_image_get_stock(image, &stock_id, NULL); - - gtk_stock_lookup (stock_id, &stock); - - if (should_show_image (image)) - dbusmenu_menuitem_property_set (menuitem, - DBUSMENU_MENUITEM_PROP_ICON_NAME, - stock_id); - else - dbusmenu_menuitem_property_remove (menuitem, - DBUSMENU_MENUITEM_PROP_ICON_NAME); - - const gchar *label = dbusmenu_menuitem_property_get (menuitem, - DBUSMENU_MENUITEM_PROP_LABEL); - - if (stock.label != NULL && label != NULL) - { - dbusmenu_menuitem_property_set (menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - stock.label); - - return TRUE; - } - - return FALSE; -} - static void checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi) { @@ -561,27 +525,82 @@ checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi) } static void -update_icon_name (DbusmenuMenuitem *menuitem, - GtkWidget *widget) +update_icon (DbusmenuMenuitem *menuitem, GtkImage *image) { - GtkImage *image; - - g_return_if_fail (GTK_IS_IMAGE (widget)); - - image = GTK_IMAGE (widget); + GdkPixbuf * pixbuf = NULL; + const gchar * icon_name = NULL; + GtkStockItem stock; + GIcon * gicon; + GtkIconInfo * info; + gint width; + + if (image != NULL && should_show_image (image)) { + switch (gtk_image_get_storage_type (image)) { + case GTK_IMAGE_PIXBUF: + pixbuf = g_object_ref (gtk_image_get_pixbuf (image)); + break; + + case GTK_IMAGE_ICON_NAME: + gtk_image_get_icon_name (image, &icon_name, NULL); + break; + + case GTK_IMAGE_STOCK: + gtk_image_get_stock (image, (gchar **) &icon_name, NULL); + if (gtk_stock_lookup (icon_name, &stock)) { + /* Now set label too */ + const gchar * label = NULL; + label = dbusmenu_menuitem_property_get (menuitem, + DBUSMENU_MENUITEM_PROP_LABEL); + if (stock.label != NULL && label != NULL) { + dbusmenu_menuitem_property_set (menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + stock.label); + } + } + break; + + case GTK_IMAGE_GICON: + /* Load up a pixbuf and send that over. We don't bother differentiating + between icon-name gicons and pixbuf gicons because even when given a + icon-name gicon, there's no easy way to lookup which icon-name among + its set is present and should be used among the icon themes available. + So instead, we render to a pixbuf and watch icon theme changes. */ + gtk_image_get_gicon (image, &gicon, NULL); + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, NULL); + info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), + gicon, width, + GTK_ICON_LOOKUP_FORCE_SIZE); + if (info != NULL) { + pixbuf = gtk_icon_info_load_icon (info, NULL); + gtk_icon_info_free (info); + } + break; - if (gtk_image_get_storage_type (image) != GTK_IMAGE_ICON_NAME) - return; + default: + g_debug ("Could not handle image type %i\n", gtk_image_get_storage_type (image)); + break; + } + } - if (should_show_image (image)) { - const gchar * icon_name = NULL; - gtk_image_get_icon_name(image, &icon_name, NULL); + if (icon_name != NULL) { dbusmenu_menuitem_property_set (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, icon_name); - } else { + } + else if (pixbuf != NULL) { + dbusmenu_menuitem_property_set_image (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_DATA, + pixbuf); + } + else { dbusmenu_menuitem_property_remove (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME); + dbusmenu_menuitem_property_remove (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_DATA); + } + + if (pixbuf != NULL) { + g_object_unref (pixbuf); } } @@ -629,6 +648,29 @@ label_notify_cb (GtkWidget *widget, } } +static void +image_notify_cb (GtkWidget *widget, + GParamSpec *pspec, + gpointer data) +{ + DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; + + if (pspec->name == g_intern_static_string ("file") || + pspec->name == g_intern_static_string ("gicon") || + pspec->name == g_intern_static_string ("icon-name") || + pspec->name == g_intern_static_string ("icon-set") || + pspec->name == g_intern_static_string ("image") || + pspec->name == g_intern_static_string ("mask") || + pspec->name == g_intern_static_string ("pixbuf") || + pspec->name == g_intern_static_string ("pixbuf-animation") || + pspec->name == g_intern_static_string ("pixmap") || + pspec->name == g_intern_static_string ("stock") || + pspec->name == g_intern_static_string ("storage-type")) + { + update_icon (mi, GTK_IMAGE (widget)); + } +} + static void action_notify_cb (GtkAction *action, GParamSpec *pspec, @@ -723,13 +765,12 @@ widget_notify_cb (GtkWidget *widget, DBUSMENU_MENUITEM_PROP_VISIBLE, gtk_widget_get_visible (widget)); } - else if (pspec->name == g_intern_static_string ("stock")) - { - update_stock_item (child, widget); - } - else if (pspec->name == g_intern_static_string ("icon-name")) + else if (pspec->name == g_intern_static_string ("image") || + pspec->name == g_intern_static_string ("always-show-image")) { - update_icon_name (child, widget); + GtkWidget *image; + image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); + update_icon (child, GTK_IMAGE (image)); } else if (pspec->name == g_intern_static_string ("parent")) { @@ -797,6 +838,23 @@ child_added_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) parse_menu_structure_helper(widget, &recurse); } +static void +theme_changed_cb (GtkIconTheme *theme, gpointer data) +{ + GtkWidget *image; + + image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (data)); + + gpointer pmi = g_object_get_data(G_OBJECT(data), CACHED_MENUITEM); + if (pmi != NULL) { + update_icon(DBUSMENU_MENUITEM(pmi), GTK_IMAGE(image)); + } + + /* Switch signal to new theme */ + g_signal_handlers_disconnect_by_func(theme, G_CALLBACK(theme_changed_cb), data); + g_signal_connect(gtk_icon_theme_get_default(), "changed", G_CALLBACK(theme_changed_cb), data); +} + static gboolean should_show_image (GtkImage *image) { -- 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(+) 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(-) 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(-) 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(+) 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(+) 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(-) 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(+) 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(-) 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(+) 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(-) 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(+) 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(-) 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(-) 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(-) 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 --- configure.ac | 10 +++------- libdbusmenu-glib/client.c | 3 --- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 381df76..017d1b4 100644 --- a/configure.ac +++ b/configure.ac @@ -42,11 +42,9 @@ GNOME_DOC_INIT ########################### GLIB_REQUIRED_VERSION=2.26 -XML_REQUIRED_VERSION=2.6 PKG_CHECK_MODULES(DBUSMENUGLIB, glib-2.0 >= $GLIB_REQUIRED_VERSION - gio-2.0 >= $GLIB_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) + gio-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(DBUSMENUGLIB_CFLAGS) AC_SUBST(DBUSMENUGLIB_LIBS) @@ -65,16 +63,14 @@ AC_ARG_WITH([gtk], [with_gtk=2]) AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-3.0 >= $GTK3_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) + glib-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available]) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - libxml-2.0 >= $XML_REQUIRED_VERSION) + glib-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) ], 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 3cebed3db50dd6325c725d87a6ec5eabc21d2ba3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Feb 2011 22:33:02 -0600 Subject: Making sure the root isn't NULL before continuing --- tests/test-glib-layout-client.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 5ea0cf8..3afe042 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -81,6 +81,11 @@ layout_updated (DbusmenuClient * client, gpointer data) g_debug("Layout Updated"); DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(client); + if (menuroot == NULL) { + g_debug("Root NULL, waiting"); + return; + } + layout_t * layout = &layouts[layouton]; if (!verify_root_to_layout(menuroot, layout)) { -- 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(-) 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(-) 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(-) 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(-) 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 e1094452eda0314065bb1b02d616d573c0367a74 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Feb 2011 11:50:54 -0600 Subject: Don't unref the variant as we don't really have a ref to it, it's still floating --- tests/json-loader.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/json-loader.c b/tests/json-loader.c index 14e90e0..36157dc 100644 --- a/tests/json-loader.c +++ b/tests/json-loader.c @@ -109,7 +109,6 @@ set_props (DbusmenuMenuitem * mi, JsonObject * node) if (variant != NULL) { dbusmenu_menuitem_property_set_variant(mi, member, variant); - g_variant_unref(variant); } } -- cgit v1.2.3 From fd71ffff45749bc72cabcd4c5fd8b258d7d25c72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Feb 2011 15:06:42 -0600 Subject: Make sure to clean up the reports --- tests/Makefile.am | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 62142dc..32c8437 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,6 +2,7 @@ DBUS_RUNNER=dbus-test-runner CLEANFILES= +DISTCLEANFILES= TESTS = \ test-glib-objects-test \ @@ -260,6 +261,8 @@ test_glib_objects_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +DISTCLEANFILES += $(OBJECT_XML_REPORT) + ###################### # Test Glib Properties ###################### @@ -386,6 +389,8 @@ test_gtk_objects_LDADD = \ $(DBUSMENUGLIB_LIBS) \ $(DBUSMENUGTK_LIBS) +DISTCLEANFILES += $(GTK_OBJECT_XML_REPORT) + ###################### # Test GTK Parser ###################### @@ -414,6 +419,7 @@ test_gtk_parser_LDADD = \ $(DBUSMENUGLIB_LIBS) \ $(DBUSMENUGTK_LIBS) +DISTCLEANFILES += $(GTK_PARSER_XML_REPORT) ######################### # Test GTK Label @@ -622,8 +628,6 @@ CLEANFILES += \ distclean-local: -rm -rf $(builddir)/mago.results -DISTCLEANFILES = \ - $(TESTS) \ - $(OBJECT_XML_REPORT) \ - $(GTK_OBJECT_XML_REPORT) +DISTCLEANFILES += \ + $(TESTS) -- cgit v1.2.3 From 273fd4ea8fb0376256d773914786ebc433399c6f Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Feb 2011 16:59:17 +0100 Subject: tools/dbusmenu-dumper: Proper GVariant handling of gdbus call to make this actually work --- tools/dbusmenu-dumper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index bd986e8..2db437d 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -270,10 +270,12 @@ init_dbus_vars_from_window(Window window) error = NULL; GVariant * retval; + GVariant * args[1]; + args[0] = g_variant_new("u", window); retval = g_dbus_proxy_call_sync(proxy, "GetMenuForWindow", - g_variant_new("u", window), + g_variant_new_tuple(args, 1), G_DBUS_CALL_FLAGS_NONE, -1, NULL, @@ -285,7 +287,7 @@ init_dbus_vars_from_window(Window window) return FALSE; } - g_variant_get(retval, "so", &dbusname, &dbusobject); + g_variant_get(retval, "(so)", &dbusname, &dbusobject); g_variant_unref(retval); g_object_unref(proxy); -- 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(-) 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(-) 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 98e01df8406f305f8d232cf41e5facaf559afe0f Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Feb 2011 20:56:38 +0100 Subject: Fix g-ir-scanner file list for gtk Analoguous to r211 for the GTK library. --- libdbusmenu-gtk/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index f66f1f5..50a8f2c 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -78,21 +78,21 @@ if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --warn-all \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ - $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) \ + $(addprefix --c-include=libdbusmenu-gtk/, $(libdbusmenu_gtkinclude_HEADERS)) \ --symbol-prefix=dbusmenu \ --identifier-prefix=DbusmenuGtk else INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ --warn-all \ --add-include-path=$(top_builddir)/libdbusmenu-glib \ - $(addprefix --c-include=libdbusmenu-gtk/, $(introspection_sources)) + $(addprefix --c-include=libdbusmenu-gtk/, $(libdbusmenu_gtkinclude_HEADERS)) endif INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_builddir)/libdbusmenu-glib if HAVE_INTROSPECTION -introspection_sources = $(libdbusmenu_gtkinclude_HEADERS) +introspection_sources = $(filter-out genericmenuitem.%, $(libdbusmenu_gtkinclude_HEADERS) $(libdbusmenu_gtk_la_SOURCES)) DbusmenuGtk$(VER)-0.4.gir: libdbusmenu-gtk$(VER).la DbusmenuGtk_0_4_gir_INCLUDES = \ -- cgit v1.2.3 From 558fa9265c05452de03ddd9f8543dfdce1b81e7b Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Feb 2011 21:06:14 +0100 Subject: Fix GI annotations for DbusmenuGtk --- libdbusmenu-gtk/client.c | 110 +++++++++++++++--------------- libdbusmenu-gtk/genericmenuitem.c | 52 +++++++------- libdbusmenu-gtk/menu.c | 34 +++++----- libdbusmenu-gtk/menuitem.c | 120 ++++++++++++++++----------------- libdbusmenu-gtk/menuitem.h | 2 +- libdbusmenu-gtk/parser.c | 20 +++--- libdbusmenu-gtk/serializablemenuitem.c | 62 ++++++++--------- 7 files changed, 200 insertions(+), 200 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 7ab2fe9..4128b02 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -219,13 +219,13 @@ refresh_shortcut (DbusmenuGtkClient * client, DbusmenuMenuitem * mi) /** - dbusmenu_gtkclient_set_accel_group: - @client: To set the group on - @agroup: The new acceleration group - - Sets the acceleration group for the menu items with accelerators - on this client. -*/ + * dbusmenu_gtkclient_set_accel_group: + * @client: To set the group on + * @agroup: The new acceleration group + * + * Sets the acceleration group for the menu items with accelerators + * on this client. + */ void dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * agroup) { @@ -256,14 +256,14 @@ dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * } /** - dbusmenu_gtkclient_get_accel_group: - @client: Client to query for an accelerator group - - Gets the accel group for this client. - - Return value: Either a valid group or #NULL on error or - none set. -*/ + * dbusmenu_gtkclient_get_accel_group: + * @client: Client to query for an accelerator group + * + * Gets the accel group for this client. + * + * Return value: (transfer none): Either a valid group or #NULL on error or + * none set. + */ GtkAccelGroup * dbusmenu_gtkclient_get_accel_group (DbusmenuGtkClient * client) { @@ -493,21 +493,21 @@ destroy_gmi (GtkMenuItem * gmi, DbusmenuMenuitem * mi) #endif /** - dbusmenu_gtkclient_newitem_base: - @client: The client handling everything on this connection - @item: The #DbusmenuMenuitem to attach the GTK-isms to - @gmi: A #GtkMenuItem representing the GTK world's view of this menuitem - @parent: The parent #DbusmenuMenuitem - - This function provides some of the basic connectivity for being in - the GTK world. Things like visibility and sensitivity of the item are - handled here so that the subclasses don't have to. If you're building - your on GTK menu item you can use this function to apply those basic - attributes so that you don't have to deal with them either. - - This also handles passing the "activate" signal back to the - #DbusmenuMenuitem side of thing. -*/ + * dbusmenu_gtkclient_newitem_base: + * @client: The client handling everything on this connection + * @item: The #DbusmenuMenuitem to attach the GTK-isms to + * @gmi: A #GtkMenuItem representing the GTK world's view of this menuitem + * @parent: The parent #DbusmenuMenuitem + * + * This function provides some of the basic connectivity for being in + * the GTK world. Things like visibility and sensitivity of the item are + * handled here so that the subclasses don't have to. If you're building + * your on GTK menu item you can use this function to apply those basic + * attributes so that you don't have to deal with them either. + * + * This also handles passing the "activate" signal back to the + * #DbusmenuMenuitem side of thing. + */ void dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * item, GtkMenuItem * gmi, DbusmenuMenuitem * parent) { @@ -617,15 +617,15 @@ move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint ol /* Public API */ /** - dbusmenu_gtkclient_new: - @dbus_name: Name of the #DbusmenuServer on DBus - @dbus_name: Name of the object on the #DbusmenuServer - - Creates a new #DbusmenuGtkClient object and creates a #DbusmenuClient - that connects across DBus to a #DbusmenuServer. - - Return value: A new #DbusmenuGtkClient sync'd with a server -*/ + * dbusmenu_gtkclient_new: + * @dbus_name: Name of the #DbusmenuServer on DBus + * @dbus_name: Name of the object on the #DbusmenuServer + * + * Creates a new #DbusmenuGtkClient object and creates a #DbusmenuClient + * that connects across DBus to a #DbusmenuServer. + * + * Return value: A new #DbusmenuGtkClient sync'd with a server + */ DbusmenuGtkClient * dbusmenu_gtkclient_new (gchar * dbus_name, gchar * dbus_object) { @@ -636,15 +636,15 @@ dbusmenu_gtkclient_new (gchar * dbus_name, gchar * dbus_object) } /** - dbusmenu_gtkclient_menuitem_get: - @client: A #DbusmenuGtkClient with the item in it. - @item: #DbusmenuMenuitem to get associated #GtkMenuItem on. - - This grabs the #GtkMenuItem that is associated with the - #DbusmenuMenuitem. - - Return value: The #GtkMenuItem that can be played with. -*/ + * dbusmenu_gtkclient_menuitem_get: + * @client: A #DbusmenuGtkClient with the item in it. + * @item: #DbusmenuMenuitem to get associated #GtkMenuItem on. + * + * This grabs the #GtkMenuItem that is associated with the + * #DbusmenuMenuitem. + * + * Return value: (transfer none): The #GtkMenuItem that can be played with. + */ GtkMenuItem * dbusmenu_gtkclient_menuitem_get (DbusmenuGtkClient * client, DbusmenuMenuitem * item) { @@ -660,13 +660,13 @@ dbusmenu_gtkclient_menuitem_get (DbusmenuGtkClient * client, DbusmenuMenuitem * } /** - dbusmenu_gtkclient_menuitem_get_submenu: - @client: A #DbusmenuGtkClient with the item in it. - @item: #DbusmenuMenuitem to get associated #GtkMenu on. - - This grabs the submenu associated with the menuitem. - - Return value: The #GtkMenu if there is one. + * dbusmenu_gtkclient_menuitem_get_submenu: + * @client: A #DbusmenuGtkClient with the item in it. + * @item: #DbusmenuMenuitem to get associated #GtkMenu on. + * + * This grabs the submenu associated with the menuitem. + * + * Return value: (transfer none): The #GtkMenu if there is one. */ GtkMenu * dbusmenu_gtkclient_menuitem_get_submenu (DbusmenuGtkClient * client, DbusmenuMenuitem * item) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 2af70f3..2fd6fba 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -278,12 +278,12 @@ activate (GtkMenuItem * menu_item) } /** - genericmenuitem_set_check_type: - @item: #Genericmenuitem to set the type on - @check_type: Which type of check should be displayed - - This function changes the type of the checkmark that - appears in the left hand gutter for the menuitem. + * genericmenuitem_set_check_type: + * @item: #Genericmenuitem to set the type on + * @check_type: Which type of check should be displayed + * + * This function changes the type of the checkmark that + * appears in the left hand gutter for the menuitem. */ void genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType check_type) @@ -317,14 +317,14 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType } /** - genericmenuitem_set_state: - @item: #Genericmenuitem to set the type on - @check_type: What is the state of the check - - Sets the state of the check in the menu item. It does - not require, but isn't really useful if the type of - check that the menuitem is set to #GENERICMENUITEM_CHECK_TYPE_NONE. -*/ + * genericmenuitem_set_state: + * @item: #Genericmenuitem to set the type on + * @check_type: What is the state of the check + * + * Sets the state of the check in the menu item. It does + * not require, but isn't really useful if the type of + * check that the menuitem is set to #GENERICMENUITEM_CHECK_TYPE_NONE. + */ void genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) { @@ -377,11 +377,11 @@ set_image_helper (GtkWidget * widget, gpointer data) } /** - genericmenuitem_set_image: - @item: A #Genericmenuitem - @image: The image to set as the image of @item - - Sets the image of the menu item. + * genericmenuitem_set_image: + * @item: A #Genericmenuitem + * @image: The image to set as the image of @item + * + * Sets the image of the menu item. */ void genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image) @@ -439,13 +439,13 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image) } /** - genericmenuitem_get_image: - @item: A #Genericmenuitem - - Returns the image if there is one. - - Return value: A pointer to the image of the item or #NULL - if there isn't one. + * genericmenuitem_get_image: + * @item: A #Genericmenuitem + * + * Returns the image if there is one. + * + * Return value: (transfer none): A pointer to the image of the item or #NULL + * if there isn't one. */ GtkWidget * genericmenuitem_get_image (Genericmenuitem * menu_item) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 2a27fe2..9788ffc 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -398,15 +398,15 @@ build_client (DbusmenuGtkMenu * self) /* Public API */ /** - dbusmenu_gtkmenu_new: - @dbus_name: Name of the #DbusmenuServer on DBus - @dbus_name: Name of the object on the #DbusmenuServer - - Creates a new #DbusmenuGtkMenu object and creates a #DbusmenuClient - that connects across DBus to a #DbusmenuServer. - - Return value: A new #DbusmenuGtkMenu sync'd with a server -*/ + * dbusmenu_gtkmenu_new: + * @dbus_name: Name of the #DbusmenuServer on DBus + * @dbus_name: Name of the object on the #DbusmenuServer + * + * Creates a new #DbusmenuGtkMenu object and creates a #DbusmenuClient + * that connects across DBus to a #DbusmenuServer. + * + * Return value: A new #DbusmenuGtkMenu sync'd with a server + */ DbusmenuGtkMenu * dbusmenu_gtkmenu_new (gchar * dbus_name, gchar * dbus_object) { @@ -417,14 +417,14 @@ dbusmenu_gtkmenu_new (gchar * dbus_name, gchar * dbus_object) } /** - dbusmenu_gtkmenu_get_client: - @menu: The #DbusmenuGtkMenu to get the client from - - An accessor for the client that this menu is using to - communicate with the server. - - Return value: A valid #DbusmenuGtkClient or NULL on error. -*/ + * dbusmenu_gtkmenu_get_client: + * @menu: The #DbusmenuGtkMenu to get the client from + * + * An accessor for the client that this menu is using to + * communicate with the server. + * + * Return value: (transfer none): A valid #DbusmenuGtkClient or NULL on error. + */ DbusmenuGtkClient * dbusmenu_gtkmenu_get_client (DbusmenuGtkMenu * menu) { diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index fa5eb89..4e92961 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -31,17 +31,17 @@ License version 3 and version 2.1 along with this program. If not, see #include /** - dbusmenu_menuitem_property_set_image: - @menuitem: The #DbusmenuMenuitem to set the property on. - @property: Name of the property to set. - @data: The image to place on the property. - - This function takes the pixbuf that is stored in @data and - turns it into a base64 encoded PNG so that it can be placed - onto a standard #DbusmenuMenuitem property. - - Return value: Whether the function was able to set the property - or not. + * dbusmenu_menuitem_property_set_image: + * @menuitem: The #DbusmenuMenuitem to set the property on. + * @property: Name of the property to set. + * @data: The image to place on the property. + * + * This function takes the pixbuf that is stored in @data and + * turns it into a base64 encoded PNG so that it can be placed + * onto a standard #DbusmenuMenuitem property. + * + * Return value: Whether the function was able to set the property + * or not. */ gboolean dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * property, const GdkPixbuf * data) @@ -77,17 +77,17 @@ dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * } /** - dbusmenu_menuitem_property_get_image: - @menuitem: The #DbusmenuMenuite to look for the property on - @property: The name of the property to look for. - - This function looks on the menu item for a property by the - name of @property. If one exists it tries to turn it into - a #GdkPixbuf. It assumes that the property is a base64 encoded - PNG file like the one created by #dbusmenu_menuite_property_set_image. - - Return value: A pixbuf or #NULL to signal error. -*/ + * dbusmenu_menuitem_property_get_image: + * @menuitem: The #DbusmenuMenuite to look for the property on + * @property: The name of the property to look for. + * + * This function looks on the menu item for a property by the + * name of @property. If one exists it tries to turn it into + * a #GdkPixbuf. It assumes that the property is a base64 encoded + * PNG file like the one created by #dbusmenu_menuite_property_set_image. + * + * Return value: (transfer full): A pixbuf or #NULL to signal error. + */ GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * property) { @@ -131,16 +131,16 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * } /** - dbusmenu_menuitem_property_set_shortcut_string: - @menuitem: The #DbusmenuMenuitem to set the shortcut on - @shortcut: String describing the shortcut - - This function takes a GTK shortcut string as defined in - #gtk_accelerator_parse and turns that into the information - required to send it over DBusmenu. - - Return value: Whether it was successful at setting the property. -*/ + * dbusmenu_menuitem_property_set_shortcut_string: + * @menuitem: The #DbusmenuMenuitem to set the shortcut on + * @shortcut: String describing the shortcut + * + * This function takes a GTK shortcut string as defined in + * #gtk_accelerator_parse and turns that into the information + * required to send it over DBusmenu. + * + * Return value: Whether it was successful at setting the property. + */ gboolean dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut) { @@ -161,16 +161,16 @@ dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, con } /** - dbusmenu_menuitem_property_set_shortcut: - @menuitem: The #DbusmenuMenuitem to set the shortcut on - @key: The keycode of the key to send - @modifier: A bitmask of modifiers used to activate the item - - Takes the modifer described by @key and @modifier and places that into - the format sending across Dbus for shortcuts. - - Return value: Whether it was successful at setting the property. -*/ + * dbusmenu_menuitem_property_set_shortcut: + * @menuitem: The #DbusmenuMenuitem to set the shortcut on + * @key: The keycode of the key to send + * @modifier: A bitmask of modifiers used to activate the item + * + * Takes the modifer described by @key and @modifier and places that into + * the format sending across Dbus for shortcuts. + * + * Return value: Whether it was successful at setting the property. + */ gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier) { @@ -213,16 +213,16 @@ find_closure (GtkAccelKey * key, GClosure * closure, gpointer user_data) } /** - dbusmenu_menuitem_property_set_shortcut_menuitem: - @menuitem: The #DbusmenuMenuitem to set the shortcut on - @gmi: A menu item to steal the shortcut off of - - Takes the shortcut that is installed on a menu item and calls - #dbusmenu_menuitem_property_set_shortcut with it. It also sets - up listeners to watch it change. - - Return value: Whether it was successful at setting the property. -*/ + * dbusmenu_menuitem_property_set_shortcut_menuitem: + * @menuitem: The #DbusmenuMenuitem to set the shortcut on + * @gmi: A menu item to steal the shortcut off of + * + * Takes the shortcut that is installed on a menu item and calls + * #dbusmenu_menuitem_property_set_shortcut with it. It also sets + * up listeners to watch it change. + * + * Return value: Whether it was successful at setting the property. + */ gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi) { @@ -260,14 +260,14 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c } /** - dbusmenu_menuitem_property_get_shortcut: - @menuitem: The #DbusmenuMenuitem to get the shortcut off - @key: Location to put the key value - @modifier: Location to put the modifier mask - - This function gets a GTK shortcut as a key and a mask - for use to set the accelerators. -*/ + * dbusmenu_menuitem_property_get_shortcut: + * @menuitem: The #DbusmenuMenuitem to get the shortcut off + * @key: (out): Location to put the key value + * @modifier: (out): Location to put the modifier mask + * + * This function gets a GTK shortcut as a key and a mask + * for use to set the accelerators. + */ void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifier) { diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h index 4fc42f9..6f009df 100644 --- a/libdbusmenu-gtk/menuitem.h +++ b/libdbusmenu-gtk/menuitem.h @@ -43,7 +43,7 @@ GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, c gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier); gboolean dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut); gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi); -void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifiers); +void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifier); G_END_DECLS diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 70cde53..d00870a 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -81,16 +81,16 @@ static void menuitem_notify_cb (GtkWidget * widget, gpointer data); /** - dbusmenu_gtk_parse_menu_structure: - @widget: A #GtkMenuItem or #GtkMenuShell to turn into a #DbusmenuMenuitem - - Goes through the GTK structures and turns them into the appropraite - Dbusmenu structures along with setting up all the relationships - between the objects. It also stores the dbusmenu items as a cache - on the GTK items so that they'll be reused if necissary. - - Return value: A dbusmenu item representing the menu structure -*/ + * dbusmenu_gtk_parse_menu_structure: + * @widget: A #GtkMenuItem or #GtkMenuShell to turn into a #DbusmenuMenuitem + * + * Goes through the GTK structures and turns them into the appropraite + * Dbusmenu structures along with setting up all the relationships + * between the objects. It also stores the dbusmenu items as a cache + * on the GTK items so that they'll be reused if necissary. + * + * Return value: (transfer none): A dbusmenu item representing the menu structure + */ DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) { diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index cfd864d..f5dbbf1 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -166,18 +166,18 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) } /** - dbusmenu_gtk_serializable_menu_item_build_menuitem: - @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring - - This function is for menu items that are instanciated from - GTK and have their properites set using GTK functions. This - builds a #DbusmenuMenuitem that then has the properties that - should be sent over the bus to create a new item of this - type on the other side. - - Return value: (transfer full) A #DbusmenuMenuitem who's values will be - set by this object. -*/ + * dbusmenu_gtk_serializable_menu_item_build_menuitem: + * @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring + * + * This function is for menu items that are instanciated from + * GTK and have their properites set using GTK functions. This + * builds a #DbusmenuMenuitem that then has the properties that + * should be sent over the bus to create a new item of this + * type on the other side. + * + * Return value: (transfer full): A #DbusmenuMenuitem who's values will be + * set by this object. + */ DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_menuitem (DbusmenuGtkSerializableMenuItem * smi) { @@ -225,15 +225,15 @@ type_destroy_handler (DbusmenuClient * client, const gchar * type, gpointer user } /** - dbusmenu_gtk_serializable_menu_item_register_to_client: - @client: #DbusmenuClient that we should register a type at. - @item_type: The #GType of a class that is a subclass of #DbusmenuGtkSerializableMenuItem - - Registers a generic handler for dealing with all subclasses of - #DbusmenuGtkSerializableMenuItem. This handler responds to the callback, - creates a new object and attaches it to the appropriate #DbusmenuMenuitem - object. -*/ + * dbusmenu_gtk_serializable_menu_item_register_to_client: + * @client: #DbusmenuClient that we should register a type at. + * @item_type: The #GType of a class that is a subclass of #DbusmenuGtkSerializableMenuItem + * + * Registers a generic handler for dealing with all subclasses of + * #DbusmenuGtkSerializableMenuItem. This handler responds to the callback, + * creates a new object and attaches it to the appropriate #DbusmenuMenuitem + * object. + */ void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) { @@ -265,16 +265,16 @@ dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, } /** - dbusmenu_gtk_serializable_menu_item_set_menuitem: - @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of - @mi: Menuitem to get the properties from - - This function is used on the server side to signal to the object - that it should get its' property change events from @mi instead - of expecting calls to its' API. A call to this function sets the - property and subclasses should listen to the notify signal to - pick up this property being set. -*/ + * dbusmenu_gtk_serializable_menu_item_set_menuitem: + * @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of + * @mi: Menuitem to get the properties from + * + * This function is used on the server side to signal to the object + * that it should get its' property change events from @mi instead + * of expecting calls to its' API. A call to this function sets the + * property and subclasses should listen to the notify signal to + * pick up this property being set. + */ void dbusmenu_gtk_serializable_menu_item_set_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) { -- cgit v1.2.3 From 2ee586c80b9cd334cc98559a9754c3492d01e8b3 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 17 Feb 2011 07:48:27 -0500 Subject: make sure other icon property is removed when setting one --- libdbusmenu-gtk/parser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 38528d8..8aa2837 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -586,8 +586,12 @@ update_icon (DbusmenuMenuitem *menuitem, GtkImage *image) dbusmenu_menuitem_property_set (menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, icon_name); + dbusmenu_menuitem_property_remove (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_DATA); } else if (pixbuf != NULL) { + dbusmenu_menuitem_property_remove (menuitem, + DBUSMENU_MENUITEM_PROP_ICON_NAME); dbusmenu_menuitem_property_set_image (menuitem, DBUSMENU_MENUITEM_PROP_ICON_DATA, pixbuf); -- cgit v1.2.3 From 87703b408d42ce97b5a64142b0c33951d366890a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 10:46:34 -0600 Subject: 0.3.98 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index ad343f5..a1af560 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.97, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.98, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.97, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.98, [-Wno-portability]) AM_MAINTAINER_MODE @@ -132,7 +132,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=3 -LIBDBUSMENU_REVISION=5 +LIBDBUSMENU_REVISION=6 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 52e9e4c8125943abc8d7513501aad1698ab4d7f6 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 21 Feb 2011 11:30:50 +0100 Subject: add test-glib-simple-items.py Python GI test This replicates tests/test-glib-simple-items.c using Python and GI. Update the Makefile to use the locally generated GI typelibs for the tests. --- tests/Makefile.am | 8 ++++++-- tests/test-glib-simple-items.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100755 tests/test-glib-simple-items.py diff --git a/tests/Makefile.am b/tests/Makefile.am index 62142dc..9259ed1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,7 +17,8 @@ TESTS = \ test-gtk-shortcut \ test-gtk-reorder \ test-gtk-submenu \ - test-gtk-parser-test + test-gtk-parser-test \ + test-glib-simple-items.py check_PROGRAMS = \ glib-server-nomenu \ @@ -48,6 +49,9 @@ check_PROGRAMS = \ XVFB_RUN=". $(srcdir)/run-xvfb.sh" +# for the GI tests, prefer/use the typelibs from the local build tree +TESTS_ENVIRONMENT = env GI_TYPELIB_PATH=$(top_builddir)/libdbusmenu-glib:$(top_builddir)/libdbusmenu-gtk:$(GI_TYPELIB_PATH) + ###################### # JSON Loader lib ###################### @@ -623,7 +627,7 @@ distclean-local: -rm -rf $(builddir)/mago.results DISTCLEANFILES = \ - $(TESTS) \ + $(filter-out %.py, $(TESTS)) \ $(OBJECT_XML_REPORT) \ $(GTK_OBJECT_XML_REPORT) diff --git a/tests/test-glib-simple-items.py b/tests/test-glib-simple-items.py new file mode 100755 index 0000000..d7ad7d7 --- /dev/null +++ b/tests/test-glib-simple-items.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +# This is the Python GI version of test-glib-simple-items.c + +import gobject +from gi.repository import Dbusmenu + +dummies = ['Bob', 'Jim', 'Alvin', 'Mary'] + +def dummy_users(root): + count = 0 + for user in dummies: + mi = Dbusmenu.Menuitem() + print 'Creating item: %d %s' % (mi.get_id(), user) + print '\tRoot ID:', root.get_id() + mi.property_set('label', user) + root.child_add_position(mi, count) + assert mi.property_get('label') == user + count += 1 + +def quititall(mainloop): + mainloop.quit() + return False + +# main + +server = Dbusmenu.Server.new('/test/object') +root_menuitem = Dbusmenu.Menuitem() +server.set_root(root_menuitem) +print 'Root ID:', root_menuitem.get_id() + +dummy_users(root_menuitem) + +mainloop = gobject.MainLoop() +gobject.timeout_add_seconds(1, quititall, mainloop) +mainloop.run() -- cgit v1.2.3 From 3f3db4e1ea5e5b2321a7266edf018bb510fcdfb4 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 21 Feb 2011 12:43:43 +0100 Subject: fix typo in annotation --- libdbusmenu-gtk/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 9788ffc..c2720ac 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -400,7 +400,7 @@ build_client (DbusmenuGtkMenu * self) /** * dbusmenu_gtkmenu_new: * @dbus_name: Name of the #DbusmenuServer on DBus - * @dbus_name: Name of the object on the #DbusmenuServer + * @dbus_object: Name of the object on the #DbusmenuServer * * Creates a new #DbusmenuGtkMenu object and creates a #DbusmenuClient * that connects across DBus to a #DbusmenuServer. -- cgit v1.2.3 From 83a270fd9db6cda2dbff19335c97361aa4ad6781 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 21 Feb 2011 14:06:43 +0100 Subject: add test-gtk-shortcut-client.py Python GI test This replicates tests/test-gtk-shortcut-client.c using Python and GI. --- tests/Makefile.am | 7 ++++++ tests/test-gtk-shortcut-client.py | 52 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 tests/test-gtk-shortcut-client.py diff --git a/tests/Makefile.am b/tests/Makefile.am index c0081b0..f9102ed 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,6 +16,7 @@ TESTS = \ test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ + test-gtk-shortcut-python \ test-gtk-reorder \ test-gtk-submenu \ test-gtk-parser-test \ @@ -476,6 +477,12 @@ test-gtk-shortcut: test-gtk-shortcut-client test-gtk-shortcut-server Makefile.am @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ @chmod +x $@ +test-gtk-shortcut-python: test-gtk-shortcut-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + test_gtk_shortcut_server_SOURCES = \ test-gtk-shortcut-server.c diff --git a/tests/test-gtk-shortcut-client.py b/tests/test-gtk-shortcut-client.py new file mode 100755 index 0000000..885d227 --- /dev/null +++ b/tests/test-gtk-shortcut-client.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +# A test for libdbusmenu to ensure its quality. This is the Python GI version +# of test-gtk-shortcut-client.c +# +# Copyright 2011 Canonical Ltd. +# Authors: +# Martin Pitt + +import sys +import gobject +from gi.repository import Gtk, DbusmenuGtk +Gtk.require_version('2.0') + +passed = True +main_loop = gobject.MainLoop() + +def timer_func(data): + passed = True + main_loop.quit() + return False + +# main +print 'Building Window' +window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) +menubar = Gtk.MenuBar() +menuitem = Gtk.MenuItem(label='Test') + +dmenu = DbusmenuGtk.Menu(dbus_name='glib.label.test', dbus_object='/org/test') +dclient = dmenu.get_client() +agroup = Gtk.AccelGroup() +dclient.set_accel_group(agroup) + +menuitem.set_submenu(dmenu) +menuitem.show() +menubar.append(menuitem) +menubar.show() +window.add(menubar) +window.set_title('libdbusmenu-gtk test') +window.add_accel_group(agroup) +window.show_all() + +gobject.timeout_add_seconds(10, timer_func, window) + +print 'Entering Mainloop' +main_loop.run() + +if passed: + print 'Quiting' +else: + print "Quiting as we're a failure" + sys.exit(1) -- cgit v1.2.3 From fec6317262d94b29c41fa0632236910b4bd11244 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 09:54:31 -0600 Subject: Fixing transfer from the parser to be full --- 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 180b66e..f516dde 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -93,7 +93,7 @@ static void menuitem_notify_cb (GtkWidget * widget, * between the objects. It also stores the dbusmenu items as a cache * on the GTK items so that they'll be reused if necissary. * - * Return value: (transfer none): A dbusmenu item representing the menu structure + * Return value: (transfer full): A dbusmenu item representing the menu structure */ DbusmenuMenuitem * dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) -- cgit v1.2.3 From f7c526d16a75a6f2dd606cb80093ac2b54f537cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:04:27 -0600 Subject: Fixing the variable name --- libdbusmenu-gtk/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 4128b02..50978ff 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -619,7 +619,7 @@ move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint ol /** * dbusmenu_gtkclient_new: * @dbus_name: Name of the #DbusmenuServer on DBus - * @dbus_name: Name of the object on the #DbusmenuServer + * @dbus_object: Name of the object on the #DbusmenuServer * * Creates a new #DbusmenuGtkClient object and creates a #DbusmenuClient * that connects across DBus to a #DbusmenuServer. -- cgit v1.2.3 From d436a1866030bc9720c49c696753afd65b08bf12 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:04:44 -0600 Subject: Typo in reference --- libdbusmenu-gtk/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 4e92961..508b43f 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -78,7 +78,7 @@ dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * /** * dbusmenu_menuitem_property_get_image: - * @menuitem: The #DbusmenuMenuite to look for the property on + * @menuitem: The #DbusmenuMenuitem to look for the property on * @property: The name of the property to look for. * * This function looks on the menu item for a property by the -- cgit v1.2.3 From 18c5f32b393ada7a3a7507b0a83bbd98f88a1722 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:05:04 -0600 Subject: Removing parsing of unneeded comment block --- libdbusmenu-gtk/serializablemenuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/serializablemenuitem.c b/libdbusmenu-gtk/serializablemenuitem.c index f5dbbf1..29f83a8 100644 --- a/libdbusmenu-gtk/serializablemenuitem.c +++ b/libdbusmenu-gtk/serializablemenuitem.c @@ -33,7 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client.h" #include "serializablemenuitem.h" -/** +/* DbusmenuGtkSerializableMenuItemPrivate: @mi: Menuitem to watch the property changes from */ -- cgit v1.2.3 From f3eb3cbb4623b9e996d2cc62a21b6fcc4a2331c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:18:48 -0600 Subject: Fixing distcheck by including py file and cleaning up it's pyc --- tests/Makefile.am | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index f9102ed..1f8faec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,6 +3,7 @@ DBUS_RUNNER=dbus-test-runner CLEANFILES= DISTCLEANFILES= +EXTRA_DIST = TESTS = \ test-glib-objects-test \ @@ -477,12 +478,6 @@ test-gtk-shortcut: test-gtk-shortcut-client test-gtk-shortcut-server Makefile.am @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ @chmod +x $@ -test-gtk-shortcut-python: test-gtk-shortcut-server Makefile.am - @echo "#!/bin/bash" > $@ - @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ - @chmod +x $@ - test_gtk_shortcut_server_SOURCES = \ test-gtk-shortcut-server.c @@ -513,6 +508,19 @@ test_gtk_shortcut_client_LDADD = \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) +######################### +# Test GTK Shortcut Python +######################### + +test-gtk-shortcut-python: test-gtk-shortcut-server test-gtk-shortcut-client.py Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + +EXTRA_DIST += test-gtk-shortcut-client.py +CLEANFILES += test-gtk-shortcut-client.pyc + ######################### # Test GTK Reorder ######################### @@ -607,7 +615,7 @@ jsondir = $(datadir)/${PACKAGE}/json/ json_DATA = \ test-gtk-label.json -EXTRA_DIST = \ +EXTRA_DIST += \ $(examples_DATA) \ run-xvfb.sh \ $(json_DATA) \ -- cgit v1.2.3 From dcf34291bd1cc3f58652c96bd37de3162497b269 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:22:35 -0600 Subject: Bringing along the simple items test as well --- tests/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f8faec..09bc4c5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -367,6 +367,8 @@ test_glib_simple_items_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +EXTRA_DIST += test-glib-simple-items.py + ###################### # Test GTK Object ###################### -- cgit v1.2.3 From 5b9418cb4be5823df8eb7c01f854eed0a13a2c9f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:50:34 -0600 Subject: Fixing the path of the python in the test --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 09bc4c5..61b3e69 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -517,7 +517,7 @@ test_gtk_shortcut_client_LDADD = \ test-gtk-shortcut-python: test-gtk-shortcut-server test-gtk-shortcut-client.py Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) --task $(srcdir)/test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ @chmod +x $@ EXTRA_DIST += test-gtk-shortcut-client.py -- cgit v1.2.3