Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Thu, 15 Oct 2015 20:48:08 UTC Commit: a79e888927f3ac1a4cc0bfe1b710a6f41ace7196 https://github.com/geany/geany-plugins/commit/a79e888927f3ac1a4cc0bfe1b710a6...
Log Message: ----------- Addons: Remove hard-coded keybinding count in wrapwords addon
The amount of keybindings in the Addons plugin was hard-coded in the wrapwords addon. Since this is error prone, now the real keybinding count is passed to the wrapwords init function to make the code more robust.
Modified Paths: -------------- addons/src/addons.c addons/src/ao_wrapwords.c addons/src/ao_wrapwords.h
Modified: addons/src/addons.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -291,7 +291,7 @@ void plugin_init(GeanyData *data) ao_blanklines_set_enable(ao_info->strip_trailing_blank_lines);
/* setup keybindings */ - key_group = plugin_set_key_group(geany_plugin, "addons", KB_COUNT+8, NULL); + key_group = plugin_set_key_group(geany_plugin, "addons", KB_COUNT + AO_WORDWRAP_KB_COUNT, NULL); keybindings_set_item(key_group, KB_FOCUS_BOOKMARK_LIST, kb_bmlist_activate, 0, 0, "focus_bookmark_list", _("Focus Bookmark List"), NULL); keybindings_set_item(key_group, KB_FOCUS_TASKS, kb_tasks_activate, @@ -301,7 +301,7 @@ void plugin_init(GeanyData *data) keybindings_set_item(key_group, KB_XMLTAGGING, kb_ao_xmltagging, 0, 0, "xml_tagging", _("Run XML tagging"), NULL);
- ao_enclose_words_init(ao_info->config_file, key_group); + ao_enclose_words_init(ao_info->config_file, key_group, KB_COUNT); ao_enclose_words_set_enabled (ao_info->enable_enclose_words, ao_info->enable_enclose_words_auto);
g_key_file_free(config);
Modified: addons/src/ao_wrapwords.c 9 lines changed, 4 insertions(+), 5 deletions(-) =================================================================== @@ -143,7 +143,7 @@ gboolean on_key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data * Loads the enclosing characters from the config file and sets keybindings. */
-void ao_enclose_words_init (gchar *config_file_name, GeanyKeyGroup *key_group) +void ao_enclose_words_init (gchar *config_file_name, GeanyKeyGroup *key_group, gint ao_kb_count) { GKeyFile *config = g_key_file_new(); gchar key_name[] = "Enclose_x"; @@ -152,14 +152,13 @@ void ao_enclose_words_init (gchar *config_file_name, GeanyKeyGroup *key_group) config_file = g_strdup (config_file_name); g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, NULL);
- for (i = 0; i < 8; i++) + for (i = 0; i < AO_WORDWRAP_KB_COUNT; i++) { key_name [8] = (gchar) (i + '0'); enclose_chars [i] = utils_get_setting_string (config, "addons", key_name, " "); key_name [8] = (gchar) ((i + 1) + '0'); - keybindings_set_item (key_group, i+4, (GeanyKeyCallback) enclose_text_action, 0, 0, key_name, - key_name, NULL); - + keybindings_set_item (key_group, i + ao_kb_count, + (GeanyKeyCallback) enclose_text_action, 0, 0, key_name, key_name, NULL); }
g_key_file_free(config);
Modified: addons/src/ao_wrapwords.h 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -20,8 +20,9 @@ #ifndef __AO_WRAPWORDS_H__ #define __AO_WRAPWORDS_H__
+#define AO_WORDWRAP_KB_COUNT 8
-void ao_enclose_words_init(gchar *, GeanyKeyGroup *); +void ao_enclose_words_init(gchar *, GeanyKeyGroup *, gint); void ao_enclose_words_config(GtkButton *, GtkWidget *); void ao_enclose_words_set_enabled(gboolean, gboolean);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).