[Geany] Plugin keybindings support in SVN

Jeff Pohlmeyer yetanothergeek at xxxxx
Thu Mar 13 09:43:54 UTC 2008


On Wed, Mar 12, 2008 at 12:30 PM, Nick Treleaven
<nick.treleaven at btinternet.com> wrote:

>  I've just merged plugin keybindings support into the trunk.

Excellent!!!

I hooked this API up to the Lua plugin, and already it is working!

Now users can list a few of their favorite scripts in
~/.geany/plugins/geanylua/hotkeys.cfg and the entries
will show up in Geany's Edit->Preferences->Keybindings
window.


But that leaves me with some questions...

Since the number of bindings needs to be pre-determined at
compile time, I currently allow for a maximum of five script
bindings - Does that sound like a reasonable number?

Also, I need to allow for the possibility that some users
won't have any scripts assigned, and others might have less
than the maximum. So that leaves me with some potentially
empty KeyBinding structures. I don't see where this would
be a problem except that g_key_file_set_string() complains
about NULL key names, so at the very least the name field
needs to have some value.


So for the empty entries, I can just do something like:

  p_keybindings->set_item(plugin_key_group,
    5, NULL, 0, 0, "lua_key_5", NULL, NULL);

That seems to work fine, except that I end up with blank rows
in the Edit->Preferences->Keybindings window.


So I wonder if it would be OK to change the init_keybindings()
in geany/src/prefs.c to show only enries with non-null labels,
e.g:

+ if ( kb->label != NULL )
+ {
    key_string = gtk_accelerator_name(kb->key, kb->mods);
    gtk_tree_store_append(store, &iter, &parent);
    gtk_tree_store_set(store, &iter, KB_TREE_ACTION, kb->label,
      KB_TREE_SHORTCUT, key_string, KB_TREE_INDEX, i, -1);
    g_free(key_string);
+ }



Also (slightly off topic) I noticed that the htmlchars
plugin behaves badly when it is unloaded/reloaded from
the plugin manager.

It needs this line at the end of cleanup()
+  sc_dialog = NULL;


 - Jeff



More information about the Users mailing list