From 14e661f9fddc3045815050ca3a29bcd7bf3da094 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Thu, 27 Sep 2007 11:13:59 +0000 Subject: [PATCH] Add enable_vte_bash_keys keybindings.conf hidden pref in [Settings]. Refactor keybindings_init(). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1911 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 7 +++++++ src/keybindings.c | 39 ++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb4eb554..61f82001 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-09-27 Nick Treleaven + + * src/keybindings.c: + Add enable_vte_bash_keys keybindings.conf hidden pref in [Settings]. + Refactor keybindings_init(). + + 2007-09-26 Nick Treleaven * src/keybindings.c: diff --git a/src/keybindings.c b/src/keybindings.c index 5406e40e..8dfd7178 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -46,7 +46,8 @@ #include "vte.h" -const gboolean swap_alt_tab_order = FALSE; +static const gboolean swap_alt_tab_order = FALSE; +static gboolean enable_vte_bash_keys; /* simple convenience function to allocate and fill the struct */ @@ -105,15 +106,8 @@ static void cb_func_current_word(guint key_id); static void keybindings_add_accels(); -void keybindings_init(void) +static void init_default_kb() { - gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL); - gchar *val; - guint i; - guint key; - GdkModifierType mods; - GKeyFile *config = g_key_file_new(); - // init all fields of keys with default values keys[GEANY_KEYS_MENU_NEW] = fill(cb_func_file_action, GDK_n, GDK_CONTROL_MASK, "menu_new", _("New")); @@ -324,6 +318,17 @@ void keybindings_init(void) 0, 0, "popup_gototagdeclaration", _("Go to Tag Declaration")); keys[GEANY_KEYS_POPUP_CONTEXTACTION] = fill(cb_func_current_word, 0, 0, "popup_contextaction", _("Context Action")); +} + + +static void load_user_kb() +{ + gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL); + gchar *val; + guint i; + guint key; + GdkModifierType mods; + GKeyFile *config = g_key_file_new(); // now load user defined keys if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL)) @@ -340,6 +345,17 @@ void keybindings_init(void) g_free(val); } } + enable_vte_bash_keys = + utils_get_setting_boolean(config, "Settings", "enable_vte_bash_keys", TRUE); + g_free(configfile); + g_key_file_free(config); +} + + +void keybindings_init(void) +{ + init_default_kb(); + load_user_kb(); // set section name keys[GEANY_KEYS_MENU_NEW]->section = _("File menu"); @@ -354,9 +370,6 @@ void keybindings_init(void) keys[GEANY_KEYS_EDIT_TOGGLECASE]->section = _("Editing commands"); keys[GEANY_KEYS_EDIT_AUTOCOMPLETE]->section = _("Tag commands"); - g_free(configfile); - g_key_file_free(config); - keybindings_add_accels(); } @@ -728,7 +741,7 @@ gboolean keybindings_got_event(GtkWidget *widget, GdkEventKey *event, gpointer u event->state -= GDK_MOD2_MASK; // special cases - if (check_vte(event, keyval)) + if (enable_vte_bash_keys && check_vte(event, keyval)) return FALSE; if (check_construct_completion(event)) return TRUE;