diff options
Diffstat (limited to 'common/dconf-gvdb-utils.c')
-rw-r--r-- | common/dconf-gvdb-utils.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/common/dconf-gvdb-utils.c b/common/dconf-gvdb-utils.c index e70e2dc..56609cc 100644 --- a/common/dconf-gvdb-utils.c +++ b/common/dconf-gvdb-utils.c @@ -32,6 +32,37 @@ #include <string.h> DConfChangeset * +dconf_gvdb_utils_changeset_from_table (GvdbTable *table) +{ + DConfChangeset *database = dconf_changeset_new_database (NULL); + gchar **names; + gsize n_names; + gsize i; + + names = gvdb_table_get_names (table, &n_names); + for (i = 0; i < n_names; i++) + { + if (dconf_is_key (names[i], NULL)) + { + GVariant *value; + + value = gvdb_table_get_value (table, names[i]); + + if (value != NULL) + { + dconf_changeset_set (database, names[i], value); + g_variant_unref (value); + } + } + + g_free (names[i]); + } + + g_free (names); + return database; +} + +DConfChangeset * dconf_gvdb_utils_read_and_back_up_file (const gchar *filename, gboolean *file_missing, GError **error) @@ -95,38 +126,14 @@ dconf_gvdb_utils_read_and_back_up_file (const gchar *filename, return NULL; } - /* Only allocate once we know we are in a non-error situation */ - database = dconf_changeset_new_database (NULL); - /* Fill the table up with the initial state */ if (table != NULL) { - gchar **names; - gsize n_names; - gsize i; - - names = gvdb_table_get_names (table, &n_names); - for (i = 0; i < n_names; i++) - { - if (dconf_is_key (names[i], NULL)) - { - GVariant *value; - - value = gvdb_table_get_value (table, names[i]); - - if (value != NULL) - { - dconf_changeset_set (database, names[i], value); - g_variant_unref (value); - } - } - - g_free (names[i]); - } - + database = dconf_gvdb_utils_changeset_from_table (table); gvdb_table_free (table); - g_free (names); } + else + database = dconf_changeset_new_database (NULL); if (file_missing) *file_missing = (table == NULL); |