]> git.pld-linux.org Git - packages/gnome-panel.git/blob - 0005-panel-run-dialog-resurrect-function-gnome_desktop_pr.patch
Fixes from git to build on GNOME 3.8
[packages/gnome-panel.git] / 0005-panel-run-dialog-resurrect-function-gnome_desktop_pr.patch
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
6
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 .)
11 ---
12  gnome-panel/panel-run-dialog.c | 135 ++++++++++++++++++++++++++++++++++++++++-
13  1 file changed, 133 insertions(+), 2 deletions(-)
14
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
19 @@ -25,6 +25,7 @@
20   *     Havoc Pennington <hp@pobox.com>
21   *      George Lebl <jirka@5z.com>
22   *     Mark McLoughlin <mark@skynet.ie>
23 + *     Tom Tromey (Copyright (C) 1998)
24   */
25  
26  #include <config.h>
27 @@ -42,8 +43,6 @@
28  #include <gdk/gdkkeysyms.h>
29  #include <gmenu-tree.h>
30  
31 -#include <libgnome-desktop/gnome-desktop-utils.h>
32 -
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,
37          */
38  }
39  
40 +
41 +/**
42 + * gnome_desktop_prepend_terminal_to_vector:
43 + * @argc: a pointer to the vector size
44 + * @argv: a pointer to the vector
45 + *
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.
54 + **/
55 +static void
56 +gnome_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
57 +{
58 +#ifndef G_OS_WIN32
59 +        char **real_argv;
60 +        int real_argc;
61 +        int i, j;
62 +       char **term_argv = NULL;
63 +       int term_argc = 0;
64 +       GSettings *settings;
65 +
66 +       gchar *terminal = NULL;
67 +
68 +       char **the_argv;
69 +
70 +        g_return_if_fail (argc != NULL);
71 +        g_return_if_fail (argv != NULL);
72 +
73 +        // _gnome_desktop_init_i18n ();
74 +
75 +       /* sanity */
76 +        if(*argv == NULL)
77 +                *argc = 0;
78 +
79 +       the_argv = *argv;
80 +
81 +       /* compute size if not given */
82 +       if (*argc < 0) {
83 +               for (i = 0; the_argv[i] != NULL; i++)
84 +                       ;
85 +               *argc = i;
86 +       }
87 +
88 +       settings = g_settings_new ("org.gnome.desktop.default-applications.terminal");
89 +       terminal = g_settings_get_string (settings, "exec");
90 +
91 +       if (terminal) {
92 +               gchar *command_line;
93 +               gchar *exec_flag;
94 +
95 +               exec_flag = g_settings_get_string (settings, "exec-arg");
96 +
97 +               if (exec_flag == NULL)
98 +                       command_line = g_strdup (terminal);
99 +               else
100 +                       command_line = g_strdup_printf ("%s %s", terminal,
101 +                                                       exec_flag);
102 +
103 +               g_shell_parse_argv (command_line,
104 +                                   &term_argc,
105 +                                   &term_argv,
106 +                                   NULL /* error */);
107 +
108 +               g_free (command_line);
109 +               g_free (exec_flag);
110 +               g_free (terminal);
111 +       }
112 +
113 +       g_object_unref (settings);
114 +
115 +       if (term_argv == NULL) {
116 +               char *check;
117 +
118 +               term_argc = 2;
119 +               term_argv = g_new0 (char *, 3);
120 +
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");
127 +               } else {
128 +                       if (check == NULL)
129 +                               check = g_find_program_in_path ("nxterm");
130 +                       if (check == NULL)
131 +                               check = g_find_program_in_path ("color-xterm");
132 +                       if (check == NULL)
133 +                               check = g_find_program_in_path ("rxvt");
134 +                       if (check == NULL)
135 +                               check = g_find_program_in_path ("xterm");
136 +                       if (check == NULL)
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");
142 +                       }
143 +                       term_argv[0] = check;
144 +                       term_argv[1] = g_strdup ("-e");
145 +               }
146 +       }
147 +
148 +        real_argc = term_argc + *argc;
149 +        real_argv = g_new (char *, real_argc + 1);
150 +
151 +        for (i = 0; i < term_argc; i++)
152 +                real_argv[i] = term_argv[i];
153 +
154 +        for (j = 0; j < *argc; j++, i++)
155 +                real_argv[i] = (char *)the_argv[j];
156 +
157 +       real_argv[i] = NULL;
158 +
159 +       g_free (*argv);
160 +       *argv = real_argv;
161 +       *argc = real_argc;
162 +
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);
166 +#else
167 +       /* FIXME: Implement when needed */
168 +       g_warning ("gnome_prepend_terminal_to_vector: Not implemented");
169 +#endif
170 +}
171 +
172  static gboolean
173  panel_run_dialog_launch_command (PanelRunDialog *dialog,
174                                  const char     *command,
175 -- 
176 1.8.2
177
This page took 0.0422 seconds and 3 git commands to generate.