static int trg_gtk_app_command_line(GApplication * application, GApplicationCommandLine * cmdline) { GList *windows = gtk_application_get_windows(GTK_APPLICATION(application)); TrgMainWindow *window; gchar **argv; if (!windows || !windows->data) return 1; window = TRG_MAIN_WINDOW(windows->data); argv = g_application_command_line_get_arguments(cmdline, NULL); if (g_application_command_line_get_is_remote(cmdline)) { if (!argv[0]) { gtk_window_present(GTK_WINDOW(window)); g_strfreev(argv); } else { return trg_add_from_filename(window, argv); } } else { trg_main_window_set_start_args(window, argv); auto_connect_if_required(TRG_MAIN_WINDOW(windows->data)); } return 0; }
static void gbp_greeter_application_addin_handle_command_line (IdeApplicationAddin *addin, IdeApplication *application, GApplicationCommandLine *cmdline) { GbpGreeterApplicationAddin *self = (GbpGreeterApplicationAddin *)addin; g_auto(GStrv) argv = NULL; GVariantDict *dict; const gchar *clone_uri = NULL; gint argc; g_assert (GBP_IS_GREETER_APPLICATION_ADDIN (self)); g_assert (IDE_IS_APPLICATION (application)); g_assert (G_IS_APPLICATION_COMMAND_LINE (cmdline)); dict = g_application_command_line_get_options_dict (cmdline); argv = ide_application_get_argv (IDE_APPLICATION (application), cmdline); argc = g_strv_length (argv); /* * If we are processing the arguments for the startup of the primary * instance, then we want to show the greeter if no arguments are * provided. (That means argc == 1, the programe executable). * * Also, if they provided --greeter or -g we'll show a new greeter. */ if ((!g_application_command_line_get_is_remote (cmdline) && argc == 1) || g_variant_dict_contains (dict, "greeter")) { present_greeter_with_surface (NULL, NULL, addin); return; } /* * If the --clone=URI option was provided, switch the greeter to the * clone surface and begin cloning. */ if (dict != NULL && g_variant_dict_lookup (dict, "clone", "&s", &clone_uri)) { IdeGreeterWorkspace *workspace; IdeWorkbench *workbench; IdeSurface *surface; workbench = ide_workbench_new (); ide_application_add_workbench (self->application, workbench); workspace = ide_greeter_workspace_new (self->application); ide_workbench_add_workspace (workbench, IDE_WORKSPACE (workspace)); surface = ide_workspace_get_surface_by_name (IDE_WORKSPACE (workspace), "clone"); ide_workspace_set_visible_surface (IDE_WORKSPACE (workspace), surface); if (IDE_IS_CLONE_SURFACE (surface)) ide_clone_surface_set_uri (IDE_CLONE_SURFACE (surface), clone_uri); ide_workbench_focus_workspace (workbench, IDE_WORKSPACE (workspace)); } }