Check plugin keybinding group name is valid.
Ignore plugin keybinding groups with no elements defined. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2339 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
6ad9240601
commit
4472929989
@ -3,6 +3,9 @@
|
||||
* src/plugindata.h, doc/plugins.dox:
|
||||
Update documentation for plugin_key_group[] to mention declaring it
|
||||
manually.
|
||||
* src/keybindings.c, src/keybindings.h, src/plugins.c, doc/plugins.dox:
|
||||
Check plugin keybinding group name is valid.
|
||||
Ignore plugin keybinding groups with no elements defined.
|
||||
|
||||
|
||||
2008-03-13 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
@ -68,7 +68,11 @@
|
||||
* Most plugins should use the PLUGIN_KEY_GROUP() macro to define it. However,
|
||||
* its fields are not read until after init() is called for the plugin, so it
|
||||
* is possible to setup a variable number of keybindings, e.g. based on the
|
||||
* plugin's configuration file.
|
||||
* plugin's configuration file settings.
|
||||
* - The @c name field must not be empty or match Geany's default group name.
|
||||
* - Ths @c label field is set by Geany after init() is called to the name of the
|
||||
* plugin.
|
||||
*
|
||||
* @note This is a single element array for implementation reasons,
|
||||
* but you can treat it like a pointer.
|
||||
*
|
||||
|
@ -49,7 +49,7 @@
|
||||
GPtrArray *keybinding_groups; /* array of KeyBindingGroup pointers */
|
||||
|
||||
/* keyfile group name for non-plugin KB groups */
|
||||
static const gchar default_group_name[] = "Bindings";
|
||||
const gchar keybindings_keyfile_group_name[] = "Bindings";
|
||||
|
||||
static const gboolean swap_alt_tab_order = FALSE;
|
||||
|
||||
@ -143,7 +143,7 @@ static KeyBindingGroup *add_kb_group(KeyBindingGroup *group,
|
||||
* add_kb_group(&groups[GEANY_KEY_GROUP_FILE], NULL, _("File menu"),
|
||||
* GEANY_KEYS_FILE_COUNT, FILE_keys); */
|
||||
#define ADD_KB_GROUP(group_id, label) \
|
||||
add_kb_group(&groups[GEANY_KEY_GROUP_ ## group_id], default_group_name, label, \
|
||||
add_kb_group(&groups[GEANY_KEY_GROUP_ ## group_id], keybindings_keyfile_group_name, label, \
|
||||
GEANY_KEYS_ ## group_id ## _COUNT, group_id ## _keys)
|
||||
|
||||
/* Init all fields of keys with default values.
|
||||
|
@ -65,6 +65,8 @@ KeyBindingGroup;
|
||||
|
||||
extern GPtrArray *keybinding_groups; /* array of KeyBindingGroup pointers */
|
||||
|
||||
extern const gchar keybindings_keyfile_group_name[];
|
||||
|
||||
|
||||
/** Keybinding group IDs */
|
||||
enum
|
||||
|
@ -342,9 +342,18 @@ static void add_callbacks(Plugin *plugin, GeanyCallback *callbacks)
|
||||
static void
|
||||
add_kb_group(Plugin *plugin)
|
||||
{
|
||||
g_ptr_array_add(keybinding_groups, plugin->key_group);
|
||||
g_return_if_fail(NZV(plugin->key_group->name));
|
||||
g_return_if_fail(! g_str_equal(plugin->key_group->name, keybindings_keyfile_group_name));
|
||||
|
||||
if (plugin->key_group->count == 0)
|
||||
{
|
||||
plugin->key_group = NULL; /* Ignore the group */
|
||||
return;
|
||||
}
|
||||
|
||||
plugin->key_group->label = plugin->info()->name;
|
||||
|
||||
g_ptr_array_add(keybinding_groups, plugin->key_group);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user