5 activate (GApplication *application)
7 g_application_hold (application);
8 g_print ("activated\n");
9 g_application_release (application);
13 open (GApplication *application,
20 g_application_hold (application);
23 for (i = 0; i < n_files; i++)
25 gchar *uri = g_file_get_uri (files[i]);
29 g_application_release (application);
35 command_line (GApplication *application,
36 GApplicationCommandLine *cmdline)
41 argv = g_application_command_line_get_arguments (cmdline, &argc);
43 g_application_command_line_print (cmdline, "%d + %d = %d\n", 40, 2, 42);
45 g_assert_cmpint (argc, ==, 3);
46 g_assert_cmpstr (argv[0], ==, "./cmd");
47 g_assert_cmpstr (argv[1], ==, "40 +");
48 g_assert_cmpstr (argv[2], ==, "2");
49 g_assert (argv[3] == NULL);
50 g_print ("cmdline '%s' '%s'\n", argv[1], argv[2]);
57 main (int argc, char **argv)
62 app = g_application_new ("org.gtk.TestApplication",
63 G_APPLICATION_HANDLES_OPEN |
64 (g_strcmp0 (argv[1], "./cmd") == 0 ?
65 G_APPLICATION_HANDLES_COMMAND_LINE
67 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
68 g_signal_connect (app, "open", G_CALLBACK (open), NULL);
69 g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
71 g_application_set_inactivity_timeout (app, 10000);
73 g_application_set_inactivity_timeout (app, 1000);
75 status = g_application_run (app, argc - 1, argv + 1);
79 g_print ("exit status: %d\n", status);