aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-02-04 10:56:49 -0800
committerTed Gould <ted@gould.cx>2010-02-04 10:56:49 -0800
commit82d0a5a336c8d3f5de5b8831ae31571fdeeb8160 (patch)
treeebaae34c15129083b31f1f96511ac1243d910057
parenta5c79e6483cda97ac21ca1a609b19bf37bfe17f3 (diff)
downloadlibdbusmenu-82d0a5a336c8d3f5de5b8831ae31571fdeeb8160.tar.gz
libdbusmenu-82d0a5a336c8d3f5de5b8831ae31571fdeeb8160.tar.bz2
libdbusmenu-82d0a5a336c8d3f5de5b8831ae31571fdeeb8160.zip
Switching to transforming values
-rw-r--r--libdbusmenu-gtk/client.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c
index 0109a83..781326e 100644
--- a/libdbusmenu-gtk/client.c
+++ b/libdbusmenu-gtk/client.c
@@ -154,14 +154,19 @@ process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * va
GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE;
- if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) {
- const gchar * strval = g_value_get_string(value);
+ 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 (!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);
@@ -174,20 +179,20 @@ static void
process_toggle_state (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value)
{
if (!IS_GENERICMENUITEM(gmi)) return;
- if (value == NULL) return;
GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED;
- if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_INT) {
- int val = g_value_get_int(value);
+ 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 (val == DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED) {
state = GENERICMENUITEM_STATE_CHECKED;
} else if (val == DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN) {
state = GENERICMENUITEM_STATE_INDETERMINATE;
}
- } else {
- g_warning("Toggle state changed without having an int");
}
genericmenuitem_set_state(GENERICMENUITEM(gmi), state);