Skip to content

Commit

Permalink
Fix existing user's goto tag/move tab workaround (oops)
Browse files Browse the repository at this point in the history
Write an empty keybindings.conf for new users to prevent the workaround
for old defaults being written.

Also remove generated comment in keybindings.conf, this file doesn't
need an explanation as it is generated by Geany.
  • Loading branch information
ntrel committed Mar 20, 2012
1 parent 99e8ed4 commit ec3efe0
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/keybindings.c
Expand Up @@ -656,22 +656,24 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
static void load_user_kb(void)
{
gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL);
gchar *geanyconf = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
GKeyFile *config = g_key_file_new();

/* backwards compatibility with Geany 0.21 defaults */
if (!g_file_test(configfile, G_FILE_TEST_EXISTS) &&
g_file_test(geanyconf, G_FILE_TEST_EXISTS))
if (!g_file_test(configfile, G_FILE_TEST_EXISTS))
{
utils_write_file(configfile, "[Bindings]\n"
gchar *geanyconf = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
const gchar data[] = "[Bindings]\n"
"popup_gototagdefinition=\n"
"edit_transposeline=<Control>t\n"
"edit_movelineup=\n"
"edit_movelinedown=\n"
"move_tableft=<Alt>Page_Up\n"
"move_tabright=<Alt>Page_Down\n");
"move_tabright=<Alt>Page_Down\n";

utils_write_file(configfile, g_file_test(geanyconf, G_FILE_TEST_EXISTS) ?
data : "");
g_free(geanyconf);
}
g_free(geanyconf);

/* now load user defined keys */
if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
Expand Down Expand Up @@ -766,14 +768,7 @@ void keybindings_write_to_file(void)
gchar *data;
GKeyFile *config = g_key_file_new();

/* add comment if the file is newly created */
if (! g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
{
g_key_file_set_comment(config, NULL, NULL,
"Keybindings for Geany\nThe format looks like \"<Control>a\" or \"<Shift><Alt>F1\".\n"
"But you can also change the keys in Geany's preferences dialog.", NULL);
}

g_key_file_load_from_file(config, configfile, 0, NULL);
keybindings_foreach(set_keyfile_kb, config);

/* write the file */
Expand Down

0 comments on commit ec3efe0

Please sign in to comment.