static char * get_terminal_command_prefix (gboolean for_command) { int argc; char **argv; char *command; guint i; static const char *const commands[][3] = { { "gnome-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); gnome_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; }
static void nautilus_makepkg_menu_item_activate_cb (NautilusMenuItem *item, gpointer user_data) { gchar *options, *command, **argv; gint argc; GError *error = NULL; MenuItemActivateData *data = (MenuItemActivateData *) user_data; NautilusMakepkgPrivate *priv = data->self->priv; options = gconf_client_get_string (priv->conf, NAUTILUS_MAKEPKG_CONF_OPTIONS, &error); if (options == NULL) { g_warning ("Unable to retrieve key " NAUTILUS_MAKEPKG_CONF_OPTIONS ": %s\n", error->message); g_error_free (error); return; } command = g_strdup_printf ("%s %s", NAUTILUS_MAKEPKG_COMMAND, options); g_free (options); if (!g_shell_parse_argv (command, &argc, &argv, &error)) { g_warning ("Unable to understand options: %s\n", error->message); g_error_free (error); g_free (command); return; } gnome_desktop_prepend_terminal_to_vector (&argc, &argv); g_free (command); if (!gdk_spawn_on_screen (data->screen, data->path, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error)) { g_warning ("Unable to run makepkg: %s\n", error->message); g_error_free (error); g_strfreev (argv); return; } g_strfreev (argv); return; }