[gconf] Support relocatable schemas in gsettings-data-convert
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gconf] Support relocatable schemas in gsettings-data-convert
- Date: Mon, 19 Apr 2010 22:00:08 +0000 (UTC)
commit 043f2148d2203a6f6f848689c0739a734222bf52
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 18 15:34:26 2010 -0400
Support relocatable schemas in gsettings-data-convert
We allow to specify a path in the group name.
gsettings/gsettings-data-convert.c | 68 ++++++++++++++++++++++------------
gsettings/gsettings-data-convert.xml | 16 ++++++-
2 files changed, 57 insertions(+), 27 deletions(-)
---
diff --git a/gsettings/gsettings-data-convert.c b/gsettings/gsettings-data-convert.c
index c7fb866..6f79615 100644
--- a/gsettings/gsettings-data-convert.c
+++ b/gsettings/gsettings-data-convert.c
@@ -19,6 +19,7 @@
* Author: Matthias Clasen <mclasen redhat com>
*/
+#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -28,11 +29,13 @@
#include <gio/gio.h>
#include <gconf/gconf-client.h>
-static const gchar convert_dir[] = "/usr/share/gsettings-data-convert";
+static const gchar convert_dir[] = "/usr/share/gconf/gsettings";
static gboolean verbose = FALSE;
static gboolean dry_run = FALSE;
+extern const gchar *gconf_value_type_to_string (int type);
+
static gboolean
handle_file (const gchar *filename)
{
@@ -43,7 +46,6 @@ handle_file (const gchar *filename)
gchar *gconf_key;
gchar **groups;
gchar **keys;
- GConfValueType list_type;
GVariantBuilder *builder;
GVariant *v;
const gchar *s;
@@ -71,10 +73,18 @@ handle_file (const gchar *filename)
groups = g_key_file_get_groups (keyfile, NULL);
for (i = 0; groups[i]; i++)
{
+ gchar **schema_path;
+
+ schema_path = g_strsplit (groups[i], ":", 2);
+
if (verbose)
- g_print ("collecting settings for schema '%s'\n", groups[i]);
+ {
+ g_print ("collecting settings for schema '%s'\n", schema_path[0]);
+ if (schema_path[1])
+ g_print ("for storage at '%s'\n", schema_path[1]);
+ }
- settings = g_settings_new (groups[i]);
+ settings = g_settings_new_with_path (schema_path[0], schema_path[1]);
g_settings_delay (settings);
error = NULL;
@@ -102,13 +112,15 @@ handle_file (const gchar *filename)
{
if (error)
{
- g_printerr ("Failed to get GConf key '%s': %s\n", gconf_key, error->message);
+ g_printerr ("Failed to get GConf key '%s': %s\n",
+ gconf_key, error->message);
g_error_free (error);
}
else
{
if (verbose)
- g_print ("Skipping GConf key '%s', no user value\n", gconf_key);
+ g_print ("Skipping GConf key '%s', no user value\n",
+ gconf_key);
}
g_free (gconf_key);
@@ -120,30 +132,38 @@ handle_file (const gchar *filename)
{
case GCONF_VALUE_STRING:
if (dry_run)
- g_print ("set key '%s' to string '%s'\n", keys[j], gconf_value_get_string (value));
+ g_print ("set key '%s' to string '%s'\n", keys[j],
+ gconf_value_get_string (value));
else
- g_settings_set (settings, keys[j], "s", gconf_value_get_string (value));
+ g_settings_set (settings, keys[j], "s",
+ gconf_value_get_string (value));
break;
case GCONF_VALUE_INT:
if (dry_run)
- g_print ("set key '%s' to integer '%d'\n", keys[j], gconf_value_get_int (value));
+ g_print ("set key '%s' to integer '%d'\n",
+ keys[j], gconf_value_get_int (value));
else
- g_settings_set (settings, keys[j], "i", gconf_value_get_int (value));
+ g_settings_set (settings, keys[j], "i",
+ gconf_value_get_int (value));
break;
case GCONF_VALUE_BOOL:
if (dry_run)
- g_print ("set key '%s' to boolean '%d'\n", keys[j], gconf_value_get_bool (value));
+ g_print ("set key '%s' to boolean '%d'\n",
+ keys[j], gconf_value_get_bool (value));
else
- g_settings_set (settings, keys[j], "b", gconf_value_get_bool (value));
+ g_settings_set (settings, keys[j], "b",
+ gconf_value_get_bool (value));
break;
case GCONF_VALUE_FLOAT:
if (dry_run)
- g_print ("set key '%s' to double '%g'\n", keys[j], gconf_value_get_float (value));
+ g_print ("set key '%s' to double '%g'\n",
+ keys[j], gconf_value_get_float (value));
else
- g_settings_set (settings, keys[j], "d", gconf_value_get_float (value));
+ g_settings_set (settings, keys[j], "d",
+ gconf_value_get_float (value));
break;
case GCONF_VALUE_LIST:
@@ -163,7 +183,8 @@ handle_file (const gchar *filename)
if (dry_run)
{
str = g_variant_print (v, FALSE);
- g_print ("set key '%s' to a list of strings: %s\n", keys[j], str);
+ g_print ("set key '%s' to a list of strings: %s\n",
+ keys[j], str);
g_free (str);
}
else
@@ -187,7 +208,8 @@ handle_file (const gchar *filename)
if (dry_run)
{
str = g_variant_print (v, FALSE);
- g_print ("set key '%s' to a list of integers: %s\n", keys[j], str);
+ g_print ("set key '%s' to a list of integers: %s\n",
+ keys[j], str);
g_free (str);
}
else
@@ -198,13 +220,15 @@ handle_file (const gchar *filename)
break;
default:
- g_printerr ("Keys of type 'list of %s' not handled yet\n", gconf_value_type_to_string (gconf_value_get_list_type (value)));
+ g_printerr ("Keys of type 'list of %s' not handled yet\n",
+ gconf_value_type_to_string (gconf_value_get_list_type (value)));
break;
}
break;
default:
- g_printerr ("Keys of type %s not handled yet\n", gconf_value_type_to_string (value->type));
+ g_printerr ("Keys of type %s not handled yet\n",
+ gconf_value_type_to_string (value->type));
break;
}
@@ -218,6 +242,7 @@ handle_file (const gchar *filename)
g_settings_apply (settings);
g_object_unref (settings);
+ g_strfreev (schema_path);
}
g_strfreev (groups);
@@ -332,19 +357,14 @@ save_state (time_t mtime,
int
main (int argc, char *argv[])
{
- gchar *state_filename;
time_t stored_mtime;
time_t dir_mtime;
struct stat statbuf;
- gchar *contents;
GError *error;
- gchar *converted_filename;
gchar **converted;
- GConfClient *client;
GDir *dir;
const gchar *name;
gchar *filename;
- GString *string;
gint i;
GOptionContext *context;
GOptionEntry entries[] = {
@@ -390,7 +410,7 @@ main (int argc, char *argv[])
dir = g_dir_open (convert_dir, 0, &error);
if (dir == NULL)
{
- g_printerr ("Failed to open '%s': %s\n", error->message);
+ g_printerr ("Failed to open '%s': %s\n", convert_dir, error->message);
return 1;
}
diff --git a/gsettings/gsettings-data-convert.xml b/gsettings/gsettings-data-convert.xml
index c45cdc8..40db6a5 100644
--- a/gsettings/gsettings-data-convert.xml
+++ b/gsettings/gsettings-data-convert.xml
@@ -25,7 +25,7 @@ GConf database and stores them in GSettings.
</para>
<para>
The information about the mapping from GConf keys to GSettings keys
-is taken from files in <filename>/usr/share/gconv-convert</filename>.
+is taken from files in <filename>/usr/share/gconf/gsettings</filename>.
Each file in that directory is read as a key file, with sections
for each GSettings schema that is being converted. The entries in
each section map GSettings keys to paths in the GConf database.
@@ -43,6 +43,13 @@ rgba_order = /desktop/gnome/font_rendering/rgba_order
</programlisting>
</para>
<para>
+If the GSettings schema does not have a fixed path, you must specify
+the path in the group name, separated by a colon character:
+<programlisting>
+[org.gnome.fonts:/desktop/gnome/font-rendering/]
+</programlistling>
+</para>
+<para>
<command>gsettings-data-convert</command> keeps a list of the key files it
has already converted, so it is safe to run it repeatedly to handle
newly appeared key files. The expected use of this utility is to make
@@ -80,8 +87,11 @@ Show verbose messages
</refsect1>
<refsect1><title>See also</title>
<para>
-<command>gsettings-schema-convert(1)</command> is a related command that
-helps with the conversion of schemas from GConf to GSettings.
+<citerefentry>
+ <refentrytitle>gsettings-schema-convert</refentrytitle>
+ <manvolnum>1</manvolnum>
+</citerefentry> is a related command that helps with the conversion
+of schemas from GConf to GSettings.
</para>
</refsect1>
</refentry>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]