Merge lp:~cszikszoy/do/kb-disabled-keys into lp:do
- kb-disabled-keys
- Merge into trunk
Proposed by
Chris S.
Status: | Superseded |
---|---|
Proposed branch: | lp:~cszikszoy/do/kb-disabled-keys |
Merge into: | lp:do |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~cszikszoy/do/kb-disabled-keys |
Related bugs: |
This proposal supersedes a proposal from 2009-08-08.
This proposal has been superseded by a proposal from 2009-08-09.
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Robert Dyer (psybers) wrote : Posted in a previous version of this proposal | # |
review:
Approve
Revision history for this message
Chris S. (cszikszoy) wrote : Posted in a previous version of this proposal | # |
> 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 : Posted in a previous version of this proposal | # |
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"...
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 22:41:51 +0000 |
114 | @@ -117,13 +117,16 @@ |
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 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Enter Text Mode"), "period", |
124 | OnTextModePressEvent)); |
125 | |
126 | + Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Clear"), "Escape", |
127 | + OnClearKeyPressEvent)); |
128 | + |
129 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Copy to Clipboard"), "<Control>c", |
130 | OnCopyEvent)); |
131 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Paste from Clipboard"), "<Control>v", |
132 | @@ -135,24 +138,24 @@ |
133 | OnNextPanePressEvent)); |
134 | |
135 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Item"), "Up", |
136 | - OnUpKeyPressEvent)); |
137 | + OnPreviousItemPressEvent)); |
138 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Item"), "Down", |
139 | - OnDownKeyPressEvent)); |
140 | + OnNextItemPressEvent)); |
141 | |
142 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("First Item"), "Home", |
143 | - OnHomeKeyPressEvent)); |
144 | + OnFirstItemPressEvent)); |
145 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Last Item"), "End", |
146 | - OnEndKeyPressEvent)); |
147 | + OnLastItemPressEvent)); |
148 | |
149 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous 5 Results"), "Page_Up", |
150 | - OnPageUpKeyPressEvent)); |
151 | + OnNextItemPagePressEvent)); |
152 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next 5 Results"), "Page_Down", |
153 | - OnPageDownKeyPressEvent)); |
154 | + OnPreviousItemPagePressEvent)); |
155 | |
156 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Out of Item"), "Left", |
157 | - OnLeftKeyPressEvent)); |
158 | + OnStepOutItemPressEvent)); |
159 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Into Item"), "Right", |
160 | - OnRightKeyPressEvent)); |
161 | + OnStepInItemPressEvent)); |
162 | |
163 | Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Select Multiple Items"), "comma", |
164 | OnSelectionKeyPressEvent)); |
165 | @@ -453,12 +456,11 @@ |
166 | private void KeyPressWrap (EventKey evnt) |
167 | { |
168 | Key key = (Key) evnt.KeyValue; |
169 | - |
170 | - |
171 | - // Currently - only hardcoded are enter keys, escape and delete/backspace |
172 | - if (key == Key.Escape) { |
173 | - OnEscapeKeyPressEvent (evnt); |
174 | - } else if (key == Key.Return || |
175 | + |
176 | + Console.WriteLine (evnt.Key.ToString ()); |
177 | + |
178 | + // Currently - only hardcoded are enter keys and delete/backspace |
179 | + if (key == Key.Return || |
180 | key == Key.ISO_Enter || |
181 | key == Key.KP_Enter) { |
182 | OnActivateKeyPressEvent (evnt); |
183 | @@ -539,7 +541,7 @@ |
184 | UpdatePane (CurrentPane); |
185 | } |
186 | |
187 | - void OnEscapeKeyPressEvent (EventKey evnt) |
188 | + void OnClearKeyPressEvent (EventKey evnt) |
189 | { |
190 | im_context.Reset (); |
191 | if (SearchController.TextType == TextModeType.Explicit) { |
192 | @@ -588,7 +590,7 @@ |
193 | } |
194 | } |
195 | |
196 | - void OnLeftKeyPressEvent (EventKey evnt) |
197 | + void OnStepOutItemPressEvent (EventKey evnt) |
198 | { |
199 | im_context.Reset (); |
200 | if (!SearchController.Results.Any ()) return; |
201 | @@ -603,7 +605,7 @@ |
202 | } |
203 | |
204 | // Hmm. |
205 | - void OnRightKeyPressEvent (EventKey evnt) |
206 | + void OnStepInItemPressEvent (EventKey evnt) |
207 | { |
208 | im_context.Reset (); |
209 | if (!SearchController.Results.Any ()) return; |
210 | @@ -655,7 +657,7 @@ |
211 | UpdatePane (CurrentPane); |
212 | } |
213 | |
214 | - void OnUpKeyPressEvent (EventKey evnt) |
215 | + void OnPreviousItemPressEvent (EventKey evnt) |
216 | { |
217 | im_context.Reset (); |
218 | if (!results_grown) { |
219 | @@ -671,7 +673,7 @@ |
220 | } |
221 | } |
222 | |
223 | - void OnDownKeyPressEvent (EventKey evnt) |
224 | + void OnNextItemPressEvent (EventKey evnt) |
225 | { |
226 | im_context.Reset (); |
227 | if (!results_grown) { |
228 | @@ -681,25 +683,25 @@ |
229 | SearchController.Cursor++; |
230 | } |
231 | |
232 | - void OnHomeKeyPressEvent (EventKey evnt) |
233 | + void OnFirstItemPressEvent (EventKey evnt) |
234 | { |
235 | im_context.Reset (); |
236 | SearchController.Cursor = 0; |
237 | } |
238 | |
239 | - void OnEndKeyPressEvent (EventKey evnt) |
240 | + void OnLastItemPressEvent (EventKey evnt) |
241 | { |
242 | im_context.Reset (); |
243 | SearchController.Cursor = SearchController.Results.Count - 1; |
244 | } |
245 | |
246 | - void OnPageUpKeyPressEvent (EventKey evnt) |
247 | + void OnNextItemPagePressEvent (EventKey evnt) |
248 | { |
249 | im_context.Reset (); |
250 | SearchController.Cursor -= 5; |
251 | } |
252 | |
253 | - void OnPageDownKeyPressEvent (EventKey evnt) |
254 | + void OnPreviousItemPagePressEvent (EventKey evnt) |
255 | { |
256 | im_context.Reset (); |
257 | SearchController.Cursor += 5; |
258 | @@ -733,7 +735,7 @@ |
259 | if (evnt.Key == Key.ISO_Left_Tab) |
260 | return string.Format ("{0}{1}", modifier, Key.Tab); |
261 | } |
262 | - return string.Format ("{0}{1}", modifier, evnt.Key.ToString ()); |
263 | + return string.Format ("{0}{1}", modifier, Gtk.Accelerator.Name (evnt.KeyValue, Gdk.ModifierType.None)); |
264 | } |
265 | #endregion |
266 | |
267 | |
268 | === modified file 'Do/src/Do.UI/KeybindingTreeView.cs' |
269 | --- Do/src/Do.UI/KeybindingTreeView.cs 2009-08-03 21:28:26 +0000 |
270 | +++ Do/src/Do.UI/KeybindingTreeView.cs 2009-08-08 22:41:51 +0000 |
271 | @@ -67,9 +67,11 @@ |
272 | ListStore store = Model as ListStore; |
273 | store.Clear (); |
274 | |
275 | - foreach (KeyBinding binding in Services.Keybinder.Bindings) { //.OrderBy (k => k.Description)) { |
276 | - Log<KeybindingTreeView>.Debug (binding.Description); |
277 | - store.AppendValues (binding.Description, binding.KeyString, binding.DefaultKeyString, binding); |
278 | + string ks; |
279 | + |
280 | + foreach (KeyBinding binding in Services.Keybinder.Bindings) { |
281 | + ks = (string.IsNullOrEmpty (binding.KeyString)) ? Catalog.GetString ("Disabled") : binding.KeyString; |
282 | + store.AppendValues (binding.Description, ks, binding.DefaultKeyString, binding); |
283 | } |
284 | } |
285 | |
286 | @@ -96,7 +98,7 @@ |
287 | { |
288 | string binding = model.GetValue (treeiter, (int) Column.BoundKeyString) as string; |
289 | if (binding == keyBinding) { |
290 | - model.SetValue (treeiter, (int) Column.BoundKeyString, ""); |
291 | + model.SetValue (treeiter, (int) Column.BoundKeyString, Catalog.GetString ("Disabled")); |
292 | } |
293 | return false; |
294 | } |
295 | @@ -132,11 +134,13 @@ |
296 | |
297 | store = Model as ListStore; |
298 | store.GetIter (out iter, new TreePath (args.PathString)); |
299 | + |
300 | try { |
301 | string defaultVal = store.GetValue (iter, (int) Column.DefaultKeybinding).ToString (); |
302 | + defaultVal = (string.IsNullOrEmpty (defaultVal)) ? Catalog.GetString ("Disabled") : defaultVal; |
303 | store.SetValue (iter, (int) Column.BoundKeyString, defaultVal); |
304 | } catch (Exception e) { |
305 | - store.SetValue (iter, (int) Column.BoundKeyString, ""); |
306 | + store.SetValue (iter, (int) Column.BoundKeyString, Catalog.GetString ("Disabled")); |
307 | } |
308 | |
309 | SaveBindings (); |
310 | @@ -152,6 +156,8 @@ |
311 | string newKeyString = model.GetValue (iter, (int) Column.BoundKeyString) as string; |
312 | KeyBinding binding = model.GetValue (iter, (int) Column.Binding) as KeyBinding; |
313 | |
314 | + newKeyString = (newKeyString == Catalog.GetString ("Disabled")) ? "" : newKeyString; |
315 | + |
316 | //only save if the keystring changed |
317 | if (newKeyString != null && binding.KeyString != newKeyString) { |
318 | //try to save |
Other than the Console.WriteLine on 226, looks good!