[tracker/gsettings-remaining-bits: 2/2] libtracker-fts: Port TrackerFTSConfig to gsettings.



commit 07c7045cec8051237b63a6d4b983e76d6a8ef9e9
Author: Ivan Frade <ivan frade nokia com>
Date:   Mon Mar 14 15:10:37 2011 +0200

    libtracker-fts: Port TrackerFTSConfig to gsettings.
    
    Remove manpage and add gsetting schema

 data/gschemas/Makefile.am                          |    1 +
 .../org.freedesktop.Tracker.FTS.gschema.xml.in     |   68 ++++
 .../org.freedesktop.Tracker.gschema.xml.in         |    1 +
 docs/manpages/tracker-fts.cfg.5                    |   44 ---
 src/libtracker-fts/tracker-fts-config.c            |  322 ++++----------------
 src/libtracker-fts/tracker-fts-config.h            |    4 +-
 6 files changed, 124 insertions(+), 316 deletions(-)
---
diff --git a/data/gschemas/Makefile.am b/data/gschemas/Makefile.am
index d0e67c9..6eacdfc 100644
--- a/data/gschemas/Makefile.am
+++ b/data/gschemas/Makefile.am
@@ -4,6 +4,7 @@ gsettings_ENUM_NAMESPACE = org.freedesktop.Tracker
 gsettings_ENUM_FILES = $(top_srcdir)/src/libtracker-common/tracker-enums.h
 gsettings_SCHEMAS = \
 	org.freedesktop.Tracker.gschema.xml \
+	org.freedesktop.Tracker.FTS.gschema.xml \
 	org.freedesktop.Tracker.Store.gschema.xml \
 	org.freedesktop.Tracker.Store.DB.gschema.xml \
 	org.freedesktop.Tracker.Extractor.gschema.xml \
diff --git a/data/gschemas/org.freedesktop.Tracker.FTS.gschema.xml.in b/data/gschemas/org.freedesktop.Tracker.FTS.gschema.xml.in
new file mode 100644
index 0000000..0be6367
--- /dev/null
+++ b/data/gschemas/org.freedesktop.Tracker.FTS.gschema.xml.in
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (C) 2011, Nokia <ivan frade nokia com>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA  02110-1301, USA.
+-->
+<schemalist>
+  <schema id="org.freedesktop.Tracker.FTS" path="/org/freedesktop/tracker/fts/">
+
+    <key name="min-word-length" type="i">
+      <default>3</default>
+      <range min="0" max="30"/>
+      <_summary>Minimum length of a word to be indexed</_summary>
+      <_description>Words with less characters than this will be ignored by the indexer.</_description>
+    </key>
+
+    <key name="max-word-length" type="i">
+      <default>30</default>
+      <range min="0" max="200"/>
+      <_summary>Maximum length of a word to be indexed</_summary>
+      <_description>Words with more characters than this lenght will be ignored by the indexer.</_description>
+    </key>
+
+    <key name="max-words-to-index" type="i">
+      <default>10000</default>
+      <_summary>Maximum number of words to index in a document</_summary>
+      <_description>Indexer will read only this maximum number of words from a single document.</_description>
+    </key>
+
+    <key name="enable-stemmer" type="b">
+      <_summary>Enable stemmer</_summary>
+      <_description>Simplify the words to its root to provide more results.</_description>
+      <default>false</default>
+    </key>
+
+    <key name="enable-unaccent" type="b">
+      <_summary>Enable unaccent</_summary>
+      <_description>Translated accented characters to the equivalent unaccented.</_description>
+      <default>true</default>
+    </key>
+
+    <key name="ignore-numbers" type="b">
+      <_summary>Ignore numbers</_summary>
+      <_description>If enabled, numbers will not be indexed.</_description>
+      <default>true</default>
+    </key>
+
+    <key name="ignore-stop-words" type="b">
+      <_summary>Ignore stop words</_summary>
+      <_description>If enabled, the words listed in the stop-words list are ignored.</_description>
+      <default>true</default>
+    </key>
+
+  </schema>
+</schemalist>
diff --git a/data/gschemas/org.freedesktop.Tracker.gschema.xml.in b/data/gschemas/org.freedesktop.Tracker.gschema.xml.in
index 98f7f12..75b6053 100644
--- a/data/gschemas/org.freedesktop.Tracker.gschema.xml.in
+++ b/data/gschemas/org.freedesktop.Tracker.gschema.xml.in
@@ -23,6 +23,7 @@ Boston, MA  02110-1301, USA.
     <child name="extractor" schema="org.freedesktop.Tracker.Extractor"/>
     <child name="writeback" schema="org.freedesktop.Tracker.Writeback"/>
     <child name="miners" schema="org.freedesktop.Tracker.Miners"/>
+    <child name="fts" schema="org.freedesktop.TrackerFTS"/>
   </schema>
 
   <schema id="org.freedesktop.Tracker.Miners" path="/org/freedesktop/tracker/miners/" />
diff --git a/src/libtracker-fts/tracker-fts-config.c b/src/libtracker-fts/tracker-fts-config.c
index f3b1faa..adce3d3 100644
--- a/src/libtracker-fts/tracker-fts-config.c
+++ b/src/libtracker-fts/tracker-fts-config.c
@@ -29,8 +29,6 @@
 
 #include "tracker-fts-config.h"
 
-#define TRACKER_FTS_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_FTS_CONFIG, TrackerFTSConfigPrivate))
-
 /* GKeyFile defines */
 #define GROUP_INDEXING             "Indexing"
 
@@ -43,24 +41,6 @@
 #define DEFAULT_ENABLE_STEMMER       FALSE  /* As per GB#526346, disabled */
 #define DEFAULT_ENABLE_UNACCENT      TRUE
 
-typedef struct {
-	/* Indexing */
-	gint min_word_length;
-	gint max_word_length;
-	gboolean enable_stemmer;
-	gboolean enable_unaccent;
-	gboolean ignore_numbers;
-	gboolean ignore_stop_words;
-	gint max_words_to_index;
-}  TrackerFTSConfigPrivate;
-
-typedef struct {
-	GType  type;
-	const gchar *property;
-	const gchar *group;
-	const gchar *key;
-} ObjectToKeyFile;
-
 static void config_set_property         (GObject       *object,
                                          guint          param_id,
                                          const GValue  *value,
@@ -71,10 +51,6 @@ static void config_get_property         (GObject       *object,
                                          GParamSpec    *pspec);
 static void config_finalize             (GObject       *object);
 static void config_constructed          (GObject       *object);
-static void config_create_with_defaults (TrackerFTSConfig *config,
-                                         GKeyFile      *key_file,
-                                         gboolean       overwrite);
-static void config_load                 (TrackerFTSConfig *config);
 
 enum {
 	PROP_0,
@@ -91,17 +67,17 @@ enum {
 	PROP_MAX_WORDS_TO_INDEX,
 };
 
-static ObjectToKeyFile conversions[] = {
-	{ G_TYPE_INT,     "min-word-length",    GROUP_INDEXING, "MinWordLength"   },
-	{ G_TYPE_INT,     "max-word-length",    GROUP_INDEXING, "MaxWordLength"   },
-	{ G_TYPE_BOOLEAN, "enable-stemmer",     GROUP_INDEXING, "EnableStemmer"   },
-	{ G_TYPE_BOOLEAN, "enable-unaccent",    GROUP_INDEXING, "EnableUnaccent"  },
-	{ G_TYPE_BOOLEAN, "ignore-numbers",     GROUP_INDEXING, "IgnoreNumbers"   },
-	{ G_TYPE_BOOLEAN, "ignore-stop-words",  GROUP_INDEXING, "IgnoreStopWords" },
-	{ G_TYPE_INT,     "max-words-to-index", GROUP_INDEXING, "MaxWordsToIndex" },
+static TrackerConfigMigrationEntry migration[] = {
+	{ G_TYPE_INT,     GROUP_INDEXING, "MinWordLength",   "min-word-length"    },
+	{ G_TYPE_INT,     GROUP_INDEXING, "MaxWordLength",   "max-word-length"    },
+	{ G_TYPE_BOOLEAN, GROUP_INDEXING, "EnableStemmer" ,  "enable-stemmer"     },
+	{ G_TYPE_BOOLEAN, GROUP_INDEXING, "EnableUnaccent",  "enable-unaccent"    },
+	{ G_TYPE_BOOLEAN, GROUP_INDEXING, "IgnoreNumbers",   "ignore-numbers"     },
+	{ G_TYPE_BOOLEAN, GROUP_INDEXING, "IgnoreStopWords", "ignore-stop-words"  },
+	{ G_TYPE_INT,     GROUP_INDEXING, "MaxWordsToIndex", "max-words-to-index" },
 };
 
-G_DEFINE_TYPE (TrackerFTSConfig, tracker_fts_config, TRACKER_TYPE_CONFIG_FILE);
+G_DEFINE_TYPE (TrackerFTSConfig, tracker_fts_config, G_TYPE_SETTINGS);
 
 static void
 tracker_fts_config_class_init (TrackerFTSConfigClass *klass)
@@ -122,7 +98,7 @@ tracker_fts_config_class_init (TrackerFTSConfigClass *klass)
 	                                                   0,
 	                                                   30,
 	                                                   DEFAULT_MIN_WORD_LENGTH,
-	                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                   G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
 	                                 PROP_MAX_WORD_LENGTH,
 	                                 g_param_spec_int ("max-word-length",
@@ -131,35 +107,35 @@ tracker_fts_config_class_init (TrackerFTSConfigClass *klass)
 	                                                   0,
 	                                                   200, /* Is this a reasonable limit? */
 	                                                   DEFAULT_MAX_WORD_LENGTH,
-	                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                   G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
 	                                 PROP_ENABLE_STEMMER,
 	                                 g_param_spec_boolean ("enable-stemmer",
 	                                                       "Enable Stemmer",
 	                                                       " Flag to enable word stemming utility (default=FALSE)",
 	                                                       DEFAULT_ENABLE_STEMMER,
-	                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                       G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
 	                                 PROP_ENABLE_UNACCENT,
 	                                 g_param_spec_boolean ("enable-unaccent",
 	                                                       "Enable Unaccent",
 	                                                       " Flag to enable word unaccenting (default=TRUE)",
 	                                                       DEFAULT_ENABLE_UNACCENT,
-	                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                       G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
 	                                 PROP_IGNORE_NUMBERS,
 	                                 g_param_spec_boolean ("ignore-numbers",
 	                                                       "Ignore numbers",
 	                                                       " Flag to ignore numbers in FTS (default=TRUE)",
 	                                                       DEFAULT_IGNORE_NUMBERS,
-	                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                       G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
 	                                 PROP_IGNORE_STOP_WORDS,
 	                                 g_param_spec_boolean ("ignore-stop-words",
 	                                                       "Ignore stop words",
 	                                                       " Flag to ignore stop words in FTS (default=TRUE)",
 	                                                       DEFAULT_IGNORE_STOP_WORDS,
-	                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                       G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
 	                                 PROP_MAX_WORDS_TO_INDEX,
 	                                 g_param_spec_int ("max-words-to-index",
@@ -168,9 +144,8 @@ tracker_fts_config_class_init (TrackerFTSConfigClass *klass)
 	                                                   0,
 	                                                   G_MAXINT,
 	                                                   DEFAULT_MAX_WORDS_TO_INDEX,
-	                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+	                                                   G_PARAM_READWRITE));
 
-	g_type_class_add_private (object_class, sizeof (TrackerFTSConfigPrivate));
 }
 
 static void
@@ -227,32 +202,30 @@ config_get_property (GObject    *object,
                      GValue     *value,
                      GParamSpec *pspec)
 {
-	TrackerFTSConfigPrivate *priv;
-
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (object);
+        TrackerFTSConfig *config = TRACKER_FTS_CONFIG (object);
 
 	switch (param_id) {
 		/* Indexing */
 	case PROP_MIN_WORD_LENGTH:
-		g_value_set_int (value, priv->min_word_length);
+		g_value_set_int (value, tracker_fts_config_get_min_word_length (config));
 		break;
 	case PROP_MAX_WORD_LENGTH:
-		g_value_set_int (value, priv->max_word_length);
+		g_value_set_int (value, tracker_fts_config_get_max_word_length (config));
 		break;
 	case PROP_ENABLE_STEMMER:
-		g_value_set_boolean (value, priv->enable_stemmer);
+		g_value_set_boolean (value, tracker_fts_config_get_enable_stemmer (config));
 		break;
 	case PROP_ENABLE_UNACCENT:
-		g_value_set_boolean (value, priv->enable_unaccent);
+		g_value_set_boolean (value, tracker_fts_config_get_enable_unaccent (config));
 		break;
 	case PROP_IGNORE_NUMBERS:
-		g_value_set_boolean (value, priv->ignore_numbers);
+		g_value_set_boolean (value, tracker_fts_config_get_ignore_numbers (config));
 		break;
 	case PROP_IGNORE_STOP_WORDS:
-		g_value_set_boolean (value, priv->ignore_stop_words);
+		g_value_set_boolean (value, tracker_fts_config_get_ignore_stop_words (config));
 		break;
 	case PROP_MAX_WORDS_TO_INDEX:
-		g_value_set_int (value, priv->max_words_to_index);
+		g_value_set_int (value, tracker_fts_config_get_max_words_to_index (config));
 		break;
 
 	default:
@@ -274,151 +247,26 @@ config_finalize (GObject *object)
 static void
 config_constructed (GObject *object)
 {
-	(G_OBJECT_CLASS (tracker_fts_config_parent_class)->constructed) (object);
-
-	config_load (TRACKER_FTS_CONFIG (object));
-}
+        TrackerConfigFile *config_file;
 
-static void
-config_create_with_defaults (TrackerFTSConfig *config,
-                             GKeyFile      *key_file,
-                             gboolean       overwrite)
-{
-	gint i;
-
-	g_message ("Loading defaults into GKeyFile...");
-
-	for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
-		gboolean has_key;
-
-		has_key = g_key_file_has_key (key_file,
-		                              conversions[i].group,
-		                              conversions[i].key,
-		                              NULL);
-		if (!overwrite && has_key) {
-			continue;
-		}
-
-		switch (conversions[i].type) {
-		case G_TYPE_INT:
-			g_key_file_set_integer (key_file,
-			                        conversions[i].group,
-			                        conversions[i].key,
-			                        tracker_keyfile_object_default_int (config,
-			                                                            conversions[i].property));
-			break;
-		case G_TYPE_BOOLEAN:
-			g_key_file_set_boolean (key_file,
-			                        conversions[i].group,
-			                        conversions[i].key,
-			                        tracker_keyfile_object_default_boolean (config,
-			                                                                conversions[i].property));
-			break;
-		default:
-			g_assert_not_reached ();
-			break;
-		}
-
-		g_key_file_set_comment (key_file,
-		                        conversions[i].group,
-		                        conversions[i].key,
-		                        tracker_keyfile_object_blurb (config,
-		                                                      conversions[i].property),
-		                        NULL);
-	}
-}
+	(G_OBJECT_CLASS (tracker_fts_config_parent_class)->constructed) (object);
 
-static void
-config_load (TrackerFTSConfig *config)
-{
-	TrackerConfigFile *file;
-	gint i;
-
-	file = TRACKER_CONFIG_FILE (config);
-	config_create_with_defaults (config, file->key_file, FALSE);
-
-	if (!file->file_exists) {
-		tracker_config_file_save (file);
-	}
-
-	for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
-		gboolean has_key;
-
-		has_key = g_key_file_has_key (file->key_file,
-		                              conversions[i].group,
-		                              conversions[i].key,
-		                              NULL);
-
-		switch (conversions[i].type) {
-		case G_TYPE_INT:
-			tracker_keyfile_object_load_int (G_OBJECT (file),
-			                                 conversions[i].property,
-			                                 file->key_file,
-			                                 conversions[i].group,
-			                                 conversions[i].key);
-			break;
-		case G_TYPE_BOOLEAN:
-			tracker_keyfile_object_load_boolean (G_OBJECT (file),
-			                                     conversions[i].property,
-			                                     file->key_file,
-			                                     conversions[i].group,
-			                                     conversions[i].key);
-			break;
-		default:
-			g_assert_not_reached ();
-			break;
-		}
-	}
-}
+        g_settings_delay (G_SETTINGS (object));
 
-static gboolean
-config_save (TrackerFTSConfig *config)
-{
-	TrackerConfigFile *file;
-	gint i;
-
-	file = TRACKER_CONFIG_FILE (config);
-
-	if (!file->key_file) {
-		g_critical ("Could not save config, GKeyFile was NULL, has the config been loaded?");
-
-		return FALSE;
-	}
-
-	g_message ("Setting details to GKeyFile object...");
-
-	for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
-		switch (conversions[i].type) {
-		case G_TYPE_INT:
-			tracker_keyfile_object_save_int (file,
-			                                 conversions[i].property,
-			                                 file->key_file,
-			                                 conversions[i].group,
-			                                 conversions[i].key);
-			break;
-
-		case G_TYPE_BOOLEAN:
-			tracker_keyfile_object_save_boolean (file,
-			                                     conversions[i].property,
-			                                     file->key_file,
-			                                     conversions[i].group,
-			                                     conversions[i].key);
-			break;
-
-		default:
-			g_assert_not_reached ();
-			break;
-		}
-	}
-
-	return tracker_config_file_save (TRACKER_CONFIG_FILE (config));
+        /* migrate keyfile-based configuration */
+        config_file = tracker_config_file_new ();
+        if (config_file) {
+                tracker_config_file_migrate (config_file, G_SETTINGS (object), migration);
+                g_object_unref (config_file);
+        }
 }
 
 TrackerFTSConfig *
 tracker_fts_config_new (void)
 {
 	return g_object_new (TRACKER_TYPE_FTS_CONFIG,
-	                     "domain", "tracker-fts",
+                             "schema", "org.freedesktop.Tracker.FTS",
+                             "path", "/org/freedesktop/tracker/fts/",
 	                     NULL);
 }
 
@@ -427,108 +275,74 @@ tracker_fts_config_save (TrackerFTSConfig *config)
 {
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), FALSE);
 
-	return config_save (config);
+        g_settings_apply (G_SETTINGS (config));
+
+	return TRUE;
 }
 
 gint
 tracker_fts_config_get_min_word_length (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_MIN_WORD_LENGTH);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->min_word_length;
+	return g_settings_get_int (G_SETTINGS (config), "min-word-length");
 }
 
 gint
 tracker_fts_config_get_max_word_length (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_MAX_WORD_LENGTH);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->max_word_length;
+	return g_settings_get_int (G_SETTINGS (config), "max-word-length");
 }
 
 gboolean
 tracker_fts_config_get_enable_stemmer (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_ENABLE_STEMMER);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->enable_stemmer;
+	return g_settings_get_boolean (G_SETTINGS (config), "enable-stemmer");
 }
 
 gboolean
 tracker_fts_config_get_enable_unaccent (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_ENABLE_UNACCENT);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->enable_unaccent;
+	return g_settings_get_boolean (G_SETTINGS (config), "enable-unaccent");
 }
 
 gboolean
 tracker_fts_config_get_ignore_numbers (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_IGNORE_NUMBERS);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->ignore_numbers;
+	return g_settings_get_boolean (G_SETTINGS (config), "ignore-numbers");
 }
 
 gboolean
 tracker_fts_config_get_ignore_stop_words (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_IGNORE_STOP_WORDS);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->ignore_stop_words;
+	return g_settings_get_boolean (G_SETTINGS (config),  "ignore-stop-words");
 }
 
 gint
 tracker_fts_config_get_max_words_to_index (TrackerFTSConfig *config)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_FTS_CONFIG (config), DEFAULT_MAX_WORDS_TO_INDEX);
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	return priv->max_words_to_index;
+	return g_settings_get_int (G_SETTINGS (config), "max-words-to-index");
 }
 
 void
 tracker_fts_config_set_min_word_length (TrackerFTSConfig *config,
                                         gint              value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	if (!tracker_keyfile_object_validate_int (config, "min-word-length", value)) {
-		return;
-	}
-
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->min_word_length = value;
+        g_settings_set_int (G_SETTINGS (config), "min-word-length", value);
 	g_object_notify (G_OBJECT (config), "min-word-length");
 }
 
@@ -536,17 +350,9 @@ void
 tracker_fts_config_set_max_word_length (TrackerFTSConfig *config,
                                         gint              value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	if (!tracker_keyfile_object_validate_int (config, "max-word-length", value)) {
-		return;
-	}
-
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->max_word_length = value;
+        g_settings_set_int (G_SETTINGS (config), "max-word-length", value);
 	g_object_notify (G_OBJECT (config), "max-word-length");
 }
 
@@ -554,13 +360,9 @@ void
 tracker_fts_config_set_enable_stemmer (TrackerFTSConfig *config,
                                        gboolean          value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->enable_stemmer = value;
+        g_settings_set_boolean (G_SETTINGS (config), "enable-stemmer", value);
 	g_object_notify (G_OBJECT (config), "enable-stemmer");
 }
 
@@ -568,13 +370,9 @@ void
 tracker_fts_config_set_enable_unaccent (TrackerFTSConfig *config,
 					gboolean          value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->enable_unaccent = value;
+        g_settings_set_boolean (G_SETTINGS (config), "enable-unaccent", value);
 	g_object_notify (G_OBJECT (config), "enable-unaccent");
 }
 
@@ -582,13 +380,9 @@ void
 tracker_fts_config_set_ignore_numbers (TrackerFTSConfig *config,
                                        gboolean          value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->ignore_numbers = value;
+        g_settings_set_boolean (G_SETTINGS (config), "ignore-numbers", value);
 	g_object_notify (G_OBJECT (config), "ignore-numbers");
 }
 
@@ -596,13 +390,9 @@ void
 tracker_fts_config_set_ignore_stop_words (TrackerFTSConfig *config,
                                           gboolean          value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->ignore_stop_words = value;
+        g_settings_set_boolean (G_SETTINGS (config), "ignore-stop-words", value);
 	g_object_notify (G_OBJECT (config), "ignore-stop-words");
 }
 
@@ -610,16 +400,8 @@ void
 tracker_fts_config_set_max_words_to_index (TrackerFTSConfig *config,
                                            gint              value)
 {
-	TrackerFTSConfigPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_FTS_CONFIG (config));
 
-	if (!tracker_keyfile_object_validate_int (config, "max-words-to-index", value)) {
-		return;
-	}
-
-	priv = TRACKER_FTS_CONFIG_GET_PRIVATE (config);
-
-	priv->max_words_to_index = value;
+        g_settings_set_int (G_SETTINGS (config), "max-words-to-index", value);
 	g_object_notify (G_OBJECT (config), "max-words-to-index");
 }
diff --git a/src/libtracker-fts/tracker-fts-config.h b/src/libtracker-fts/tracker-fts-config.h
index de75fb8..a3e4a86 100644
--- a/src/libtracker-fts/tracker-fts-config.h
+++ b/src/libtracker-fts/tracker-fts-config.h
@@ -37,11 +37,11 @@ typedef struct TrackerFTSConfig              TrackerFTSConfig;
 typedef struct TrackerFTSConfigClass TrackerFTSConfigClass;
 
 struct TrackerFTSConfig {
-	TrackerConfigFile parent;
+        GSettings parent;
 };
 
 struct TrackerFTSConfigClass {
-	TrackerConfigFileClass parent_class;
+        GSettingsClass parent_class;
 };
 
 GType             tracker_fts_config_get_type               (void) G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]