Do

Merge lp:~cszikszoy/do/kb-service into lp:do

Proposed by Chris S.
Status: Superseded
Proposed branch: lp:~cszikszoy/do/kb-service
Merge into: lp:do
Diff against target: None lines
To merge this branch: bzr merge lp:~cszikszoy/do/kb-service
Reviewer Review Type Date Requested Status
Do Core Team Pending
Review via email: mp+9183@code.launchpad.net

This proposal has been superseded by a proposal from 2009-07-27.

To post a comment you must log in.
Revision history for this message
Chris S. (cszikszoy) wrote :

This adds a Keybinding service to Do.Platform.

This service is what all other assemblies will interact with to register keys (both internal and with the host OS) to perform specific actions. Keys can now be bound from any other assmebly that references Do.Platform. Also, multiple key combinations can now be registered with the host OS. For example, I've added a new global hotkey, "<Super>period", this will summon do directly in text mode. Using the keybinding service, this can all be done in one line.

The keybinding service consists of an interface in Do.Platform, IKeyBindingService. Next, in Do.Platform.Common an AbstractKeyBindingService is defined. This class implements all of the platform independant code relating to mapping and keeping track of hotkeys. For example, all internal events (anything other than the summon key, basically) get handled by this class. This class defines two abstract methods, RegisterOSKey, and UnRegisterOSKey. These methods should be defined in the platform specific implementation of the Keybinding service which gets placed in Do.Platform.*

Along with creating the keybinging service, I've also edited libdo to return gbooleans when it tries to register or unregister keys. This feedback helpful in determining if we were successful in attempting to register a particular keystring with the host OS. Should the binding of a keystring, the KeybindingService will attempt to use the DefaultKeystring, instead of what's in the preferences.

Finally, I've removed unnecessary files (XKeyBinder.cs & CoreKeyBindings.cs, both in Do) and fixed the KeyBindingTreeview in the preferences widget. Thanks to a tip I saw on a bug report, setting the CellRendererAccelMode to "Other" allows many more keys to be grabbed.

I originally wrote this service as a part of the Windows port, and I've already written the windows specific implementation of KeyBindingService there.

lp:~cszikszoy/do/kb-service updated
1285. By Chris S.

remove debug msg

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

Also, please ignore the Console.WriteLine () on line 1038 of the diff. I removed that in rev 1285, but LP currently doesn't update the merge diff when I add revisions after I proposed the merge.

(Here's to hoping they fix that! https://bugs.launchpad.net/launchpad-code/+bug/392343)

Revision history for this message
David Siegel (djsiegel-deactivatedaccount) wrote :

Awesome.

Revision history for this message
Alex Launi (alexlauni) wrote :

Please remove the <Super>period global keybinding, and then we'll be merge
ready!

--
--Alex Launi

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

I can do that, but I thought it was pretty neat and useful for plugins that primarily use text mode, like Microblogging or Translate. It was also something that I put in there to highlight the capabilities of the new keybinding service, but if you think it should go, I can take it out.

Revision history for this message
Alex Launi (alexlauni) wrote :

On Sat, Jul 25, 2009 at 12:28 AM, Chris S. <email address hidden> wrote:

> I can do that, but I thought it was pretty neat and useful for plugins that
> primarily use text mode, like Microblogging or Translate. It was also
> something that I put in there to highlight the capabilities of the new
> keybinding service, but if you think it should go, I can take it out.
> --
> https://code.edge.launchpad.net/~cszikszoy/do/kb-service/+merge/9183<https://code.edge.launchpad.net/%7Ecszikszoy/do/kb-service/+merge/9183>
> Your team GNOME Do Core Team is subscribed to branch lp:do.
>

I can see why it'd be neat but I don't think it's useful enough to warrant a
second keybinding to summon Do, and has the potential to be more confusing
than useful. I wouldn't be opposed to leaving it in the keybindings UI but
unbound by default, so that power users can bind it if they want. How do you
feel about that?

--
--Alex Launi

lp:~cszikszoy/do/kb-service updated
1286. By Chris S.

change dict to list, leave summon in text mode unbound by default

1287. By Chris S.

merge trunk

1288. By Chris S.

fixes as per Roberts review

1289. By Chris S.

it helps when I save the file _before_ pushing...

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Do.Platform.Linux/Do.Platform.Linux.dll.config.in'
2--- Do.Platform.Linux/Do.Platform.Linux.dll.config.in 1970-01-01 00:00:00 +0000
3+++ Do.Platform.Linux/Do.Platform.Linux.dll.config.in 2009-07-23 07:17:00 +0000
4@@ -0,0 +1,3 @@
5+<configuration>
6+ <dllmap dll="libdo" target="@expanded_libdir@/@PACKAGE@/libdo.so"/>
7+</configuration>
8
9=== modified file 'Do.Platform.Linux/Do.Platform.Linux.mdp'
10--- Do.Platform.Linux/Do.Platform.Linux.mdp 2009-06-26 11:01:40 +0000
11+++ Do.Platform.Linux/Do.Platform.Linux.mdp 2009-07-22 01:12:59 +0000
12@@ -52,6 +52,7 @@
13 <File name="src/Do.Platform/Do.Platform.Linux/NetworkService.cs" subtype="Code" buildaction="Compile" />
14 <File name="src/Do.Widgets/PluginAvailableDialog.cs" subtype="Code" buildaction="Compile" />
15 <File name="gtk-gui/Do.Platform.Linux.PluginAvailableDialog.cs" subtype="Code" buildaction="Compile" />
16+ <File name="src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs" subtype="Code" buildaction="Compile" />
17 </Contents>
18 <References>
19 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
20@@ -71,7 +72,7 @@
21 <ProjectReference type="Project" localcopy="True" refto="Do.Interface.Linux" />
22 <ProjectReference type="Gac" localcopy="True" refto="gnome-vfs-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
23 <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
24+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
25 <ProjectReference type="Gac" localcopy="True" refto="nunit.framework, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
26- <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
27 </References>
28 </Project>
29\ No newline at end of file
30
31=== modified file 'Do.Platform.Linux/Makefile.am'
32--- Do.Platform.Linux/Makefile.am 2009-06-26 11:01:40 +0000
33+++ Do.Platform.Linux/Makefile.am 2009-07-23 07:17:00 +0000
34@@ -7,7 +7,7 @@
35 FILES = \
36 gtk-gui/Do.Platform.Linux.AbstractLoginWidget.cs \
37 gtk-gui/Do.Platform.Linux.PluginAvailableDialog.cs \
38- gtk-gui/generated.cs \
39+ gtk-gui/generated.cs \
40 src/AssemblyInfo.cs \
41 src/Do.Platform/ConsoleCrayon.cs \
42 src/Do.Platform/Do.Platform.Linux/Do.Platform.Linux.DBus/IController.cs \
43@@ -23,6 +23,7 @@
44 src/Do.Platform/Do.Platform.Linux/TrayIconService.cs \
45 src/Do.Platform/Do.Platform.Linux/UniverseFactoryService.cs \
46 src/Do.Platform/Do.Platform.Linux/NetworkService.cs \
47+ src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs \
48 src/Do.Universe/ApplicationItem.cs \
49 src/Do.Universe/CategoryItem.cs \
50 src/Do.Universe/NullApplicationItem.cs \
51@@ -63,3 +64,8 @@
52 Do.Universe \
53 Do.Platform \
54 Do.Interface.Linux
55+
56+CLEANFILES += Do.Platform.Linux.dll.config
57+EXTRA_DIST += Do.Platform.Linux.dll.config.in
58+
59+module_DATA += Do.Platform.Linux.dll.config
60
61=== modified file 'Do.Platform.Linux/Resources/Do.Platform.Linux.addin.xml'
62--- Do.Platform.Linux/Resources/Do.Platform.Linux.addin.xml 2009-06-26 09:44:33 +0000
63+++ Do.Platform.Linux/Resources/Do.Platform.Linux.addin.xml 2009-07-22 01:12:59 +0000
64@@ -22,6 +22,7 @@
65 <Service type="Do.Platform.Linux.NetworkService" />
66 <Service type="Do.Platform.Linux.TrayIconService" />
67 <Service type="Do.Platform.Linux.ConsoleLogService" />
68+ <Service type="Do.Platform.Linux.KeyBindingService" />
69 <Service type="Do.Platform.Linux.EnvironmentService" />
70 <Service type="Do.Platform.Linux.UniverseFactoryService" />
71 <Service type="Do.Platform.Linux.GConfPreferencesService" />
72
73=== added file 'Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs'
74--- Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs 1970-01-01 00:00:00 +0000
75+++ Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs 2009-07-23 07:17:00 +0000
76@@ -0,0 +1,57 @@
77+using System;
78+using System.Linq;
79+using System.Collections.Generic;
80+using System.Runtime.InteropServices;
81+
82+using Mono.Unix;
83+using Gdk;
84+using Do.Platform.Common;
85+
86+namespace Do.Platform.Linux
87+{
88+ class KeyBindingService : AbstractKeyBindingService
89+ {
90+
91+ [DllImport("libdo")]
92+ static extern void gnomedo_keybinder_init ();
93+
94+ [DllImport("libdo")]
95+ static extern bool gnomedo_keybinder_bind (string keystring, BindkeyHandler handler);
96+
97+ [DllImport("libdo")]
98+ static extern bool gnomedo_keybinder_unbind (string keystring, BindkeyHandler handler);
99+
100+ public delegate void BindkeyHandler (string key, IntPtr user_data);
101+
102+ BindkeyHandler key_handler;
103+
104+ public KeyBindingService () : base ()
105+ {
106+ key_handler = new BindkeyHandler (KeybindingPressed);
107+
108+ try {
109+ gnomedo_keybinder_init ();
110+ } catch (DllNotFoundException) {
111+ Log.Error ("libdo not found - keybindings will not work.");
112+ }
113+ }
114+
115+ void KeybindingPressed (string keystring, IntPtr user_data) {
116+ if (Bindings.ContainsKey (keystring)) {
117+ Bindings [keystring].Callback (null);
118+ }
119+ }
120+
121+ public override bool RegisterOSKey (string keyString, EventCallback cb) {
122+ return gnomedo_keybinder_bind (keyString, key_handler);
123+ }
124+
125+ public override bool UnRegisterOSKey (string keyString) {
126+
127+ if (Bindings.ContainsKey (keyString)) {
128+ return gnomedo_keybinder_unbind (keyString, key_handler);
129+ }
130+ return false;
131+ }
132+ }
133+}
134\ No newline at end of file
135
136=== modified file 'Do.Platform/Do.Platform.mdp'
137--- Do.Platform/Do.Platform.mdp 2009-06-26 11:01:40 +0000
138+++ Do.Platform/Do.Platform.mdp 2009-07-23 07:17:00 +0000
139@@ -86,6 +86,10 @@
140 <File name="src/Do.Platform/Do.Platform.Default/PluginManagerService.cs" subtype="Code" buildaction="Compile" />
141 <File name="src/Do.Platform/Do.Platform.ServiceStack/IStrictService.cs" subtype="Code" buildaction="Compile" />
142 <File name="src/Do.Universe/Do.Universe.Common/CopyToClipboardAction.cs" subtype="Code" buildaction="Compile" />
143+ <File name="src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs" subtype="Code" buildaction="Compile" />
144+ <File name="src/Do.Platform/IKeyBindingService.cs" subtype="Code" buildaction="Compile" />
145+ <File name="src/Do.Platform/KeyBinding.cs" subtype="Code" buildaction="Compile" />
146+ <File name="src/Do.Platform/Do.Platform.Default/KeyBindingService.cs" subtype="Code" buildaction="Compile" />
147 </Contents>
148 <References>
149 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
150@@ -95,7 +99,7 @@
151 <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
152 <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
153 <ProjectReference type="Gac" localcopy="True" refto="gnome-vfs-sharp, Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
154+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
155 <ProjectReference type="Gac" localcopy="True" refto="nunit.framework, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
156- <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
157 </References>
158-</Project>
159+</Project>
160\ No newline at end of file
161
162=== modified file 'Do.Platform/Makefile.am'
163--- Do.Platform/Makefile.am 2009-06-26 11:01:40 +0000
164+++ Do.Platform/Makefile.am 2009-07-23 07:17:00 +0000
165@@ -14,6 +14,7 @@
166 src/Do.Platform/Do.Platform.Common/DictionaryPreferencesService.cs \
167 src/Do.Platform/Do.Platform.Common/EventsOnlyNotificationsService.cs \
168 src/Do.Platform/Do.Platform.Common/FileLogService.cs \
169+ src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs \
170 src/Do.Platform/Do.Platform.Default/CoreService.cs \
171 src/Do.Platform/Do.Platform.Default/DefaultApplicationService.cs \
172 src/Do.Platform/Do.Platform.Default/DefaultSystemService.cs \
173@@ -28,6 +29,7 @@
174 src/Do.Platform/Do.Platform.Default/UniverseFactoryService.cs \
175 src/Do.Platform/Do.Platform.Default/WindowingService.cs \
176 src/Do.Platform/Do.Platform.Default/NetworkService.cs \
177+ src/Do.Platform/Do.Platform.Default/KeyBindingService.cs \
178 src/Do.Platform/Do.Platform.Preferences/PreferencesFactory.cs \
179 src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs \
180 src/Do.Platform/Do.Platform.ServiceStack/IInitializedService.cs \
181@@ -57,6 +59,8 @@
182 src/Do.Platform/Services.cs \
183 src/Do.Platform/INetworkService.cs \
184 src/Do.Platform/NetworkStateChangedEventArgs.cs \
185+ src/Do.Platform/IKeyBindingService.cs \
186+ src/Do.Platform/KeyBinding.cs \
187 src/Do.Universe/Do.Universe.Common/EmailAction.cs \
188 src/Do.Universe/Do.Universe.Common/OpenAction.cs \
189 src/Do.Universe/Do.Universe.Common/OpenUrlAction.cs \
190@@ -89,5 +93,6 @@
191 System \
192 System.Core \
193 Mono.Posix \
194+ $(GTK_SHARP_20_LIBS) \
195 $(MONO_ADDINS_LIBS) \
196 $(NUNIT_LIBS)
197
198=== added file 'Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs'
199--- Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 1970-01-01 00:00:00 +0000
200+++ Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-07-23 07:17:00 +0000
201@@ -0,0 +1,102 @@
202+using System;
203+using System.Collections.Generic;
204+using System.Linq;
205+using System.Text;
206+
207+using Do.Platform.Common;
208+
209+namespace Do.Platform.Common
210+{
211+ public abstract class AbstractKeyBindingService : IKeyBindingService
212+ {
213+
214+ public abstract bool RegisterOSKey (string keyString, EventCallback cb);
215+ public abstract bool UnRegisterOSKey (string keyString);
216+
217+ IPreferences prefs;
218+
219+ #region IInitializedService
220+
221+ public void Initialize () {
222+ Bindings = new Dictionary<string, KeyBinding> ();
223+
224+ prefs = Services.Preferences.Get<AbstractKeyBindingService> ();
225+ }
226+
227+ #endregion
228+
229+ #region IKeyBindingService
230+
231+ // keyString -> KeyEvent
232+ public Dictionary<string, KeyBinding> Bindings { get; private set; }
233+
234+ public bool RegisterKeyBinding (KeyBinding binding) {
235+ bool success = true;
236+
237+ //first check if this event is already mapped
238+ if (Bindings.ContainsKey (binding.KeyString)) {
239+ Log<AbstractKeyBindingService>.Error ("'{0}' is already mapped", binding.KeyString);
240+ return false;
241+ }
242+
243+ //try to get the keystring from the prefs. We default to the KeyBinding.KeyString, so we can later check
244+ //if the prefs value matches that, we're using the default, otherwise we're using a user specified value
245+ string prefsKeyString = prefs.Get (binding.Description.Replace (' ', '_'), binding.KeyString);
246+ //if these values don't match then the user has specified a new keystring
247+ //update the KeyEvent then continue
248+ if (prefsKeyString != binding.KeyString)
249+ binding.KeyString = prefsKeyString;
250+
251+ //if we are registering a key with the OS, do something special
252+ if (binding.IsOSKey) {
253+ //try to register the key from the prefs with the OS
254+ success = RegisterOSKey (binding.KeyString, binding.Callback);
255+ //if we fail to register the summon key, try again with the default binding
256+ if (!success && RegisterOSKey (binding.DefaultKeyString, binding.Callback)) {
257+ //if we succeeded now, change the event's keystring
258+ binding.KeyString = binding.DefaultKeyString;
259+ success = true;
260+ }
261+ }
262+
263+ if (success) {
264+ //add the event to our mapped events dict
265+ Bindings.Add (binding.KeyString, binding);
266+ //set the bound keystring in the prefs
267+ SetKeyString (binding, binding.KeyString);
268+ }
269+
270+ return success;
271+ }
272+
273+ public bool SetKeyString (KeyBinding binding, string newKeyString) {
274+ bool success = true;
275+
276+ //if this key should be registered with the OS
277+ if (binding.IsOSKey) {
278+ //remove the old keystring from the OS
279+ UnRegisterOSKey (binding.KeyString);
280+ //register again with the new keystring
281+ success = RegisterOSKey (newKeyString, binding.Callback);
282+ }
283+
284+ if (success) {
285+ //first remove the old binding
286+ Bindings.Remove (binding.KeyString);
287+ //next set the new keystring
288+ binding.KeyString = newKeyString;
289+ //now add it back to the dict of bindings
290+ Bindings.Add (binding.KeyString, binding);
291+
292+ //save the new value in the prefs
293+ prefs.Set (binding.Description.Replace (' ', '_'), binding.KeyString);
294+
295+ Log<AbstractKeyBindingService>.Debug ("Event '{0}' now mapped to: {1}", binding.Description, binding.KeyString);
296+ }
297+
298+ return success;
299+ }
300+
301+ #endregion
302+ }
303+}
304\ No newline at end of file
305
306=== added file 'Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs'
307--- Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 1970-01-01 00:00:00 +0000
308+++ Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 2009-07-23 07:17:00 +0000
309@@ -0,0 +1,23 @@
310+using System;
311+using System.Collections.Generic;
312+using System.Linq;
313+using System.Text;
314+
315+using Do.Platform.Common;
316+
317+namespace Do.Platform.Default
318+{
319+ class KeyBindingService : IKeyBindingService
320+ {
321+ public bool RegisterKeyBinding (KeyBinding evnt) {
322+ Log.Error ("Default keybinding service cannot register key events. {0}", evnt.KeyString);
323+ return false;
324+ }
325+ public bool SetKeyString (KeyBinding binding, string keyString) {
326+ return false;
327+ }
328+ public Dictionary<string, KeyBinding> Bindings { get { return null; } }
329+ public void Initialize () {
330+ }
331+ }
332+}
333
334=== added file 'Do.Platform/src/Do.Platform/IKeyBindingService.cs'
335--- Do.Platform/src/Do.Platform/IKeyBindingService.cs 1970-01-01 00:00:00 +0000
336+++ Do.Platform/src/Do.Platform/IKeyBindingService.cs 2009-07-23 07:17:00 +0000
337@@ -0,0 +1,19 @@
338+using System;
339+using System.Collections.Generic;
340+
341+using Do.Platform.Common;
342+using Do.Platform.ServiceStack;
343+
344+using Gdk;
345+
346+namespace Do.Platform
347+{
348+ public delegate void EventCallback (EventKey evtky);
349+
350+ public interface IKeyBindingService : IInitializedService
351+ {
352+ bool RegisterKeyBinding (KeyBinding evnt);
353+ bool SetKeyString (KeyBinding binding, string keyString);
354+ Dictionary<string, KeyBinding> Bindings { get; }
355+ }
356+}
357
358=== added file 'Do.Platform/src/Do.Platform/KeyBinding.cs'
359--- Do.Platform/src/Do.Platform/KeyBinding.cs 1970-01-01 00:00:00 +0000
360+++ Do.Platform/src/Do.Platform/KeyBinding.cs 2009-07-23 07:17:00 +0000
361@@ -0,0 +1,33 @@
362+using System;
363+using System.Collections.Generic;
364+using System.Linq;
365+using System.Text;
366+
367+using Do.Platform.Common;
368+
369+using Gdk;
370+
371+namespace Do.Platform
372+{
373+ public class KeyBinding
374+ {
375+ public string Description { get; private set; }
376+ public EventCallback Callback { get; private set; }
377+ public string KeyString { get; set; }
378+ public string DefaultKeyString { get; private set; }
379+ public bool IsOSKey { get; private set; }
380+
381+ public KeyBinding (string description, string keyString, EventCallback eventFunc) : this (description, keyString, eventFunc, false)
382+ {
383+ }
384+
385+ public KeyBinding (string description, string keyString, EventCallback eventFunc, bool isoskey)
386+ {
387+ this.Description = description;
388+ this.KeyString = keyString;
389+ this.DefaultKeyString = keyString;
390+ this.Callback = eventFunc;
391+ this.IsOSKey = isoskey;
392+ }
393+ }
394+}
395\ No newline at end of file
396
397=== modified file 'Do.Platform/src/Do.Platform/Services.cs'
398--- Do.Platform/src/Do.Platform/Services.cs 2009-06-26 11:01:40 +0000
399+++ Do.Platform/src/Do.Platform/Services.cs 2009-07-22 01:12:59 +0000
400@@ -38,6 +38,7 @@
401 static INetworkService network;
402 static IWindowingService windowing;
403 static AbstractSystemService system;
404+ static IKeyBindingService keybinder;
405 static IEnumerable<ILogService> logs;
406 static PreferencesFactory preferences;
407 static IEnvironmentService environment;
408@@ -198,6 +199,7 @@
409 return package_manager;
410 }
411 }
412+
413 public static IPluginManagerService PluginManager {
414 get {
415 if (plugin_manager == null)
416@@ -205,6 +207,14 @@
417 return plugin_manager;
418 }
419 }
420+
421+ public static IKeyBindingService Keybinder {
422+ get {
423+ if (keybinder == null)
424+ keybinder = LocateService<IKeyBindingService, Default.KeyBindingService> ();
425+ return keybinder;
426+ }
427+ }
428
429 public static PreferencesFactory Preferences {
430
431
432=== removed file 'Do/Do.exe.config.in'
433--- Do/Do.exe.config.in 2008-04-27 01:12:26 +0000
434+++ Do/Do.exe.config.in 1970-01-01 00:00:00 +0000
435@@ -1,4 +0,0 @@
436-<configuration>
437- <dllmap dll="libc" target="libc.so.6"/>
438- <dllmap dll="libdo" target="@expanded_libdir@/@PACKAGE@/libdo.so"/>
439-</configuration>
440
441=== modified file 'Do/Makefile.am'
442--- Do/Makefile.am 2009-06-26 11:01:40 +0000
443+++ Do/Makefile.am 2009-07-23 09:29:41 +0000
444@@ -16,7 +16,6 @@
445 gtk-gui/generated.cs \
446 src/AssemblyInfo.cs \
447 src/CorePreferences.cs \
448- src/CoreKeybindings.cs \
449 src/Do.Core/Do.Core.Addins/AddinClassifier.cs \
450 src/Do.Core/Do.Core.Addins/CommunityAddinClassifier.cs \
451 src/Do.Core/Do.Core.Addins/GreedyAddinClassifier.cs \
452@@ -73,8 +72,7 @@
453 src/Mono.Addins/AddinExtensions.cs \
454 src/Mono.Addins/Mono.Addins.Setup/AddinRepositoryEntryExtensions.cs \
455 src/PathExtensions.cs \
456- src/Util.cs \
457- src/XKeybinder.cs
458+ src/Util.cs
459
460 RESOURCES = \
461 gtk-gui/gui.stetic \
462@@ -103,10 +101,10 @@
463 # Extra rules for our binary, not worth factoring out
464 #
465
466-CLEANFILES += Do.exe.config gnome-do
467-EXTRA_DIST += Do.exe.config.in gnome-do.in Do.addins
468+CLEANFILES += gnome-do
469+EXTRA_DIST += gnome-do.in Do.addins
470
471-module_DATA += Do.exe.config Do.addins
472+module_DATA += Do.addins
473 bin_SCRIPTS = gnome-do
474
475 MCS_FLAGS += -unsafe
476
477=== modified file 'Do/gtk-gui/gui.stetic'
478--- Do/gtk-gui/gui.stetic 2009-06-26 11:01:40 +0000
479+++ Do/gtk-gui/gui.stetic 2009-07-23 07:17:00 +0000
480@@ -5,9 +5,6 @@
481 <target-gtk-version>2.12</target-gtk-version>
482 </configuration>
483 <import>
484- <widget-library name="../../Do.Platform.Linux/bin/Debug/Do.Platform.Linux.dll" />
485- <widget-library name="../../Do.Interface.Linux/bin/Debug/Do.Interface.Linux.dll" />
486- <widget-library name="../../Do.Interface.Linux.AnimationBase/bin/Debug/Do.Interface.Linux.AnimationBase.dll" />
487 <widget-library name="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
488 <widget-library name="../bin/Debug/Do.exe" internal="true" />
489 </import>
490@@ -136,6 +133,7 @@
491 <property name="Position">0</property>
492 <property name="AutoSize">False</property>
493 <property name="Expand">False</property>
494+ <property name="Fill">False</property>
495 </packing>
496 </child>
497 <child>
498@@ -143,7 +141,8 @@
499 <property name="MemberName" />
500 <property name="Ypad">1</property>
501 <property name="Xalign">0</property>
502- <property name="LabelProp" translatable="yes">To edit a shortcut, double-click it and type a new one.</property>
503+ <property name="LabelProp" translatable="yes">To edit a shortcut, double-click it and type a new one.
504+To restore a shortcut to the default, double click and press Backspace.</property>
505 <property name="Wrap">True</property>
506 </widget>
507 <packing>
508
509=== removed file 'Do/src/CoreKeybindings.cs'
510--- Do/src/CoreKeybindings.cs 2009-03-28 23:09:02 +0000
511+++ Do/src/CoreKeybindings.cs 1970-01-01 00:00:00 +0000
512@@ -1,230 +0,0 @@
513-
514-/* Keybindings.cs
515- *
516- * GNOME Do is the legal property of its developers. Please refer to the
517- * COPYRIGHT file distributed with this
518- * source distribution.
519- *
520- * This program is free software: you can redistribute it and/or modify
521- * it under the terms of the GNU General Public License as published by
522- * the Free Software Foundation, either version 3 of the License, or
523- * (at your option) any later version.
524- *
525- * This program is distributed in the hope that it will be useful,
526- * but WITHOUT ANY WARRANTY; without even the implied warranty of
527- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
528- * GNU General Public License for more details.
529- *
530- * You should have received a copy of the GNU General Public License
531- * along with this program. If not, see <http://www.gnu.org/licenses/>.
532- */
533-
534-using System;
535-using System.Linq;
536-using System.Collections;
537-using System.Collections.Generic;
538-using Env = System.Environment;
539-
540-using Do.Platform;
541-
542-namespace Do
543-{
544-
545- class CoreKeybindings
546- {
547- Dictionary<string, string> KeycodeMap ; // keybinding -> shortcut name
548- Dictionary<string, Shortcut> ShortcutMap ; // shortcut name -> shortcut
549- Dictionary<string, string> DefaultShortcutMap ; // default keybinding -> shortcut name
550-
551- IPreferences Preferences { get; set; }
552-
553- public ArrayList Shortcuts ;
554- public Dictionary<string, List<KeyChangedCb>> PreferencesCbs;
555- public delegate void KeyChangedCb (object sender, PreferencesChangedEventArgs e);
556-
557- public CoreKeybindings ()
558- {
559-
560- Preferences = Services.Preferences.Get<CoreKeybindings> ();
561- Preferences.PreferencesChanged += PreferencesChanged;
562-
563- Shortcuts = new ArrayList ();
564- KeycodeMap = new Dictionary<string, string> (); // keybinding -> shortcut name
565- ShortcutMap = new Dictionary<string, Shortcut> (); // shortcut name -> shortcut
566- DefaultShortcutMap = new Dictionary<string, string> (); // default keybinding -> shortcut name
567- PreferencesCbs = new Dictionary<string, List<KeyChangedCb>> ();
568-
569- Initialize ();
570- }
571-
572- public void Initialize ()
573- {
574- // Read all values out of preferences and populate the KeybindingMap
575- ReadShortcuts ();
576- }
577-
578- public bool RegisterShortcut (Shortcut sc, string defaultBinding)
579- {
580- if (!RegisterShortcut (sc))
581- return false;
582- if (!BindDefault (sc, defaultBinding))
583- return false;
584- return true;
585- }
586-
587- public bool RegisterShortcut (Shortcut sc)
588- {
589- if (Shortcuts.Contains (sc) || ShortcutMap.ContainsKey (sc.ShortcutName))
590- return false;
591-
592- Shortcuts.Add (sc);
593- ShortcutMap [sc.ShortcutName] = sc;
594- PreferencesCbs [sc.ShortcutName] = new List<KeyChangedCb> ();
595- SaveShortcuts ();
596- return true;
597- }
598-
599- public Shortcut GetShortcutByKeycode (string keycode)
600- {
601- if (!KeycodeMap.ContainsKey (keycode))
602- return null;
603-
604- string scname = KeycodeMap [keycode];
605-
606- if (!ShortcutMap.ContainsKey (scname))
607- return null;
608-
609- return ShortcutMap [scname];
610-
611- }
612-
613- public string GetKeybinding (Shortcut sc)
614- {
615- return GetKeybinding (sc.ShortcutName);
616- }
617-
618- public string GetKeybinding (string sc)
619- {
620-
621- foreach (KeyValuePair<string, string> entry in KeycodeMap) {
622- if (entry.Value == sc)
623- return entry.Key;
624- }
625- return null;
626- }
627-
628- public string GetDefaultKeybinding (Shortcut sc)
629- {
630- return GetDefaultKeybinding (sc.ShortcutName);
631- }
632-
633- public string GetDefaultKeybinding (string sc)
634- {
635- foreach (KeyValuePair<string, string> entry in DefaultShortcutMap) {
636- if (entry.Value == sc)
637- return entry.Key;
638- }
639- return null;
640- }
641-
642-
643- public bool BindShortcut (Shortcut sc, string keycode)
644- {
645- // Add this function to our keybinding map
646- return BindShortcut (sc.ShortcutName, keycode);
647-
648- }
649-
650- public bool BindShortcut (string sc, string keycode)
651- {
652- string oldcode = GetKeybinding (sc);
653- if (oldcode != null)
654- KeycodeMap.Remove (oldcode); // remove the old keybinding from the map
655-
656- KeycodeMap [keycode] = sc;
657- Preferences.Set (sc, keycode);
658-
659- return true;
660- }
661-
662- // Add Default Keycode mapping - used for resetting to default or not overwriting read values
663- public bool BindDefault (Shortcut sc, string keycode)
664- {
665- return BindDefault (sc.ShortcutName, keycode);
666-
667- }
668-
669- public bool BindDefault (string sc, string keycode)
670- {
671-
672- string assigned_keycode = GetKeybinding (sc);
673- if (assigned_keycode == null) {
674- // Put this shortcut in the mapping
675- BindShortcut (sc, keycode);
676- }
677-
678- DefaultShortcutMap [keycode] = sc;
679- return true;
680-
681- }
682-
683- public bool UnregisterShortcut (Shortcut sc)
684- {
685- if (!Shortcuts.Contains (sc))
686- return false;
687-
688- Shortcuts.Remove (sc);
689- ShortcutMap.Remove (sc.ShortcutName);
690- SaveShortcuts ();
691- return true;
692- }
693-
694- public bool RegisterNotification (Shortcut sc, KeyChangedCb cb)
695- {
696- return RegisterNotification (sc.ShortcutName, cb);
697- }
698-
699- public bool RegisterNotification (string scname, KeyChangedCb cb)
700- {
701- PreferencesCbs [scname].Add (cb);
702- return true;
703- }
704-
705- void SaveShortcuts ()
706- {
707- string scstring = "";
708- foreach (Shortcut sc in Shortcuts) {
709- scstring += sc.ShortcutName.Trim () + ",";
710- }
711- Preferences.Set ("RegisteredShortcuts", scstring);
712- }
713-
714- void ReadShortcuts ()
715- {
716- string scstring = Preferences.Get ("RegisteredShortcuts", "").Trim ();
717- if (scstring == "")
718- return;
719-
720- foreach (string sc in scstring.Split (',')) {
721- if (sc.Trim () == "")
722- continue;
723-
724- string keycode = Preferences.Get (sc, "");
725- if (keycode != "")
726- BindShortcut (sc, keycode);
727- }
728- }
729-
730- void PreferencesChanged (object sender, PreferencesChangedEventArgs e)
731- {
732-
733- if (PreferencesCbs.ContainsKey (e.Key)) {
734- foreach (KeyChangedCb cb in PreferencesCbs [e.Key]) {
735- cb (this, e);
736- }
737- }
738- }
739-
740- }
741-
742-}
743
744=== modified file 'Do/src/Do.Core/Controller.cs'
745--- Do/src/Do.Core/Controller.cs 2009-06-24 01:42:21 +0000
746+++ Do/src/Do.Core/Controller.cs 2009-07-23 09:14:01 +0000
747@@ -30,6 +30,7 @@
748 using Do.UI;
749 using Do.Universe;
750 using Do.Platform;
751+using Do.Platform.Common;
752 using Do.Interface;
753
754 namespace Do.Core
755@@ -108,96 +109,37 @@
756 Screen.Default.CompositedChanged += OnCompositingChanged;
757
758 // Register Shortcuts
759- // TODO: Localize the text here.
760- // Previous shortcuts
761- Do.Keybindings.RegisterShortcut (
762- new Shortcut ("SummonKey",
763- Catalog.GetString ("Summon GNOME Do"),
764- OnSummonKeyPressEvent),
765- "<Super>space");
766- Do.Keybindings.RegisterShortcut (
767- new Shortcut ("TextModeKey",
768- Catalog.GetString ("Enter text mode"),
769- OnTextModePressEvent),
770- "period");
771- // New shortcuts
772- Do.Keybindings.RegisterShortcut (
773- new Shortcut ("CopyKey",
774- Catalog.GetString ("Copy Text"),
775- OnCopyEvent),
776- "<Control>c");
777- Do.Keybindings.RegisterShortcut (
778- new Shortcut ("PasteKey",
779- Catalog.GetString ("Paste Text"),
780- OnPasteEvent),
781- "<Control>v");
782- Do.Keybindings.RegisterShortcut (
783- new Shortcut ("AlternateEscapeKey",
784- Catalog.GetString ("Alternate Escape"),
785- OnEscapeKeyPressEvent));
786- Do.Keybindings.RegisterShortcut (
787- new Shortcut ("AlternateActivateKey",
788- Catalog.GetString ("Alternate Activate"),
789- OnActivateKeyPressEvent));
790- Do.Keybindings.RegisterShortcut (
791- new Shortcut ("AlternateDeleteKey",
792- Catalog.GetString ("Alternate Delete"),
793- OnDeleteKeyPressEvent));
794- Do.Keybindings.RegisterShortcut (
795- new Shortcut ("ShiftTabKey",
796- Catalog.GetString ("Previous Pane"),
797- OnShiftTabKeyPressEvent),
798- "ISO_Left_Tab");
799- Do.Keybindings.RegisterShortcut (
800- new Shortcut ("TabKey",
801- Catalog.GetString ("Next Pane"),
802- OnTabKeyPressEvent),
803- "Tab");
804- Do.Keybindings.RegisterShortcut (
805- new Shortcut ("UpKey",
806- Catalog.GetString ("Previous Result"),
807- OnUpKeyPressEvent),
808- "Up");
809- Do.Keybindings.RegisterShortcut (
810- new Shortcut ("DownKey",
811- Catalog.GetString ("Next Result"),
812- OnDownKeyPressEvent),
813- "Down");
814- Do.Keybindings.RegisterShortcut (
815- new Shortcut ("HomeKey",
816- Catalog.GetString ("First Result"),
817- OnHomeKeyPressEvent),
818- "Home");
819- Do.Keybindings.RegisterShortcut (
820- new Shortcut ("EndKey",
821- Catalog.GetString ("Last Result"),
822- OnEndKeyPressEvent),
823- "End");
824- Do.Keybindings.RegisterShortcut (
825- new Shortcut ("PageUpKey",
826- Catalog.GetString ("Previous 5 Results"),
827- OnPageUpKeyPressEvent),
828- "Page_Up");
829- Do.Keybindings.RegisterShortcut (
830- new Shortcut ("PageDownKey",
831- Catalog.GetString ("Next 5 Results"),
832- OnPageDownKeyPressEvent),
833- "Page_Down");
834- Do.Keybindings.RegisterShortcut (
835- new Shortcut ("LeftKey",
836- Catalog.GetString ("Step out of Item"),
837- OnLeftKeyPressEvent),
838- "Left");
839- Do.Keybindings.RegisterShortcut (
840- new Shortcut ("RightKey",
841- Catalog.GetString ("Browse Into Item"),
842- OnRightKeyPressEvent),
843- "Right");
844- Do.Keybindings.RegisterShortcut (
845- new Shortcut ("CommaKey",
846- Catalog.GetString ("Multiple selection"),
847- OnSelectionKeyPressEvent),
848- "comma");
849+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Enter Text Mode"), "period",
850+ OnTextModePressEvent));
851+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Copy to Clipboard"), "<Control>c",
852+ OnCopyEvent));
853+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Paste Current Text"), "<Control>v",
854+ OnPasteEvent));
855+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Pane"), "<Shift>Tab",
856+ OnPreviousPanePressEvent));
857+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Pane"), "Tab",
858+ OnNextPanePressEvent));
859+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Item"), "Up",
860+ OnUpKeyPressEvent));
861+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Item"), "Down",
862+ OnDownKeyPressEvent));
863+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("First Item"), "Home",
864+ OnHomeKeyPressEvent));
865+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Last Item"), "End",
866+ OnEndKeyPressEvent));
867+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous 5 Results"), "Page_Up",
868+ OnPageUpKeyPressEvent));
869+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next 5 Results"), "Page_Down",
870+ OnPageDownKeyPressEvent));
871+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Out of Item"), "Left",
872+ OnLeftKeyPressEvent));
873+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Browse Into Item"), "Right",
874+ OnRightKeyPressEvent));
875+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Select Multiple Items"), "comma",
876+ OnSelectionKeyPressEvent));
877+ //summon in text mode
878+ Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon in Text Mode"), "<Super>period",
879+ delegate { this.Summon (); SearchController.TextMode = true; UpdatePane (CurrentPane); } , true));
880 }
881
882 void OnSummoned ()
883@@ -507,13 +449,10 @@
884 } else if (key == Key.Delete ||
885 key == Key.BackSpace) {
886 OnDeleteKeyPressEvent (evnt);
887- } else {
888+ } else if (Services.Keybinder.Bindings.ContainsKey (KeyEventToString (evnt))) {
889 // User set keybindings
890- Shortcut sc = Do.Keybindings.GetShortcutByKeycode (KeyEventToString (evnt));
891- if (sc != null) {
892- sc.Callback (evnt);
893- return;
894- }
895+ Services.Keybinder.Bindings [KeyEventToString (evnt)].Callback (evnt);
896+ } else {
897 OnInputKeyPressEvent (evnt);
898 }
899 }
900@@ -648,7 +587,7 @@
901 if (SearchController.ItemChildSearch ()) GrowResults ();
902 }
903
904- void OnTabKeyPressEvent (EventKey evnt)
905+ void OnNextPanePressEvent (EventKey evnt)
906 {
907 im_context.Reset ();
908 ShrinkResults ();
909@@ -661,7 +600,7 @@
910 UpdatePane (CurrentPane);
911 }
912
913- void OnShiftTabKeyPressEvent (EventKey evnt)
914+ void OnPreviousPanePressEvent (EventKey evnt)
915 {
916 im_context.Reset ();
917 ShrinkResults ();
918@@ -760,7 +699,14 @@
919 if ((evnt.State & ModifierType.Mod1Mask) != 0) {
920 modifier += "<Alt>";
921 }
922- return modifier + evnt.Key.ToString ();
923+ if ((evnt.State & ModifierType.ShiftMask) != 0) {
924+ modifier += "<Shift>";
925+ //if we're pressing shift, and the key is ISO_Left_Tab,
926+ //just make it Tab
927+ if (evnt.Key == Key.ISO_Left_Tab)
928+ return string.Format ("{0}{1}", modifier, Key.Tab);
929+ }
930+ return string.Format ("{0}{1}", modifier, evnt.Key.ToString ());
931 }
932 #endregion
933
934
935=== modified file 'Do/src/Do.UI/KeybindingTreeView.cs'
936--- Do/src/Do.UI/KeybindingTreeView.cs 2009-06-20 04:30:05 +0000
937+++ Do/src/Do.UI/KeybindingTreeView.cs 2009-07-23 09:14:01 +0000
938@@ -20,40 +20,41 @@
939
940
941 using System;
942+using System.Linq;
943+
944 using Gtk;
945 using Mono.Unix;
946
947+using Do.Platform;
948+using Do.Platform.Common;
949+
950 namespace Do.UI
951 {
952 public class KeybindingTreeView : TreeView
953 {
954 enum Column {
955 Action = 0,
956+ BoundKeyString,
957+ DefaultKeybinding,
958 Binding,
959- DefaultKeybinding,
960- ShortcutName,
961 NumColumns
962 }
963
964 public KeybindingTreeView ()
965 {
966- Model = new ListStore (typeof (string), typeof (string), typeof (string), typeof (string));
967+ Model = new ListStore (typeof (string), typeof (string), typeof (string), typeof (KeyBinding));
968
969 CellRendererText actionCell = new CellRendererText ();
970 actionCell.Width = 150;
971 InsertColumn (-1, Catalog.GetString ("Action"), actionCell, "text", (int)Column.Action);
972
973 CellRendererAccel bindingCell = new CellRendererAccel ();
974- bindingCell.AccelMode = CellRendererAccelMode.Gtk;
975+ bindingCell.AccelMode = CellRendererAccelMode.Other;
976 bindingCell.Editable = true;
977 bindingCell.AccelEdited += new AccelEditedHandler (OnAccelEdited);
978 bindingCell.AccelCleared += new AccelClearedHandler (OnAccelCleared);
979- InsertColumn (-1, Catalog.GetString ("Shortcut"), bindingCell, "text", (int)Column.Binding);
980-
981- CellRendererText defaultbindingCell = new CellRendererText ();
982- actionCell.Width = 150;
983-// InsertColumn (-1, Catalog.GetString ("Default Shortcut"), defaultbindingCell, "text", (int)Column.DefaultKeybinding);
984-
985+ InsertColumn (-1, Catalog.GetString ("Shortcut"), bindingCell, "text", (int)Column.BoundKeyString);
986+
987 RowActivated += new RowActivatedHandler (OnRowActivated);
988 ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
989
990@@ -66,9 +67,8 @@
991 ListStore store = Model as ListStore;
992 store.Clear ();
993
994- foreach (Shortcut sc in Do.Keybindings.Shortcuts) {
995- store.AppendValues (sc.FriendlyName, Do.Keybindings.GetKeybinding (sc),
996- Do.Keybindings.GetDefaultKeybinding (sc), sc.ShortcutName);
997+ foreach (KeyBinding binding in Services.Keybinder.Bindings.Values.OrderBy (k => k.Description)) {
998+ store.AppendValues (binding.Description, binding.KeyString, binding.DefaultKeyString, binding);
999 }
1000 }
1001
1002@@ -81,21 +81,21 @@
1003
1004 if (GetPathAtPos ((int) args.Event.X, (int) args.Event.Y,out path)) {
1005 GrabFocus ();
1006- SetCursor (path, GetColumn ((int) Column.Binding), true);
1007+ SetCursor (path, GetColumn ((int) Column.BoundKeyString), true);
1008 }
1009 }
1010
1011 private void OnRowActivated (object o, RowActivatedArgs args)
1012 {
1013 GrabFocus ();
1014- SetCursor (args.Path, GetColumn ((int) Column.Binding), true);
1015+ SetCursor (args.Path, GetColumn ((int) Column.BoundKeyString), true);
1016 }
1017
1018 private bool ClearPreviousBinding (TreeModel model, TreePath path, TreeIter treeiter, string keyBinding)
1019 {
1020- string binding = model.GetValue (treeiter, (int) Column.Binding) as string;
1021+ string binding = model.GetValue (treeiter, (int) Column.BoundKeyString) as string;
1022 if (binding == keyBinding) {
1023- model.SetValue (treeiter, (int) Column.Binding, "");
1024+ model.SetValue (treeiter, (int) Column.BoundKeyString, "");
1025 }
1026 return false;
1027 }
1028@@ -110,10 +110,18 @@
1029
1030 string realKey = Gtk.Accelerator.Name (args.AccelKey, args.AccelMods);
1031
1032+ if (args.AccelKey == (uint) Gdk.Key.Super_L) {
1033+ //setting CellRenderAccelMode to "Other" ignores the Super key as a modifier
1034+ //this prevents us from grabbing _only_ the Super key.
1035+ return;
1036+ }
1037+
1038+ Console.WriteLine ("key: {0}, mods: {1}", args.AccelKey, args.AccelMods);
1039+
1040 // Look for any other rows that have the same binding and then zero that binding out
1041 Model.Foreach ((model, path, treeiter) => ClearPreviousBinding (model, path, treeiter, realKey));
1042
1043- store.SetValue (iter, (int) Column.Binding, realKey);
1044+ store.SetValue (iter, (int) Column.BoundKeyString, realKey);
1045
1046 SaveBindings ();
1047 }
1048@@ -127,9 +135,9 @@
1049 store.GetIter (out iter, new TreePath (args.PathString));
1050 try {
1051 string defaultVal = store.GetValue (iter, (int) Column.DefaultKeybinding).ToString ();
1052- store.SetValue (iter, (int) Column.Binding, defaultVal);
1053+ store.SetValue (iter, (int) Column.BoundKeyString, defaultVal);
1054 } catch (Exception e) {
1055- store.SetValue (iter, (int) Column.Binding, "");
1056+ store.SetValue (iter, (int) Column.BoundKeyString, "");
1057 }
1058
1059 SaveBindings ();
1060@@ -142,12 +150,17 @@
1061
1062 private bool SaveBindingsForeachFunc (TreeModel model, TreePath path, TreeIter iter)
1063 {
1064- string binding, shortcutname;
1065- binding = model.GetValue (iter, (int) Column.Binding) as string;
1066- shortcutname = model.GetValue (iter, (int) Column.ShortcutName) as string;
1067-
1068- if (binding != null && binding != "DISABLED" && binding != Do.Keybindings.GetKeybinding (shortcutname))
1069- Do.Keybindings.BindShortcut (shortcutname, binding);
1070+ string newKeyString = model.GetValue (iter, (int) Column.BoundKeyString) as string;
1071+ KeyBinding binding = model.GetValue (iter, (int) Column.Binding) as KeyBinding;
1072+
1073+ if (newKeyString != null) {
1074+ //try to save
1075+ if (!Services.Keybinder.SetKeyString (binding, newKeyString)) {
1076+ //if we fail reset to the default value
1077+ model.SetValue (iter, (int) Column.BoundKeyString, binding.DefaultKeyString);
1078+ Services.Keybinder.SetKeyString (binding, binding.DefaultKeyString);
1079+ }
1080+ }
1081 return false;
1082 }
1083
1084
1085=== modified file 'Do/src/Do.cs'
1086--- Do/src/Do.cs 2009-06-21 02:20:30 +0000
1087+++ Do/src/Do.cs 2009-07-23 09:29:41 +0000
1088@@ -27,18 +27,17 @@
1089 using Do.UI;
1090 using Do.Core;
1091 using Do.Platform;
1092+using Do.Platform.Common;
1093
1094 namespace Do {
1095
1096 static class Do {
1097
1098- static XKeybinder keybinder;
1099 static Controller controller;
1100 static UniverseManager universe_manager;
1101
1102- public static CorePreferences Preferences { get; private set; }
1103- public static CoreKeybindings Keybindings { get; private set; }
1104-
1105+ public static CorePreferences Preferences { get; private set; }
1106+
1107 internal static void Main (string [] args)
1108 {
1109 Catalog.Init ("gnome-do", AssemblyInfo.LocaleDirectory);
1110@@ -55,8 +54,6 @@
1111
1112 Preferences = new CorePreferences ();
1113
1114- Keybindings = new CoreKeybindings ();
1115-
1116 // Now we can set the preferred log level.
1117 if (Preferences.QuietStart)
1118 Log.DisplayLevel = LogLevel.Error;
1119@@ -73,12 +70,11 @@
1120 Controller.Initialize ();
1121 UniverseManager.Initialize ();
1122
1123- keybinder = new XKeybinder ();
1124 SetupKeybindings ();
1125
1126 if (!Preferences.QuietStart)
1127 Controller.Summon ();
1128-
1129+
1130 Gtk.Application.Run ();
1131
1132 RelevanceProvider.Serialize (RelevanceProvider.DefaultProvider);
1133@@ -100,37 +96,17 @@
1134 return universe_manager;
1135 }
1136 }
1137-
1138- static void SummonKeyCb (object sender, PreferencesChangedEventArgs e)
1139- {
1140- try {
1141- if (e.OldValue != null)
1142- keybinder.Unbind (e.OldValue as string);
1143- keybinder.Bind (Keybindings.GetKeybinding ("SummonKey"), OnActivate);
1144- } catch (Exception ex) {
1145- Log.Error ("Could not bind summon key: {0}", ex.Message);
1146- Log.Debug (ex.StackTrace);
1147- }
1148-
1149- }
1150
1151 static void SetupKeybindings ()
1152 {
1153 try {
1154- keybinder.Bind (Keybindings.GetKeybinding ("SummonKey"), OnActivate);
1155+ if (!Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon Do"),
1156+ "<Super>space", delegate { controller.Summon (); }, true)))
1157+ throw new Exception ();
1158 } catch (Exception e) {
1159- Log.Error ("Could not bind summon key: {0}", e.Message);
1160+ Log.Fatal ("Could not bind summon key!");
1161 Log.Debug (e.StackTrace);
1162 }
1163-
1164- // Watch preferences for changes to the keybinding so we
1165- // can change the binding when the user reassigns it.
1166- Keybindings.RegisterNotification ("SummonKey", SummonKeyCb);
1167- }
1168-
1169- static void OnActivate (object sender, EventArgs e)
1170- {
1171- controller.Summon ();
1172 }
1173 }
1174 }
1175
1176=== removed file 'Do/src/XKeybinder.cs'
1177--- Do/src/XKeybinder.cs 2008-12-18 18:39:06 +0000
1178+++ Do/src/XKeybinder.cs 1970-01-01 00:00:00 +0000
1179@@ -1,103 +0,0 @@
1180-/*****************************************************************************/
1181-/* XKeybinder.cs - Keybinding code taken from Tomboy */
1182-/* Copyright (C) 2004-2007 Alex Graveley <alex@beatniksoftware.com> */
1183-/* */
1184-/* This library is free software; you can redistribute it and/or */
1185-/* modify it under the terms of the GNU Lesser General Public */
1186-/* License as published by the Free Software Foundation; either */
1187-/* version 2.1 of the License, or (at your option) any later version. */
1188-/* */
1189-/* This library is distributed in the hope that it will be useful, */
1190-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
1191-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
1192-/* Lesser General Public License for more details. */
1193-/* */
1194-/* You should have received a copy of the GNU Lesser General Public */
1195-/* License along with this library; if not, write to the Free Software */
1196-/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1197-/*****************************************************************************/
1198-
1199-using System;
1200-using System.Collections;
1201-using System.Runtime.InteropServices;
1202-using Mono.Unix;
1203-
1204-using Do.Platform;
1205-
1206-namespace Do
1207-{
1208- public class XKeybinder
1209- {
1210- [DllImport("libdo")]
1211- static extern void gnomedo_keybinder_init ();
1212-
1213- [DllImport("libdo")]
1214- static extern void gnomedo_keybinder_bind (string keystring, BindkeyHandler handler);
1215-
1216- [DllImport("libdo")]
1217- static extern void gnomedo_keybinder_unbind (string keystring, BindkeyHandler handler);
1218-
1219- public delegate void BindkeyHandler (string key, IntPtr user_data);
1220-
1221- ArrayList bindings;
1222- BindkeyHandler key_handler;
1223-
1224- struct Binding {
1225- internal string keystring;
1226- internal EventHandler handler;
1227- }
1228-
1229- public XKeybinder ()
1230- : base ()
1231- {
1232- bindings = new ArrayList ();
1233- key_handler = new BindkeyHandler (KeybindingPressed);
1234-
1235- try {
1236- gnomedo_keybinder_init ();
1237- } catch (DllNotFoundException) {
1238- Log.Error ("libdo not found - keybindings will not work.");
1239- }
1240- }
1241-
1242- void KeybindingPressed (string keystring, IntPtr user_data)
1243- {
1244- foreach (Binding bind in bindings) {
1245- if (bind.keystring == keystring) {
1246- bind.handler (this, new EventArgs ());
1247- }
1248- }
1249- }
1250-
1251- public void Bind (string keystring, EventHandler handler)
1252- {
1253- Binding bind = new Binding ();
1254- bind.keystring = keystring;
1255- bind.handler = handler;
1256- bindings.Add (bind);
1257-
1258- gnomedo_keybinder_bind (bind.keystring, key_handler);
1259- }
1260-
1261- public void Unbind (string keystring)
1262- {
1263- foreach (Binding bind in bindings) {
1264- if (bind.keystring == keystring) {
1265- gnomedo_keybinder_unbind (bind.keystring, key_handler);
1266-
1267- bindings.Remove (bind);
1268- break;
1269- }
1270- }
1271- }
1272-
1273- public virtual void UnbindAll ()
1274- {
1275- foreach (Binding bind in bindings) {
1276- gnomedo_keybinder_unbind (bind.keystring, key_handler);
1277- }
1278-
1279- bindings.Clear ();
1280- }
1281- }
1282-}
1283
1284=== modified file 'configure.ac'
1285--- configure.ac 2009-07-08 09:33:18 +0000
1286+++ configure.ac 2009-07-23 09:14:01 +0000
1287@@ -134,7 +134,6 @@
1288
1289 AC_CONFIG_FILES([
1290 BundledLibraries/Makefile
1291-Do/Do.exe.config
1292 Do/Makefile
1293 Do/gnome-do
1294 Do/src/AssemblyInfo.cs
1295@@ -152,6 +151,7 @@
1296 Do.Platform/Makefile
1297 Do.Platform/src/AssemblyInfo.cs
1298 Do.Platform.Linux/Makefile
1299+Do.Platform.Linux/Do.Platform.Linux.dll.config
1300 Do.Platform.Linux/src/AssemblyInfo.cs
1301 Do.Platform.Linux.JoliCloud/Makefile
1302 Do.Platform.Linux.JoliCloud/src/AssemblyInfo.cs
1303@@ -201,4 +201,4 @@
1304 Release Build: ${enable_release}
1305 NUnit: ${have_nunit}
1306
1307-EOF
1308\ No newline at end of file
1309+EOF
1310
1311=== modified file 'libdo/keybinder.c'
1312--- libdo/keybinder.c 2008-02-18 14:40:44 +0000
1313+++ libdo/keybinder.c 2009-07-23 07:17:00 +0000
1314@@ -257,7 +257,7 @@
1315 NULL);
1316 }
1317
1318-void
1319+gboolean
1320 gnomedo_keybinder_bind (const char *keystring,
1321 GnomeDoBindkeyHandler handler,
1322 gpointer user_data)
1323@@ -279,9 +279,11 @@
1324 g_free (binding->keystring);
1325 g_free (binding);
1326 }
1327+
1328+ return success;
1329 }
1330
1331-void
1332+gboolean
1333 gnomedo_keybinder_unbind (const char *keystring,
1334 GnomeDoBindkeyHandler handler)
1335 {
1336@@ -302,6 +304,8 @@
1337 g_free (binding);
1338 break;
1339 }
1340+
1341+ return TRUE;
1342 }
1343
1344 /*
1345
1346=== modified file 'libdo/keybinder.h'
1347--- libdo/keybinder.h 2008-02-18 14:40:44 +0000
1348+++ libdo/keybinder.h 2009-07-23 07:17:00 +0000
1349@@ -32,11 +32,11 @@
1350
1351 void gnomedo_keybinder_init (void);
1352
1353-void gnomedo_keybinder_bind (const char *keystring,
1354+gboolean gnomedo_keybinder_bind (const char *keystring,
1355 GnomeDoBindkeyHandler handler,
1356 gpointer user_data);
1357
1358-void gnomedo_keybinder_unbind (const char *keystring,
1359+gboolean gnomedo_keybinder_unbind (const char *keystring,
1360 GnomeDoBindkeyHandler handler);
1361
1362 gboolean gnomedo_keybinder_is_modifier (guint keycode);