Branch data Line data Source code
1 : : #include <gio/gio.h> 2 : : #include <stdlib.h> 3 : : #include <string.h> 4 : : 5 : : static void 6 : 0 : activate (GApplication *application) 7 : : { 8 : 0 : 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 : 0 : } 16 : : 17 : : static void 18 : 0 : app_open (GApplication *application, 19 : : GFile **files, 20 : : gint n_files, 21 : : const gchar *hint) 22 : : { 23 : : gint i; 24 : : 25 [ # # ]: 0 : for (i = 0; i < n_files; i++) 26 : : { 27 : 0 : gchar *uri = g_file_get_uri (files[i]); 28 : 0 : g_print ("open %s\n", uri); 29 : 0 : 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 : 0 : } 38 : : 39 : : int 40 : 0 : main (int argc, char **argv) 41 : : { 42 : : GApplication *app; 43 : : int status; 44 : : 45 : 0 : app = g_application_new ("org.gtk.TestApplication", 46 : : G_APPLICATION_HANDLES_OPEN); 47 : 0 : g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); 48 : 0 : g_signal_connect (app, "open", G_CALLBACK (app_open), NULL); 49 : 0 : g_application_set_inactivity_timeout (app, 10000); 50 : : 51 : 0 : status = g_application_run (app, argc, argv); 52 : : 53 : 0 : g_object_unref (app); 54 : : 55 : 0 : return status; 56 : : }