6 command_line (GApplication *application,
7 GApplicationCommandLine *cmdline)
13 argv = g_application_command_line_get_arguments (cmdline, &argc);
15 for (i = 0; i < argc; i++)
16 g_print ("handling argument %s remotely\n", argv[i]);
24 test_local_cmdline (GApplication *application,
33 for (i = 0; argv[i]; i++)
35 if (g_str_has_prefix (argv[i], "--local-"))
37 g_print ("handling argument %s locally\n", argv[i]);
38 for (j = i + 1; argv[j]; j++)
40 argv[j - 1] = argv[j];
51 typedef GApplication TestApplication;
52 typedef GApplicationClass TestApplicationClass;
54 G_DEFINE_TYPE (TestApplication, test_application, G_TYPE_APPLICATION)
57 test_application_finalize (GObject *object)
59 G_OBJECT_CLASS (test_application_parent_class)->finalize (object);
63 test_application_init (TestApplication *app)
68 test_application_class_init (TestApplicationClass *class)
70 G_APPLICATION_CLASS (class)->local_command_line = test_local_cmdline;
74 test_application_new (const gchar *application_id,
75 GApplicationFlags flags)
77 g_return_val_if_fail (g_application_id_is_valid (application_id), NULL);
81 return g_object_new (test_application_get_type (),
82 "application-id", application_id,
88 main (int argc, char **argv)
93 app = test_application_new ("org.gtk.TestApplication", 0);
94 g_application_set_inactivity_timeout (app, 10000);
95 g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
97 status = g_application_run (app, argc, argv);