gnome-terminal r3190 - branches/gnome-2-24/src



Author: chpe
Date: Wed Oct 22 12:16:50 2008
New Revision: 3190
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=3190&view=rev

Log:
Revert "Bug 548600 â Can no longer configure keyboard shortcuts for switching tabs"

This reverts commit 4f3858ac5295d4714e1d81d302524635cd1fde60.

Modified:
   branches/gnome-2-24/src/gnome-terminal.schemas.in
   branches/gnome-2-24/src/terminal-accels.c
   branches/gnome-2-24/src/terminal-tabs-menu.c

Modified: branches/gnome-2-24/src/gnome-terminal.schemas.in
==============================================================================
--- branches/gnome-2-24/src/gnome-terminal.schemas.in	(original)
+++ branches/gnome-2-24/src/gnome-terminal.schemas.in	Wed Oct 22 12:16:50 2008
@@ -916,102 +916,6 @@
     </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>&lt;Alt&gt;1</default>
-    </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>&lt;Alt&gt;2</default>
-    </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>&lt;Alt&gt;3</default>
-    </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>&lt;Alt&gt;4</default>
-    </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>&lt;Alt&gt;5</default>
-    </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>&lt;Alt&gt;6</default>
-    </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>&lt;Alt&gt;7</default>
-    </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>&lt;Alt&gt;8</default>
-    </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>&lt;Alt&gt;9</default>
-    </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 -->
-    </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 -->
-    </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 -->
-    </schema>
-
-    <schema>
       <key>/schemas/apps/gnome-terminal/keybindings/help</key>
       <applyto>/apps/gnome-terminal/keybindings/help</applyto>
       <owner>gnome-terminal</owner>

Modified: branches/gnome-2-24/src/terminal-accels.c
==============================================================================
--- branches/gnome-2-24/src/terminal-accels.c	(original)
+++ branches/gnome-2-24/src/terminal-accels.c	Wed Oct 22 12:16:50 2008
@@ -20,14 +20,11 @@
 
 #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
@@ -74,7 +71,6 @@
 #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"
@@ -97,7 +93,6 @@
 #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
 {
@@ -180,47 +175,6 @@
     KEY_DETACH_TAB, ACCEL_PATH_DETACH_TAB, 0, 0, NULL, FALSE, TRUE },
 };
 
-#define UN_(x) (x)
-
-static KeyEntry jump_tab_entries[] = {
-  { UN_("Switch to Tab 1"),
-    KEY_SWITCH_TAB_PREFIX "1",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "1", GDK_1, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 2"),
-    KEY_SWITCH_TAB_PREFIX "2",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "2", GDK_2, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 3"),
-    KEY_SWITCH_TAB_PREFIX "3",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "3", GDK_3, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 4"),
-    KEY_SWITCH_TAB_PREFIX "4",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "4", GDK_4, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 5"),
-    KEY_SWITCH_TAB_PREFIX "5",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "5", GDK_5, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 6"),
-    KEY_SWITCH_TAB_PREFIX "6",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "6", GDK_6, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 7"),
-    KEY_SWITCH_TAB_PREFIX "7",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "7", GDK_7, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 8"),
-    KEY_SWITCH_TAB_PREFIX "8",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "8", GDK_8, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 9"),
-    KEY_SWITCH_TAB_PREFIX "9",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "9", GDK_9, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 10"),
-    KEY_SWITCH_TAB_PREFIX "10",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "10", GDK_0, GDK_MOD1_MASK, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 11"),
-    KEY_SWITCH_TAB_PREFIX "11",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "11", 0, 0, NULL, FALSE, TRUE },
-  { UN_("Switch to Tab 12"),
-    KEY_SWITCH_TAB_PREFIX "12",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "12", 0, 0, NULL, FALSE, TRUE }
-};
-
 static KeyEntry help_entries[] = {
   { N_("Contents"), KEY_HELP, ACCEL_PATH_HELP, 0, 0, NULL, FALSE, TRUE }
 };
@@ -232,8 +186,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") },
-  { jump_tab_entries, G_N_ELEMENTS (jump_tab_entries), NULL }
+  { help_entries, G_N_ELEMENTS (help_entries), N_("Help") }
 };
 
 enum
@@ -917,8 +870,7 @@
   g_signal_connect (tree, "row-changed", G_CALLBACK (row_changed), NULL);
 #endif
 
-  /* -1 because we can't add the Tabs entries on gnome-2-24 b/c of string freeze */
-  for (i = 0; i < G_N_ELEMENTS (all_entries) - 1; ++i)
+  for (i = 0; i < G_N_ELEMENTS (all_entries); ++i)
     {
       GtkTreeIter parent_iter;
       int j;

Modified: branches/gnome-2-24/src/terminal-tabs-menu.c
==============================================================================
--- branches/gnome-2-24/src/terminal-tabs-menu.c	(original)
+++ branches/gnome-2-24/src/terminal-tabs-menu.c	Wed Oct 22 12:16:50 2008
@@ -30,16 +30,14 @@
 #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   strlen (ACTION_VERB_FORMAT_PREFIX)
+#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_LENGTH	strlen (ACTION_VERB_FORMAT) + 14 + 1
 #define ACTION_VERB_FORMAT_BASE         (16) /* %x is hex */
-#define ACCEL_PATH_FORMAT		"<Actions>/Main/TabsSwitch%u"
-#define ACCEL_PATH_FORMAT_LENGTH	strlen (ACCEL_PATH_FORMAT) + 14 + 1
+#define ACCEL_PATH_FORMAT		"<Actions>/TabsActions/%s"
+#define ACCEL_PATH_FORMAT_LENGTH	strlen (ACCEL_PATH_FORMAT) -2 + ACTION_VERB_FORMAT_LENGTH
 #define DATA_KEY			"TerminalTabsMenu::Action"
 
 #define UI_PATH                         "/menubar/Tabs"
@@ -381,7 +379,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>/Main/TabsSwitch*");
+        gtk_accel_map_add_filter ("<Actions>/TabsActions/JmpTab*");
 }
 
 static void
@@ -418,19 +416,40 @@
 			    guint tab_number,
 			    gboolean is_single_tab)
 {
-        if (!is_single_tab &&
-            tab_number < TERMINAL_ACCELS_N_TABS_SWITCH)
-        {
-                char accel_path[ACCEL_PATH_FORMAT_LENGTH];
+	const char *verb;
+	char accel_path[ACCEL_PATH_FORMAT_LENGTH];
+	char accel[7];
+	gint accel_number;
+	guint accel_key;
+	GdkModifierType accel_mods;
+
+	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);
 
-                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;
-        }
+	/* 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);
+	}
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]