1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
Index: src/terminal-accels.c
===================================================================
--- src/terminal-accels.c (revision 3169)
+++ src/terminal-accels.c (revision 3171)
@@ -20,11 +20,14 @@
#include <string.h>
+#include <gdk/gdkkeysyms.h>
+
#include "terminal-accels.h"
#include "terminal-app.h"
#include "terminal-intl.h"
#include "terminal-profile.h"
#include "terminal-util.h"
+#include "terminal-accels.h"
#ifdef DEBUG_ACCELS
#define D(x) x
@@ -71,6 +74,7 @@
#define ACCEL_PATH_MOVE_TAB_LEFT ACCEL_PATH_ROOT "TabsMoveLeft"
#define ACCEL_PATH_MOVE_TAB_RIGHT ACCEL_PATH_ROOT "TabsMoveRight"
#define ACCEL_PATH_DETACH_TAB ACCEL_PATH_ROOT "TabsDetach"
+#define ACCEL_PATH_SWITCH_TAB_PREFIX ACCEL_PATH_ROOT "TabsSwitch"
#define KEY_CLOSE_TAB CONF_KEYS_PREFIX "/close_tab"
#define KEY_CLOSE_WINDOW CONF_KEYS_PREFIX "/close_window"
@@ -93,6 +97,7 @@
#define KEY_ZOOM_IN CONF_KEYS_PREFIX "/zoom_in"
#define KEY_ZOOM_NORMAL CONF_KEYS_PREFIX "/zoom_normal"
#define KEY_ZOOM_OUT CONF_KEYS_PREFIX "/zoom_out"
+#define KEY_SWITCH_TAB_PREFIX CONF_KEYS_PREFIX "/switch_to_tab_"
typedef struct
{
@@ -173,6 +178,42 @@
KEY_MOVE_TAB_RIGHT, ACCEL_PATH_MOVE_TAB_RIGHT, 0, 0, NULL, FALSE, TRUE },
{ N_("Detach Tab"),
KEY_DETACH_TAB, ACCEL_PATH_DETACH_TAB, 0, 0, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 1"),
+ KEY_SWITCH_TAB_PREFIX "1",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "1", GDK_1, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 2"),
+ KEY_SWITCH_TAB_PREFIX "2",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "2", GDK_2, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 3"),
+ KEY_SWITCH_TAB_PREFIX "3",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "3", GDK_3, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 4"),
+ KEY_SWITCH_TAB_PREFIX "4",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "4", GDK_4, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 5"),
+ KEY_SWITCH_TAB_PREFIX "5",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "5", GDK_5, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 6"),
+ KEY_SWITCH_TAB_PREFIX "6",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "6", GDK_6, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 7"),
+ KEY_SWITCH_TAB_PREFIX "7",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "7", GDK_7, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 8"),
+ KEY_SWITCH_TAB_PREFIX "8",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "8", GDK_8, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 9"),
+ KEY_SWITCH_TAB_PREFIX "9",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "9", GDK_9, GDK_MOD1_MASK, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 10"),
+ KEY_SWITCH_TAB_PREFIX "10",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "10", 0, 0, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 11"),
+ KEY_SWITCH_TAB_PREFIX "11",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "11", 0, 0, NULL, FALSE, TRUE },
+ { N_("Switch to Tab 12"),
+ KEY_SWITCH_TAB_PREFIX "12",
+ ACCEL_PATH_SWITCH_TAB_PREFIX "12", 0, 0, NULL, FALSE, TRUE }
};
static KeyEntry help_entries[] = {
@@ -186,7 +227,7 @@
{ view_entries, G_N_ELEMENTS (view_entries), N_("View") },
{ terminal_entries, G_N_ELEMENTS (terminal_entries), N_("Terminal") },
{ tabs_entries, G_N_ELEMENTS (tabs_entries), N_("Tabs") },
- { help_entries, G_N_ELEMENTS (help_entries), N_("Help") }
+ { help_entries, G_N_ELEMENTS (help_entries), N_("Help") },
};
enum
Index: src/terminal-tabs-menu.c
===================================================================
--- src/terminal-tabs-menu.c (revision 3169)
+++ src/terminal-tabs-menu.c (revision 3171)
@@ -30,14 +30,16 @@
#include "terminal-screen-container.h"
#include "terminal-intl.h"
+#define TERMINAL_ACCELS_N_TABS_SWITCH (12)
+
#define LABEL_WIDTH_CHARS 32
#define ACTION_VERB_FORMAT_PREFIX "JmpTab"
-#define ACTION_VERB_FORMAT_PREFIX_LEN (6) /* strlen (ACTION_VERB_FORMAT_PREFIX) */
-#define ACTION_VERB_FORMAT ACTION_VERB_FORMAT_PREFIX "%x"
+#define ACTION_VERB_FORMAT_PREFIX_LEN strlen (ACTION_VERB_FORMAT_PREFIX)
+#define ACTION_VERB_FORMAT ACTION_VERB_FORMAT_PREFIX "%u"
#define ACTION_VERB_FORMAT_LENGTH strlen (ACTION_VERB_FORMAT) + 14 + 1
#define ACTION_VERB_FORMAT_BASE (16) /* %x is hex */
-#define ACCEL_PATH_FORMAT "<Actions>/TabsActions/%s"
-#define ACCEL_PATH_FORMAT_LENGTH strlen (ACCEL_PATH_FORMAT) -2 + ACTION_VERB_FORMAT_LENGTH
+#define ACCEL_PATH_FORMAT "<Actions>/Main/TabsSwitch%u"
+#define ACCEL_PATH_FORMAT_LENGTH strlen (ACCEL_PATH_FORMAT) + 14 + 1
#define DATA_KEY "TerminalTabsMenu::Action"
#define UI_PATH "/menubar/Tabs"
@@ -379,7 +381,7 @@
g_type_class_add_private (object_class, sizeof (TerminalTabsMenuPrivate));
/* We don't want to save accels, so skip them */
- gtk_accel_map_add_filter ("<Actions>/TabsActions/JmpTab*");
+ gtk_accel_map_add_filter ("<Actions>/Main/TabsSwitch*");
}
static void
@@ -416,40 +418,19 @@
guint tab_number,
gboolean is_single_tab)
{
- const char *verb;
- char accel_path[ACCEL_PATH_FORMAT_LENGTH];
- char accel[7];
- gint accel_number;
- guint accel_key;
- GdkModifierType accel_mods;
+ if (!is_single_tab &&
+ tab_number < TERMINAL_ACCELS_N_TABS_SWITCH)
+ {
+ char accel_path[ACCEL_PATH_FORMAT_LENGTH];
- verb = gtk_action_get_name (action);
-
- /* set the accel path for the menu item */
- g_snprintf (accel_path, sizeof (accel_path),
- ACCEL_PATH_FORMAT, verb);
- gtk_action_set_accel_path (action, accel_path);
-
- /* Only the first ten tabs get accelerators starting from 1 through 0 */
- if (tab_number < 10 && !is_single_tab)
- {
- accel_key = 0;
- accel_number = (tab_number + 1) % 10;
-
- g_snprintf (accel, sizeof (accel), "<alt>%d", accel_number);
-
- gtk_accelerator_parse (accel, &accel_key, &accel_mods);
-
- if (accel_key != 0)
- {
- gtk_accel_map_change_entry (accel_path, accel_key,
- accel_mods, TRUE);
- }
- }
- else
- {
- gtk_accel_map_change_entry (accel_path, 0, 0, TRUE);
- }
+ g_snprintf (accel_path, sizeof (accel_path), ACCEL_PATH_FORMAT, tab_number + 1);
+ gtk_action_set_accel_path (action, accel_path);
+ }
+ else
+ {
+ gtk_action_set_accel_path (action, NULL);
+ return;
+ }
}
static void
Index: src/gnome-terminal.schemas.in
===================================================================
--- src/gnome-terminal.schemas.in (revision 3169)
+++ src/gnome-terminal.schemas.in (revision 3171)
@@ -916,6 +916,210 @@
</schema>
<schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_1</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_1</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>1</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 1</short>
+ <long>
+ Keyboard shortcut key for switch to tab 1. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_2</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_2</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>2</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 2</short>
+ <long>
+ Keyboard shortcut key for switch to tab 2. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_3</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_3</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>3</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 3</short>
+ <long>
+ Keyboard shortcut key for switch to tab 3. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_4</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_4</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>4</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 4</short>
+ <long>
+ Keyboard shortcut key for switch to tab 4. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_5</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_5</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>5</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 5</short>
+ <long>
+ Keyboard shortcut key for switch to tab 5. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_6</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_6</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>6</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 6</short>
+ <long>
+ Keyboard shortcut key for switch to tab 6. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_7</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_7</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>7</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 7</short>
+ <long>
+ Keyboard shortcut key for switch to tab 7. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_8</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_8</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>8</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 8</short>
+ <long>
+ Keyboard shortcut key for switch to tab 8. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_9</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_9</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+ <default><Alt>9</default>
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 9</short>
+ <long>
+ Keyboard shortcut key for switch to tab 9. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_10</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_10</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+<!-- no default -->
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 10</short>
+ <long>
+ Keyboard shortcut key for switch to tab 10. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_11</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_11</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+<!-- no default -->
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 11</short>
+ <long>
+ Keyboard shortcut key for switch to tab 11. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_12</key>
+ <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_12</applyto>
+ <owner>gnome-terminal</owner>
+ <type>string</type>
+<!-- no default -->
+ <locale name="C">
+ <short>Keyboard shortcut to switch to tab 12</short>
+ <long>
+ Keyboard shortcut key for switch to tab 12. Expressed as a string
+ in the same format used for GTK+ resource files.
+ If you set the option to the special string "disabled", then there
+ will be no keyboard shortcut for this action.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/gnome-terminal/keybindings/help</key>
<applyto>/apps/gnome-terminal/keybindings/help</applyto>
<owner>gnome-terminal</owner>
|