~ubuntu-branches/ubuntu/maverick/gnome-terminal/maverick

« back to all changes in this revision

Viewing changes to src/terminal-tabs-menu.c

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane, Pedro Fragoso, Iain Lane
  • Date: 2008-10-23 10:20:55 UTC
  • mfrom: (1.3.25 upstream)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20081023102055-vea3bmq8oebd16d2
Tags: 2.24.1.1-0ubuntu1
[ Pedro Fragoso ]
* New upstream release
  - Revert the partial fix for bug #548600 due to regression
    it causes
* debian/patches/06_add_locale_to_schemas.patch:
  - Removed due to regression
* debian/patches/99_autoreconf.patch:
  - Refreshed

[ Iain Lane ]
* debian/patches/05_restore_tab_switching_shortcuts.patch:
  - Re-add patch dropped by upstream due to missing commit in stable branch
    and crasher regression. Fix for crasher is already in 2.24.1.1.
    (LP: #272199)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "terminal-screen-container.h"
31
31
#include "terminal-intl.h"
32
32
 
33
 
#define TERMINAL_ACCELS_N_TABS_SWITCH (12)
34
 
 
35
33
#define LABEL_WIDTH_CHARS 32
36
34
#define ACTION_VERB_FORMAT_PREFIX       "JmpTab"
37
 
#define ACTION_VERB_FORMAT_PREFIX_LEN   strlen (ACTION_VERB_FORMAT_PREFIX)
 
35
#define ACTION_VERB_FORMAT_PREFIX_LEN   (6) /* strlen (ACTION_VERB_FORMAT_PREFIX) */
38
36
#define ACTION_VERB_FORMAT              ACTION_VERB_FORMAT_PREFIX "%x"
39
37
#define ACTION_VERB_FORMAT_LENGTH       strlen (ACTION_VERB_FORMAT) + 14 + 1
40
38
#define ACTION_VERB_FORMAT_BASE         (16) /* %x is hex */
41
 
#define ACCEL_PATH_FORMAT               "<Actions>/Main/TabsSwitch%u"
42
 
#define ACCEL_PATH_FORMAT_LENGTH        strlen (ACCEL_PATH_FORMAT) + 14 + 1
 
39
#define ACCEL_PATH_FORMAT               "<Actions>/TabsActions/%s"
 
40
#define ACCEL_PATH_FORMAT_LENGTH        strlen (ACCEL_PATH_FORMAT) -2 + ACTION_VERB_FORMAT_LENGTH
43
41
#define DATA_KEY                        "TerminalTabsMenu::Action"
44
42
 
45
43
#define UI_PATH                         "/menubar/Tabs"
381
379
        g_type_class_add_private (object_class, sizeof (TerminalTabsMenuPrivate));
382
380
 
383
381
        /* We don't want to save accels, so skip them */
384
 
        gtk_accel_map_add_filter ("<Actions>/Main/TabsSwitch*");
 
382
        gtk_accel_map_add_filter ("<Actions>/TabsActions/JmpTab*");
385
383
}
386
384
 
387
385
static void
418
416
                            guint tab_number,
419
417
                            gboolean is_single_tab)
420
418
{
421
 
        if (!is_single_tab &&
422
 
            tab_number < TERMINAL_ACCELS_N_TABS_SWITCH)
423
 
        {
424
 
                char accel_path[ACCEL_PATH_FORMAT_LENGTH];
425
 
 
426
 
                g_snprintf (accel_path, sizeof (accel_path), ACCEL_PATH_FORMAT, tab_number + 1);
427
 
                gtk_action_set_accel_path (action, accel_path);
428
 
        }
429
 
        else
430
 
        {
431
 
                gtk_action_set_accel_path (action, NULL);
432
 
                return;
433
 
        }
 
419
        const char *verb;
 
420
        char accel_path[ACCEL_PATH_FORMAT_LENGTH];
 
421
        char accel[7];
 
422
        gint accel_number;
 
423
        guint accel_key;
 
424
        GdkModifierType accel_mods;
 
425
 
 
426
        verb = gtk_action_get_name (action);
 
427
 
 
428
        /* set the accel path for the menu item */
 
429
        g_snprintf (accel_path, sizeof (accel_path),
 
430
                    ACCEL_PATH_FORMAT, verb);
 
431
        gtk_action_set_accel_path (action, accel_path);
 
432
 
 
433
        /* Only the first ten tabs get accelerators starting from 1 through 0 */
 
434
        if (tab_number < 10 && !is_single_tab)
 
435
        {
 
436
                accel_key = 0;
 
437
                accel_number = (tab_number + 1) % 10;
 
438
 
 
439
                g_snprintf (accel, sizeof (accel), "<alt>%d", accel_number);
 
440
 
 
441
                gtk_accelerator_parse (accel, &accel_key, &accel_mods);
 
442
 
 
443
                if (accel_key != 0)
 
444
                {
 
445
                        gtk_accel_map_change_entry (accel_path, accel_key,
 
446
                                                    accel_mods, TRUE);
 
447
                }
 
448
        }
 
449
        else
 
450
        {
 
451
                gtk_accel_map_change_entry (accel_path, 0, 0, TRUE);
 
452
        }
434
453
}
435
454
 
436
455
static void