[longomatch] Allow use of direct hotkeys (without Shift or Alt combination)



commit bba499aed4e58822c3321e6ee27fd783c86105b5
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Dec 29 19:34:21 2009 +0100

    Allow use of direct hotkeys (without Shift or Alt combination)

 LongoMatch/Gui/Component/CategoryProperties.cs     |    3 --
 LongoMatch/Gui/Dialog/HotKeySelectorDialog.cs      |   12 +++++++--
 LongoMatch/Handlers/HotKeysManager.cs              |   23 ++++++++-----------
 LongoMatch/Time/HotKey.cs                          |    8 ++++--
 .../LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs  |    4 +-
 LongoMatch/gtk-gui/gui.stetic                      |    5 ++-
 6 files changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/CategoryProperties.cs b/LongoMatch/Gui/Component/CategoryProperties.cs
index 1fda7fd..93cf4b0 100644
--- a/LongoMatch/Gui/Component/CategoryProperties.cs
+++ b/LongoMatch/Gui/Component/CategoryProperties.cs
@@ -102,8 +102,5 @@ namespace LongoMatch.Gui.Component
 		{
 			stn.Name = nameentry.Text;
 		}
-
-
-
 	}
 }
diff --git a/LongoMatch/Gui/Dialog/HotKeySelectorDialog.cs b/LongoMatch/Gui/Dialog/HotKeySelectorDialog.cs
index a09e92e..a4b90c4 100644
--- a/LongoMatch/Gui/Dialog/HotKeySelectorDialog.cs
+++ b/LongoMatch/Gui/Dialog/HotKeySelectorDialog.cs
@@ -54,11 +54,17 @@ namespace LongoMatch.Gui.Dialog
 		{
 			Gdk.Key key = evnt.Key;
 			ModifierType modifier = evnt.State;
-
-			if ((modifier & (ModifierType.Mod1Mask | ModifierType.ShiftMask)) != 0
+			
+			// Only react to {Shift|Alt|Ctrl}+key
+			// Ctrl is a modifier to select single keys
+			// Combination are allowed with Alt and Shift (Ctrl is not allowed to avoid
+			// conflicts with menus shortcuts)
+			if ((modifier & (ModifierType.Mod1Mask | ModifierType.ShiftMask | ModifierType.ControlMask)) != 0
 			                && key != Gdk.Key.Shift_L
 			                && key != Gdk.Key.Shift_R
-			                && key != Gdk.Key.Alt_L)
+			                && key != Gdk.Key.Alt_L
+			                && key != Gdk.Key.Control_L
+			                && key != Gdk.Key.Control_R)
 			{
 				hotKey.Key = key;
 				hotKey.Modifier = modifier & (ModifierType.Mod1Mask | ModifierType.ShiftMask);
diff --git a/LongoMatch/Handlers/HotKeysManager.cs b/LongoMatch/Handlers/HotKeysManager.cs
index b6e8b2b..e584c03 100644
--- a/LongoMatch/Handlers/HotKeysManager.cs
+++ b/LongoMatch/Handlers/HotKeysManager.cs
@@ -39,6 +39,7 @@ namespace LongoMatch.Handlers
 			dic = new Dictionary<HotKey,int>();
 		}
 
+		// Set the active Hotkeys for the current project
 		public Sections Sections {
 			set {
 				dic.Clear();
@@ -52,22 +53,18 @@ namespace LongoMatch.Handlers
 			}
 		}
 
+		// Listen to key press events and fire a newMarkEvent event if the key combination
+		// is associated to a Category
 		public void KeyListener(object sender, KeyPressEventArgs args) {
-			if ((args.Event.State  & (ModifierType.Mod1Mask | ModifierType.Mod5Mask | ModifierType.ShiftMask)) != 0) {
-				int section=-1;
-				HotKey hotkey = new HotKey();
-				hotkey.Key=args.Event.Key;
-				hotkey.Modifier=args.Event.State & (ModifierType.Mod1Mask | ModifierType.Mod5Mask | ModifierType.ShiftMask);
-				if (dic.TryGetValue(hotkey,out section)) {
-					if (newMarkEvent != null) {
-						newMarkEvent(section);
-					}
+			int section=-1;
+			HotKey hotkey = new HotKey();
+			hotkey.Key=args.Event.Key;
+			hotkey.Modifier=args.Event.State & (ModifierType.Mod1Mask | ModifierType.Mod5Mask | ModifierType.ShiftMask);
+			if (dic.TryGetValue(hotkey,out section)) {
+				if (newMarkEvent != null) {
+					newMarkEvent(section);
 				}
 			}
 		}
-
-
-
-
 	}
 }
diff --git a/LongoMatch/Time/HotKey.cs b/LongoMatch/Time/HotKey.cs
index 0e6735b..682d3de 100644
--- a/LongoMatch/Time/HotKey.cs
+++ b/LongoMatch/Time/HotKey.cs
@@ -126,11 +126,13 @@ namespace LongoMatch.TimeNodes
 			if (!Defined)
 				return Catalog.GetString("Not defined");
 			if (Modifier == ModifierType.Mod1Mask)
-				modifierS = "Alt";
+				modifierS = "<Alt>+";
 			else if (Modifier == ModifierType.ShiftMask)
-				modifierS = "Shift";
+				modifierS = "<Shift>+";
+			else if (modifier == -1)
+				modifierS = "";
 
-			return string.Format("<{0}>+{1}", modifierS,(Key.ToString()).ToLower());
+			return string.Format("{0}{1}", modifierS,(Key.ToString()).ToLower());
 		}
 		#endregion	
 	}
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs
index 7af65ae..567f6e0 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs
@@ -35,7 +35,7 @@ namespace LongoMatch.Gui.Dialog {
             // Container child dialog1_VBox.Gtk.Box+BoxChild
             this.label1 = new Gtk.Label();
             this.label1.Name = "label1";
-            this.label1.LabelProp = Mono.Unix.Catalog.GetString("Press a key combination using  Shift or Alt keys");
+            this.label1.LabelProp = Mono.Unix.Catalog.GetString("Press a key combination using  Shift+key or Alt+key.\nHotkeys with a single key are also allowed with Ctrl+key.");
             w1.Add(this.label1);
             Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(w1[this.label1]));
             w2.Position = 0;
@@ -61,7 +61,7 @@ namespace LongoMatch.Gui.Dialog {
                 this.Child.ShowAll();
             }
             this.DefaultWidth = 385;
-            this.DefaultHeight = 79;
+            this.DefaultHeight = 94;
             this.Show();
         }
     }
diff --git a/LongoMatch/gtk-gui/gui.stetic b/LongoMatch/gtk-gui/gui.stetic
index d6b5425..9ea5b41 100644
--- a/LongoMatch/gtk-gui/gui.stetic
+++ b/LongoMatch/gtk-gui/gui.stetic
@@ -3331,7 +3331,7 @@ You can download it using this direct link:</property>
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.HotKeySelectorDialog" design-size="385 79">
+  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.HotKeySelectorDialog" design-size="385 94">
     <property name="MemberName" />
     <property name="Title" translatable="yes">Select a HotKey</property>
     <property name="Icon">stock:longomatch Dialog</property>
@@ -3349,7 +3349,8 @@ You can download it using this direct link:</property>
         <child>
           <widget class="Gtk.Label" id="label1">
             <property name="MemberName" />
-            <property name="LabelProp" translatable="yes">Press a key combination using  Shift or Alt keys</property>
+            <property name="LabelProp" translatable="yes">Press a key combination using  Shift+key or Alt+key.
+Hotkeys with a single key are also allowed with Ctrl+key.</property>
           </widget>
           <packing>
             <property name="Position">0</property>



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