mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 05:20:17 +00:00
Fix the GAction test
We weren't setting the state of the stateful actions.
This commit is contained in:
parent
dba8d1ff77
commit
c7ad8d29e9
@ -24,8 +24,13 @@ toggle_menu_item (GSimpleAction *action,
|
|||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GVariant *state = g_action_get_state (G_ACTION (action));
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (label), "Text set from toggle menu item");
|
gtk_label_set_label (GTK_LABEL (label), "Text set from toggle menu item");
|
||||||
|
|
||||||
|
g_simple_action_set_state (action, g_variant_new_boolean (!g_variant_get_boolean (state)));
|
||||||
|
|
||||||
|
g_variant_unref (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -39,15 +44,16 @@ submenu_item (GSimpleAction *action,
|
|||||||
static void
|
static void
|
||||||
radio (GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
radio (GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
{
|
{
|
||||||
GVariant *new_state = g_variant_new_string (g_variant_get_string (parameter, NULL));
|
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
str = g_strdup_printf ("From Radio menu item %s",
|
str = g_strdup_printf ("From Radio menu item %s",
|
||||||
g_variant_get_string (new_state, NULL));
|
g_variant_get_string (parameter, NULL));
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (label), str);
|
gtk_label_set_label (GTK_LABEL (label), str);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
|
g_simple_action_set_state (action, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +63,7 @@ static const GActionEntry win_actions[] = {
|
|||||||
{ "normal-menu-item", normal_menu_item, NULL, NULL, NULL },
|
{ "normal-menu-item", normal_menu_item, NULL, NULL, NULL },
|
||||||
{ "toggle-menu-item", toggle_menu_item, NULL, "true", NULL },
|
{ "toggle-menu-item", toggle_menu_item, NULL, "true", NULL },
|
||||||
{ "submenu-item", submenu_item, NULL, NULL, NULL },
|
{ "submenu-item", submenu_item, NULL, NULL, NULL },
|
||||||
{ "radio", radio, "s", "1", NULL },
|
{ "radio", radio, "s", "'1'", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user