diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-06-10 07:55:45 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-06-10 08:10:08 -0400 |
commit | c7ad8d29e9a1cbf139a516244a87f91d2fd379dc (patch) | |
tree | e8b7f359b62d3746cb91468f95975be635173296 | |
parent | dba8d1ff7772983a76e256999692b2e4cab82b08 (diff) | |
download | gtk+-c7ad8d29e9a1cbf139a516244a87f91d2fd379dc.tar.gz |
Fix the GAction test
We weren't setting the state of the stateful actions.
-rw-r--r-- | tests/testgaction.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/testgaction.c b/tests/testgaction.c index 3a28d0b465..49635bfd1f 100644 --- a/tests/testgaction.c +++ b/tests/testgaction.c @@ -24,8 +24,13 @@ toggle_menu_item (GSimpleAction *action, GVariant *parameter, 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"); + + g_simple_action_set_state (action, g_variant_new_boolean (!g_variant_get_boolean (state))); + + g_variant_unref (state); } static void @@ -39,15 +44,16 @@ submenu_item (GSimpleAction *action, static void radio (GSimpleAction *action, GVariant *parameter, gpointer user_data) { - GVariant *new_state = g_variant_new_string (g_variant_get_string (parameter, NULL)); char *str; 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); 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 }, { "toggle-menu-item", toggle_menu_item, NULL, "true", NULL }, { "submenu-item", submenu_item, NULL, NULL, NULL }, - { "radio", radio, "s", "1", NULL }, + { "radio", radio, "s", "'1'", NULL }, }; |