[gnome-terminal/gnome-3-8] accels: Simplify code



commit 108428dc62fbe89580ca803091a93a368aa8b6b7
Author: Christian Persch <chpe gnome org>
Date:   Wed Mar 20 20:11:44 2013 +0100

    accels: Simplify code
    
    Make this more easily extensible, and drop the trivially different summaries
    for the various gsettings keys.

 src/terminal-accels.c |   62 ++++++++++++++++++++----------------------------
 1 files changed, 26 insertions(+), 36 deletions(-)
---
diff --git a/src/terminal-accels.c b/src/terminal-accels.c
index 1170c8c..5d6468b 100644
--- a/src/terminal-accels.c
+++ b/src/terminal-accels.c
@@ -196,44 +196,34 @@ static KeyEntry tabs_entries[] =
     KEY_MOVE_TAB_RIGHT, ACCEL_PATH_MOVE_TAB_RIGHT, { GDK_SHIFT_MASK | GDK_CONTROL_MASK, GDK_KEY_Page_Down }, 
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_MOD1_MASK, GDK_KEY_1 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 2"),
-    KEY_SWITCH_TAB_PREFIX "2",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "2", { GDK_MOD1_MASK, GDK_KEY_2 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 3"),
-    KEY_SWITCH_TAB_PREFIX "3",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "3", { GDK_MOD1_MASK, GDK_KEY_3 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 4"),
-    KEY_SWITCH_TAB_PREFIX "4",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "4", { GDK_MOD1_MASK, GDK_KEY_4 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 5"),
-    KEY_SWITCH_TAB_PREFIX "5",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "5", { GDK_MOD1_MASK, GDK_KEY_5 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 6"),
-    KEY_SWITCH_TAB_PREFIX "6",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "6", { GDK_MOD1_MASK, GDK_KEY_6 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 7"),
-    KEY_SWITCH_TAB_PREFIX "7",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "7", { GDK_MOD1_MASK, GDK_KEY_7 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 8"),
-    KEY_SWITCH_TAB_PREFIX "8",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "8", { GDK_MOD1_MASK, GDK_KEY_8 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 9"),
-    KEY_SWITCH_TAB_PREFIX "9",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "9", { GDK_MOD1_MASK, GDK_KEY_9 }, NULL, FALSE, TRUE },
-  { N_("Switch to Tab 10"),
-    KEY_SWITCH_TAB_PREFIX "10",
-    ACCEL_PATH_SWITCH_TAB_PREFIX "10", { GDK_MOD1_MASK, GDK_KEY_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 }
+
+#define SWITCH_TAB_ACCEL(name, num, modifier, key)       \
+  { name, \
+    KEY_SWITCH_TAB_PREFIX # num, \
+    ACCEL_PATH_SWITCH_TAB_PREFIX # num, \
+    { modifier, key }, \
+    NULL, \
+    FALSE, \
+    TRUE \
+  }
+
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 1"), 1, GDK_MOD1_MASK, GDK_KEY_1),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 2"), 2,  GDK_MOD1_MASK, GDK_KEY_2),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 3"), 3,  GDK_MOD1_MASK, GDK_KEY_3),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 4"), 4,  GDK_MOD1_MASK, GDK_KEY_4),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 5"), 5,  GDK_MOD1_MASK, GDK_KEY_5),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 6"), 6,  GDK_MOD1_MASK, GDK_KEY_6),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 7"), 7,  GDK_MOD1_MASK, GDK_KEY_7),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 8"), 8,  GDK_MOD1_MASK, GDK_KEY_8),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 9"), 9,  GDK_MOD1_MASK, GDK_KEY_9),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 10"), 10, GDK_MOD1_MASK, GDK_KEY_0),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 11"), 11, 0, 0),
+  SWITCH_TAB_ACCEL (N_("Switch to Tab 12"), 12, 0, 0)
 };
 
+#undef SWITCH_TAB_ACCEL
+#undef SWITCH_TAB_ACCEL_NO_DEFAULT
+
 static KeyEntry help_entries[] = {
   { N_("Contents"), KEY_HELP, ACCEL_PATH_HELP, { 0, GDK_KEY_F1 }, NULL, FALSE, TRUE }
 };


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