~ubuntu-branches/ubuntu/saucy/gnome-panel/saucy-proposed

« back to all changes in this revision

Viewing changes to gnome-panel/libpanel-util/panel-launch.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-06-19 11:49:35 UTC
  • mfrom: (2.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20130619114935-e912mx6nwxecoaib
Tags: 1:3.6.2-0ubuntu7
* Sync with Debian svn (LP: #1185873). Remaining changes:
  - Use epoch
  - Add apport hook
  - debian/control:
    + Recommend indicator-complete
    + Don't depend on nautilus 3.8 yet
  - debian/patches/14_revert_timedate_change.patch:
    + Dropped, we're using timedated
  - debian/patches/40_unset_menuproxy.patch:
    + Make sure gnome-panel and the applets don't pick up menu proxies.
  - debian/patches/41_classic_layout.patch:
    + Change the defaults to be more "classic Ubuntu": Show indicators
      & show desktop, drop GNOME clock & notification area
  - debian/patches/85_disable_shutdown_on_ltsp.patch:
    + Suppress the shutdown option in the panel if LTSP_CLIENT is set.
* debian/patches/50_ubuntu_sessions.patch:
  - Merge patch from gnome-session to split sessions into GNOME Flashback
    (No effects) using Metacity and GNOME Flashback using Compiz
* debian/patches/51_dont_require_nautilus38.patch:
  - Run Flashback without Nautilus 3.8 since it's not in Saucy yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
        return _panel_launch_handle_error (fallback_exec,
281
281
                                           screen, local_error, error);
282
282
}
283
 
 
284
 
/**
285
 
 * panel_util_desktop_prepend_terminal_to_vector:
286
 
 * @argc: a pointer to the vector size
287
 
 * @argv: a pointer to the vector
288
 
 *
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.
297
 
 **/
298
 
void
299
 
panel_util_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
300
 
{
301
 
#ifndef G_OS_WIN32
302
 
        char **real_argv;
303
 
        int real_argc;
304
 
        int i, j;
305
 
        char **term_argv = NULL;
306
 
        int term_argc = 0;
307
 
        GSettings *settings;
308
 
 
309
 
        gchar *terminal = NULL;
310
 
 
311
 
        char **the_argv;
312
 
 
313
 
        g_return_if_fail (argc != NULL);
314
 
        g_return_if_fail (argv != NULL);
315
 
 
316
 
        // _gnome_desktop_init_i18n ();
317
 
 
318
 
        /* sanity */
319
 
        if(*argv == NULL)
320
 
                *argc = 0;
321
 
 
322
 
        the_argv = *argv;
323
 
 
324
 
        /* compute size if not given */
325
 
        if (*argc < 0) {
326
 
                for (i = 0; the_argv[i] != NULL; i++)
327
 
                        ;
328
 
                *argc = i;
329
 
        }
330
 
 
331
 
        settings = g_settings_new ("org.gnome.desktop.default-applications.terminal");
332
 
        terminal = g_settings_get_string (settings, "exec");
333
 
 
334
 
        if (terminal) {
335
 
                gchar *command_line;
336
 
                gchar *exec_flag;
337
 
 
338
 
                exec_flag = g_settings_get_string (settings, "exec-arg");
339
 
 
340
 
                if (exec_flag == NULL)
341
 
                        command_line = g_strdup (terminal);
342
 
                else
343
 
                        command_line = g_strdup_printf ("%s %s", terminal,
344
 
                                                        exec_flag);
345
 
 
346
 
                g_shell_parse_argv (command_line,
347
 
                                    &term_argc,
348
 
                                    &term_argv,
349
 
                                    NULL /* error */);
350
 
 
351
 
                g_free (command_line);
352
 
                g_free (exec_flag);
353
 
                g_free (terminal);
354
 
        }
355
 
 
356
 
        g_object_unref (settings);
357
 
 
358
 
        if (term_argv == NULL) {
359
 
                char *check;
360
 
 
361
 
                term_argc = 2;
362
 
                term_argv = g_new0 (char *, 3);
363
 
 
364
 
                check = g_find_program_in_path ("gnome-terminal");
365
 
                if (check != NULL) {
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");
370
 
                } else {
371
 
                        if (check == NULL)
372
 
                                check = g_find_program_in_path ("nxterm");
373
 
                        if (check == NULL)
374
 
                                check = g_find_program_in_path ("color-xterm");
375
 
                        if (check == NULL)
376
 
                                check = g_find_program_in_path ("rxvt");
377
 
                        if (check == NULL)
378
 
                                check = g_find_program_in_path ("xterm");
379
 
                        if (check == NULL)
380
 
                                check = g_find_program_in_path ("dtterm");
381
 
                        if (check == NULL) {
382
 
                                g_warning (_("Cannot find a terminal, using "
383
 
                                             "xterm, even if it may not work"));
384
 
                                check = g_strdup ("xterm");
385
 
                        }
386
 
                        term_argv[0] = check;
387
 
                        term_argv[1] = g_strdup ("-e");
388
 
                }
389
 
        }
390
 
 
391
 
        real_argc = term_argc + *argc;
392
 
        real_argv = g_new (char *, real_argc + 1);
393
 
 
394
 
        for (i = 0; i < term_argc; i++)
395
 
                real_argv[i] = term_argv[i];
396
 
 
397
 
        for (j = 0; j < *argc; j++, i++)
398
 
                real_argv[i] = (char *)the_argv[j];
399
 
 
400
 
        real_argv[i] = NULL;
401
 
 
402
 
        g_free (*argv);
403
 
        *argv = real_argv;
404
 
        *argc = real_argc;
405
 
 
406
 
        /* we use g_free here as we sucked all the inner strings
407
 
         * out from it into real_argv */
408
 
        g_free (term_argv);
409
 
#else
410
 
        /* FIXME: Implement when needed */
411
 
        g_warning ("gnome_prepend_terminal_to_vector: Not implemented");
412
 
#endif
413
 
}
414