Add some more cases to the app-id unit tests
[glib.git] / gio / tests / gapplication-example-open.c
blob6dcf53c22cb836a1d5d0cbbfa2a740089f8a364c
1 #include <gio/gio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 static void
6 activate (GApplication *application)
8 g_print ("activated\n");
10 /* Note: when doing a longer-lasting action here that returns
11 * to the mainloop, you should use g_application_hold() and
12 * g_application_release() to keep the application alive until
13 * the action is completed.
17 static void
18 open (GApplication *application,
19 GFile **files,
20 gint n_files,
21 const gchar *hint)
23 gint i;
25 for (i = 0; i < n_files; i++)
27 gchar *uri = g_file_get_uri (files[i]);
28 g_print ("open %s\n", uri);
29 g_free (uri);
32 /* Note: when doing a longer-lasting action here that returns
33 * to the mainloop, you should use g_application_hold() and
34 * g_application_release() to keep the application alive until
35 * the action is completed.
39 int
40 main (int argc, char **argv)
42 GApplication *app;
43 int status;
45 app = g_application_new ("org.gtk.TestApplication",
46 G_APPLICATION_HANDLES_OPEN);
47 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
48 g_signal_connect (app, "open", G_CALLBACK (open), NULL);
49 g_application_set_inactivity_timeout (app, 10000);
51 status = g_application_run (app, argc, argv);
53 g_object_unref (app);
55 return status;