From 7887103193de4230a1ccb8dc7100816e523e5b9c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 31 Oct 2010 22:05:20 -0400 Subject: [PATCH] Add an example of invoking actions --- gio/tests/gapplication-example-actions.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gio/tests/gapplication-example-actions.c b/gio/tests/gapplication-example-actions.c index 4bb7fc620..3fc55f789 100644 --- a/gio/tests/gapplication-example-actions.c +++ b/gio/tests/gapplication-example-actions.c @@ -38,6 +38,7 @@ activate_toggle_action (GAction *action, b = g_variant_get_boolean (state); g_variant_unref (state); g_action_set_state (action, g_variant_new_boolean (!b)); + g_print ("state change %d -> %d\n", b, !b); g_application_release (application); } @@ -77,6 +78,19 @@ main (int argc, char **argv) add_actions (app); + if (argc > 1 && strcmp (argv[1], "--simple-action") == 0) + { + g_application_register (app, NULL, NULL); + g_action_group_activate_action (G_ACTION_GROUP (app), "simple-action", NULL); + exit (0); + } + else if (argc > 1 && strcmp (argv[1], "--toggle-action") == 0) + { + g_application_register (app, NULL, NULL); + g_action_group_activate_action (G_ACTION_GROUP (app), "toggle-action", NULL); + exit (0); + } + status = g_application_run (app, argc, argv); g_object_unref (app);