diff options
author | Ted Gould <ted@gould.cx> | 2010-11-29 12:32:35 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-11-29 12:32:35 -0600 |
commit | 938856dbb01aa4e583ce637a0cd34846f8a940fd (patch) | |
tree | bad45ff6dfacef71ce38a433771e2eeaaaf65d4a | |
parent | 02be403c32b2228b33d3cb122750889f165419d1 (diff) | |
download | libdbusmenu-938856dbb01aa4e583ce637a0cd34846f8a940fd.tar.gz libdbusmenu-938856dbb01aa4e583ce637a0cd34846f8a940fd.tar.bz2 libdbusmenu-938856dbb01aa4e583ce637a0cd34846f8a940fd.zip |
Switching shortcut parsing code to more directly use the variant iterator
-rw-r--r-- | libdbusmenu-gtk/menuitem.c | 45 |
1 files 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; } |