1 From bf6af945130299a69a244afaee4eecbd3fb77233 Mon Sep 17 00:00:00 2001
2 From: Philipp Kaluza <phk@src.gnome.org>
3 Date: Fri, 8 Mar 2013 18:08:32 +0100
4 Subject: [PATCH 5/6] panel-run-dialog: resurrect function
5 gnome_desktop_prepend_terminal_to_vector
7 , which was removed from gnome-desktop in commit
8 9bab2144b7c8ace0c057720be3c48fb24a80a19d , and keep a local
9 copy in panel-run-dialog.c (simple helper function, static).
10 (Second half of fix for bug #237308 .)
12 gnome-panel/panel-run-dialog.c | 135 ++++++++++++++++++++++++++++++++++++++++-
13 1 file changed, 133 insertions(+), 2 deletions(-)
15 diff --git a/gnome-panel/panel-run-dialog.c b/gnome-panel/panel-run-dialog.c
16 index 801b9bc..faf3d7e 100644
17 --- a/gnome-panel/panel-run-dialog.c
18 +++ b/gnome-panel/panel-run-dialog.c
20 * Havoc Pennington <hp@pobox.com>
21 * George Lebl <jirka@5z.com>
22 * Mark McLoughlin <mark@skynet.ie>
23 + * Tom Tromey (Copyright (C) 1998)
28 #include <gdk/gdkkeysyms.h>
29 #include <gmenu-tree.h>
31 -#include <libgnome-desktop/gnome-desktop-utils.h>
33 #include <libpanel-util/panel-error.h>
34 #include <libpanel-util/panel-glib.h>
35 #include <libpanel-util/panel-gtk.h>
36 @@ -335,6 +334,138 @@ dummy_child_watch (GPid pid,
42 + * gnome_desktop_prepend_terminal_to_vector:
43 + * @argc: a pointer to the vector size
44 + * @argv: a pointer to the vector
46 + * Description: Prepends a terminal (either the one configured as default in
47 + * the user's GNOME setup, or one of the common xterm emulators) to the passed
48 + * in vector, modifying it in the process. The vector should be allocated with
49 + * #g_malloc, as this will #g_free the original vector. Also all elements must
50 + * have been allocated separately. That is the standard glib/GNOME way of
51 + * doing vectors however. If the integer that @argc points to is negative, the
52 + * size will first be computed. Also note that passing in pointers to a vector
53 + * that is empty, will just create a new vector for you.
56 +gnome_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
62 + char **term_argv = NULL;
64 + GSettings *settings;
66 + gchar *terminal = NULL;
70 + g_return_if_fail (argc != NULL);
71 + g_return_if_fail (argv != NULL);
73 + // _gnome_desktop_init_i18n ();
81 + /* compute size if not given */
83 + for (i = 0; the_argv[i] != NULL; i++)
88 + settings = g_settings_new ("org.gnome.desktop.default-applications.terminal");
89 + terminal = g_settings_get_string (settings, "exec");
92 + gchar *command_line;
95 + exec_flag = g_settings_get_string (settings, "exec-arg");
97 + if (exec_flag == NULL)
98 + command_line = g_strdup (terminal);
100 + command_line = g_strdup_printf ("%s %s", terminal,
103 + g_shell_parse_argv (command_line,
108 + g_free (command_line);
109 + g_free (exec_flag);
113 + g_object_unref (settings);
115 + if (term_argv == NULL) {
119 + term_argv = g_new0 (char *, 3);
121 + check = g_find_program_in_path ("gnome-terminal");
122 + if (check != NULL) {
123 + term_argv[0] = check;
124 + /* Note that gnome-terminal takes -x and
125 + * as -e in gnome-terminal is broken we use that. */
126 + term_argv[1] = g_strdup ("-x");
129 + check = g_find_program_in_path ("nxterm");
131 + check = g_find_program_in_path ("color-xterm");
133 + check = g_find_program_in_path ("rxvt");
135 + check = g_find_program_in_path ("xterm");
137 + check = g_find_program_in_path ("dtterm");
138 + if (check == NULL) {
139 + g_warning (_("Cannot find a terminal, using "
140 + "xterm, even if it may not work"));
141 + check = g_strdup ("xterm");
143 + term_argv[0] = check;
144 + term_argv[1] = g_strdup ("-e");
148 + real_argc = term_argc + *argc;
149 + real_argv = g_new (char *, real_argc + 1);
151 + for (i = 0; i < term_argc; i++)
152 + real_argv[i] = term_argv[i];
154 + for (j = 0; j < *argc; j++, i++)
155 + real_argv[i] = (char *)the_argv[j];
157 + real_argv[i] = NULL;
163 + /* we use g_free here as we sucked all the inner strings
164 + * out from it into real_argv */
165 + g_free (term_argv);
167 + /* FIXME: Implement when needed */
168 + g_warning ("gnome_prepend_terminal_to_vector: Not implemented");
173 panel_run_dialog_launch_command (PanelRunDialog *dialog,