Add a bit about autofoo for schemas
authorMatthias Clasen <mclasen@redhat.com>
Mon, 19 Apr 2010 12:54:01 +0000 (08:54 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 19 Apr 2010 12:57:19 +0000 (08:57 -0400)
Always a good idea to have copiable snipplets in a porting guide...

docs/reference/gio/migrating.xml

index ab4682d..f73f37a 100644 (file)
@@ -311,6 +311,36 @@ start_monitoring_trash (void)
       <title>Schema conversion</title>
 
       <para>
+        If you are porting your application from GConf, most likely you already
+        have a GConf schema. GIO comes with a commandline tool
+        <link linkend="gsettings-schema-convert">gsettings-schema-convert</link>
+        that can help with the task of converting a GConf schema into
+        an equivalent GSettings schema. The tool is not perfect and
+        may need assistence in some cases.
+      </para>
+
+      <para>
+        GSettings schemas are described by XML files that need to get installed
+        into <filename>$datadir/glib-2.0/schemas</filename>, and need to be
+        compiled into a binary form by the <link linkend="gschema-compile">gschema-compile</link>
+        utility. GIO provides variables <literal>gsettingsschemadir</literal>
+        and <literal>gsettingsupdateschemacache</literal> for the location
+        and the command, which can be used in <filename>configure.in</filename>
+        as follows:
+<programlisting>
+AC_SUBST(gsettingsschemadir, `pkg-config --variable gsettingsschemadir gio-2.0`)
+AC_SUBST(gsettingsupdateschemacache, `pkg-config --variable gsettingsupdateschemacache gio-2.0`)
+</programlisting>
+        The corresponding <filename>Makefile.am</filename> fragment looks like
+        this:
+<programlisting>
+gsettingsschema_DATA = my.app.gschema.xml
+install-data-hook:
+        $(gsettingsupdateschemacache) $(gsettingsschemadir)
+</programlisting>
+      </para>
+
+      <para>
         One possible pitfall in doing schema conversion is that the default
         values in GSettings schemas are parsed by the #GVariant parser.
         This means that strings need to include quotes in the XML.  Also note
@@ -390,13 +420,6 @@ start_monitoring_trash (void)
         GSettings. By the time you have finished porting your application
         you must ensure that all key names are valid.
       </para>
-      <para>
-        GIO comes with a commandline tool
-        <link linkend="gsettings-schema-convert">gsettings-schema-convert</link>
-        that can help with the task of converting a GConf schema into
-        an equivalent GSettings schema. The tool is not perfect and
-        may need assistence in some cases.
-      </para>
     </section>
 
     <section><title>Data conversion</title>