Dear lazy web,
How can I add some global keybindings in a GTK+ application? Something like GNOME-do does…
Tags: global keybindings, gnome, gtk+
This entry was posted
on Sunday, December 14th, 2008 at 8:32 pm and is filed under General.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.
I don’t know, but the answer lies in the gnome-do source, which you are allowed to read. Tomboy, too.
Read the GNOME-do source code…
Gnome-Do use a lib: libdo which does, I think, what you’re looking for. Check this file: http://bazaar.launchpad.net/~do-core/do/trunk/annotate/628?file_id=keybinder.c-20080218143923-igx29g94mjn48las-5
Hopes it helps.
Why don’t you grab the gnome-do source code and see for yourself? It’s in libdo, you might also want to take a look at tomboy’s they do it too.
The “correct” way is to register them in gnome-keybindings-properties like detailed in http://live.gnome.org/ControlCenter/ApplicationDefinedKeybindings
Please write a patch for gnome-do while you’re at it.
Hmm. Imagine if we could somehow see the source code of GNOME-do… That would be awesome!
I wrote a library to do exactly this. GtkHotkey: https://launchpad.net/gtkhotkey
There’s no good way to do this, your two bizarre hack-ish solutions are:
1. Use gconf and steal one of the metacity keybindings (like Automatix does)
2. Use Tomboy’s .so file (I forget the name), like gnome-do
1. Means that you potentially steamroller over user preferences unless you’re very careful, and you have a (small) chance of not being able to register a keybinding at all. 2. means that you need to depend on code from Tomboy, so you either have to depend on Tomboy directly (like gnome-do used to) or copy code from them and keep it updated manually (like gnome-do now does).
Probably a bit rough but the only thing that I can think of:
make the application remote controllable with libunique or dbus, provide it with some command line option to do what you want and bind those to metacity global keybindings setting the relevant keys in /apps/metacity/global_key_bindings and /apps/metacity/keybinding_commands.
Any better idea?
I think it’s with http://library.gnome.org/devel/gdk/stable/GdkDisplay.html#gdk-display-add-client-message-filter
Then there’s some copy-paste code available for actually capturing the key, look for tomboykeybinder.c
Kind of irrelevant, but one thing I don’t get is how Gnome’s keyboard shortcuts completely fail at using the super keys, but both Compiz Fusion and Gnome Do don’t have any trouble at all…
Thanks for this post! I discovered gnome-keybindings which right what I’m looking for.
No well, that wasn’t what I was looking for really. It’s only an entry in gnome-control-center, nothing more. I think i’ll go for the egg!
Bruno Boaventura (brunobol) is proudly powered by
WordPress MU running on GNOME Blogs. Create a new blog and join in the fun!
and Comments (RSS).