Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not save config keys that still have the default value
This way mce package upgrade can change config keys that the
user has not explicitly set to non-default value.
  • Loading branch information
spiiroin committed Apr 11, 2013
1 parent 0486ce0 commit 42d2769
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion builtin-gconf.c
Expand Up @@ -128,6 +128,8 @@ typedef struct GConfEntry

// private

char *def;

} GConfEntry;

typedef struct GConfClient
Expand Down Expand Up @@ -1091,6 +1093,7 @@ gconf_entry_init(const char *key, const char *type, const char *data)
{
GConfEntry *self = calloc(1, sizeof *self);
self->key = strdup(key);
self->def = data ? strdup(data) : 0;

GConfValueType ltype = GCONF_VALUE_INVALID;
GConfValueType vtype = gconf_parse_type(type[0]);
Expand Down Expand Up @@ -1333,7 +1336,18 @@ static void gconf_client_save_values(GConfClient *self, const char *path)
{
GConfEntry *entry = e_iter->data;
char *str = gconf_value_str(entry->value);
fprintf(file, "%s=%s\n", entry->key, str);

if( !str )
{
mce_log(LL_WARN, "failed to serialize value of key %s", entry->key);
continue;
}

/* Omit values that do not differ from defaults */
if( !entry->def || strcmp(entry->def, str) )
{
fprintf(file, "%s=%s\n", entry->key, str);
}
free(str);
}

Expand Down

0 comments on commit 42d2769

Please sign in to comment.