[Geany-devel] Having trouble with keybindings

Lex Trotman elextr at xxxxx
Wed Dec 7 22:00:02 UTC 2011


On Thu, Dec 8, 2011 at 5:04 AM, Nathan Broadbent <nathan.f77 at gmail.com> wrote:
> Hello,
>
> I'm working on the TreeBrowser plugin. I have fixed a few bugs, so I'm
> looking forward to sending pull requests when geany-plugins is on
> github :)
>
> I'm currently trying to add a keybinding for deleting objects from the
> treeview. I have added a KB_DELETE_OBJECT keybinding, and I've mapped
> this to the delete key, which works fine. However, the keybinding for
> the sidebar is still activated when the editor has focus, and I press
> the 'delete' key.
> I would like the keybinding to only activate if the sidebar widget has
> focus (is active). This is also a problem for the 'rename object'
> keybinding that was already there.

Keybindings are global, they don't apply to one widget.

Why is this so?  Because GTK keybinding has changed several times over
the life of Geany so Geany does it itself and so can support a range
of GTK versions.

>
> The last parameter to the 'keybindings_set_item' function is:
> GtkWidget * menu_item  -  "Optional widget to set an accelerator for,
> or NULL."
> I've tried setting this to 'treeview' or 'sidebar_vbox', but that
> doesn't seem to work.

This is the menu_item (which is the parameter name :) to show the
accelerator on, not a widget to apply it to.

>
> I'd be really grateful if someone would be able to help me understand
> how to solve this.
>

You need to use the GTK keybinding facilities to bind keys to widgets.
 But of course you can't use the standard keybinding prefs AFAIK.

Cheers
Lex



More information about the Devel mailing list