Friday, June 1, 2007

Key Reassignment

So the first part of my project this summer is to work into Finch the ability to (re)bind keys to actions. So far I haven't done much productive work because I'm still learning how the API works. As it stands now, I have built a window that flows from a window listing the actions available to the current widget and the key bindings associated with those actions.

When I started working, the window listing the key assignments and their associated actions was already created. The user was able to hit a key combination (Alt-/) and it would come up showing a listing for the widget currently in focus. The user was able to scroll up and down the list, but it was merely informational. I took this and added the ability to hit on a given keystroke/actions pair. Pressing on a pair triggers the creation of a new window that prompts the user to type in a new key combination to be bound to the action. It's a pretty simple concept, one that most who have dealt with modifying shortcuts for a window manager have seen before.

The hard part I'm still trying to figure out is how to gather all the needed information I'll need when the rebinding call occurs. I need the following information: key combination, the class object for the widget, callback function for the action, name for the action, and an optional list of parameters to pass to the callback function. The key combination is trivial, I grab it from the user and store it. The class of the widget I can get from the parent window that listed all the keystroke/action pairs. The callback function is tricky, I haven't figured out how to do that yet. The name of the action I can get from the keystroke/action listing window. The parameters I really don't know what to do here. I'm not even sure if any of the actions take parameters at this point. I get the feeling this is just a feature that is available but not being used yet. So I'll have to talk to Sadrul, my mentor.

So as can be seen, all the information I need for the reassignment is available at the start of this process. My only task is to gather it, grab a new key combination from the user and call a register_action method. Depending on how things are implemented, I might have to check to see if another action is bound to that key combination to prevent double assignments. This is another thing I'll have to talk to my mentor about.

I can't wait to get to a point where I can commit my code and have the other developers tell me what is good and what needs to change. I am often stressed about not knowing whether a way of doing something is bad and/or not liked by the Pidgin development team. On the other hand this is causing me to really think about how I do things. So that in the end, if they don't like something I did, I can at least have something to stand on and defend my method. This could possibly even bring a new concept to the team, thus offer change and benefit.

No comments: