aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-06-23 14:32:47 -0500
committerTed Gould <ted@gould.cx>2010-06-23 14:32:47 -0500
commit9c28ec10b2481d4374dd83310d9a894dca01d5c1 (patch)
tree21ac0fa70ff9018da73e7582f4b65aeb3e653e72
parent5bed312e9e03a4fd0f3ef189205bd3eb3f1a43bf (diff)
downloadlibdbusmenu-9c28ec10b2481d4374dd83310d9a894dca01d5c1.tar.gz
libdbusmenu-9c28ec10b2481d4374dd83310d9a894dca01d5c1.tar.bz2
libdbusmenu-9c28ec10b2481d4374dd83310d9a894dca01d5c1.zip
Start building structures more like the KDE ones.
-rw-r--r--libdbusmenu-gtk/menuitem.c39
1 files 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);