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; }
// command-line signal // Beware - this is called many times when starting up. It is a bit strange, // but this function can be called from different processes during startup. static void commandLine(GApplication *gapp, GApplicationCommandLine *cmdline, gpointer user_data) { int argc; gchar **argv = g_application_command_line_get_arguments(cmdline, &argc); bool goodArgs = true; for(gint i = 0; i < argc && goodArgs; i++) { char const * fn = nullptr; int line = 1; for(int argi=1; argi<argc; argi++) { if(argv[argi][0] == '+') { if(argv[argi][1] == 'p') { OovString fname = FilePathFixFilePath(&argv[argi][2]); gEditor->setProjectDir(fname); } else sscanf(&argv[argi][1], "%d", &line); } else if(argv[argi][0] == '-') { if(argv[argi][1] == 'p') { OovString fname = FilePathFixFilePath(&argv[argi][2]); gEditor->setProjectDir(fname); } else goodArgs = false; } else fn = argv[argi]; } if(fn) { activateApp(gapp); gEditor->getEditFiles().viewModule(FilePathFixFilePath(fn), line); } } if(goodArgs) { activateApp(gapp); } else { std::string str = "OovEdit version "; str += OOV_VERSION; str += "\n"; str += "oovEdit: Args are: filename [args]...\n"; str += "args are:\n"; str += " +<line> line number of opened file\n"; str += " -p<projectDir> directory of project files\n"; fprintf(stderr, "%s\n", str.c_str()); fflush(stderr); Gui::messageBox(str); } }
static void command_line(GApplication *app, GApplicationCommandLine *command_line, gpointer user_data) { gchar **argc; gint argv; argc = g_application_command_line_get_arguments(command_line, &argv); new_window(GTK_APPLICATION(app), argc, argv); }
static gint command_line (GApplication *application, GApplicationCommandLine *command_line) { int argc; char **argv; argv = g_application_command_line_get_arguments (command_line, &argc); if (argc == 2) load_file (argv[1]); return 0; }
static int gw_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { //Declarations LwDictionary *dictionary; GwSearchWindow *window; GwDictionaryList *dictionarylist; GwApplicationPrivate *priv; gint argc; gchar **argv; gint position; //Initializations priv = GW_APPLICATION (application)->priv; dictionarylist = gw_application_get_installed_dictionarylist (GW_APPLICATION (application)); argv = NULL; if (command_line != NULL) { argv = g_application_command_line_get_arguments (command_line, &argc); gw_application_parse_args (GW_APPLICATION (application), &argc, &argv); } g_application_activate (G_APPLICATION (application)); window = gw_application_get_last_focused_searchwindow (GW_APPLICATION (application)); if (window == NULL) return 0; dictionary = lw_dictionarylist_get_dictionary_fuzzy (LW_DICTIONARYLIST (dictionarylist), priv->arg_dictionary); //Set the initial dictionary if (dictionary != NULL) { position = lw_dictionarylist_get_position (LW_DICTIONARYLIST (dictionarylist), dictionary); gw_searchwindow_set_dictionary (window, position); } //Set the initial query text if it was passed as an argument to the program if (priv->arg_query != NULL) { gw_searchwindow_entry_set_text (window, priv->arg_query); gw_searchwindow_search_cb (GTK_WIDGET (window), window); } //Cleanup if (argv != NULL) g_strfreev (argv); argv = NULL; return 0; }
static int pragha_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { PraghaApplication *pragha = PRAGHA_APPLICATION (application); int ret = 0; gint argc; gchar **argv = g_application_command_line_get_arguments (command_line, &argc); if (argc <= 1) { pragha_application_activate (application); goto exit; } ret = handle_command_line (pragha, command_line, argc, argv); exit: g_strfreev (argv); return ret; }
static int gs_editor_commandline_cb (GApplication *application, GApplicationCommandLine *cmdline, GsEditor *self) { GtkWindow *window; gint argc; gboolean verbose = FALSE; g_auto(GStrv) argv = NULL; g_autoptr(GOptionContext) context = NULL; const GOptionEntry options[] = { { "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose, /* TRANSLATORS: show the program version */ _("Use verbose logging"), NULL }, { NULL} }; /* get arguments */ argv = g_application_command_line_get_arguments (cmdline, &argc); context = g_option_context_new (NULL); /* TRANSLATORS: program name, an application to add and remove software repositories */ g_option_context_set_summary(context, _("GNOME Software Banner Designer")); g_option_context_add_main_entries (context, options, NULL); if (!g_option_context_parse (context, &argc, &argv, NULL)) return FALSE; /* simple logging... */ if (verbose) g_setenv ("G_MESSAGES_DEBUG", "Gs", TRUE); /* make sure the window is raised */ window = GTK_WINDOW (gtk_builder_get_object (self->builder, "window_main")); gtk_window_present (window); return TRUE; }
int fcitx_config_app_handle_command_line (GApplication *application, GApplicationCommandLine *command_line, gpointer user_data ) { int argc; gchar** argv = g_application_command_line_get_arguments(command_line, &argc); g_application_activate(G_APPLICATION (application)); GList* list = gtk_application_get_windows (GTK_APPLICATION(application)); if (list) { FcitxMainWindow* mainWindow = FCITX_MAIN_WINDOW (list->data); FcitxAddon* addon = NULL; if (argc >= 2 && argv[1]) addon = find_addon_by_name(mainWindow->addons, argv[1]); if (addon) { GtkWidget* dialog = fcitx_config_dialog_new(addon, GTK_WINDOW(mainWindow)); if (dialog) gtk_widget_show_all(GTK_WIDGET(dialog)); } } g_strfreev(argv); return 0; }
/* Handle command-line on primary instance */ static int _xfdashboard_application_command_line(GApplication *inApplication, GApplicationCommandLine *inCommandLine) { XfdashboardApplication *self; XfdashboardApplicationPrivate *priv; XfdashboardStage *stage; GOptionContext *context; gboolean result; gint argc; gchar **argv; GError *error; gboolean optionDaemonize; gboolean optionQuit; gboolean optionRestart; gboolean optionToggle; gchar *optionSwitchToView; GOptionEntry XfdashboardApplicationOptions[]= { { "daemonize", 'd', 0, G_OPTION_ARG_NONE, &optionDaemonize, N_("Fork to background"), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &optionQuit, N_("Quit running instance"), NULL }, { "restart", 'r', 0, G_OPTION_ARG_NONE, &optionRestart, N_("Restart running instance"), NULL }, { "toggle", 't', 0, G_OPTION_ARG_NONE, &optionToggle, N_("Toggles suspend/resume state if running instance was started in daemon mode otherwise it quits running non-daemon instance"), NULL }, { "view", 0, 0, G_OPTION_ARG_STRING, &optionSwitchToView, N_(""), NULL }, { NULL } }; g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication), 1); self=XFDASHBOARD_APPLICATION(inApplication); priv=self->priv; error=NULL; stage=NULL; /* Set up options */ optionDaemonize=FALSE; optionQuit=FALSE; optionRestart=FALSE; optionToggle=FALSE; optionSwitchToView=NULL; /* Parse command-line arguments */ argv=g_application_command_line_get_arguments(inCommandLine, &argc); /* Setup command-line options */ context=g_option_context_new(N_("- A Gnome Shell like dashboard for Xfce4")); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_add_group(context, clutter_get_option_group_without_init()); g_option_context_add_group(context, xfce_sm_client_get_option_group(argc, argv)); g_option_context_add_main_entries(context, XfdashboardApplicationOptions, GETTEXT_PACKAGE); #ifdef DEBUG /* I always forget the name of the environment variable to get the debug * message display which are emitted with g_debug(). So display a hint * if application was compiled with debug enabled. */ g_print("** To get debug messages set environment variable G_MESSAGES_DEBUG to %s\n", PACKAGE_NAME); g_print("** e.g.: G_MESSAGES_DEBUG=%s %s\n", PACKAGE_NAME, argv[0]); #endif result=g_option_context_parse(context, &argc, &argv, &error); g_strfreev(argv); g_option_context_free(context); if(result==FALSE) { /* Show error */ g_print(N_("%s\n"), (error && error->message) ? error->message : _("unknown error")); if(error) g_error_free(error); /* Release allocated resources */ if(optionSwitchToView) g_free(optionSwitchToView); return(XFDASHBOARD_APPLICATION_ERROR_FAILED); } /* Handle options: restart * - Only handle option if application was inited already */ if(priv->inited && optionRestart) { /* Return state to restart this applicationa */ g_debug("Received request to restart application!"); /* Release allocated resources */ if(optionSwitchToView) g_free(optionSwitchToView); return(XFDASHBOARD_APPLICATION_ERROR_RESTART); } /* Handle options: quit */ if(optionQuit) { /* Quit existing instance */ g_debug("Quitting running instance!"); _xfdashboard_application_quit(self, TRUE); /* Release allocated resources */ if(optionSwitchToView) g_free(optionSwitchToView); return(XFDASHBOARD_APPLICATION_ERROR_QUIT); } /* Handle options: toggle * - If application was not inited yet, perform normal start-up as usual * with command-line options given * - If running in daemon mode, resume if suspended otherwise suspend * - If not running in daemon mode, quit application */ if(priv->inited && optionToggle) { /* If application is running in daemon mode, toggle between suspend/resume ... */ if(priv->isDaemon) { if(priv->isSuspended) { /* Switch to view if requested */ _xfdashboard_application_switch_to_view(self, optionSwitchToView); /* Show application again */ _xfdashboard_application_activate(inApplication); } else { /* Hide application */ _xfdashboard_application_quit(self, FALSE); } } /* ... otherwise if not running in daemon mode, just quit */ else { /* Hide application */ _xfdashboard_application_quit(self, FALSE); } /* Release allocated resources */ if(optionSwitchToView) g_free(optionSwitchToView); /* Stop here because option was handled and application does not get initialized */ return(XFDASHBOARD_APPLICATION_ERROR_NONE); } /* Handle options: daemonize */ if(!priv->inited) { priv->isDaemon=optionDaemonize; g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_DAEMONIZED]); if(priv->isDaemon) { priv->isSuspended=TRUE; g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_SUSPENDED]); } } /* Check if this instance needs to be initialized fully */ if(!priv->inited) { /* Perform full initialization of this application instance */ result=_xfdashboard_application_initialize_full(self, &stage); if(result==FALSE) return(XFDASHBOARD_APPLICATION_ERROR_FAILED); /* Switch to view if requested */ _xfdashboard_application_switch_to_view(self, optionSwitchToView); /* Show application if not started daemonized */ if(!priv->isDaemon) clutter_actor_show(CLUTTER_ACTOR(stage)); } /* Check if this instance need to be activated. Is should only be done * if instance is initialized */ if(priv->inited) { /* Switch to view if requested */ _xfdashboard_application_switch_to_view(self, optionSwitchToView); /* Show application */ _xfdashboard_application_activate(inApplication); } /* Release allocated resources */ if(optionSwitchToView) g_free(optionSwitchToView); /* All done successfully so return status code 0 for success */ priv->inited=TRUE; return(XFDASHBOARD_APPLICATION_ERROR_NONE); }
static int goo_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { char **argv; int argc; GOptionContext *options_context; GError *error = NULL; GtkWidget *window; argv = g_application_command_line_get_arguments (command_line, &argc); options_context = goo_application_create_option_context (); if (! g_option_context_parse (options_context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (options_context); return goo_application_command_line_finished (application, EXIT_FAILURE); } g_option_context_free (options_context); /* check the gstreamer plugins */ if (! required_gstreamer_plugins_available ()) { GtkWidget *d; d = _gtk_message_dialog_new (NULL, 0, _GTK_ICON_NAME_DIALOG_ERROR, _("Cannot start the CD player"), _("In order to read CDs you have to install the gstreamer base plugins"), _GTK_LABEL_OK, GTK_RESPONSE_OK, NULL); g_signal_connect_swapped (G_OBJECT (d), "response", G_CALLBACK (gtk_widget_destroy), d); gtk_window_set_application (GTK_WINDOW (d), GTK_APPLICATION (application)); gtk_widget_show (d); return goo_application_command_line_finished (application, EXIT_FAILURE); } /* execute the command line */ window = _gtk_application_get_current_window (GTK_APPLICATION (application)); if (window == NULL) window = goo_window_new (NULL); gtk_window_present (GTK_WINDOW (window)); if (arg_auto_play) { goo_window_play (GOO_WINDOW (window)); } else if (arg_toggle_play) { goo_window_toggle_play (GOO_WINDOW (window)); } else if (arg_stop) { goo_window_stop (GOO_WINDOW (window)); } else if (arg_next) { goo_window_next (GOO_WINDOW (window)); } else if (arg_prev) { goo_window_prev (GOO_WINDOW (window)); } else if (arg_eject) { goo_window_eject (GOO_WINDOW (window)); } else if (arg_toggle_visibility) { goo_window_toggle_visibility (GOO_WINDOW (window)); } else if (arg_quit) { goo_window_close (GOO_WINDOW (window)); } else if (arg_device != NULL) { BraseroDrive *drive; drive = main_get_drive_for_device (arg_device); window = main_get_window_from_device (arg_device); if (window == NULL) { window = goo_window_new (drive); gtk_widget_show (window); } else goo_window_set_drive (GOO_WINDOW (window), drive); g_object_unref (drive); g_free (arg_device); arg_device = NULL; } return goo_application_command_line_finished (application, EXIT_SUCCESS); }
static int gth_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { char **argv; int argc; GOptionContext *context; GError *error = NULL; const char *arg; int i; GList *files; GList *dirs; GFile *location; gboolean singleton; GList *scan; argv = g_application_command_line_get_arguments (command_line, &argc); /* parse command line options */ context = gth_application_create_option_context (); if (! g_option_context_parse (context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); return EXIT_FAILURE; } g_option_context_free (context); g_strfreev (argv); gdk_notify_startup_complete (); /* exec the command line */ if (ImportPhotos) { GFile *location = NULL; if (remaining_args != NULL) location = g_file_new_for_commandline_arg (remaining_args[0]); import_photos_from_location (location); return 0; } if (remaining_args == NULL) { /* No location specified. */ GFile *location; GSettings *settings; char *file_to_select_uri; GFile *file_to_select; location = g_file_new_for_uri (gth_pref_get_startup_location ()); settings = g_settings_new (GTHUMB_BROWSER_SCHEMA); file_to_select_uri = _g_settings_get_uri (settings, PREF_BROWSER_STARTUP_CURRENT_FILE); if (file_to_select_uri != NULL) file_to_select = g_file_new_for_uri (file_to_select_uri); else file_to_select = NULL; open_browser_window (location, file_to_select, TRUE); _g_object_unref (file_to_select); g_free (file_to_select_uri); g_object_unref (settings); g_object_unref (location); return 0; } /* At least a location was specified */ files = NULL; dirs = NULL; for (i = 0; (arg = remaining_args[i]) != NULL; i++) { GFile *location; GFileType file_type; location = g_file_new_for_commandline_arg (arg); file_type = _g_file_get_standard_type (location); if (file_type == G_FILE_TYPE_REGULAR) files = g_list_prepend (files, location); else dirs = g_list_prepend (dirs, location); } files = g_list_reverse (files); dirs = g_list_reverse (dirs); location = gth_hook_invoke_get ("command-line-files", files); if (location != NULL) { open_browser_window (location, NULL, FALSE); g_object_unref (location); } else { /* Open each file in a new window */ singleton = (files != NULL) && (files->next == NULL); for (scan = files; scan; scan = scan->next) open_browser_window ((GFile *) scan->data, NULL, ! singleton); } /* Open each dir in a new window */ for (scan = dirs; scan; scan = scan->next) open_browser_window ((GFile *) scan->data, NULL, TRUE); _g_object_list_unref (dirs); _g_object_list_unref (files); return 0; }
static int cc_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { CcApplication *self = CC_APPLICATION (application); int argc; char **argv; int retval = 0; GOptionContext *context; GError *error = NULL; GVariantBuilder *flags_builder; verbose = FALSE; show_overview = FALSE; show_help = FALSE; start_panels = NULL; flags_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT); argv = g_application_command_line_get_arguments (command_line, &argc); context = g_option_context_new (N_("- Settings")); g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); cc_panel_loader_add_option_groups (context, flags_builder); g_option_context_set_help_enabled (context, FALSE); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); g_option_context_free (context); return 1; } if (show_help || show_help_all || show_help_gtk) { gchar *help; GOptionGroup *group; if (show_help || show_help_all) group = NULL; else group = gtk_get_option_group (FALSE); help = g_option_context_get_help (context, FALSE, group); g_print ("%s", help); g_free (help); g_option_context_free (context); return 0; } if (list_panels) { GList *panels, *l; panels = cc_panel_loader_get_panels (); g_print ("%s\n", _("Available panels:")); for (l = panels; l != NULL; l = l->next) g_print ("\t%s\n", (char *) l->data); g_list_free (panels); return 0; } #ifdef HAVE_CHEESE cheese_gtk_init (&argc, &argv); #endif /* HAVE_CHEESE */ cc_shell_log_set_debug (verbose); cc_window_show (self->priv->window); if (search_str) { cc_window_set_search_item (self->priv->window, search_str); } else if (show_overview) { cc_window_set_overview_page (self->priv->window); } else if (start_panels != NULL && start_panels[0] != NULL) { const char *start_id; GError *err = NULL; GVariant *parameters; GVariantBuilder *builder; int i; start_id = start_panels[0]; if (start_panels[1]) g_debug ("Extra argument: %s", start_panels[1]); else g_debug ("No extra argument"); builder = g_variant_builder_new (G_VARIANT_TYPE ("av")); g_variant_builder_add (builder, "v", g_variant_builder_end (flags_builder)); for (i = 1; start_panels[i] != NULL; i++) g_variant_builder_add (builder, "v", g_variant_new_string (start_panels[i])); parameters = g_variant_builder_end (builder); if (!cc_shell_set_active_panel_from_id (CC_SHELL (self->priv->window), start_id, parameters, &err)) { g_warning ("Could not load setting panel \"%s\": %s", start_id, (err) ? err->message : "Unknown error"); retval = 1; if (err) { g_error_free (err); err = NULL; } } } if (start_panels != NULL) { g_strfreev (start_panels); start_panels = NULL; } show_overview = FALSE; g_option_context_free (context); g_strfreev (argv); return retval; }
static int application_command_line_cb (GApplication *application, GApplicationCommandLine *command_line, GnomeControlCenter *shell) { int argc; char **argv; int retval = 0; GOptionContext *context; GError *error = NULL; verbose = FALSE; show_overview = FALSE; show_help = FALSE; start_panels = NULL; argv = g_application_command_line_get_arguments (command_line, &argc); context = g_option_context_new (N_("- System Settings")); g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_set_help_enabled (context, FALSE); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); g_option_context_free (context); return 1; } if (show_help || show_help_all || show_help_gtk) { gchar *help; GOptionGroup *group; if (show_help || show_help_all) group = NULL; else group = gtk_get_option_group (FALSE); help = g_option_context_get_help (context, FALSE, group); g_print ("%s", help); g_free (help); g_option_context_free (context); return 0; } g_option_context_free (context); cc_shell_log_set_debug (verbose); gnome_control_center_show (shell, GTK_APPLICATION (application)); if (show_overview) { gnome_control_center_set_overview_page (shell); } else if (start_panels != NULL && start_panels[0] != NULL) { const char *start_id; GError *err = NULL; start_id = start_panels[0]; if (start_panels[1]) g_debug ("Extra argument: %s", start_panels[1]); else g_debug ("No extra argument"); if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, (const gchar**)start_panels+1, &err)) { g_warning ("Could not load setting panel \"%s\": %s", start_id, (err) ? err->message : "Unknown error"); retval = 1; if (err) { g_error_free (err); err = NULL; } } } gnome_control_center_present (shell); gdk_notify_startup_complete (); g_strfreev (argv); if (start_panels != NULL) { g_strfreev (start_panels); start_panels = NULL; } show_overview = FALSE; return retval; }
static int fr_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { char **argv; int argc; GOptionContext *context; GError *error = NULL; GFile *extraction_destination = NULL; GFile *add_to_archive = NULL; GFile *default_directory = NULL; argv = g_application_command_line_get_arguments (command_line, &argc); /* parse command line options */ context = fr_application_create_option_context (); if (! g_option_context_parse (context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); return fr_application_command_line_finished (application, EXIT_FAILURE); } g_option_context_free (context); /* restore the session */ #ifdef USE_SMCLIENT { EggSMClient *client; client = egg_sm_client_get (); g_signal_connect (client, "save_state", G_CALLBACK (client_save_state), NULL); g_signal_connect (client, "quit", G_CALLBACK (client_quit_cb), NULL); if (egg_sm_client_is_resumed (client)) { fr_restore_session (client); return fr_application_command_line_finished (application, EXIT_SUCCESS); } } #endif if (remaining_args == NULL) { /* No archive specified. */ if (! arg_service) gtk_widget_show (fr_window_new ()); return fr_application_command_line_finished (application, EXIT_SUCCESS); } if (arg_extract_to != NULL) extraction_destination = g_file_new_for_commandline_arg (arg_extract_to); if (arg_add_to != NULL) add_to_archive = g_file_new_for_commandline_arg (arg_add_to); if (arg_default_dir != NULL) default_directory = g_file_new_for_commandline_arg (arg_default_dir); if ((arg_add_to != NULL) || (arg_add == 1)) { /* Add files to an archive */ GtkWidget *window; GList *file_list; const char *filename; int i = 0; window = fr_window_new (); if (default_directory != NULL) fr_window_set_default_dir (FR_WINDOW (window), default_directory, TRUE); file_list = NULL; while ((filename = remaining_args[i++]) != NULL) file_list = g_list_prepend (file_list, g_file_new_for_commandline_arg (filename)); file_list = g_list_reverse (file_list); fr_window_new_batch (FR_WINDOW (window), _("Compress")); fr_window_set_batch__add (FR_WINDOW (window), add_to_archive, file_list); if (! arg_notify) fr_window_append_batch_action (FR_WINDOW (window), FR_BATCH_ACTION_QUIT, NULL, NULL); else fr_window_set_notify (FR_WINDOW (window), TRUE); fr_window_start_batch (FR_WINDOW (window)); _g_object_list_unref (file_list); } else if ((arg_extract_to != NULL) || (arg_extract == 1) || (arg_extract_here == 1)) { /* Extract all archives. */ GtkWidget *window; const char *archive; int i = 0; window = fr_window_new (); if (default_directory != NULL) fr_window_set_default_dir (FR_WINDOW (window), default_directory, TRUE); fr_window_new_batch (FR_WINDOW (window), _("Extract archive")); while ((archive = remaining_args[i++]) != NULL) { GFile *file; file = g_file_new_for_commandline_arg (archive); if (arg_extract_here == 1) fr_window_set_batch__extract_here (FR_WINDOW (window), file); else fr_window_set_batch__extract (FR_WINDOW (window), file, extraction_destination); g_object_unref (file); } if (! arg_notify) fr_window_append_batch_action (FR_WINDOW (window), FR_BATCH_ACTION_QUIT, NULL, NULL); else fr_window_set_notify (FR_WINDOW (window), TRUE); fr_window_start_batch (FR_WINDOW (window)); } else { /* Open each archive in a window */ const char *filename = NULL; int i = 0; while ((filename = remaining_args[i++]) != NULL) { GtkWidget *window; GFile *file; window = fr_window_new (); gtk_widget_show (window); file = g_file_new_for_commandline_arg (filename); fr_window_archive_open (FR_WINDOW (window), file, GTK_WINDOW (window)); g_object_unref (file); } } _g_object_unref (default_directory); _g_object_unref (add_to_archive); _g_object_unref (extraction_destination); return fr_application_command_line_finished (application, EXIT_SUCCESS); }
static gint remmina_on_command_line(GApplication *app, GApplicationCommandLine *cmdline) { gint status = 0; gint argc; gchar **argv; GError *error = NULL; GOptionContext *context; gboolean parsed; gchar *s; gboolean executed = FALSE; remmina_option_about = FALSE; remmina_option_connect = NULL; remmina_option_edit = NULL; remmina_option_help = FALSE; remmina_option_new = FALSE; remmina_option_pref = NULL; remmina_option_plugin = NULL; remmina_option_server = NULL; remmina_option_protocol = NULL; remmina_option_icon = FALSE; argv = g_application_command_line_get_arguments(cmdline, &argc); context = g_option_context_new("- The GTK+ Remote Desktop Client"); g_option_context_add_main_entries(context, remmina_options, GETTEXT_PACKAGE); g_option_context_set_help_enabled(context, FALSE); parsed = g_option_context_parse(context, &argc, &argv, &error); g_strfreev(argv); if (!parsed) { g_print("option parsing failed: %s\n", error->message); status = 1; } if (remmina_option_quit) { gtk_main_quit(); status = 1; } if (remmina_option_about) { remmina_exec_command(REMMINA_COMMAND_ABOUT, NULL); executed = TRUE; } if (remmina_option_connect) { remmina_exec_command(REMMINA_COMMAND_CONNECT, remmina_option_connect); executed = TRUE; } if (remmina_option_edit) { remmina_exec_command(REMMINA_COMMAND_EDIT, remmina_option_edit); executed = TRUE; } if (remmina_option_help) { s = g_option_context_get_help(context, TRUE, NULL); g_print("%s", s); g_free(s); status = 1; } if (remmina_option_new) { if (remmina_option_server) { s = g_strdup_printf("%s,%s", remmina_option_protocol, remmina_option_server); } else { s = g_strdup(remmina_option_protocol); } remmina_exec_command(REMMINA_COMMAND_NEW, s); g_free(s); executed = TRUE; } if (remmina_option_pref) { remmina_exec_command(REMMINA_COMMAND_PREF, remmina_option_pref); executed = TRUE; } if (remmina_option_plugin) { remmina_exec_command(REMMINA_COMMAND_PLUGIN, remmina_option_plugin); executed = TRUE; } if (remmina_option_icon) { remmina_exec_command(REMMINA_COMMAND_NONE, remmina_option_icon); executed = TRUE; } if (!executed) { remmina_exec_command(REMMINA_COMMAND_MAIN, NULL); } g_option_context_free(context); return status; }
static int gnote_app_command_line(GApplication *, GApplicationCommandLine * command_line) { int argc; char **argv = g_application_command_line_get_arguments(command_line, &argc); return Gnote::obj().command_line(argc, argv); }