Revision: 1579 http://svn.sourceforge.net/geany/?rev=1579&view=rev Author: eht16 Date: 2007-05-26 08:09:06 -0700 (Sat, 26 May 2007)
Log Message: ----------- Use current locale as default encoding for new files. Don't keep comments in configuration file to work around a bug in newer GLib versions. If config file doesn't exist, try to load a global one from $prefix/share/geany/. Don't create an empty geany.conf as write test, use access() instead.
Modified Paths: -------------- trunk/ChangeLog trunk/src/keyfile.c trunk/src/utils.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-26 12:13:53 UTC (rev 1578) +++ trunk/ChangeLog 2007-05-26 15:09:06 UTC (rev 1579) @@ -8,6 +8,14 @@
* src/filetypes.c: Ignore case of filename extensions on Windows. * src/ui_utils.c: Add missing header file. + * src/keyfile.c: + Use current locale as default encoding for new files. + Don't keep comments in configuration file to work around a bug in + newer GLib versions. + If config file doesn't exist, try to load a global one from + $prefix/share/geany/. + * src/utils.c: + Don't create an empty geany.conf as write test, use access() instead.
2007-05-25 Enrico Tröger enrico.troeger@uvena.de
Modified: trunk/src/keyfile.c =================================================================== --- trunk/src/keyfile.c 2007-05-26 12:13:53 UTC (rev 1578) +++ trunk/src/keyfile.c 2007-05-26 15:09:06 UTC (rev 1579) @@ -138,22 +138,14 @@
void configuration_save() { - gboolean config_exists; GKeyFile *config = g_key_file_new(); gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); gchar *data; GtkTextBuffer *buffer; GtkTextIter start, end;
- config_exists = g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL); + g_key_file_load_from_file(config, configfile, 0, NULL);
- if (!config_exists) - { - gchar *start_comm = g_strdup_printf(_("%s configuration file, edit as you need"), PACKAGE); - g_key_file_set_comment(config, NULL, NULL, start_comm, NULL); - g_free(start_comm); - } - // gets the text from the scribble textview buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble"))); gtk_text_buffer_get_bounds(buffer, &start, &end); @@ -350,16 +342,23 @@
gboolean configuration_load() { - gboolean config_exists; guint geo_len; gint *geo; gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); gchar *tmp_string, *tmp_string2; + const gchar *default_charset = NULL; GKeyFile *config = g_key_file_new(); GError *error = NULL;
- config_exists = g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL); + if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK)) + { // config file does not (yet) exist, so try to load a global config file which may be + // created by distributors + geany_debug("No config file found, try to use global configuration."); + setptr(configfile, g_strconcat(app->datadir, G_DIR_SEPARATOR_S "geany.conf", NULL)); + }
+ g_key_file_load_from_file(config, configfile, 0, NULL); + app->toolbar_visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE); { GtkIconSize tb_iconsize; @@ -435,8 +434,10 @@
app->pref_editor_tab_width = utils_get_setting_integer(config, PACKAGE, "pref_editor_tab_width", 4); app->pref_editor_use_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_use_tabs", TRUE); + // use current locale encoding as default for new files (should be in most cases UTF-8) + g_get_charset(&default_charset); tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_encoding", - encodings[GEANY_ENCODING_UTF_8].charset); + default_charset); if (tmp_string) { const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2007-05-26 12:13:53 UTC (rev 1578) +++ trunk/src/utils.c 2007-05-26 15:09:06 UTC (rev 1579) @@ -810,13 +810,7 @@
if (error_nr == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS)) { // try to write geany.conf - error_nr = utils_write_file(conf_file, ""); - - if (error_nr == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS)) - { // check whether write test was successful, otherwise directory is not writable - geany_debug("The chosen configuration directory is not writable."); - errno = EPERM; - } + error_nr = access(app->configdir, W_OK); }
// make subdir for filetype definitions
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.