File port-to-GSettings.patch of Package gjiten

From: Yavor Doganov <yavor@gnu.org>
Date: Sat, 13 Oct 2018 11:42:25 +0300
Subject: port to GSettings

---
 configure.in                    |   7 +-
 data/Makefile.am                |  16 +--
 data/gjiten-dicfiles.schemas.in |  40 ------
 data/gjiten.convert             |  48 +++++++
 data/gjiten.schemas.in          | 168 ------------------------
 data/net.sf.gjiten.gschema.xml  | 158 ++++++++++++++++++++++
 po/POTFILES.in                  |   2 +-
 src/conf.c                      | 284 +++++++++++++++++++++-------------------
 src/conf.h                      |  10 +-
 src/gjiten.c                    |   1 -
 src/kanjidic.c                  |   3 +
 src/pref.c                      |   1 -
 src/worddic.c                   |   3 +
 13 files changed, 372 insertions(+), 369 deletions(-)
 delete mode 100644 data/gjiten-dicfiles.schemas.in
 create mode 100644 data/gjiten.convert
 delete mode 100644 data/gjiten.schemas.in
 create mode 100644 data/net.sf.gjiten.gschema.xml

Index: gjiten-2.6/configure.in
===================================================================
--- gjiten-2.6.orig/configure.in
+++ gjiten-2.6/configure.in
@@ -16,12 +16,11 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AM_PROG_LIBTOOL
 AC_PROG_MAKE_SET
-AC_PROG_INTLTOOL([0.22])
-AC_PATH_PROG([GCONFTOOL], [gconftool-2])
+AC_PROG_INTLTOOL([0.50.1])
 
 dnl GNOME_PLATFORM_GNOME_2(yes, force)
-PKG_CHECK_MODULES(GJITEN, gtk+-2.0 >= 2.14 gmodule-export-2.0 gconf-2.0)
-AM_GCONF_SOURCE_2
+PKG_CHECK_MODULES(GJITEN, gtk+-2.0 >= 2.14 gmodule-export-2.0)
+GLIB_GSETTINGS
 
 # Checks for header files.
 AC_HEADER_STDC
Index: gjiten-2.6/data/Makefile.am
===================================================================
--- gjiten-2.6.orig/data/Makefile.am
+++ gjiten-2.6/data/Makefile.am
@@ -3,16 +3,12 @@ pkgdata_DATA = vconj.utf8 radkfile.utf8
 gladedir	= $(pkgdatadir)
 glade_DATA	= gjiten-settings.glade worddic.glade
 
-schemasdir       = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = gjiten.schemas.in gjiten-dicfiles.schemas.in
-schemas_DATA     = $(schemas_in_files:.schemas.in=.schemas)
-@INTLTOOL_SCHEMAS_RULE@
+data_convertdir = $(datadir)/GConf/gsettings
+dist_data_convert_DATA = gjiten.convert
 
-CLEANFILES = *.bak *.gladep $(schemas_DATA)
+gsettings_SCHEMAS = net.sf.gjiten.gschema.xml
+@GSETTINGS_RULES@
 
-EXTRA_DIST = $(schemas_in_files) $(glade_DATA) radkfile.utf8 vconj.utf8
+CLEANFILES = *.bak *.gladep
 
-if GCONF_SCHEMAS_INSTALL
-install-data-local: $(schemas_DATA)
-        GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schemas_DATA);
-endif
+EXTRA_DIST = $(gsettings_SCHEMAS) $(glade_DATA) radkfile.utf8 vconj.utf8
Index: gjiten-2.6/data/gjiten-dicfiles.schemas.in
===================================================================
--- gjiten-2.6.orig/data/gjiten-dicfiles.schemas.in
+++ /dev/null
@@ -1,40 +0,0 @@
-<!-- Install with the following command:
-GCONF_CONFIG_SOURCE=xml::/etc/gconf/gconf.xml.defaults /usr/bin/gconftool - -makefile-install-rule /home/boti/gjiten.schema
--->
-
-<gconfschemafile>
-  <schemalist>
-
-    <schema>
-      <key>/schemas/apps/gjiten/general/dictionary_list</key>
-      <applyto>/apps/gjiten/general/dictionary_list</applyto>
-      <owner>gjiten</owner>
-      <type>list</type>
-      <list_type>string</list_type>
-      <default>[/usr/share/gjiten/dics/edict
-English-main,/usr/share/gjiten/dics/compdic
-Computers]</default>
-      <locale name="C">
-         <short>List of dictionary files</short>
-         <long>
-          List of dictionary files. Format is: 
-          [/path/to/dicfile1\ndictionary_name1,/path/to/dicfile2\ndictionary_name2]
-          Don't put a space after the comma!
-         </long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/kanjidicfile</key>
-      <applyto>/apps/gjiten/kanjidic/kanjidicfile</applyto>
-      <owner>gjiten</owner>
-      <type>string</type>
-      <default>/usr/share/gjiten/dics/kanjidic</default>
-      <locale name="C">
-       <short>Kanjidic dictionary file</short>
-       <long>Kanjidic dictionary file</long>
-      </locale>
-    </schema>
-
-  </schemalist>
-</gconfschemafile>
Index: gjiten-2.6/data/gjiten.convert
===================================================================
--- /dev/null
+++ gjiten-2.6/data/gjiten.convert
@@ -0,0 +1,48 @@
+[net.sf.gjiten]
+autoadjust-enabled = /apps/gjiten/general/autoadjust_enabled
+bigkanji = /apps/gjiten/general/bigkanji
+bigwords = /apps/gjiten/general/bigwords
+envvar-override = /apps/gjiten/general/envvar_override
+force-ja-jp = /apps/gjiten/general/force_ja_JP
+force-language-c = /apps/gjiten/general/force_language_c
+gdk-use-xft = /apps/gjiten/general/gdk_use_xft
+kanjipad = /apps/gjiten/general/kanjipad
+largefont = /apps/gjiten/general/largefont
+maxwordmatches = /apps/gjiten/general/maxwordmatches
+normalfont = /apps/gjiten/general/normalfont
+search-hira-on-kata = /apps/gjiten/general/search_hira_on_kata
+search-kata-on-hira = /apps/gjiten/general/search_kata_on_hira
+searchlimit-enabled = /apps/gjiten/general/searchlimit_enabled
+version = /apps/gjiten/general/version
+
+[net.sf.gjiten.kanjidic]
+bushu = /apps/gjiten/kanjidic/bushu
+classic = /apps/gjiten/kanjidic/classic
+cref = /apps/gjiten/kanjidic/cref
+deroo = /apps/gjiten/kanjidic/deroo
+eindex = /apps/gjiten/kanjidic/eindex
+english = /apps/gjiten/kanjidic/english
+fourc = /apps/gjiten/kanjidic/fourc
+freq = /apps/gjiten/kanjidic/freq
+hindex = /apps/gjiten/kanjidic/hindex
+iindex = /apps/gjiten/kanjidic/iindex
+jisascii = /apps/gjiten/kanjidic/jisascii
+jouyou = /apps/gjiten/kanjidic/jouyou
+kanji = /apps/gjiten/kanjidic/kanji
+kanjidicfile = /apps/gjiten/kanjidic/kanjidicfile
+kindex = /apps/gjiten/kanjidic/kindex
+korean = /apps/gjiten/kanjidic/korean
+lindex = /apps/gjiten/kanjidic/lindex
+missc = /apps/gjiten/kanjidic/missc
+mnindex = /apps/gjiten/kanjidic/mnindex
+mpindex = /apps/gjiten/kanjidic/mpindex
+nindex = /apps/gjiten/kanjidic/nindex
+oindex = /apps/gjiten/kanjidic/oindex
+pinyin = /apps/gjiten/kanjidic/pinyin
+radical = /apps/gjiten/kanjidic/radical
+reading = /apps/gjiten/kanjidic/reading
+skip = /apps/gjiten/kanjidic/skip
+strokes = /apps/gjiten/kanjidic/strokes
+unicode = /apps/gjiten/kanjidic/unicode
+unicode-radicals = /apps/gjiten/kanjidic/unicode_radicals
+vindex = /apps/gjiten/kanjidic/vindex
Index: gjiten-2.6/data/gjiten.schemas.in
===================================================================
--- gjiten-2.6.orig/data/gjiten.schemas.in
+++ /dev/null
@@ -1,168 +0,0 @@
-<!-- Install with the following command:
-GCONF_CONFIG_SOURCE=xml::/etc/gconf/gconf.xml.defaults /usr/bin/gconftool - -makefile-install-rule /home/boti/gjiten.schema
--->
-
-<gconfschemafile>
-  <schemalist>
-
-<!--
-    <schema>
-      <key>/schemas/apps/gjiten/general/envvar_override</key>
-      <applyto>/apps/gjiten/general/envvar_override</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/general/force_ja_JP</key>
-      <applyto>/apps/gjiten/general/force_ja_JP</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
--->
-    <schema>
-      <key>/schemas/apps/gjiten/general/search_kata_on_hira</key>
-      <applyto>/apps/gjiten/general/search_kata_on_hira</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/general/autoadjust_enabled</key>
-      <applyto>/apps/gjiten/general/autoadjust_enabled</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-<!-- KanjiDic -->
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/english</key>
-      <applyto>/apps/gjiten/kanjidic/english</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/freq</key>
-      <applyto>/apps/gjiten/kanjidic/freq</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/kanji</key>
-      <applyto>/apps/gjiten/kanjidic/kanji</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/jouyou</key>
-      <applyto>/apps/gjiten/kanjidic/jouyou</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/korean</key>
-      <applyto>/apps/gjiten/kanjidic/korean</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/pinyin</key>
-      <applyto>/apps/gjiten/kanjidic/pinyin</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/radical</key>
-      <applyto>/apps/gjiten/kanjidic/radical</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/reading</key>
-      <applyto>/apps/gjiten/kanjidic/reading</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-    <schema>
-      <key>/schemas/apps/gjiten/kanjidic/strokes</key>
-      <applyto>/apps/gjiten/kanjidic/strokes</applyto>
-      <owner>gjiten</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-       <short></short>
-       <long></long>
-      </locale>
-    </schema>
-
-
-  </schemalist>
-</gconfschemafile>
Index: gjiten-2.6/data/net.sf.gjiten.gschema.xml
===================================================================
--- /dev/null
+++ gjiten-2.6/data/net.sf.gjiten.gschema.xml
@@ -0,0 +1,158 @@
+<schemalist gettext-domain="gjiten">
+  <schema id="net.sf.gjiten" path="/net/sf/gjiten/">
+    <child name="kanjidic" schema="net.sf.gjiten.kanjidic"/>
+    <key name="autoadjust-enabled" type="b">
+      <default>true</default>
+    </key>
+    <key name="bigkanji" type="b">
+      <default>false</default>
+    </key>
+    <key name="bigwords" type="b">
+      <default>false</default>
+    </key>
+    <key name="deinflection-enabled" type="b">
+      <default>false</default>
+    </key>
+    <key name="dictionary-list" type="a(ss)">
+      <default>[('/usr/share/gjiten/dics/edict', 'English-main'),
+      ('/usr/share/gjiten/dics/compdic', 'Computers')]</default>
+      <summary>List of dictionary files</summary>
+      <description>List of dictionary files. Format is:
+      [('/path/to/dicfile1', 'dictionary_name1'), ('/path/to/dicfile2',
+      'dictionary_name2')]</description>
+    </key>
+    <key name="envvar-override" type="b">
+      <default>false</default>
+    </key>
+    <key name="force-ja-jp" type="b">
+      <default>false</default>
+    </key>
+    <key name="force-language-c" type="b">
+      <default>false</default>
+    </key>
+    <key name="gdk-use-xft" type="b">
+      <default>false</default>
+    </key>
+    <key name="history" type="as">
+      <default>[]</default>
+    </key>
+    <key name="kanjipad" type="s">
+      <default>'/usr/bin/kanjipad'</default>
+    </key>
+    <key name="largefont" type="s">
+      <default>''</default>
+    </key>
+    <key name="maxwordmatches" type="i">
+      <default>100</default>
+    </key>
+    <key name="normalfont" type="s">
+      <default>''</default>
+    </key>
+    <key name="search-hira-on-kata" type="b">
+      <default>false</default>
+    </key>
+    <key name="search-kata-on-hira" type="b">
+      <default>true</default>
+    </key>
+    <key name="searchlimit-enabled" type="b">
+      <default>false</default>
+    </key>
+    <key name="version" type="s">
+      <default>''</default>
+    </key>
+  </schema>
+  <schema id="net.sf.gjiten.kanjidic" path="/net/sf/gjiten/kanjidic/">
+    <key name="bushu" type="b">
+      <default>false</default>
+    </key>
+    <key name="classic" type="b">
+      <default>false</default>
+    </key>
+    <key name="cref" type="b">
+      <default>false</default>
+    </key>
+    <key name="deroo" type="b">
+      <default>false</default>
+    </key>
+    <key name="eindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="english" type="b">
+      <default>true</default>
+    </key>
+    <key name="fourc" type="b">
+      <default>false</default>
+    </key>
+    <key name="freq" type="b">
+      <default>true</default>
+    </key>
+    <key name="hindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="iindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="jisascii" type="b">
+      <default>false</default>
+    </key>
+    <key name="jouyou" type="b">
+      <default>true</default>
+    </key>
+    <key name="kanji" type="b">
+      <default>true</default>
+    </key>
+    <key name="kanjidicfile" type="s">
+      <default>'/usr/share/gjiten/dics/kanjidic'</default>
+      <summary>Kanjidic dictionary file</summary>
+      <description>Kanjidic dictionary file</description>
+    </key>
+    <key name="kindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="korean" type="b">
+      <default>true</default>
+    </key>
+    <key name="lindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="missc" type="b">
+      <default>false</default>
+    </key>
+    <key name="mnindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="mpindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="nindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="oindex" type="b">
+      <default>false</default>
+    </key>
+    <key name="pinyin" type="b">
+      <default>true</default>
+    </key>
+    <key name="radical" type="b">
+      <default>true</default>
+    </key>
+    <key name="reading" type="b">
+      <default>true</default>
+    </key>
+    <key name="skip" type="b">
+      <default>false</default>
+    </key>
+    <key name="strokes" type="b">
+      <default>true</default>
+    </key>
+    <key name="unicode" type="b">
+      <default>false</default>
+    </key>
+    <key name="unicode-radicals" type="b">
+      <default>false</default>
+    </key>
+    <key name="vindex" type="b">
+      <default>false</default>
+    </key>
+  </schema>
+</schemalist>
Index: gjiten-2.6/po/POTFILES.in
===================================================================
--- gjiten-2.6.orig/po/POTFILES.in
+++ gjiten-2.6/po/POTFILES.in
@@ -1,6 +1,6 @@
 data/gjiten-settings.glade
 data/worddic.glade
-data/gjiten.schemas.in
+[type: gettext/gsettings]data/net.sf.gjiten.gschema.xml
 gnome/gjiten.desktop.in
 src/gjiten.c
 src/pref.c
Index: gjiten-2.6/src/conf.c
===================================================================
--- gjiten-2.6.orig/src/conf.c
+++ gjiten-2.6/src/conf.c
@@ -35,23 +35,72 @@
 extern gchar *kanjidicstrg[];
 extern gchar *gnome_dialog_msg;
 GjitenConfig conf;
-GConfClient *gconf_client;
+GSettings *settings;
+GSettings *kanji_settings;
+
+static gchar *migrate_gconf_settings(const gchar *name) {
+  gboolean needed = TRUE;
+  GError *error = NULL;
+  GKeyFile *kf;
+  gchar **list;
+  gchar *msg = NULL;
+  gsize i, n;
+
+  kf = g_key_file_new();
+
+  g_key_file_load_from_data_dirs(kf, "gsettings-data-convert",
+                                 NULL, G_KEY_FILE_NONE, NULL);
+  list = g_key_file_get_string_list(kf, "State", "converted", &n, NULL);
+
+  if (list) {
+    for (i = 0; i < n; i++)
+      if (! g_strcmp0(list[i], name)) {
+        needed = FALSE;
+        break;
+      }
+    g_strfreev(list);
+  }
+  g_key_file_free(kf);
+
+  if (needed) {
+    g_spawn_command_line_sync("gsettings-data-convert",
+                              NULL, NULL, NULL, &error);
+    if (error) {
+      msg = g_strdup_printf(_("Could not migrate old GConf settings: %s\n"
+                              "Please make sure that GConf is installed "
+                              "and the gsettings-data-convert tool is in "
+                              "your PATH.\nAlternatively, ignore this "
+                              "message and convert your old settings "
+                              "manually."), error->message);
+      g_error_free(error);
+    } else {
+      msg = g_strdup(_("Old GConf settings were either missing or "
+                       "migrated successfully."));
+
+      /* Allow some time for the GSettings backend to record the
+         changes, otherwise the default values from the new schema
+         might be set.  */
+      sleep(1);
+    }
+  }
+
+  return msg;
+}
 
 GjitenConfig *conf_load() {
-  gchar *dicprefix = "/apps/gjiten/general/dic";
   gchar *tmpstrg;
-  gchar historystr[31];
-  gchar *tmpptr, *endptr;
-  gchar *gnomekcfg = "/apps/gjiten/kanjidic/";
+  gchar *tmpptr;
   int i;
 	GjitenDicfile *dicfile;
-	GSList *gconf_diclist = NULL;
-	GSList *diclist;
+	GVariant *diclist;
+	GVariantIter iter;
 	GjitenConfig *conf;
 
+
 	conf = g_new0(GjitenConfig, 1);
+	conf->gconf_migration = migrate_gconf_settings("gjiten.convert");
 
-  conf->version = gconf_client_get_string(gconf_client, "/apps/gjiten/general/version", NULL);
+  conf->version = g_settings_get_string(settings, "version");
 	/*
   if (conf->version == NULL) { // FIXME: gconf schema
     conf->kdiccfg[KANJI] = TRUE; 
@@ -76,44 +125,38 @@ GjitenConfig *conf_load() {
   }
 	*/
 
-  conf->autoadjust_enabled = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/autoadjust_enabled", NULL);
+  conf->autoadjust_enabled = g_settings_get_boolean(settings, "autoadjust-enabled");
 
-  conf->bigwords = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/bigwords", NULL);
-  conf->bigkanji = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/bigkanji", NULL);
-  conf->largefont = gconf_client_get_string(gconf_client, "/apps/gjiten/general/largefont", NULL);
-  conf->normalfont = gconf_client_get_string(gconf_client, "/apps/gjiten/general/normalfont", NULL);
-  conf->gdk_use_xft = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/gdk_use_xft", NULL);
-  conf->force_ja_JP = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/force_ja_JP", NULL);
-  conf->force_language_c = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/force_language_c", NULL);
-  conf->envvar_override = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/envvar_override", NULL);
+  conf->bigwords = g_settings_get_boolean(settings, "bigwords");
+  conf->bigkanji = g_settings_get_boolean(settings, "bigkanji");
+  conf->largefont = g_settings_get_string(settings, "largefont");
+  conf->normalfont = g_settings_get_string(settings, "normalfont");
+  conf->gdk_use_xft = g_settings_get_boolean(settings, "gdk-use-xft");
+  conf->force_ja_JP = g_settings_get_boolean(settings, "force-ja-jp");
+  conf->force_language_c = g_settings_get_boolean(settings, "force-language-c");
+  conf->envvar_override = g_settings_get_boolean(settings, "envvar-override");
 
-  conf->searchlimit_enabled = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/searchlimit_enabled", NULL);
-  conf->maxwordmatches = gconf_client_get_int(gconf_client, "/apps/gjiten/general/maxwordmatches", NULL);
+  conf->searchlimit_enabled = g_settings_get_boolean(settings, "searchlimit-enabled");
+  conf->maxwordmatches = g_settings_get_int(settings, "maxwordmatches");
 	if (conf->maxwordmatches < 1) {
 		conf->searchlimit_enabled = FALSE;
 		conf->maxwordmatches = 100;
 	}
 
-  conf->dictpath = gconf_client_get_string(gconf_client, "/apps/gjiten/general/dictpath", NULL);
-  conf->menubar = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/menubar", NULL);
-  conf->toolbar = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/toolbar", NULL);
-
-  conf->search_kata_on_hira = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/search_kata_on_hira", NULL);
-  conf->search_hira_on_kata = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/search_hira_on_kata", NULL);
-  conf->verb_deinflection = gconf_client_get_bool(gconf_client, "/apps/gjiten/general/deinflection_enabled", NULL);
+  conf->search_kata_on_hira = g_settings_get_boolean(settings, "search-kata-on-hira");
+  conf->search_hira_on_kata = g_settings_get_boolean(settings, "search-hira-on-kata");
+  conf->verb_deinflection = g_settings_get_boolean(settings, "deinflection-enabled");
 
   if (conf->kanjidic == NULL) conf->kanjidic = g_new0(GjitenDicfile, 1);
-  conf->kanjidic->path = gconf_client_get_string(gconf_client, "/apps/gjiten/kanjidic/kanjidicfile", NULL);
+  conf->kanjidic->path = g_settings_get_string(kanji_settings, "kanjidicfile");
 	if ((conf->kanjidic->path == NULL) || (strlen(conf->kanjidic->path)) == 0) {
 		conf->kanjidic->path = GJITEN_DICDIR"/kanjidic";
 	}
-  conf->unicode_radicals = gconf_client_get_bool(gconf_client, "/apps/gjiten/kanjidic/unicode_radicals", NULL);
+  conf->unicode_radicals = g_settings_get_boolean(kanji_settings, "unicode-radicals");
 	
 
-  conf->kanjipad = gconf_client_get_string(gconf_client, "/apps/gjiten/general/kanjipad", NULL);
-	if (conf->kanjipad == NULL) conf->kanjipad = "";
-
-  conf->numofdics = gconf_client_get_int(gconf_client, "/apps/gjiten/general/numofdics", NULL);
+  conf->kanjipad = g_settings_get_string(settings, "kanjipad");
+	if (conf->kanjipad == NULL) conf->kanjipad = "/usr/bin/kanjipad";
 
 	if (conf->dicfile_list != NULL) {
 		dicutil_unload_dic();
@@ -121,170 +164,137 @@ GjitenConfig *conf_load() {
 		conf->dicfile_list = NULL;
 	}
 
-	if (conf->numofdics != 0) {
-		//Load dicfiles from old style config [compatibility with older versions]
-		for (i = 0; i < conf->numofdics; i++) {
-			//if (i == MAXDICFILES - 1) break;
-			tmpstrg = g_strdup_printf("%s%d", dicprefix, i); 
+	diclist = g_settings_get_value(settings, "dictionary-list");
+	g_variant_iter_init(&iter, diclist);
+	while (g_variant_iter_next(&iter, "(&s&s)", &tmpstrg, &tmpptr)) {
+		if (tmpstrg != NULL) {
 			dicfile = g_new0(GjitenDicfile, 1);
-			dicfile->name = gconf_client_get_string(gconf_client, tmpstrg, NULL);
-			if (conf->dictpath[strlen(conf->dictpath - 1)] == '/') {
-				dicfile->path = g_strdup_printf("%s%s", conf->dictpath, dicfile->name);
-			}
-			else {
-				dicfile->path = g_strdup_printf("%s/%s", conf->dictpath, dicfile->name);
-			}
+			dicfile->path = g_strdup(tmpstrg);
+			dicfile->name = g_strdup(tmpptr);
+			//				printf("%s\n%s\n", tmpstrg, tmpptr);
 			conf->dicfile_list = g_slist_append(conf->dicfile_list, dicfile);
-			g_free(tmpstrg);
-		}
-	}
-	else { //new config
-		gconf_diclist = gconf_client_get_list(gconf_client, GCONF_PATH_GENERAL"/dictionary_list", GCONF_VALUE_STRING, NULL);
-		diclist = gconf_diclist;
-		while (diclist != NULL) {
-			if (diclist->data == NULL) break;
-			tmpstrg = diclist->data;
-			if (tmpstrg != NULL) {
-				tmpptr = tmpstrg;
-				endptr = tmpptr + strlen(tmpstrg);
-				while ((tmpptr != endptr) && (*tmpptr != '\n')) tmpptr++;
-				if (*tmpptr == '\n') {
-					*tmpptr = 0;
-					tmpptr++;
-				}
-				dicfile = g_new0(GjitenDicfile, 1);
-				dicfile->path = g_strdup(tmpstrg);
-				dicfile->name = g_strdup(tmpptr);
-				//				printf("%s\n%s\n", tmpstrg, tmpptr);
-				conf->dicfile_list = g_slist_append(conf->dicfile_list, dicfile);
-			}
-			diclist = g_slist_next(diclist);
 		}
 	}
+	g_variant_unref(diclist);
+
 	if (conf->dicfile_list != NULL) conf->selected_dic = conf->dicfile_list->data;
 
   //Load kanji info settings
   for (i = 0; i < KCFGNUM; i++) { 
-		tmpptr = g_strdup_printf("%s%s", gnomekcfg, kanjidicstrg[i]);
-    if (gconf_client_get_bool(gconf_client, tmpptr, NULL)) {
-      conf->kdiccfg[i] = TRUE;
+    conf->kdiccfg[i] = g_settings_get_boolean(kanji_settings, kanjidicstrg[i]);
       /* printf("%s : %d\n",kanjidicstrg[i], conf->kdiccfg[i]); */
-    }
-    else conf->kdiccfg[i] = FALSE; 
-    g_free(tmpptr);
   }
  
   //Load gjiten search history
-  for (i = 0; i <= 50; i++) {
-    snprintf(historystr, 31, "/apps/gjiten/history/history%d", i);
-    conf->history[i] = gconf_client_get_string(gconf_client, historystr, NULL);
-    if (conf->history[i] == NULL) break;
-  }
+  conf->history = g_settings_get_strv(settings, "history");
 
   return conf;
 }
 
 void conf_save(GjitenConfig *conf) {
-  gchar *gnomekcfg = "/apps/gjiten/kanjidic/";
   int i;
-  gchar *confpath, *tmpstrg;
-	GConfValue *gconfList;
-	GSList *gconf_diclist = NULL;
 	GSList *diclist;
 	GjitenDicfile *dicfile;
+	GVariantBuilder builder;
 
-  gconf_client_set_string(gconf_client, "/apps/gjiten/general/version", VERSION, NULL);
+	/* Apply all changes at once.  */
+	g_settings_delay(settings);
+	g_settings_delay(kanji_settings);
+
+  g_settings_set_string(settings, "version", VERSION);
   //Save kanjidic display options
   for (i = 0; i < KCFGNUM; i++) { 
-		confpath = g_strdup_printf("%s%s", gnomekcfg, kanjidicstrg[i]);
-    gconf_client_set_bool(gconf_client, confpath, conf->kdiccfg[i], NULL);
-    g_free(confpath);
+    g_settings_set_boolean(kanji_settings, kanjidicstrg[i], conf->kdiccfg[i]);
   }
   
   //gconf_client_set_bool(gconf_client, "/apps/gjiten/general/tooltips", conf->tooltips, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/menubar", conf->menubar, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/toolbar", conf->toolbar, NULL);
-  gconf_client_set_string(gconf_client, "/apps/gjiten/general/dictpath", conf->dictpath == NULL ? "" : conf->dictpath, NULL);
-  gconf_client_set_string(gconf_client, "/apps/gjiten/kanjidic/kanjidicfile", conf->kanjidic->path, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/kanjidic/unicode_radicals", conf->unicode_radicals, NULL);
+  g_settings_set_string(kanji_settings, "kanjidicfile", conf->kanjidic->path);
+  g_settings_set_boolean(kanji_settings, "unicode-radicals", conf->unicode_radicals);
 
 	if (conf->kanjipad == NULL) conf->kanjipad = "";
-  gconf_client_set_string(gconf_client, "/apps/gjiten/general/kanjipad", conf->kanjipad, NULL);
+  g_settings_set_string(settings, "kanjipad", conf->kanjipad);
 
-	//Deprecated dictionary file number, zero it out.
-	//gconf_client_set_int(gconf_client, "/apps/gjiten/general/numofdics", conf->numofdics, NULL);
-	gconf_client_set_int(gconf_client, "/apps/gjiten/general/numofdics", 0, NULL);
-
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/bigwords", conf->bigwords, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/bigkanji", conf->bigkanji, NULL);
-  gconf_client_set_string(gconf_client, "/apps/gjiten/general/largefont", conf->largefont == NULL ? "" : conf->largefont, NULL);
-  gconf_client_set_string(gconf_client, "/apps/gjiten/general/normalfont", conf->normalfont == NULL ? "" : conf->normalfont, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/gdk_use_xft", conf->gdk_use_xft, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/force_ja_JP", conf->force_ja_JP, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/force_language_c", conf->force_language_c, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/envvar_override", conf->envvar_override, NULL);
-
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/search_kata_on_hira", conf->search_kata_on_hira, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/search_hira_on_kata", conf->search_hira_on_kata, NULL);
-  gconf_client_set_bool(gconf_client, "/apps/gjiten/general/deinflection_enabled", conf->verb_deinflection, NULL);
+  g_settings_set_boolean(settings, "bigwords", conf->bigwords);
+  g_settings_set_boolean(settings, "bigkanji", conf->bigkanji);
+  g_settings_set_string(settings, "largefont", conf->largefont == NULL ? "" : conf->largefont);
+  g_settings_set_string(settings, "normalfont", conf->normalfont == NULL ? "" : conf->normalfont);
+  g_settings_set_boolean(settings, "gdk-use-xft", conf->gdk_use_xft);
+  g_settings_set_boolean(settings, "force-ja-jp", conf->force_ja_JP);
+  g_settings_set_boolean(settings, "force-language-c", conf->force_language_c);
+  g_settings_set_boolean(settings, "envvar-override", conf->envvar_override);
+
+  g_settings_set_boolean(settings, "search-kata-on-hira", conf->search_kata_on_hira);
+  g_settings_set_boolean(settings, "search-hira-on-kata", conf->search_hira_on_kata);
+  g_settings_set_boolean(settings, "deinflection-enabled", conf->verb_deinflection);
 
   //Save dicfiles [path and name seperated with linebreak]
-	gconfList = gconf_value_new(GCONF_VALUE_LIST);
 	diclist = conf->dicfile_list;
+	g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ss)"));
 	while (diclist != NULL) {
 		if (diclist->data == NULL) break;
 		dicfile = diclist->data;
-		tmpstrg = g_strdup_printf("%s\n%s", dicfile->path, dicfile->name);
-		gconf_diclist = g_slist_append(gconf_diclist, tmpstrg);
+		g_variant_builder_add(&builder, "(ss)", dicfile->path, dicfile->name);
 		diclist = g_slist_next(diclist);
 	}
-	gconf_value_set_list_type(gconfList, GCONF_VALUE_STRING);
-	gconf_client_set_list(gconf_client, GCONF_PATH_GENERAL"/dictionary_list", GCONF_VALUE_STRING, gconf_diclist, NULL);
+	g_settings_set_value(settings, "dictionary-list", g_variant_builder_end(&builder));
+
+	g_settings_apply(settings);
+	g_settings_apply(kanji_settings);
 }
 
 void conf_save_history(GList *history, GjitenConfig *conf) {
-  char historystr[40];
+  gchar **vector;
+  guint size;
   int i;
   if (history != NULL) {
-    for (i = 0; i <= 50; i++) {
-      snprintf(historystr, 31, "/apps/gjiten/history/history%d", i);
-      gconf_client_set_string(gconf_client, historystr, history->data, NULL);
+    size = g_list_length(history);
+    vector = g_new0(gchar *, size + 1);
+    for (i = 0; i <= 50 && i <= size; i++) {
+      vector[i] = history->data;
       history = g_list_next(history);
       if (history == NULL) break;
     } 
+    g_settings_set_strv(settings, "history", (const gchar **)vector);
+    g_strfreev(vector);
   }
 }
 
 void conf_save_options(GjitenConfig *conf) {
-    gconf_client_set_bool(gconf_client, "/apps/gjiten/general/autoadjust_enabled", conf->autoadjust_enabled, NULL);
-    gconf_client_set_bool(gconf_client, "/apps/gjiten/general/searchlimit_enabled", conf->searchlimit_enabled, NULL);
-    gconf_client_set_int(gconf_client, "/apps/gjiten/general/maxwordmatches", conf->maxwordmatches, NULL);
+    g_settings_delay(settings);
+    g_settings_set_boolean(settings, "autoadjust-enabled", conf->autoadjust_enabled);
+    g_settings_set_boolean(settings, "searchlimit-enabled", conf->searchlimit_enabled);
+    g_settings_set_int(settings, "maxwordmatches", conf->maxwordmatches);
+    g_settings_apply(settings);
 }
 
 gboolean conf_init_handler() {
-  GError *error;
-
-  if (gconf_init(0, NULL, &error) == FALSE) {
-    gjiten_abort_with_msg("GConf init failed: %s\n", error->message);
+  if (settings == NULL) {
+		settings = g_settings_new("net.sf.gjiten");
+		kanji_settings = g_settings_get_child(settings, "kanjidic");
 	}
-  g_type_init();
 
-  if (gconf_client == NULL) {
-		gconf_client = gconf_client_get_default();
-	}
-
-  if (gconf_client == NULL) {
-    gjiten_print_error(_("Could not get gconf_client.\n"));
-    return FALSE;
-  }
 	return TRUE;
 
 }
 
 void conf_close_handler() {
-	if (gconf_client != NULL) {
-		GJITEN_DEBUG("calling g_object_unref(G_OBJECT(gconf_client)) [%d]\n", (int) gconf_client);
-		g_object_unref(G_OBJECT(gconf_client));
-		gconf_client = NULL;
+	if (settings != NULL) {
+		GJITEN_DEBUG("calling g_object_unref(settings) [%d]\n", (int) settings);
+		g_object_unref(settings);
+		g_object_unref(kanji_settings);
+		settings = NULL;
+		kanji_settings = NULL;
 	}
 }
+
+void conf_display_migration_info(GjitenConfig *conf, GtkWindow *parent) {
+	GtkWidget *dlg;
+
+	dlg = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+	                             GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+	                             "%s", conf->gconf_migration);
+	g_free(conf->gconf_migration);
+	conf->gconf_migration = NULL;
+	gtk_dialog_run(GTK_DIALOG(dlg));
+	gtk_widget_destroy(dlg);
+}
Index: gjiten-2.6/src/conf.h
===================================================================
--- gjiten-2.6.orig/src/conf.h
+++ gjiten-2.6/src/conf.h
@@ -25,7 +25,6 @@
 #define __CONF_H__
 
 
-#include <gconf/gconf-client.h>
 #include <pango/pango-font.h>
 
 #include "kanjidic.h"
@@ -40,9 +39,7 @@ struct _GjitenConfig {
 	GjitenDicfile *kanjidic;
 	GSList *dicfile_list;
 
-  char *history[60];
-  gboolean toolbar;
-  gboolean menubar;
+  gchar **history;
   gboolean kdiccfg[KCFGNUM];
   gboolean bigwords;
   gboolean bigkanji;
@@ -74,9 +71,7 @@ struct _GjitenConfig {
   GjitenDicfile *mmaped_dicfile;
   PangoFontDescription *normalfont_desc;
 
-	/* DEPRECATED */
-  char *dictpath;
-  int numofdics;
+  gchar *gconf_migration;
 
 };
 
@@ -87,5 +82,6 @@ void conf_save_history(GList *history, G
 void conf_save_options(GjitenConfig *conf);
 gboolean conf_init_handler();
 void conf_close_handler();
+void conf_display_migration_info(GjitenConfig *conf, GtkWindow *parent);
 
 #endif
Index: gjiten-2.6/src/gjiten.c
===================================================================
--- gjiten-2.6.orig/src/gjiten.c
+++ gjiten-2.6/src/gjiten.c
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
 #ifdef HAVE_INTTYPES_H
 #include <inttypes.h>
 #endif
Index: gjiten-2.6/src/kanjidic.c
===================================================================
--- gjiten-2.6.orig/src/kanjidic.c
+++ gjiten-2.6/src/kanjidic.c
@@ -1045,6 +1045,9 @@ KanjiDic *kanjidic_create() {
   g_signal_connect(G_OBJECT(kanjiDic->window), "destroy", G_CALLBACK(kanjidic_close), NULL);
   gtk_window_set_default_size(GTK_WINDOW(kanjiDic->window), 500, 500);
 
+  if (gjitenApp->conf->gconf_migration)
+    conf_display_migration_info(gjitenApp->conf, GTK_WINDOW(kanjiDic->window));
+
   vbox_maink = gtk_vbox_new(FALSE, 0);
   gtk_widget_show(vbox_maink);
   gtk_container_add(GTK_CONTAINER(kanjiDic->window), vbox_maink);
Index: gjiten-2.6/src/pref.c
===================================================================
--- gjiten-2.6.orig/src/pref.c
+++ gjiten-2.6/src/pref.c
@@ -371,7 +371,6 @@ void preferences_response_cb(GtkDialog *
 	gjitenApp->conf->verb_deinflection = GTK_TOGGLE_BUTTON(GETWIDGET("checkbutton_verb_deinflection"))->active;	
 	gjitenApp->conf->unicode_radicals = GTK_TOGGLE_BUTTON(GETWIDGET("checkbutton_unicode_radicals"))->active;	
       
-  gjitenApp->conf->numofdics = 0;
 
 	dicutil_unload_dic();
 	dicfile_list_free(gjitenApp->conf->dicfile_list);
Index: gjiten-2.6/src/worddic.c
===================================================================
--- gjiten-2.6.orig/src/worddic.c
+++ gjiten-2.6/src/worddic.c
@@ -932,6 +932,9 @@ WordDic *worddic_create() {
   g_signal_connect(G_OBJECT(wordDic->window), "destroy", G_CALLBACK(worddic_close), NULL);
   gtk_window_set_default_size(GTK_WINDOW(wordDic->window), 500, 500);
 
+  if (gjitenApp->conf->gconf_migration)
+    conf_display_migration_info(gjitenApp->conf, GTK_WINDOW(wordDic->window));
+
   dock_main = gtk_bin_get_child(GTK_BIN(wordDic->window));
   gtk_widget_show(dock_main);
openSUSE Build Service is sponsored by