From c7ad8d29e9a1cbf139a516244a87f91d2fd379dc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Jun 2021 07:55:45 -0400 Subject: Fix the GAction test We weren't setting the state of the stateful actions. --- tests/testgaction.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests') 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 }, }; -- cgit v1.2.1