6 activate (GApplication *application)
8 g_application_hold (application);
9 g_print ("activated\n");
10 g_application_release (application);
14 activate_action (GAction *action,
18 GApplication *application = data;
20 g_application_hold (application);
21 g_print ("action %s activated\n", g_action_get_name (action));
22 g_application_release (application);
26 activate_toggle_action (GAction *action,
30 GApplication *application = data;
34 g_application_hold (application);
35 g_print ("action %s activated\n", g_action_get_name (action));
37 state = g_action_get_state (action);
38 b = g_variant_get_boolean (state);
39 g_variant_unref (state);
40 g_action_set_state (action, g_variant_new_boolean (!b));
42 g_application_release (application);
46 add_actions (GApplication *app)
48 GSimpleActionGroup *actions;
49 GSimpleAction *action;
51 actions = g_simple_action_group_new ();
53 action = g_simple_action_new ("simple-action", NULL);
54 g_signal_connect (action, "activate", G_CALLBACK (activate_action), app);
55 g_simple_action_group_insert (actions, G_ACTION (action));
56 g_object_unref (action);
58 action = g_simple_action_new_stateful ("toggle-action", NULL,
59 g_variant_new_boolean (FALSE));
60 g_signal_connect (action, "activate", G_CALLBACK (activate_toggle_action), app);
61 g_simple_action_group_insert (actions, G_ACTION (action));
62 g_object_unref (action);
64 g_application_set_action_group (app, G_ACTION_GROUP (actions));
65 g_object_unref (actions);
69 main (int argc, char **argv)
74 app = g_application_new ("org.gtk.TestApplication", 0);
75 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
76 g_application_set_inactivity_timeout (app, 10000);
80 status = g_application_run (app, argc, argv);