6 static gboolean action3_added = FALSE;
9 on_app_action (GApplication *application,
10 const gchar *action_name,
11 guint action_timestamp)
13 if (strcmp (action_name, "action1") == 0)
15 else if (strcmp (action_name, "action2") == 0)
18 g_application_remove_action (application, "action3");
20 g_application_add_action (application, "action3", "An extra action");
21 action3_added = !action3_added;
26 invoke_action1 (gpointer data)
28 GApplication *app = data;
30 g_application_invoke_action (app, "action1", 0);
36 on_app_activated (GApplication *application,
38 GVariant *platform_data)
42 g_print ("got args: ");
43 str = g_variant_print (args, TRUE);
46 str = g_variant_print (platform_data, TRUE);
47 g_print ("%s\n", str);
52 main (int argc, char *argv[])
57 app = g_application_new ("org.gtk.test.app");
58 if (!(argc > 1 && strcmp (argv[1], "--non-unique") == 0))
59 g_application_register_with_data (app, argc, argv, NULL);
61 if (g_application_is_remote (app))
63 g_timeout_add (1000, invoke_action1, app);
64 loop = g_main_loop_new (NULL, FALSE);
65 g_main_loop_run (loop);
69 g_application_add_action (app, "action1", "Action1");
70 g_application_add_action (app, "action2", "Action2");
71 g_signal_connect (app, "action",
72 G_CALLBACK (on_app_action), NULL);
73 g_signal_connect (app, "prepare-activation",
74 G_CALLBACK (on_app_activated), NULL);
75 g_application_run (app);