From 45cb63b3872c0443edb0d0cd29f5b17764f534f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Wed, 15 Mar 2017 21:32:06 +0100 Subject: [PATCH] Export keybindings_load_keyfile() for plugins This allows plugins to reload keybindings later during their execution. For more info see the comment in the commit. --- src/keybindings.c | 9 +++++++++ src/keybindings.h | 4 ++-- src/plugindata.h | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/keybindings.c b/src/keybindings.c index 72a9e4a8bf..00465825f4 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -824,6 +824,15 @@ static void apply_kb_accel(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer u } +/** Reloads keybinding settings from configuration file. Normally plugins do + * not need to call this function as it is called automatically when a the + * plugin is activated. However, plugins which need to create keybindings + * dynamically and reload them when needed should call this function after + * all keybindings have been updated with plugin_set_key_group() and + * keybindings_set_item() calls - this makes sure that the corresponding user + * keybinding shortcuts are applied. + * @since 1.31. */ +GEANY_API_SYMBOL void keybindings_load_keyfile(void) { load_user_kb(); diff --git a/src/keybindings.h b/src/keybindings.h index aa2afef096..fa4e9b11af 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -293,6 +293,8 @@ GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id); GdkModifierType keybindings_get_modifiers(GdkModifierType mods); +void keybindings_load_keyfile(void); + #ifdef GEANY_PRIVATE extern GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */ @@ -300,8 +302,6 @@ extern GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */ void keybindings_init(void); -void keybindings_load_keyfile(void); - void keybindings_free(void); GeanyKeyGroup *keybindings_get_core_group(guint id); diff --git a/src/plugindata.h b/src/plugindata.h index 6a021556c4..fb06a512aa 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -59,7 +59,7 @@ G_BEGIN_DECLS * @warning You should not test for values below 200 as previously * @c GEANY_API_VERSION was defined as an enum value, not a macro. */ -#define GEANY_API_VERSION 230 +#define GEANY_API_VERSION 231 /* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins * with GTK3-linked Geany leads to crash */