Do

Code review comment for lp:~cszikszoy/do/kb-service

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.

« Back to merge proposal