[gtk/actionable-fixes: 2/6] Fix the GAction test




commit c7ad8d29e9a1cbf139a516244a87f91d2fd379dc
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 10 07:55:45 2021 -0400

    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(-)
---
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 },
 };
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]