Revision: 5121 http://geany.svn.sourceforge.net/geany/?rev=5121&view=rev Author: ntrel Date: 2010-08-10 12:46:30 +0000 (Tue, 10 Aug 2010)
Log Message: ----------- Fix writing the default value when a key is missing for hidden prefs, even if it was overridden when it was originally read.
Modified Paths: -------------- trunk/ChangeLog trunk/src/stash.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-08-10 12:43:30 UTC (rev 5120) +++ trunk/ChangeLog 2010-08-10 12:46:30 UTC (rev 5121) @@ -6,6 +6,9 @@ merged into one enum; the order of keybindings is now just the order they are added to each group. Keybindings can be reordered without breaking the plugin ABI but groups must stay the same. + * src/stash.c: + Fix writing the default value when a key is missing for hidden + prefs, even if it was overridden when it was originally read.
2010-08-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/stash.c =================================================================== --- trunk/src/stash.c 2010-08-10 12:43:30 UTC (rev 5120) +++ trunk/src/stash.c 2010-08-10 12:46:30 UTC (rev 5121) @@ -101,9 +101,9 @@ struct StashPref { GType setting_type; /* e.g. G_TYPE_INT */ - gpointer setting; + gpointer setting; /* Address of a variable */ const gchar *key_name; - gpointer default_value; + gpointer default_value; /* Default value, e.g. (gpointer)1 */ GType widget_type; /* e.g. GTK_TYPE_TOGGLE_BUTTON */ StashWidgetID widget_id; /* (GtkWidget*) or (gchar*) */ gpointer fields; /* extra fields */ @@ -233,15 +233,21 @@
foreach_array(StashPref, entry, group->entries) { - /* don't overwrite write_once prefs */ - if (group->write_once && action == SETTING_WRITE && - g_key_file_has_key(keyfile, group->name, entry->key_name, NULL)) - continue; + gpointer tmp = entry->setting; + /* don't override settings with default values */ if (!group->use_defaults && action == SETTING_READ && !g_key_file_has_key(keyfile, group->name, entry->key_name, NULL)) continue;
+ /* don't overwrite write_once prefs */ + if (group->write_once && action == SETTING_WRITE) + { + if (g_key_file_has_key(keyfile, group->name, entry->key_name, NULL)) + continue; + /* We temporarily use the default value for writing */ + entry->setting = &entry->default_value; + } switch (entry->setting_type) { case G_TYPE_BOOLEAN: @@ -251,13 +257,15 @@ case G_TYPE_STRING: handle_string_setting(group, entry, keyfile, action); break; default: - /* G_TYPE_STRV is not a constant */ + /* Note: G_TYPE_STRV is not a constant, can't use case label */ if (entry->setting_type == G_TYPE_STRV) handle_strv_setting(group, entry, keyfile, action); else g_warning("Unhandled type for %s::%s in %s()!", group->name, entry->key_name, G_STRFUNC); } + if (group->write_once && action == SETTING_WRITE) + entry->setting = tmp; } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.