diff options
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | libdbusmenu-gtk/menuitem.c | 27 |
2 files changed, 32 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index 968394b..f184645 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libdbusmenu (0.3.2-1ubuntu1~ppa5~qtish3) UNRELEASED; urgency=low + + * Upstream merge + * Checking for collections + + -- Ted Gould <ted@ubuntu.com> Wed, 23 Jun 2010 09:19:02 -0500 + libdbusmenu (0.3.2-1ubuntu1~ppa5~qtish2) lucid; urgency=low * Upstream merge diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 44e78e1..9154592 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 <gdk/gdk.h> #include <gtk/gtk.h> +#include <dbus/dbus-gtype-specialized.h> /** 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,12 +312,13 @@ 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, G_TYPE_BOXED)) { + if (!G_VALUE_HOLDS(wrapper, wrapper_type)) { g_warning("Unexpected shortcut structure. Wrapper is: %s", G_VALUE_TYPE_NAME(wrapper)); return; } @@ -310,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; } |