280
280
return _panel_launch_handle_error (fallback_exec,
281
281
screen, local_error, error);
285
* panel_util_desktop_prepend_terminal_to_vector:
286
* @argc: a pointer to the vector size
287
* @argv: a pointer to the vector
289
* Description: Prepends a terminal (either the one configured as default in
290
* the user's GNOME setup, or one of the common xterm emulators) to the passed
291
* in vector, modifying it in the process. The vector should be allocated with
292
* #g_malloc, as this will #g_free the original vector. Also all elements must
293
* have been allocated separately. That is the standard glib/GNOME way of
294
* doing vectors however. If the integer that @argc points to is negative, the
295
* size will first be computed. Also note that passing in pointers to a vector
296
* that is empty, will just create a new vector for you.
299
panel_util_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
305
char **term_argv = NULL;
309
gchar *terminal = NULL;
313
g_return_if_fail (argc != NULL);
314
g_return_if_fail (argv != NULL);
316
// _gnome_desktop_init_i18n ();
324
/* compute size if not given */
326
for (i = 0; the_argv[i] != NULL; i++)
331
settings = g_settings_new ("org.gnome.desktop.default-applications.terminal");
332
terminal = g_settings_get_string (settings, "exec");
338
exec_flag = g_settings_get_string (settings, "exec-arg");
340
if (exec_flag == NULL)
341
command_line = g_strdup (terminal);
343
command_line = g_strdup_printf ("%s %s", terminal,
346
g_shell_parse_argv (command_line,
351
g_free (command_line);
356
g_object_unref (settings);
358
if (term_argv == NULL) {
362
term_argv = g_new0 (char *, 3);
364
check = g_find_program_in_path ("gnome-terminal");
366
term_argv[0] = check;
367
/* Note that gnome-terminal takes -x and
368
* as -e in gnome-terminal is broken we use that. */
369
term_argv[1] = g_strdup ("-x");
372
check = g_find_program_in_path ("nxterm");
374
check = g_find_program_in_path ("color-xterm");
376
check = g_find_program_in_path ("rxvt");
378
check = g_find_program_in_path ("xterm");
380
check = g_find_program_in_path ("dtterm");
382
g_warning (_("Cannot find a terminal, using "
383
"xterm, even if it may not work"));
384
check = g_strdup ("xterm");
386
term_argv[0] = check;
387
term_argv[1] = g_strdup ("-e");
391
real_argc = term_argc + *argc;
392
real_argv = g_new (char *, real_argc + 1);
394
for (i = 0; i < term_argc; i++)
395
real_argv[i] = term_argv[i];
397
for (j = 0; j < *argc; j++, i++)
398
real_argv[i] = (char *)the_argv[j];
406
/* we use g_free here as we sucked all the inner strings
407
* out from it into real_argv */
410
/* FIXME: Implement when needed */
411
g_warning ("gnome_prepend_terminal_to_vector: Not implemented");