mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-14 09:53:12 +02:00
Add an example of invoking actions
This commit is contained in:
parent
d967b5ed17
commit
7887103193
@ -38,6 +38,7 @@ activate_toggle_action (GAction *action,
|
|||||||
b = g_variant_get_boolean (state);
|
b = g_variant_get_boolean (state);
|
||||||
g_variant_unref (state);
|
g_variant_unref (state);
|
||||||
g_action_set_state (action, g_variant_new_boolean (!b));
|
g_action_set_state (action, g_variant_new_boolean (!b));
|
||||||
|
g_print ("state change %d -> %d\n", b, !b);
|
||||||
|
|
||||||
g_application_release (application);
|
g_application_release (application);
|
||||||
}
|
}
|
||||||
@ -77,6 +78,19 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
add_actions (app);
|
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);
|
status = g_application_run (app, argc, argv);
|
||||||
|
|
||||||
g_object_unref (app);
|
g_object_unref (app);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user