Do

Merge lp://qastaging/~alexlauni/do/keybindings-organized into lp://qastaging/do

Proposed by Alex Launi
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~alexlauni/do/keybindings-organized
Merge into: lp://qastaging/do
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~alexlauni/do/keybindings-organized
Reviewer Review Type Date Requested Status
Do Core Team Pending
Review via email: mp+9605@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

This organizes the keybindings in a more logical fashion. It depends on my pending merge to fix the summon not closing do regression.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs'
2--- Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-08-01 22:07:20 +0000
3+++ Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-08-03 21:28:26 +0000
4@@ -15,21 +15,22 @@
5
6 IPreferences prefs;
7
8- #region IInitializedService
9+#region IInitializedService
10
11- public void Initialize () {
12- Bindings = new List<KeyBinding> ();
13-
14+ public void Initialize ()
15+ {
16+ Bindings = new List<KeyBinding> ();
17 prefs = Services.Preferences.Get<AbstractKeyBindingService> ();
18 }
19
20- #endregion
21+#endregion
22
23- #region IKeyBindingService
24+#region IKeyBindingService
25
26 public List<KeyBinding> Bindings { get; private set; }
27
28- public bool RegisterKeyBinding (KeyBinding binding) {
29+ public bool RegisterKeyBinding (KeyBinding binding)
30+ {
31 //first check if this keystring is already used
32 if (Bindings.Any (k => k.KeyString == binding.KeyString)) {
33 Log<AbstractKeyBindingService>.Error ("Key '{0}' is already mapped.", binding.KeyString);
34@@ -49,14 +50,8 @@
35 //try to register the key from the prefs with the OS
36 if (!RegisterOSKey (binding.KeyString, binding.Callback)) {
37 //if we fail to register the summon key, try again with the default binding
38- if (RegisterOSKey (binding.DefaultKeyString, binding.Callback)) {
39- //if we succeeded now, change the event's keystring
40- binding.KeyString = binding.DefaultKeyString;
41- } else {
42- //if we still didn't succeed, return false
43- return false;
44- }
45-
46+ RegisterOSKey (binding.DefaultKeyString, binding.Callback);
47+ binding.KeyString = binding.DefaultKeyString;
48 }
49 }
50
51@@ -68,7 +63,8 @@
52 return true;
53 }
54
55- public bool SetKeyString (KeyBinding binding, string newKeyString) {
56+ public bool SetKeyString (KeyBinding binding, string newKeyString)
57+ {
58 //first check if this keystring exists
59 if (!Bindings.Any (k => k.KeyString == binding.KeyString)) {
60 Log<AbstractKeyBindingService>.Error ("Key '{0}' is not mapped.", binding.KeyString);
61@@ -94,7 +90,6 @@
62
63 return true;
64 }
65-
66- #endregion
67+#endregion
68 }
69 }
70\ No newline at end of file
71
72=== modified file 'Do/src/Do.Core/Controller.cs'
73--- Do/src/Do.Core/Controller.cs 2009-08-03 20:33:51 +0000
74+++ Do/src/Do.Core/Controller.cs 2009-08-03 21:28:26 +0000
75@@ -109,37 +109,53 @@
76 Screen.Default.CompositedChanged += OnCompositingChanged;
77
78 // Register Shortcuts
79+ SetupKeybindings ();
80+ }
81+
82+ void SetupKeybindings ()
83+ {
84+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon Do"), "<Super>space",
85+ OnSummonKeyPressEvent, true));
86+
87+ // this keybinding is disabled by default, obviously
88+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon into Text Mode"),
89+ Catalog.GetString( "Disabled"), OnTextModeSummonKeyPressEvent, true));
90+
91 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Enter Text Mode"), "period",
92 OnTextModePressEvent));
93+
94 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Copy to Clipboard"), "<Control>c",
95 OnCopyEvent));
96- Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Paste Current Text"), "<Control>v",
97+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Paste from Clipboard"), "<Control>v",
98 OnPasteEvent));
99+
100 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Pane"), "<Shift>Tab",
101 OnPreviousPanePressEvent));
102 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Pane"), "Tab",
103 OnNextPanePressEvent));
104+
105 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Item"), "Up",
106 OnUpKeyPressEvent));
107 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Item"), "Down",
108 OnDownKeyPressEvent));
109+
110 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("First Item"), "Home",
111 OnHomeKeyPressEvent));
112 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Last Item"), "End",
113 OnEndKeyPressEvent));
114+
115 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous 5 Results"), "Page_Up",
116 OnPageUpKeyPressEvent));
117 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next 5 Results"), "Page_Down",
118 OnPageDownKeyPressEvent));
119+
120 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Out of Item"), "Left",
121 OnLeftKeyPressEvent));
122- Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Browse Into Item"), "Right",
123+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Into Item"), "Right",
124 OnRightKeyPressEvent));
125+
126 Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Select Multiple Items"), "comma",
127 OnSelectionKeyPressEvent));
128- //summon in text mode
129- Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon in Text Mode"), "",
130- delegate { this.Summon (); SearchController.TextMode = true; UpdatePane (CurrentPane); } , true));
131 }
132
133 void OnSummoned ()
134@@ -508,8 +524,19 @@
135
136 void OnSummonKeyPressEvent (EventKey evnt)
137 {
138- Reset ();
139- Vanish ();
140+ if (IsSummoned) {
141+ Reset ();
142+ Vanish ();
143+ } else {
144+ Summon ();
145+ }
146+ }
147+
148+ void OnTextModeSummonKeyPressEvent (EventKey evnt)
149+ {
150+ Summon ();
151+ SearchController.TextMode = true;
152+ UpdatePane (CurrentPane);
153 }
154
155 void OnEscapeKeyPressEvent (EventKey evnt)
156
157=== modified file 'Do/src/Do.UI/KeybindingTreeView.cs'
158--- Do/src/Do.UI/KeybindingTreeView.cs 2009-08-01 22:03:03 +0000
159+++ Do/src/Do.UI/KeybindingTreeView.cs 2009-08-03 21:28:26 +0000
160@@ -45,7 +45,7 @@
161 Model = new ListStore (typeof (string), typeof (string), typeof (string), typeof (KeyBinding));
162
163 CellRendererText actionCell = new CellRendererText ();
164- actionCell.Width = 150;
165+ actionCell.Width = 175;
166 InsertColumn (-1, Catalog.GetString ("Action"), actionCell, "text", (int)Column.Action);
167
168 CellRendererAccel bindingCell = new CellRendererAccel ();
169@@ -67,7 +67,8 @@
170 ListStore store = Model as ListStore;
171 store.Clear ();
172
173- foreach (KeyBinding binding in Services.Keybinder.Bindings.OrderBy (k => k.Description)) {
174+ foreach (KeyBinding binding in Services.Keybinder.Bindings) { //.OrderBy (k => k.Description)) {
175+ Log<KeybindingTreeView>.Debug (binding.Description);
176 store.AppendValues (binding.Description, binding.KeyString, binding.DefaultKeyString, binding);
177 }
178 }
179@@ -161,8 +162,6 @@
180 }
181 }
182 return false;
183- }
184-
185+ }
186 }
187-
188 }
189
190=== modified file 'Do/src/Do.cs'
191--- Do/src/Do.cs 2009-07-23 09:29:41 +0000
192+++ Do/src/Do.cs 2009-08-03 20:31:41 +0000
193@@ -70,8 +70,6 @@
194 Controller.Initialize ();
195 UniverseManager.Initialize ();
196
197- SetupKeybindings ();
198-
199 if (!Preferences.QuietStart)
200 Controller.Summon ();
201
202@@ -96,17 +94,5 @@
203 return universe_manager;
204 }
205 }
206-
207- static void SetupKeybindings ()
208- {
209- try {
210- if (!Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon Do"),
211- "<Super>space", delegate { controller.Summon (); }, true)))
212- throw new Exception ();
213- } catch (Exception e) {
214- Log.Fatal ("Could not bind summon key!");
215- Log.Debug (e.StackTrace);
216- }
217- }
218 }
219 }