On 14-06-06 07:17 AM, Thomas Martitz wrote:
Hello,
based up on Matthew's fine GtkActions branch [1] I think we could
realistically rewrite keybindings.c use GtkAction/accelerators properly.
Currently it re-implements lots of gtk stuff, such as the actual looping
through the known keybindings for the callback when a keybinding
pressed. When this would be rewritten keybindings.c could probably be
half as large (in LOC terms).
The advantage of doing so would be that plugins could register
keybindings simply by providing a GtkAction instance (and optionally a
GtkMenuItem) instead of a plain callback. This would enable to handle
keybindings in a more natural (from a glib/gtk POV) form through
signals. This is especially interesting for non-C plugins because it
easier to support/implement a gobject-based API then a
function-pointer-based one. This is the major reason I'm interested in
this.
We could alternatively add a GtkActionGroup to each GeanyPlugin(Private)
structure so plugins could just add in their own actions and not have
the core even care much. I can imagine something like this:
void plugin_init(GeanyData *unused)
{
GtkAction *action = gtk_action_new("foo", "Foo", "Does foo", NULL);
gtk_action_group_add_action(
plugin_get_action_group(geany_plugin), action);
GtkMenuItem *item = gtk_action_create_menu_item(action);
gtk_menu_shell_append(
GTK_MENU_SHELL(geany_data.main_widgets.tools_menu), item);
gtk_widget_show(item);
// etc...
}
The keybindings editor GUI would then be able to know which actions the
plugin wants managed/edited without requiring any special API functions.
I think it is possible to do this without breaking the API or at least
without actual damage because plugins don't use the fields of
GeanyKeyGroup and GeanyKeyBinding so we can change these structs.
Is such a rewrite desirable, and would it have a realistic chance of
getting merged? I'm asking because I don't want to spend time on this
and never get it merged. Otherwise I would volunteer to do this.
Calling it a re-write will mostly likely not help :)
Cheers,
Matthew Brush
_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel