1 #include <gio/gio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 static void
activate(GApplication * application)6 activate (GApplication *application)
7 {
8 g_print ("activated\n");
9
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.
14 */
15 }
16
17 static void
open(GApplication * application,GFile ** files,gint n_files,const gchar * hint)18 open (GApplication *application,
19 GFile **files,
20 gint n_files,
21 const gchar *hint)
22 {
23 gint i;
24
25 for (i = 0; i < n_files; i++)
26 {
27 gchar *uri = g_file_get_uri (files[i]);
28 g_print ("open %s\n", uri);
29 g_free (uri);
30 }
31
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.
36 */
37 }
38
39 int
main(int argc,char ** argv)40 main (int argc, char **argv)
41 {
42 GApplication *app;
43 int status;
44
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);
50
51 status = g_application_run (app, argc, argv);
52
53 g_object_unref (app);
54
55 return status;
56 }
57