static gboolean panel_run_dialog_launch_command (PanelRunDialog *dialog, const char *command, const char *locale_command) { GdkScreen *screen; gboolean result; GError *error = NULL; char **argv; int argc; GPid pid; if (!command_is_executable (locale_command, &argc, &argv)) return FALSE; screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox))) mate_desktop_prepend_terminal_to_vector (&argc, &argv); #if GTK_CHECK_VERSION (3, 0, 0) result = g_spawn_async (NULL, /* working directory */ argv, NULL, /* envp */ G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &error); #else result = gdk_spawn_on_screen (screen, NULL, /* working directory */ argv, NULL, /* envp */ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, /* child setup func */ NULL, /* user data */ &pid, /* child pid */ &error); #endif if (!result) { char *primary; primary = g_markup_printf_escaped (_("Could not run command '%s'"), command); panel_error_dialog (GTK_WINDOW (dialog->run_dialog), NULL, "cannot_spawn_command", TRUE, primary, error->message); g_free (primary); g_error_free (error); } else { g_child_watch_add (pid, dummy_child_watch, NULL); } g_strfreev (argv); return result; }
static char * get_terminal_command_prefix (gboolean for_command) { int argc; char **argv; char *command; guint i; static const char *const commands[][3] = { { "comando", "-x", "" }, { "terminal", "-x", "" }, { "lxterminal", "-x", "" }, { "vte", "-x", "" }, { "mate-terminal", "-x", "" }, { "dtterm", "-e", "-ls" }, { "nxterm", "-e", "-ls" }, { "color-xterm", "-e", "-ls" }, { "rxvt", "-e", "-ls" }, { "xterm", "-e", "-ls" }, }; /* Try the terminal from preferences. Use without any * arguments if we are just doing a standalone terminal. */ argc = 0; argv = g_new0 (char *, 1); mate_desktop_prepend_terminal_to_vector (&argc, &argv); command = NULL; if (argc != 0) { if (for_command) { command = try_terminal_command_argv (argc, argv); } else { /* Strip off the arguments in a lame attempt * to make it be an interactive shell. */ command = try_terminal_command (argv[0], NULL); } } while (argc != 0) { g_free (argv[--argc]); } g_free (argv); if (command != NULL) { return command; } /* Try well-known terminal applications in same order that gmc did. */ for (i = 0; i < G_N_ELEMENTS (commands); i++) { command = try_terminal_command (commands[i][0], commands[i][for_command ? 1 : 2]); if (command != NULL) { break; } } return command; }