Fix writing the default value when a key is missing for hidden
prefs, even if it was overridden when it was originally read. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5121 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
0c4b7a2ab0
commit
cc736eb4af
@ -6,6 +6,9 @@
|
|||||||
merged into one enum; the order of keybindings is now just the
|
merged into one enum; the order of keybindings is now just the
|
||||||
order they are added to each group. Keybindings can be reordered
|
order they are added to each group. Keybindings can be reordered
|
||||||
without breaking the plugin ABI but groups must stay the same.
|
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>
|
2010-08-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||||
|
22
src/stash.c
22
src/stash.c
@ -101,9 +101,9 @@ stash_group_update(group, parent);
|
|||||||
struct StashPref
|
struct StashPref
|
||||||
{
|
{
|
||||||
GType setting_type; /* e.g. G_TYPE_INT */
|
GType setting_type; /* e.g. G_TYPE_INT */
|
||||||
gpointer setting;
|
gpointer setting; /* Address of a variable */
|
||||||
const gchar *key_name;
|
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 */
|
GType widget_type; /* e.g. GTK_TYPE_TOGGLE_BUTTON */
|
||||||
StashWidgetID widget_id; /* (GtkWidget*) or (gchar*) */
|
StashWidgetID widget_id; /* (GtkWidget*) or (gchar*) */
|
||||||
gpointer fields; /* extra fields */
|
gpointer fields; /* extra fields */
|
||||||
@ -233,15 +233,21 @@ static void keyfile_action(SettingAction action, StashGroup *group, GKeyFile *ke
|
|||||||
|
|
||||||
foreach_array(StashPref, entry, group->entries)
|
foreach_array(StashPref, entry, group->entries)
|
||||||
{
|
{
|
||||||
/* don't overwrite write_once prefs */
|
gpointer tmp = entry->setting;
|
||||||
if (group->write_once && action == SETTING_WRITE &&
|
|
||||||
g_key_file_has_key(keyfile, group->name, entry->key_name, NULL))
|
|
||||||
continue;
|
|
||||||
/* don't override settings with default values */
|
/* don't override settings with default values */
|
||||||
if (!group->use_defaults && action == SETTING_READ &&
|
if (!group->use_defaults && action == SETTING_READ &&
|
||||||
!g_key_file_has_key(keyfile, group->name, entry->key_name, NULL))
|
!g_key_file_has_key(keyfile, group->name, entry->key_name, NULL))
|
||||||
continue;
|
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)
|
switch (entry->setting_type)
|
||||||
{
|
{
|
||||||
case G_TYPE_BOOLEAN:
|
case G_TYPE_BOOLEAN:
|
||||||
@ -251,13 +257,15 @@ static void keyfile_action(SettingAction action, StashGroup *group, GKeyFile *ke
|
|||||||
case G_TYPE_STRING:
|
case G_TYPE_STRING:
|
||||||
handle_string_setting(group, entry, keyfile, action); break;
|
handle_string_setting(group, entry, keyfile, action); break;
|
||||||
default:
|
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)
|
if (entry->setting_type == G_TYPE_STRV)
|
||||||
handle_strv_setting(group, entry, keyfile, action);
|
handle_strv_setting(group, entry, keyfile, action);
|
||||||
else
|
else
|
||||||
g_warning("Unhandled type for %s::%s in %s()!", group->name, entry->key_name,
|
g_warning("Unhandled type for %s::%s in %s()!", group->name, entry->key_name,
|
||||||
G_STRFUNC);
|
G_STRFUNC);
|
||||||
}
|
}
|
||||||
|
if (group->write_once && action == SETTING_WRITE)
|
||||||
|
entry->setting = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user