Add some more cases to the app-id unit tests
[glib.git] / gio / tests / gapplication-example-cmdline.c
blob99380cd784205b189adc745d26269f3788380658
1 #include <gio/gio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 static int
6 command_line (GApplication *application,
7 GApplicationCommandLine *cmdline)
9 gchar **argv;
10 gint argc;
11 gint i;
13 argv = g_application_command_line_get_arguments (cmdline, &argc);
15 g_application_command_line_print (cmdline,
16 "This text is written back\n"
17 "to stdout of the caller\n");
19 for (i = 0; i < argc; i++)
20 g_print ("argument %d: %s\n", i, argv[i]);
22 g_strfreev (argv);
24 return 0;
27 int
28 main (int argc, char **argv)
30 GApplication *app;
31 int status;
33 app = g_application_new ("org.gtk.TestApplication",
34 G_APPLICATION_HANDLES_COMMAND_LINE);
35 g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
36 g_application_set_inactivity_timeout (app, 10000);
38 status = g_application_run (app, argc, argv);
40 g_object_unref (app);
42 return status;