Do

Merge lp://qastaging/~cszikszoy/do/kb-disabled-keys into lp://qastaging/do

Proposed by Chris S.
Status: Superseded
Proposed branch: lp://qastaging/~cszikszoy/do/kb-disabled-keys
Merge into: lp://qastaging/do
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~cszikszoy/do/kb-disabled-keys
Reviewer Review Type Date Requested Status
Robert Dyer (community) Approve
Review via email: mp+9884@code.qastaging.launchpad.net

This proposal has been superseded by a proposal from 2009-08-09.

To post a comment you must log in.
Revision history for this message
Robert Dyer (psybers) wrote :

Other than the Console.WriteLine on 226, looks good!

review: Approve
Revision history for this message
Chris S. (cszikszoy) wrote :

> Other than the Console.WriteLine on 226, looks good!
... oh yeah. Thought I got all of those.

Revision history for this message
Chris S. (cszikszoy) wrote :

Actually, I need to hold off on something. I noticed something strange with the page_down key, need to do some testing. When I register that key in the prefs UI, it binds to "Page_Down". But that console.writeline was testing what actual event keystring gets passed when I press the key. Pressing the Page Down key on my keyboard shows the event keystring "Last"...

1290. By Chris S.

make clear (esc) key configurable

1291. By Chris S.

fix issue where keys have the wrong name

1292. By Chris S.

remove debug

1293. By Chris S.

remove more debug

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs'
2--- Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs 2009-08-01 22:03:03 +0000
3+++ Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs 2009-08-08 05:48:10 +0000
4@@ -36,23 +36,24 @@
5 }
6 }
7
8- void KeybindingPressed (string keystring, IntPtr user_data) {
9+ void KeybindingPressed (string keystring, IntPtr user_data)
10+ {
11 if (Bindings.Any (k => k.KeyString == keystring)) {
12 Bindings.First (k => k.KeyString == keystring).Callback (null);
13 }
14 }
15
16- public override bool RegisterOSKey (string keyString, EventCallback cb) {
17+ public override bool RegisterOSKey (string keyString, EventCallback cb)
18+ {
19 if (string.IsNullOrEmpty (keyString) || cb == null)
20 return false;
21 return gnomedo_keybinder_bind (keyString, key_handler);
22 }
23
24- public override bool UnRegisterOSKey (string keyString) {
25-
26- if (Bindings.Any (k => k.KeyString == keyString)) {
27+ public override bool UnRegisterOSKey (string keyString)
28+ {
29+ if (Bindings.Any (k => k.KeyString == keyString))
30 return gnomedo_keybinder_unbind (keyString, key_handler);
31- }
32 return false;
33 }
34 }
35
36=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs'
37--- Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-08-06 15:52:20 +0000
38+++ Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-08-08 05:48:10 +0000
39@@ -33,19 +33,20 @@
40
41 public bool RegisterKeyBinding (KeyBinding binding)
42 {
43- //first check if this keystring is already used
44- if (Bindings.Any (k => k.KeyString == binding.KeyString)) {
45- Log<AbstractKeyBindingService>.Error ("Failed to bind \"{0}\" to \"{1}\"", binding.KeyString);
46- return false;
47- }
48-
49 //try to get the keystring from the prefs. We default to the KeyBinding.KeyString, so we can later check
50 //if the prefs value matches that, we're using the default, otherwise we're using a user specified value
51 string prefsKeyString = prefs.Get (binding.Description.Replace (' ', '_'), binding.KeyString);
52+
53 //if these values don't match then the user has specified a new keystring
54 //update the KeyEvent then continue
55 if (prefsKeyString != binding.KeyString)
56 binding.KeyString = prefsKeyString;
57+
58+ //check if this keystring is already used
59+ if (Bindings.Any (k => k.KeyString == binding.KeyString)) {
60+ Log<AbstractKeyBindingService>.Error ("Key \"{0}\" is already mapped.", binding.KeyString);
61+ binding.KeyString = "";
62+ }
63
64 //if we are registering a key with the OS, do something special
65 if (binding.IsOSKey) {
66@@ -57,7 +58,7 @@
67 } else {
68 Log<AbstractKeyBindingService>.Error ("Failed to bind \"{0}\" to \"{1}\"", binding.Description,
69 binding.KeyString);
70- binding.KeyString = Catalog.GetString ("Disabled");
71+ binding.KeyString = "";
72 }
73 }
74 }
75@@ -73,27 +74,25 @@
76 public bool SetKeyString (KeyBinding binding, string newKeyString)
77 {
78 //first check if this keystring exists
79- if (!Bindings.Any (k => k.KeyString == binding.KeyString)) {
80- Log<AbstractKeyBindingService>.Error ("Failed to bind \"{0}\" to \"{1}\"", binding.KeyString);
81+ if (!Bindings.Any (k => k.KeyString == binding.KeyString))
82 return false;
83- }
84-
85+
86 //if this key should be registered with the OS
87 if (binding.IsOSKey) {
88 //remove the old keystring from the OS
89 UnRegisterOSKey (binding.KeyString);
90- //register again with the new keystring, otherwise bail
91- if (!RegisterOSKey (newKeyString, binding.Callback))
92- return false;
93+ //register again with the new keystring
94+ RegisterOSKey (newKeyString, binding.Callback);
95 }
96
97 //set the new keystring
98- Bindings.First (k => k.KeyString == binding.KeyString).KeyString = newKeyString;
99+ Bindings.First (k => k.Description == binding.Description).KeyString = newKeyString;
100
101 //save the new value in the prefs
102 prefs.Set (binding.Description.Replace (' ', '_'), binding.KeyString);
103
104- Log<AbstractKeyBindingService>.Debug ("\"{0}\" now mapped to \"{1}\"", binding.Description, binding.KeyString);
105+ if (!string.IsNullOrEmpty (binding.KeyString))
106+ Log<AbstractKeyBindingService>.Debug ("\"{0}\" now mapped to \"{1}\"", binding.Description, binding.KeyString);
107
108 return true;
109 }
110
111=== modified file 'Do/src/Do.Core/Controller.cs'
112--- Do/src/Do.Core/Controller.cs 2009-08-06 15:53:55 +0000
113+++ Do/src/Do.Core/Controller.cs 2009-08-08 05:48:10 +0000
114@@ -117,7 +117,7 @@
115 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon Do"), "<Super>space",
116 OnSummonKeyPressEvent, true));
117
118- // this keybinding is disabled by default - note the empty binding
119+ // this keybinding is disabled by default - note the empty keybinding
120 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon in Text Mode"), "",
121 OnTextModeSummonKeyPressEvent, true));
122
123@@ -135,24 +135,24 @@
124 OnNextPanePressEvent));
125
126 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Item"), "Up",
127- OnUpKeyPressEvent));
128+ OnPreviousItemPressEvent));
129 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Item"), "Down",
130- OnDownKeyPressEvent));
131+ OnNextItemPressEvent));
132
133 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("First Item"), "Home",
134- OnHomeKeyPressEvent));
135+ OnFirstItemPressEvent));
136 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Last Item"), "End",
137- OnEndKeyPressEvent));
138+ OnLastItemPressEvent));
139
140 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous 5 Results"), "Page_Up",
141- OnPageUpKeyPressEvent));
142+ OnNextItemPagePressEvent));
143 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next 5 Results"), "Page_Down",
144- OnPageDownKeyPressEvent));
145+ OnPreviousItemPagePressEvent));
146
147 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Out of Item"), "Left",
148- OnLeftKeyPressEvent));
149+ OnStepOutItemPressEvent));
150 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Into Item"), "Right",
151- OnRightKeyPressEvent));
152+ OnStepInItemPressEvent));
153
154 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Select Multiple Items"), "comma",
155 OnSelectionKeyPressEvent));
156@@ -588,7 +588,7 @@
157 }
158 }
159
160- void OnLeftKeyPressEvent (EventKey evnt)
161+ void OnStepOutItemPressEvent (EventKey evnt)
162 {
163 im_context.Reset ();
164 if (!SearchController.Results.Any ()) return;
165@@ -603,7 +603,7 @@
166 }
167
168 // Hmm.
169- void OnRightKeyPressEvent (EventKey evnt)
170+ void OnStepInItemPressEvent (EventKey evnt)
171 {
172 im_context.Reset ();
173 if (!SearchController.Results.Any ()) return;
174@@ -655,7 +655,7 @@
175 UpdatePane (CurrentPane);
176 }
177
178- void OnUpKeyPressEvent (EventKey evnt)
179+ void OnPreviousItemPressEvent (EventKey evnt)
180 {
181 im_context.Reset ();
182 if (!results_grown) {
183@@ -671,7 +671,7 @@
184 }
185 }
186
187- void OnDownKeyPressEvent (EventKey evnt)
188+ void OnNextItemPressEvent (EventKey evnt)
189 {
190 im_context.Reset ();
191 if (!results_grown) {
192@@ -681,25 +681,25 @@
193 SearchController.Cursor++;
194 }
195
196- void OnHomeKeyPressEvent (EventKey evnt)
197+ void OnFirstItemPressEvent (EventKey evnt)
198 {
199 im_context.Reset ();
200 SearchController.Cursor = 0;
201 }
202
203- void OnEndKeyPressEvent (EventKey evnt)
204+ void OnLastItemPressEvent (EventKey evnt)
205 {
206 im_context.Reset ();
207 SearchController.Cursor = SearchController.Results.Count - 1;
208 }
209
210- void OnPageUpKeyPressEvent (EventKey evnt)
211+ void OnNextItemPagePressEvent (EventKey evnt)
212 {
213 im_context.Reset ();
214 SearchController.Cursor -= 5;
215 }
216
217- void OnPageDownKeyPressEvent (EventKey evnt)
218+ void OnPreviousItemPagePressEvent (EventKey evnt)
219 {
220 im_context.Reset ();
221 SearchController.Cursor += 5;
222@@ -733,6 +733,7 @@
223 if (evnt.Key == Key.ISO_Left_Tab)
224 return string.Format ("{0}{1}", modifier, Key.Tab);
225 }
226+ Console.WriteLine (evnt.Key.ToString ());
227 return string.Format ("{0}{1}", modifier, evnt.Key.ToString ());
228 }
229 #endregion
230
231=== modified file 'Do/src/Do.UI/KeybindingTreeView.cs'
232--- Do/src/Do.UI/KeybindingTreeView.cs 2009-08-03 21:28:26 +0000
233+++ Do/src/Do.UI/KeybindingTreeView.cs 2009-08-08 05:48:10 +0000
234@@ -67,9 +67,11 @@
235 ListStore store = Model as ListStore;
236 store.Clear ();
237
238- foreach (KeyBinding binding in Services.Keybinder.Bindings) { //.OrderBy (k => k.Description)) {
239- Log<KeybindingTreeView>.Debug (binding.Description);
240- store.AppendValues (binding.Description, binding.KeyString, binding.DefaultKeyString, binding);
241+ string ks;
242+
243+ foreach (KeyBinding binding in Services.Keybinder.Bindings) {
244+ ks = (string.IsNullOrEmpty (binding.KeyString)) ? Catalog.GetString ("Disabled") : binding.KeyString;
245+ store.AppendValues (binding.Description, ks, binding.DefaultKeyString, binding);
246 }
247 }
248
249@@ -96,7 +98,7 @@
250 {
251 string binding = model.GetValue (treeiter, (int) Column.BoundKeyString) as string;
252 if (binding == keyBinding) {
253- model.SetValue (treeiter, (int) Column.BoundKeyString, "");
254+ model.SetValue (treeiter, (int) Column.BoundKeyString, Catalog.GetString ("Disabled"));
255 }
256 return false;
257 }
258@@ -136,7 +138,7 @@
259 string defaultVal = store.GetValue (iter, (int) Column.DefaultKeybinding).ToString ();
260 store.SetValue (iter, (int) Column.BoundKeyString, defaultVal);
261 } catch (Exception e) {
262- store.SetValue (iter, (int) Column.BoundKeyString, "");
263+ store.SetValue (iter, (int) Column.BoundKeyString, Catalog.GetString ("Disabled"));
264 }
265
266 SaveBindings ();
267@@ -152,6 +154,8 @@
268 string newKeyString = model.GetValue (iter, (int) Column.BoundKeyString) as string;
269 KeyBinding binding = model.GetValue (iter, (int) Column.Binding) as KeyBinding;
270
271+ newKeyString = (newKeyString == Catalog.GetString ("Disabled")) ? "" : newKeyString;
272+
273 //only save if the keystring changed
274 if (newKeyString != null && binding.KeyString != newKeyString) {
275 //try to save