tracker r2333 - in trunk: . src/libtracker-common src/tracker-preferences



Author: mr
Date: Wed Oct  8 16:26:51 2008
New Revision: 2333
URL: http://svn.gnome.org/viewvc/tracker?rev=2333&view=rev

Log:
	* src/libtracker-common/Makefile.am:
	* src/libtracker-common/tracker-config.[ch]: Added more functions
	to be able to more easily manipulate the lists we store in the
	configuration. Also make it possible to save the config.

	* src/libtracker-common/tracker-file-utils.c: Completely reworked
	tracker_path_list_filter_duplicates() so it works similarly to the
	hash table function. Also removed some of the debugging here and
	casting which was unnecessary.

	* src/tracker-preferences/Makefile.am: Reworked the Makefile to be
	inline with others we have. Fixed the linking order.

	* src/tracker-preferences/tracker-preferences-main.c:
	* src/tracker-preferences/tracker-preferences.c: Completely
	reworked the source here to use TrackerConfig instead of
	TrackerConfiguration.


Removed:
   trunk/src/libtracker-common/tracker-configuration.c
   trunk/src/libtracker-common/tracker-configuration.h
Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/Makefile.am
   trunk/src/libtracker-common/tracker-config.c
   trunk/src/libtracker-common/tracker-config.h
   trunk/src/libtracker-common/tracker-file-utils.c
   trunk/src/libtracker-common/tracker-language.c
   trunk/src/libtracker-common/tracker-language.h
   trunk/src/libtracker-common/tracker-type-utils.c
   trunk/src/tracker-preferences/Makefile.am
   trunk/src/tracker-preferences/tracker-preferences-main.c
   trunk/src/tracker-preferences/tracker-preferences.c

Modified: trunk/src/libtracker-common/Makefile.am
==============================================================================
--- trunk/src/libtracker-common/Makefile.am	(original)
+++ trunk/src/libtracker-common/Makefile.am	Wed Oct  8 16:26:51 2008
@@ -33,7 +33,6 @@
 	$(os_sources)					\
 	$(hal_sources)					\
 	tracker-config.c 				\
-	tracker-configuration.c 			\
 	tracker-dbus.c	 				\
 	tracker-field.c					\
 	tracker-field-data.c				\
@@ -51,7 +50,6 @@
 
 noinst_HEADERS =					\
 	$(hal_headers)					\
-	tracker-configuration.h				\
 	tracker-dbus.h					\
 	tracker-field-data.h				\
 	tracker-ioprio.h				\

Modified: trunk/src/libtracker-common/tracker-config.c
==============================================================================
--- trunk/src/libtracker-common/tracker-config.c	(original)
+++ trunk/src/libtracker-common/tracker-config.c	Wed Oct  8 16:26:51 2008
@@ -31,6 +31,7 @@
 #include "tracker-language.h"
 #include "tracker-config.h"
 #include "tracker-file-utils.h"
+#include "tracker-type-utils.h"
 
 #define TRACKER_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CONFIG, TrackerConfigPrivate))
 
@@ -104,6 +105,8 @@
 	GFile	     *file;
 	GFileMonitor *monitor;
 
+	GKeyFile     *key_file;
+
 	/* General */
 	gint	      verbosity;
 	gint	      initial_sleep;
@@ -144,16 +147,17 @@
 	gboolean      enable_xesam;
 };
 
-static void config_finalize	(GObject      *object);
-static void config_get_property (GObject      *object,
-				 guint	       param_id,
-				 GValue	      *value,
-				 GParamSpec   *pspec);
-static void config_set_property (GObject      *object,
-				 guint	       param_id,
-				 const GValue *value,
-				 GParamSpec   *pspec);
-static void config_load		(TrackerConfig *config);
+static void     config_finalize     (GObject       *object);
+static void     config_get_property (GObject       *object,
+				     guint          param_id,
+				     GValue        *value,
+				     GParamSpec    *pspec);
+static void     config_set_property (GObject       *object,
+				     guint          param_id,
+				     const GValue  *value,
+				     GParamSpec    *pspec);
+static void     config_load         (TrackerConfig *config);
+static gboolean config_save         (TrackerConfig *config);
 
 enum {
 	PROP_0,
@@ -463,6 +467,11 @@
 static void
 tracker_config_init (TrackerConfig *object)
 {
+	TrackerConfigPrivate *priv;
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (object);
+
+	priv->key_file = g_key_file_new ();
 }
 
 static void
@@ -486,6 +495,10 @@
 
 	g_free (priv->language);
 
+	if (priv->key_file) {
+		g_key_file_free (priv->key_file);
+	}
+
 	if (priv->monitor) {
 		g_object_unref (priv->monitor);
 	}
@@ -955,6 +968,10 @@
 	GSList *list = NULL;
 	gint	i;
 
+	if (!value) {
+		return NULL;
+	}
+
 	for (i = 0; value[i]; i++) {
 		const gchar *str;
 		gchar	    *validated;
@@ -1053,61 +1070,127 @@
 	TrackerConfigPrivate  *priv;
 	GSList		      *l;
 	gchar		     **value;
+	gboolean               is_directory_list = TRUE;
 
 	priv = TRACKER_CONFIG_GET_PRIVATE (config);
 
+	if (strcmp (property, "no-index-file-types") == 0 || 
+	    strcmp (property, "disabled-modules") == 0) {
+		is_directory_list = FALSE;
+	}
+
 	value = g_key_file_get_string_list (key_file, group, key, NULL, NULL);
+	l = config_string_list_to_gslist ((const gchar **) value, is_directory_list);
 
 	if (strcmp (property, "watch-directory-roots") == 0) {
-		if (value) {
-			priv->watch_directory_roots = l =
-				config_string_list_to_gslist ((const gchar **) value, TRUE);
-			priv->watch_directory_roots =
-				tracker_path_list_filter_duplicates (priv->watch_directory_roots);
-
-			g_slist_foreach (l, (GFunc) g_free, NULL);
-			g_slist_free (l);
-		}
+		priv->watch_directory_roots = tracker_path_list_filter_duplicates (l); 
 	}
 	else if (strcmp (property, "crawl-directory-roots") == 0) {
-		if (value) {
-			priv->crawl_directory_roots = l =
-				config_string_list_to_gslist ((const gchar **) value, TRUE);
-			priv->crawl_directory_roots =
-				tracker_path_list_filter_duplicates (priv->crawl_directory_roots);
-
-			g_slist_foreach (l, (GFunc) g_free, NULL);
-			g_slist_free (l);
-		}
+		priv->crawl_directory_roots = tracker_path_list_filter_duplicates (l);
 	}
 	else if (strcmp (property, "no-watch-directory-roots") == 0) {
-		if (value) {
-			priv->no_watch_directory_roots = l =
-				config_string_list_to_gslist ((const gchar **) value, TRUE);
-			priv->no_watch_directory_roots =
-				tracker_path_list_filter_duplicates (priv->no_watch_directory_roots);
+		priv->no_watch_directory_roots = tracker_path_list_filter_duplicates (l);
+	}
+	else if (strcmp (property, "no-index-file-types") == 0) {
+		priv->no_index_file_types = l;
+	}
+	else if (strcmp (property, "disabled-modules") == 0) {
+		priv->disabled_modules = l;
+	}
+	else {
+		g_warning ("Property '%s' not recognized to set string list from key '%s'",
+			   property, key);
+		return;
+	}
 
-			g_slist_foreach (l, (GFunc) g_free, NULL);
-			g_slist_free (l);
-		}
+	if (is_directory_list) {
+		g_slist_foreach (l, (GFunc) g_free, NULL);
+		g_slist_free (l);
+	}
+
+	g_strfreev (value);
+}
+
+static void
+config_save_int (TrackerConfig *config,
+		 const gchar   *property,
+		 GKeyFile      *key_file,
+		 const gchar   *group,
+		 const gchar   *key)
+{
+	gint value;
+
+	g_object_get (G_OBJECT (config), property, &value, NULL);
+	g_key_file_set_integer (key_file, group, key, value);
+}
+
+static void
+config_save_boolean (TrackerConfig *config,
+		     const gchar   *property,
+		     GKeyFile	   *key_file,
+		     const gchar   *group,
+		     const gchar   *key)
+{
+	gboolean value;
+
+	g_object_get (G_OBJECT (config), property, &value, NULL);
+	g_key_file_set_boolean (key_file, group, key, value);
+}
+
+static void
+config_save_string (TrackerConfig *config,
+		    const gchar	  *property,
+		    GKeyFile	  *key_file,
+		    const gchar	  *group,
+		    const gchar	  *key)
+{
+	gchar *value;
+
+	g_object_get (G_OBJECT (config), property, &value, NULL);
+	g_key_file_set_string (key_file, group, key, value);
+	g_free (value);
+}
+
+static void
+config_save_string_list (TrackerConfig *config,
+			 const gchar   *property,
+			 GKeyFile      *key_file,
+			 const gchar   *group,
+			 const gchar   *key)
+{
+	TrackerConfigPrivate  *priv;
+	GSList		      *list;
+	gchar		     **value;
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	if (strcmp (property, "watch-directory-roots") == 0) {
+		list = priv->watch_directory_roots;
+	}
+	else if (strcmp (property, "crawl-directory-roots") == 0) {
+		list = priv->crawl_directory_roots;
+	}
+	else if (strcmp (property, "no-watch-directory-roots") == 0) {
+		list = priv->no_watch_directory_roots;
 	}
 	else if (strcmp (property, "no-index-file-types") == 0) {
-		if (value) {
-			priv->no_index_file_types =
-				config_string_list_to_gslist ((const gchar **) value, FALSE);
-		}
+		list = priv->no_index_file_types;
 	}
 	else if (strcmp (property, "disabled-modules") == 0) {
-		if (value) {
-			priv->disabled_modules =
-				config_string_list_to_gslist ((const gchar **) value, FALSE);
-		}
+		list = priv->disabled_modules;
 	}
 	else {
 		g_warning ("Property '%s' not recognized to set string list from key '%s'",
 			   property, key);
+		return;
 	}
 
+	value = tracker_gslist_to_string_list (list);
+	g_key_file_set_string_list (key_file, 
+				    group, 
+				    key, 
+				    (const gchar * const *) value, 
+				    (gsize) g_slist_length (list));
 	g_strfreev (value);
 }
 
@@ -1145,14 +1228,11 @@
 config_load (TrackerConfig *config)
 {
 	TrackerConfigPrivate *priv;
-	GKeyFile	     *key_file;
 	GError		     *error = NULL;
 	gchar		     *filename;
 	gchar		     *directory;
 	gboolean	      value;
 
-	key_file = g_key_file_new ();
-
 	/* Check we have a config file and if not, create it based on
 	 * the default settings.
 	 */
@@ -1186,57 +1266,60 @@
 	}
 
 	/* Load options */
-	g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &error);
+	g_key_file_load_from_file (priv->key_file, 
+				   filename, 
+				   G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+				   &error);
 	if (error) {
-		config_create_with_defaults (filename, key_file);
+		config_create_with_defaults (filename, priv->key_file);
 		g_clear_error (&error);
 	}
 
 	g_free (filename);
 
 	/* General */
-	config_load_int (config, "verbosity", key_file, GROUP_GENERAL, KEY_VERBOSITY);
-	config_load_int (config, "initial-sleep", key_file, GROUP_GENERAL, KEY_INITIAL_SLEEP);
-	config_load_boolean (config, "low-memory-mode", key_file, GROUP_GENERAL, KEY_LOW_MEMORY_MODE);
-	config_load_boolean (config, "nfs-locking", key_file, GROUP_GENERAL, KEY_NFS_LOCKING);
+	config_load_int (config, "verbosity", priv->key_file, GROUP_GENERAL, KEY_VERBOSITY);
+	config_load_int (config, "initial-sleep", priv->key_file, GROUP_GENERAL, KEY_INITIAL_SLEEP);
+	config_load_boolean (config, "low-memory-mode", priv->key_file, GROUP_GENERAL, KEY_LOW_MEMORY_MODE);
+	config_load_boolean (config, "nfs-locking", priv->key_file, GROUP_GENERAL, KEY_NFS_LOCKING);
 
 	/* Watches */
-	config_load_string_list (config, "watch-directory-roots", key_file, GROUP_WATCHES, KEY_WATCH_DIRECTORY_ROOTS);
-	config_load_string_list (config, "crawl-directory-roots", key_file, GROUP_WATCHES, KEY_CRAWL_DIRECTORY_ROOTS);
-	config_load_string_list (config, "no-watch-directory-roots", key_file, GROUP_WATCHES, KEY_NO_WATCH_DIRECTORY_ROOTS);
-	config_load_boolean (config, "enable-watches", key_file, GROUP_WATCHES, KEY_ENABLE_WATCHES);
+	config_load_string_list (config, "watch-directory-roots", priv->key_file, GROUP_WATCHES, KEY_WATCH_DIRECTORY_ROOTS);
+	config_load_string_list (config, "crawl-directory-roots", priv->key_file, GROUP_WATCHES, KEY_CRAWL_DIRECTORY_ROOTS);
+	config_load_string_list (config, "no-watch-directory-roots", priv->key_file, GROUP_WATCHES, KEY_NO_WATCH_DIRECTORY_ROOTS);
+	config_load_boolean (config, "enable-watches", priv->key_file, GROUP_WATCHES, KEY_ENABLE_WATCHES);
 
 	/* Indexing */
-	config_load_int (config, "throttle", key_file, GROUP_INDEXING, KEY_THROTTLE);
-	config_load_boolean (config, "enable-indexing", key_file, GROUP_INDEXING, KEY_ENABLE_INDEXING);
-	config_load_boolean (config, "enable-content-indexing", key_file, GROUP_INDEXING, KEY_ENABLE_CONTENT_INDEXING);
-	config_load_boolean (config, "enable-thumbnails", key_file, GROUP_INDEXING, KEY_ENABLE_THUMBNAILS);
-	config_load_string_list (config, "disabled-modules", key_file, GROUP_INDEXING, KEY_DISABLED_MODULES);
-	config_load_boolean (config, "fast-merges", key_file, GROUP_INDEXING, KEY_FAST_MERGES);
-	config_load_string_list (config, "no-index-file-types", key_file, GROUP_INDEXING, KEY_NO_INDEX_FILE_TYPES);
-	config_load_int (config, "min-word-length", key_file, GROUP_INDEXING, KEY_MIN_WORD_LENGTH);
-	config_load_int (config, "max-word-length", key_file, GROUP_INDEXING, KEY_MAX_WORD_LENGTH);
-	config_load_string (config, "language", key_file, GROUP_INDEXING, KEY_LANGUAGE);
-	config_load_boolean (config, "enable-stemmer", key_file, GROUP_INDEXING, KEY_ENABLE_STEMMER);
-	config_load_boolean (config, "disable-indexing-on-battery", key_file, GROUP_INDEXING, KEY_DISABLE_INDEXING_ON_BATTERY);
-	config_load_boolean (config, "disable-indexing-on-battery-init", key_file, GROUP_INDEXING, KEY_DISABLE_INDEXING_ON_BATTERY_INIT);
-	config_load_int (config, "low-disk-space-limit", key_file, GROUP_INDEXING, KEY_LOW_DISK_SPACE_LIMIT);
-	config_load_boolean (config, "index-mounted-directories", key_file, GROUP_INDEXING, KEY_INDEX_MOUNTED_DIRECTORIES);
-	config_load_boolean (config, "index-removable-devices", key_file, GROUP_INDEXING, KEY_INDEX_REMOVABLE_DEVICES);
+	config_load_int (config, "throttle", priv->key_file, GROUP_INDEXING, KEY_THROTTLE);
+	config_load_boolean (config, "enable-indexing", priv->key_file, GROUP_INDEXING, KEY_ENABLE_INDEXING);
+	config_load_boolean (config, "enable-content-indexing", priv->key_file, GROUP_INDEXING, KEY_ENABLE_CONTENT_INDEXING);
+	config_load_boolean (config, "enable-thumbnails", priv->key_file, GROUP_INDEXING, KEY_ENABLE_THUMBNAILS);
+	config_load_string_list (config, "disabled-modules", priv->key_file, GROUP_INDEXING, KEY_DISABLED_MODULES);
+	config_load_boolean (config, "fast-merges", priv->key_file, GROUP_INDEXING, KEY_FAST_MERGES);
+	config_load_string_list (config, "no-index-file-types", priv->key_file, GROUP_INDEXING, KEY_NO_INDEX_FILE_TYPES);
+	config_load_int (config, "min-word-length", priv->key_file, GROUP_INDEXING, KEY_MIN_WORD_LENGTH);
+	config_load_int (config, "max-word-length", priv->key_file, GROUP_INDEXING, KEY_MAX_WORD_LENGTH);
+	config_load_string (config, "language", priv->key_file, GROUP_INDEXING, KEY_LANGUAGE);
+	config_load_boolean (config, "enable-stemmer", priv->key_file, GROUP_INDEXING, KEY_ENABLE_STEMMER);
+	config_load_boolean (config, "disable-indexing-on-battery", priv->key_file, GROUP_INDEXING, KEY_DISABLE_INDEXING_ON_BATTERY);
+	config_load_boolean (config, "disable-indexing-on-battery-init", priv->key_file, GROUP_INDEXING, KEY_DISABLE_INDEXING_ON_BATTERY_INIT);
+	config_load_int (config, "low-disk-space-limit", priv->key_file, GROUP_INDEXING, KEY_LOW_DISK_SPACE_LIMIT);
+	config_load_boolean (config, "index-mounted-directories", priv->key_file, GROUP_INDEXING, KEY_INDEX_MOUNTED_DIRECTORIES);
+	config_load_boolean (config, "index-removable-devices", priv->key_file, GROUP_INDEXING, KEY_INDEX_REMOVABLE_DEVICES);
 
 	/* Performance */
-	config_load_int (config, "max-text-to-index", key_file, GROUP_PERFORMANCE, KEY_MAX_TEXT_TO_INDEX);
-	config_load_int (config, "max-words-to-index", key_file, GROUP_PERFORMANCE, KEY_MAX_WORDS_TO_INDEX);
-	config_load_int (config, "max-bucket-count", key_file, GROUP_PERFORMANCE, KEY_MAX_BUCKET_COUNT);
-	config_load_int (config, "min-bucket-count", key_file, GROUP_PERFORMANCE, KEY_MIN_BUCKET_COUNT);
+	config_load_int (config, "max-text-to-index", priv->key_file, GROUP_PERFORMANCE, KEY_MAX_TEXT_TO_INDEX);
+	config_load_int (config, "max-words-to-index", priv->key_file, GROUP_PERFORMANCE, KEY_MAX_WORDS_TO_INDEX);
+	config_load_int (config, "max-bucket-count", priv->key_file, GROUP_PERFORMANCE, KEY_MAX_BUCKET_COUNT);
+	config_load_int (config, "min-bucket-count", priv->key_file, GROUP_PERFORMANCE, KEY_MIN_BUCKET_COUNT);
 
 	/* Services */
-	config_load_boolean (config, "enable-xesam", key_file, GROUP_SERVICES, KEY_ENABLE_XESAM);
+	config_load_boolean (config, "enable-xesam", priv->key_file, GROUP_SERVICES, KEY_ENABLE_XESAM);
 
 	/*
 	 * Legacy options no longer supported:
 	 */
-	value = g_key_file_get_boolean (key_file, "Emails", "IndexEvolutionEmails", &error);
+	value = g_key_file_get_boolean (priv->key_file, "Emails", "IndexEvolutionEmails", &error);
 	if (!error) {
 		gchar * const modules[2] = { "evolution", NULL };
 
@@ -1254,7 +1337,7 @@
 		g_clear_error (&error);
 	}
 
-	value = g_key_file_get_boolean (key_file, "Emails", "IndexThunderbirdEmails", &error);
+	value = g_key_file_get_boolean (priv->key_file, "Emails", "IndexThunderbirdEmails", &error);
 	if (!error) {
 		g_message ("Legacy config option 'IndexThunderbirdEmails' found");
 		g_message ("  This option is no longer supported and has no effect");
@@ -1262,7 +1345,7 @@
 		g_clear_error (&error);
 	}
 
-	value = g_key_file_get_boolean (key_file, "Indexing", "SkipMountPoints", &error);
+	value = g_key_file_get_boolean (priv->key_file, "Indexing", "SkipMountPoints", &error);
 	if (!error) {
 		g_message ("Legacy config option 'SkipMountPoints' found");
 		tracker_config_set_index_mounted_directories (config, !value);
@@ -1270,8 +1353,101 @@
 	} else {
 		g_clear_error (&error);
 	}
+}
+
+static gboolean
+config_save (TrackerConfig *config)
+{
+	TrackerConfigPrivate *priv;
+	GError		     *error = NULL;
+	gchar		     *filename;
+	gchar		     *data;
+	gsize                 size;
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	if (!priv->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...");
+
+	/* Set properties to GKeyFile */
+	config_save_int (config, "verbosity", priv->key_file, GROUP_GENERAL, KEY_VERBOSITY);
+	config_save_int (config, "initial-sleep", priv->key_file, GROUP_GENERAL, KEY_INITIAL_SLEEP);
+	config_save_boolean (config, "low-memory-mode", priv->key_file, GROUP_GENERAL, KEY_LOW_MEMORY_MODE);
+	config_save_boolean (config, "nfs-locking", priv->key_file, GROUP_GENERAL, KEY_NFS_LOCKING);
+
+	/* Watches */
+	config_save_string_list (config, "watch-directory-roots", priv->key_file, GROUP_WATCHES, KEY_WATCH_DIRECTORY_ROOTS);
+	config_save_string_list (config, "crawl-directory-roots", priv->key_file, GROUP_WATCHES, KEY_CRAWL_DIRECTORY_ROOTS);
+	config_save_string_list (config, "no-watch-directory-roots", priv->key_file, GROUP_WATCHES, KEY_NO_WATCH_DIRECTORY_ROOTS);
+	config_save_boolean (config, "enable-watches", priv->key_file, GROUP_WATCHES, KEY_ENABLE_WATCHES);
+
+	/* Indexing */
+	config_save_int (config, "throttle", priv->key_file, GROUP_INDEXING, KEY_THROTTLE);
+	config_save_boolean (config, "enable-indexing", priv->key_file, GROUP_INDEXING, KEY_ENABLE_INDEXING);
+	config_save_boolean (config, "enable-content-indexing", priv->key_file, GROUP_INDEXING, KEY_ENABLE_CONTENT_INDEXING);
+	config_save_boolean (config, "enable-thumbnails", priv->key_file, GROUP_INDEXING, KEY_ENABLE_THUMBNAILS);
+	config_save_string_list (config, "disabled-modules", priv->key_file, GROUP_INDEXING, KEY_DISABLED_MODULES);
+	config_save_boolean (config, "fast-merges", priv->key_file, GROUP_INDEXING, KEY_FAST_MERGES);
+	config_save_string_list (config, "no-index-file-types", priv->key_file, GROUP_INDEXING, KEY_NO_INDEX_FILE_TYPES);
+	config_save_int (config, "min-word-length", priv->key_file, GROUP_INDEXING, KEY_MIN_WORD_LENGTH);
+	config_save_int (config, "max-word-length", priv->key_file, GROUP_INDEXING, KEY_MAX_WORD_LENGTH);
+	config_save_string (config, "language", priv->key_file, GROUP_INDEXING, KEY_LANGUAGE);
+	config_save_boolean (config, "enable-stemmer", priv->key_file, GROUP_INDEXING, KEY_ENABLE_STEMMER);
+	config_save_boolean (config, "disable-indexing-on-battery", priv->key_file, GROUP_INDEXING, KEY_DISABLE_INDEXING_ON_BATTERY);
+	config_save_boolean (config, "disable-indexing-on-battery-init", priv->key_file, GROUP_INDEXING, KEY_DISABLE_INDEXING_ON_BATTERY_INIT);
+	config_save_int (config, "low-disk-space-limit", priv->key_file, GROUP_INDEXING, KEY_LOW_DISK_SPACE_LIMIT);
+	config_save_boolean (config, "index-mounted-directories", priv->key_file, GROUP_INDEXING, KEY_INDEX_MOUNTED_DIRECTORIES);
+	config_save_boolean (config, "index-removable-devices", priv->key_file, GROUP_INDEXING, KEY_INDEX_REMOVABLE_DEVICES);
+
+	/* Performance */
+	config_save_int (config, "max-text-to-index", priv->key_file, GROUP_PERFORMANCE, KEY_MAX_TEXT_TO_INDEX);
+	config_save_int (config, "max-words-to-index", priv->key_file, GROUP_PERFORMANCE, KEY_MAX_WORDS_TO_INDEX);
+	config_save_int (config, "max-bucket-count", priv->key_file, GROUP_PERFORMANCE, KEY_MAX_BUCKET_COUNT);
+	config_save_int (config, "min-bucket-count", priv->key_file, GROUP_PERFORMANCE, KEY_MIN_BUCKET_COUNT);
+
+	/* Services */
+	config_save_boolean (config, "enable-xesam", priv->key_file, GROUP_SERVICES, KEY_ENABLE_XESAM);
+
+	g_message ("Saving config to disk...");
+
+	/* Do the actual saving to disk now */
+	data = g_key_file_to_data (priv->key_file, &size, &error);
+	if (error) {
+		g_warning ("Could not get config data to write to file, %s",
+			   error->message);
+		g_error_free (error);
+
+		return FALSE;
+	}
+
+	filename = g_file_get_path (priv->file);
 
-	g_key_file_free (key_file);
+	g_file_set_contents (filename, data, size, &error);
+	g_free (data);
+
+	if (error) {
+		g_warning ("Could not write %d bytes to file '%s', %s",
+			   size,
+			   filename,
+			   error->message);
+		g_free (filename);
+		g_error_free (error);
+
+		return FALSE;
+	}
+
+	g_message ("Wrote config to '%s' (%d bytes)",
+		   filename, 
+		   size);
+
+	g_free (filename);
+
+	return TRUE;
 }
 
 static gboolean
@@ -1318,6 +1494,22 @@
 }
 
 /**
+ * tracker_config_save:
+ * @config: a #TrackerConfig
+ *
+ * Writes the configuration stored in TrackerConfig to disk.
+ *
+ * Return value: %TRUE on success, %FALSE otherwise.
+ */
+gboolean
+tracker_config_save (TrackerConfig *config)
+{
+	g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
+
+	return config_save (config);
+}
+
+/**
  * tracker_config_get_verbosity:
  * @config: a #TrackerConfig
  *
@@ -2214,6 +2406,106 @@
 }
 
 void
+tracker_config_add_no_index_file_types (TrackerConfig *config,
+					gchar * const *file_types)
+{
+	TrackerConfigPrivate *priv;
+	GSList		     *new_file_types;
+	gchar * const	     *p;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+	g_return_if_fail (file_types != NULL);
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	new_file_types = NULL;
+
+	for (p = file_types; *p; p++) {
+		if (g_slist_find_custom (priv->no_index_file_types,
+					 *p,
+					 (GCompareFunc) strcmp)) {
+			continue;
+		}
+
+		new_file_types = g_slist_append (new_file_types, g_strdup (*p));
+	}
+
+	priv->no_index_file_types = g_slist_concat (priv->no_index_file_types,
+						    new_file_types);
+
+	g_object_notify (G_OBJECT (config), "no-index-file-types");
+}
+
+void
+tracker_config_remove_watch_directory_roots (TrackerConfig *config,
+					     const gchar   *root)
+{
+	TrackerConfigPrivate *priv;
+	GSList		     *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+	g_return_if_fail (root != NULL);
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = g_slist_find_custom (priv->watch_directory_roots,
+				 root,
+				 (GCompareFunc) strcmp);
+
+	if (l) {
+		g_free (l->data);
+		priv->watch_directory_roots = g_slist_delete_link (priv->watch_directory_roots, l);
+		g_object_notify (G_OBJECT (config), "watch-directory-roots");
+	}
+}
+
+void
+tracker_config_remove_crawl_directory_roots (TrackerConfig *config,
+					     const gchar   *root)
+{
+	TrackerConfigPrivate *priv;
+	GSList		     *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+	g_return_if_fail (root != NULL);
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = g_slist_find_custom (priv->crawl_directory_roots,
+				 root,
+				 (GCompareFunc) strcmp);
+
+	if (l) {
+		g_free (l->data);
+		priv->crawl_directory_roots = g_slist_delete_link (priv->crawl_directory_roots, l);
+		g_object_notify (G_OBJECT (config), "crawl-directory-roots");
+	}
+}
+
+void
+tracker_config_remove_no_watch_directory_roots (TrackerConfig *config,
+						const gchar   *root)
+{
+	TrackerConfigPrivate *priv;
+	GSList		     *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+	g_return_if_fail (root != NULL);
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = g_slist_find_custom (priv->no_watch_directory_roots,
+				 root,
+				 (GCompareFunc) strcmp);
+
+	if (l) {
+		g_free (l->data);
+		priv->no_watch_directory_roots = g_slist_delete_link (priv->no_watch_directory_roots, l);
+		g_object_notify (G_OBJECT (config), "no-watch-directory-roots");
+	}
+}
+
+void
 tracker_config_remove_disabled_modules (TrackerConfig *config,
 					const gchar   *module)
 {
@@ -2235,3 +2527,151 @@
 		g_object_notify (G_OBJECT (config), "disabled-modules");
 	}
 }
+
+void
+tracker_config_remove_no_index_file_types (TrackerConfig *config,
+					   const gchar   *file_type)
+{
+	TrackerConfigPrivate *priv;
+	GSList		     *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+	g_return_if_fail (file_type != NULL);
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = g_slist_find_custom (priv->no_index_file_types,
+				 file_type,
+				 (GCompareFunc) strcmp);
+
+	if (l) {
+		g_free (l->data);
+		priv->no_index_file_types = g_slist_delete_link (priv->no_index_file_types, l);
+		g_object_notify (G_OBJECT (config), "no-index-file-types");
+	}
+}
+
+void	       
+tracker_config_set_watch_directory_roots (TrackerConfig *config,
+					  GSList        *roots)
+{
+	TrackerConfigPrivate *priv;
+	GSList               *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = priv->watch_directory_roots;
+
+	if (!roots) {
+		priv->watch_directory_roots = NULL;
+	} else {
+		priv->watch_directory_roots = tracker_gslist_copy_with_string_data (roots);
+	}
+
+	g_slist_foreach (l, (GFunc) g_free, NULL);
+	g_slist_free (l);
+
+	g_object_notify (G_OBJECT (config), "watch-directory-roots");
+}
+
+void	       
+tracker_config_set_crawl_directory_roots (TrackerConfig *config,
+					  GSList        *roots)
+{
+	TrackerConfigPrivate *priv;
+	GSList               *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = priv->crawl_directory_roots;
+
+	if (!roots) {
+		priv->crawl_directory_roots = NULL;
+	} else {
+		priv->crawl_directory_roots = tracker_gslist_copy_with_string_data (roots);
+	}
+
+	g_slist_foreach (l, (GFunc) g_free, NULL);
+	g_slist_free (l);
+
+	g_object_notify (G_OBJECT (config), "crawl-directory-roots");
+}
+
+void	       
+tracker_config_set_no_watch_directory_roots (TrackerConfig *config,
+					     GSList        *roots)
+{
+	TrackerConfigPrivate *priv;
+	GSList               *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+	
+	l = priv->no_watch_directory_roots;
+
+	if (!roots) {
+		priv->no_watch_directory_roots = NULL;
+	} else {
+		priv->no_watch_directory_roots = tracker_gslist_copy_with_string_data (roots);
+	}
+
+	g_slist_foreach (l, (GFunc) g_free, NULL);
+	g_slist_free (l);
+
+	g_object_notify (G_OBJECT (config), "no-watch-directory-roots");
+}
+
+void	       
+tracker_config_set_disabled_modules (TrackerConfig *config,
+				     GSList        *modules)
+{
+	TrackerConfigPrivate *priv;
+	GSList               *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = priv->disabled_modules;
+
+	if (!modules) {
+		priv->disabled_modules = NULL;
+	} else {
+		priv->disabled_modules = tracker_gslist_copy_with_string_data (modules);
+	}
+
+	g_slist_foreach (l, (GFunc) g_free, NULL);
+	g_slist_free (l);
+
+	g_object_notify (G_OBJECT (config), "disabled-modules");
+}
+
+void	       
+tracker_config_set_no_index_file_types (TrackerConfig *config,
+					GSList        *file_types)
+{
+	TrackerConfigPrivate *priv;
+	GSList               *l;
+
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+
+	priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+	l = priv->no_index_file_types;
+
+	if (!file_types) {
+		priv->no_index_file_types = NULL;
+	} else {
+		priv->no_index_file_types = tracker_gslist_copy_with_string_data (file_types);
+	}
+
+	g_slist_foreach (l, (GFunc) g_free, NULL);
+	g_slist_free (l);
+
+	g_object_notify (G_OBJECT (config), "no-index-file-types");
+}

Modified: trunk/src/libtracker-common/tracker-config.h
==============================================================================
--- trunk/src/libtracker-common/tracker-config.h	(original)
+++ trunk/src/libtracker-common/tracker-config.h	Wed Oct  8 16:26:51 2008
@@ -52,6 +52,8 @@
 GType	       tracker_config_get_type				   (void) G_GNUC_CONST;
 
 TrackerConfig *tracker_config_new				   (void);
+gboolean       tracker_config_save                                 (TrackerConfig *config);
+
 gint	       tracker_config_get_verbosity			   (TrackerConfig *config);
 gint	       tracker_config_get_initial_sleep			   (TrackerConfig *config);
 gboolean       tracker_config_get_low_memory_mode		   (TrackerConfig *config);
@@ -130,7 +132,7 @@
 void	       tracker_config_set_min_bucket_count		   (TrackerConfig *config,
 								    gint	   value);
 
-/* Directory root APIs*/
+/* List APIs*/
 void	       tracker_config_add_watch_directory_roots		   (TrackerConfig *config,
 								    gchar * const *roots);
 void	       tracker_config_add_crawl_directory_roots		   (TrackerConfig *config,
@@ -139,8 +141,30 @@
 								    gchar * const *roots);
 void	       tracker_config_add_disabled_modules		   (TrackerConfig *config,
 								    gchar * const *modules);
+void	       tracker_config_add_no_index_file_types		   (TrackerConfig *config,
+								    gchar * const *file_types);
+
+void	       tracker_config_remove_watch_directory_roots         (TrackerConfig *config,
+								    const gchar   *root);
+void	       tracker_config_remove_crawl_directory_roots         (TrackerConfig *config,
+								    const gchar   *root);
+void	       tracker_config_remove_no_watch_directory_roots      (TrackerConfig *config,
+								    const gchar   *root);
 void	       tracker_config_remove_disabled_modules		   (TrackerConfig *config,
 								    const gchar   *module);
+void	       tracker_config_remove_no_index_file_types	   (TrackerConfig *config,
+								    const gchar   *file_types);
+
+void	       tracker_config_set_watch_directory_roots		   (TrackerConfig *config,
+								    GSList        *roots);
+void	       tracker_config_set_crawl_directory_roots		   (TrackerConfig *config,
+								    GSList        *roots);
+void	       tracker_config_set_no_watch_directory_roots	   (TrackerConfig *config,
+								    GSList        *roots);
+void	       tracker_config_set_disabled_modules		   (TrackerConfig *config,
+								    GSList        *modules);
+void	       tracker_config_set_no_index_file_types		   (TrackerConfig *config,
+								    GSList        *types);
 
 G_END_DECLS
 

Modified: trunk/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- trunk/src/libtracker-common/tracker-file-utils.c	(original)
+++ trunk/src/libtracker-common/tracker-file-utils.c	Wed Oct  8 16:26:51 2008
@@ -35,6 +35,7 @@
 #include "tracker-log.h"
 #include "tracker-os-dependant.h"
 #include "tracker-file-utils.h"
+#include "tracker-type-utils.h"
 
 #define TEXT_SNIFF_SIZE 4096
 
@@ -481,19 +482,17 @@
 	GHashTableIter iter1, iter2;
 	gpointer       key;
 
-	g_debug ("Filtering duplicates in path hash table:");
-
 	g_hash_table_iter_init (&iter1, roots);
 	while (g_hash_table_iter_next (&iter1, &key, NULL)) {
 		const gchar *path;
 
-		path = (const gchar*) key;
+		path = key;
 
 		g_hash_table_iter_init (&iter2, roots);
 		while (g_hash_table_iter_next (&iter2, &key, NULL)) {
 			const gchar *in_path;
 
-			in_path = (const gchar*) key;
+			in_path = key;
 
 			if (path == in_path) {
 				continue;
@@ -518,7 +517,7 @@
 	}
 
 #ifdef TESTING
-	g_debug ("Using the following roots to crawl:");
+	g_debug ("Hash table paths were filtered down to:");
 
 	if (TRUE) {
 		GList *keys, *l;
@@ -537,87 +536,74 @@
 GSList *
 tracker_path_list_filter_duplicates (GSList *roots)
 {
-	GSList *checked_roots = NULL;
 	GSList *l1, *l2;
+	GSList *new_list;
 
-	/* This function CREATES a new list and the data in the list
-	 * is new too! g_free() must be called on the list data and
-	 * g_slist_free() on the list too when done with.
-	 */
+	new_list = tracker_gslist_copy_with_string_data (roots);
+	l1 = new_list;
 
-	/* ONLY HERE do we add separators on each location we check.
-	 * The reason for this is that these locations are user
-	 * entered in the configuration and we need to make sure we
-	 * don't include the same location more than once.
-	 */
+	while (l1) {
+		const gchar *path;
+		gboolean     reset = FALSE;
 
-	for (l1 = roots; l1; l1 = l1->next) {
-		gchar	 *path;
-		gboolean  should_add = TRUE;
+		path = l1->data;
 
-		if (!g_str_has_suffix (l1->data, G_DIR_SEPARATOR_S)) {
-			path = g_strconcat (l1->data, G_DIR_SEPARATOR_S, NULL);
-		} else {
-			path = g_strdup (l1->data);
-		}
+		l2 = new_list;
+
+		while (l2 && !reset) {
+			const gchar *in_path;
 
-		l2 = checked_roots;
+			in_path = l2->data;
+			
+			if (path == in_path) {
+				/* Do nothing */
+			} 
+			else if (tracker_path_is_in_path (path, in_path)) {
+				g_debug ("Removing path:'%s', it is in path:'%s'",
+					 path, in_path);
 
-		while (l2 && should_add) {
-			/* If the new path exists as a lower level
-			 * path or is the same as an existing checked
-			 * root we disgard it, it will be checked
-			 * anyway.
-			 */
-			if (g_str_has_prefix (path, l2->data)) {
-				should_add = FALSE;
-			}
+				g_free (l1->data);
+				new_list = g_slist_delete_link (new_list, l1);
+				l1 = new_list;
+
+				reset = TRUE;
 
-			/* If the new path exists as a higher level
-			 * path to one already in the checked roots,
-			 * we remove the checked roots version
-			 */
-			if (g_str_has_prefix (l2->data, path)) {
-				checked_roots = g_slist_remove_link (checked_roots, l2);
+				continue;
+			} 
+			else if (tracker_path_is_in_path (in_path, path)) {
+				g_debug ("Removing path:'%s', it is in path:'%s'",
+					 in_path, path);
+				
 				g_free (l2->data);
+				new_list = g_slist_delete_link (new_list, l2);
+				l1 = new_list;
+
+				reset = TRUE;
 
-				l2 = checked_roots;
 				continue;
 			}
 
 			l2 = l2->next;
 		}
-
-		if (should_add) {
-			gint len;
-
-			/* Don't use the trailing '/' and make sure we
-			 * don't remove '/' if that is the content of
-			 * the string or it is '//'.
-			 */
-			len = strlen (path);
-			if (len > 2) {
-				path[len - 1] = '\0';
-			}
-
-			checked_roots = g_slist_prepend (checked_roots, path);
-			continue;
+		
+		if (G_LIKELY (!reset)) {
+			l1 = l1->next;
 		}
-
-		g_free (path);
 	}
 
-	checked_roots = g_slist_reverse (checked_roots);
-
 #ifdef TESTING
-	g_debug ("Using the following roots to crawl:");
+	g_debug ("GSList paths were filtered down to:");
 
-	for (l1 = checked_roots; l1; l1 = l1->next) {
-		g_debug ("  %s", (gchar*) l1->data);
+	if (TRUE) {
+		GSList *l;
+
+		for (l = new_list; l; l = l->next) {
+			g_debug ("  %s", (gchar*) l->data);
+		}
 	}
 #endif /* TESTING */
 
-	return checked_roots;
+	return new_list;
 }
 
 gchar *

Modified: trunk/src/libtracker-common/tracker-language.c
==============================================================================
--- trunk/src/libtracker-common/tracker-language.c	(original)
+++ trunk/src/libtracker-common/tracker-language.c	Wed Oct  8 16:26:51 2008
@@ -50,19 +50,19 @@
 };
 
 static Languages all_langs[] = {
-	{ "da", "danish" },
-	{ "nl", "dutch" },
-	{ "en", "english" },
-	{ "fi", "finnish" },
-	{ "fr", "french" },
-	{ "de", "german" },
-	{ "hu", "hungarian" },
-	{ "it", "italian" },
-	{ "nb", "norwegian" },
-	{ "pt", "portuguese" },
-	{ "ru", "russian" },
-	{ "es", "spanish" },
-	{ "sv", "swedish" },
+	{ "da", "Danish" },
+	{ "nl", "Dutch" },
+	{ "en", "English" },
+	{ "fi", "Finnish" },
+	{ "fr", "French" },
+	{ "de", "German" },
+	{ "hu", "Hungarian" },
+	{ "it", "Italian" },
+	{ "nb", "Norwegian" },
+	{ "pt", "Portuguese" },
+	{ "ru", "Russian" },
+	{ "es", "Spanish" },
+	{ "sv", "Swedish" },
 	{ NULL, NULL },
 };
 
@@ -83,7 +83,6 @@
 						guint	       param_id,
 						const GValue  *value,
 						GParamSpec    *pspec);
-static const gchar *language_get_name_for_code (const gchar   *language_code);
 static void	    language_notify_cb	       (TrackerConfig *config,
 						GParamSpec    *param,
 						gpointer       user_data);
@@ -133,7 +132,7 @@
 
 	priv->stemmer_mutex = g_mutex_new ();
 
-	stem_language = language_get_name_for_code (NULL);
+	stem_language = tracker_language_get_name_by_code (NULL);
 	priv->stemmer = sb_stemmer_new (stem_language, NULL);
 }
 
@@ -228,24 +227,6 @@
 	return filename;
 }
 
-static const gchar *
-language_get_name_for_code (const gchar *language_code)
-{
-	gint i;
-
-	if (!language_code || language_code[0] == '\0') {
-		return "english";
-	}
-
-	for (i = 0; all_langs[i].code; i++) {
-		if (g_str_has_prefix (language_code, all_langs[i].code)) {
-			return all_langs[i].name;
-		}
-	}
-
-	return "";
-}
-
 static void
 language_add_stopwords (TrackerLanguage *language,
 			const gchar	*filename)
@@ -287,7 +268,8 @@
 {
 	TrackerLanguagePriv *priv;
 	gchar		    *stopword_filename;
-	const gchar	    *stem_language;
+	gchar               *stem_language_lower;
+	const gchar         *stem_language;
 
 	g_return_if_fail (TRACKER_IS_LANGUAGE (language));
 
@@ -308,7 +290,8 @@
 
 	g_message ("Setting up stemmer for language code:'%s'", language_code);
 
-	stem_language = language_get_name_for_code (language_code);
+	stem_language = tracker_language_get_name_by_code (language_code);
+	stem_language_lower = g_ascii_strdown (stem_language, -1);
 
 	g_mutex_lock (priv->stemmer_mutex);
 
@@ -316,13 +299,15 @@
 		sb_stemmer_delete (priv->stemmer);
 	}
 
-	priv->stemmer = sb_stemmer_new (stem_language, NULL);
+	priv->stemmer = sb_stemmer_new (stem_language_lower, NULL);
 	if (!priv->stemmer) {
 		g_message ("No stemmer could be found for language:'%s'",
-			   stem_language);
+			   stem_language_lower);
 	}
 
 	g_mutex_unlock (priv->stemmer_mutex);
+
+	g_free (stem_language_lower);
 }
 
 static void
@@ -487,3 +472,73 @@
 
 	return g_strdup ("en");
 }
+
+GSList *
+tracker_language_get_all_by_name (void)
+{
+	GSList *list = NULL;
+	gint i;
+
+	/* Shouldn't we use g_get_language_names() instead? -mr */
+
+	for (i = 0; all_langs[i].code; i++) {
+		list = g_slist_prepend (list, all_langs[i].name);
+	}
+
+	list = g_slist_reverse (list);
+
+	return list;
+}
+
+GSList *
+tracker_language_get_all_by_code (void)
+{
+	GSList *list = NULL;
+	gint i;
+
+	/* Shouldn't we use g_get_language_names() instead? -mr */
+
+	for (i = 0; all_langs[i].code; i++) {
+		list = g_slist_prepend (list, all_langs[i].code);
+	}
+
+	list = g_slist_reverse (list);
+
+	return list;
+}
+
+const gchar *
+tracker_language_get_name_by_code (const gchar *language_code)
+{
+	gint i;
+
+	if (!language_code || language_code[0] == '\0') {
+		return "english";
+	}
+
+	for (i = 0; all_langs[i].code; i++) {
+		if (g_str_has_prefix (language_code, all_langs[i].code)) {
+			return all_langs[i].name;
+		}
+	}
+
+	return "";
+}
+
+const gchar *
+tracker_language_get_code_by_name (const gchar *language_name)
+{
+	gint i;
+
+	if (!language_name || language_name[0] == '\0') {
+		return "en";
+	}
+
+	for (i = 0; all_langs[i].name; i++) {
+		if (g_str_has_prefix (language_name, all_langs[i].name)) {
+			return all_langs[i].code;
+		}
+	}
+
+	return "";
+}

Modified: trunk/src/libtracker-common/tracker-language.h
==============================================================================
--- trunk/src/libtracker-common/tracker-language.h	(original)
+++ trunk/src/libtracker-common/tracker-language.h	Wed Oct  8 16:26:51 2008
@@ -65,6 +65,12 @@
 gboolean	 tracker_language_check_exists	   (const gchar     *language_code);
 gchar *		 tracker_language_get_default_code (void);
 
+GSList *         tracker_language_get_all_by_name  (void);
+GSList *         tracker_language_get_all_by_code  (void);
+
+const gchar *    tracker_language_get_name_by_code (const gchar     *language_code);
+const gchar *    tracker_language_get_code_by_name (const gchar     *langauge_name);
+
 G_END_DECLS
 
 #endif /* __LIBTRACKER_COMMON_LANGUAGE_H__ */

Modified: trunk/src/libtracker-common/tracker-type-utils.c
==============================================================================
--- trunk/src/libtracker-common/tracker-type-utils.c	(original)
+++ trunk/src/libtracker-common/tracker-type-utils.c	Wed Oct  8 16:26:51 2008
@@ -739,6 +739,7 @@
 
 	return new_list;
 }
+
 gchar *
 tracker_string_boolean_to_string_gint (const gchar *value)
 {

Modified: trunk/src/tracker-preferences/Makefile.am
==============================================================================
--- trunk/src/tracker-preferences/Makefile.am	(original)
+++ trunk/src/tracker-preferences/Makefile.am	Wed Oct  8 16:26:51 2008
@@ -11,33 +11,34 @@
 
 pkgdata_DATA = tracker-preferences.glade
 
-INCLUDES = \
-	-DTRACKER_DATADIR=\""$(datadir)/tracker"\" \
-	-DTRACKER_LOCALEDIR=\""$(localedir)"\" \
-	-DTRACKER_BINDIR=\""$(bindir)"\" \
-	-DTRACKER_COMPILATION \
-	$(GLIB_CFLAGS) \
-	$(GTK2_CFLAGS) \
-	$(LIBGLADE_CFLAGS) \
-	$(DBUS_CFLAGS) \
-	-I$(top_srcdir)/src/libtracker
-
-tracker_preferences_SOURCES = \
-	tracker-preferences.c \
-	tracker-preferences.h \
-	tracker-preferences-dialogs.c \
-	tracker-preferences-dialogs.h \
-	tracker-preferences-main.c \
-	tracker-preferences-utils.c \
+INCLUDES = 								\
+	-DTRACKER_DATADIR=\""$(datadir)/tracker"\" 			\
+	-DTRACKER_LOCALEDIR=\""$(localedir)"\" 				\
+	-DTRACKER_BINDIR=\""$(bindir)"\" 				\
+	-DTRACKER_LIBEXECDIR=\""$(libexecdir)"\" 			\
+	-DTRACKER_COMPILATION 						\
+	$(LIBGLADE_CFLAGS) 						\
+	$(GTK2_CFLAGS) 							\
+	$(DBUS_CFLAGS) 							\
+	$(GLIB_CFLAGS) 							\
+	-I$(top_srcdir)/src
+
+tracker_preferences_SOURCES = 						\
+	tracker-preferences.c 						\
+	tracker-preferences.h 						\
+	tracker-preferences-dialogs.c 					\
+	tracker-preferences-dialogs.h 					\
+	tracker-preferences-main.c 					\
+	tracker-preferences-utils.c 					\
 	tracker-preferences-utils.h
 
-tracker_preferences_LDADD = \
-	$(GLIB_LIBS) \
-	$(GTK2_LIBS) \
-	$(LIBGLADE_LIBS) \
-	$(DBUS_LIBS) \
-	$(top_builddir)/src/libtracker-common/libtracker-common.la \
-	$(top_builddir)/src/libtracker/libtrackerclient.la
+tracker_preferences_LDADD = 						\
+	$(top_builddir)/src/libtracker/libtrackerclient.la		\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
+	$(LIBGLADE_LIBS)						\
+	$(GTK2_LIBS) 							\
+	$(DBUS_LIBS) 							\
+	$(GLIB_LIBS)
 
 EXTRA_DIST = $(pkgdata_DATA)
 

Modified: trunk/src/tracker-preferences/tracker-preferences-main.c
==============================================================================
--- trunk/src/tracker-preferences/tracker-preferences-main.c	(original)
+++ trunk/src/tracker-preferences/tracker-preferences-main.c	Wed Oct  8 16:26:51 2008
@@ -1,4 +1,4 @@
-/* Tracker - indexer and metadata database engine
+/*
  * Copyright (C) 2007, Saleem Abdulrasool (compnerd gentoo org)
  *
  * This library is free software; you can redistribute it and/or
@@ -17,19 +17,20 @@
  * Boston, MA  02110-1301, USA.
  */
 
+#include "config.h"
+
 #include <stdlib.h>
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #include "tracker-preferences.h"
-#include "config.h"
-
 
 gint
 main (gint argc, gchar * argv[])
 {
-	TrackerPreferences *preferences = NULL;
+	TrackerPreferences *preferences;
 
 	bindtextdomain (GETTEXT_PACKAGE, TRACKER_LOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");

Modified: trunk/src/tracker-preferences/tracker-preferences.c
==============================================================================
--- trunk/src/tracker-preferences/tracker-preferences.c	(original)
+++ trunk/src/tracker-preferences/tracker-preferences.c	Wed Oct  8 16:26:51 2008
@@ -1,5 +1,6 @@
-/* Tracker - indexer and metadata database engine
+/* 
  * Copyright (C) 2007, Saleem Abdulrasool (compnerd gentoo org)
+ * Copyright (C) 2008, Nokia
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
@@ -16,19 +17,20 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA  02110-1301, USA.
  */
+
 #include "config.h"
 
 #include <string.h>
+#include <stdlib.h>
+
 #include <glib/gi18n.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
 #include <glade/glade.h>
-#include <stdlib.h>
 
-#include "../libtracker/tracker.h"
-/* #include "../trackerd/tracker-dbus.h" */
-#include "../libtracker-common/tracker-configuration.h"
+#include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 #include "tracker-preferences.h"
 #include "tracker-preferences-dialogs.h"
@@ -39,219 +41,90 @@
 
 #define TRACKER_PREFERENCES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), TRACKER_TYPE_PREFERENCES, TrackerPreferencesPrivate))
 
-typedef struct _TrackerPreferencesPrivate {
+typedef struct _TrackerPreferencesPrivate TrackerPreferencesPrivate;
+
+struct _TrackerPreferencesPrivate {
 	GladeXML *gxml;
+
+        TrackerConfig *config;
+
 	DBusGConnection *connection;
 	DBusGProxy *dbus_proxy;
 	DBusGProxy *tracker_proxy;
-} TrackerPreferencesPrivate;
 
-static void tracker_preferences_class_init (TrackerPreferencesClass *klass);
-static void tracker_preferences_init (GTypeInstance *instance, gpointer g_class);
-static void tracker_preferences_finalize (GObject *object);
-static void setup_page_general (TrackerPreferences *preferences);
-static void setup_page_files (TrackerPreferences *preferences);
-static void setup_page_emails (TrackerPreferences *preferences);
-static void setup_page_ignored_files (TrackerPreferences *preferences);
-static void setup_page_performance (TrackerPreferences *preferences);
-static void tracker_preferences_cmd_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
-static void tracker_preferences_cmd_help (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_apply (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_cancel (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_ok (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_add_index_path (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_remove_index_path (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_add_crawled_path (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_remove_crawled_path (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_add_index_mailbox (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_remove_index_mailbox (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_add_ignore_path (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_remove_ignore_path (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_add_ignore_pattern (GtkWidget *widget, gpointer data);
-static void tracker_preferences_cmd_remove_ignore_pattern (GtkWidget *widget, gpointer data);
-static void append_item_to_list (TrackerPreferences *dialog, const gchar* const item,
-				 const gchar* const widget);
-static void remove_selection_from_list (TrackerPreferences *dialog,
-					const gchar* const widget);
-static GSList *treeview_get_values (GtkTreeView *treeview);
-static gint _strcmp (gconstpointer a, gconstpointer b);
-static void initialize_listview (GtkWidget *treeview);
-static void populate_list (GtkWidget *treeview, GSList *list);
-static gboolean str_slist_equal (GSList *a, GSList *b);
-
-static GObjectClass *parent_class = NULL;
-static gboolean flag_restart = FALSE;
-static gboolean flag_reindex = FALSE;
-static gboolean first_time = TRUE;
-static gboolean flag_quit = FALSE;
-static GtkWidget *main_window = NULL;
+        GtkWidget *main_window;
+
+        gboolean should_restart;
+        gboolean should_reindex;
+        gboolean should_quit;
+        gboolean is_first_time;
+};
+
+static void tracker_preferences_finalize (GObject            *object);
+static void create_ui                    (TrackerPreferences *preferences);
 
 
+G_DEFINE_TYPE (TrackerPreferences, tracker_preferences, G_TYPE_OBJECT);
+
 static void
 tracker_preferences_class_init (TrackerPreferencesClass *klass)
 {
-	GObjectClass *g_class = G_OBJECT_CLASS (klass);
-	parent_class = g_type_class_peek_parent (klass);
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	g_type_class_add_private (klass, sizeof (TrackerPreferencesPrivate));
+	object_class->finalize	   = tracker_preferences_finalize;
 
-	g_class->finalize = tracker_preferences_finalize;
+	g_type_class_add_private (object_class, sizeof (TrackerPreferencesPrivate));
 }
 
 static void
-tracker_preferences_init (GTypeInstance *instance, gpointer g_class)
+tracker_preferences_init (TrackerPreferences *object)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (instance);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
-
-	tracker_configuration_load ();
-
-	GtkWidget *widget = NULL;
-
-	priv->gxml =
-		glade_xml_new (TRACKER_DATADIR "/tracker-preferences.glade",
-			       NULL, NULL);
-
-	if (priv->gxml == NULL)
-		g_error ("Unable to find locate tracker-preferences.glade");
-
-	main_window = glade_xml_get_widget (priv->gxml, "dlgPreferences");
-
-	/* Hide window first to allow the dialog to reize itself without redrawing */
-	gtk_widget_hide (main_window);
-
-	gtk_window_set_icon_name (GTK_WINDOW (main_window), "tracker");
-	g_signal_connect (main_window, "delete-event",
-			  G_CALLBACK (tracker_preferences_cmd_quit), self);
-
-	/* Setup signals */
-	widget = glade_xml_get_widget (priv->gxml, "cmdHelp");
-	g_signal_connect (widget, "clicked", G_CALLBACK (tracker_preferences_cmd_help),
-			  self);
-	gtk_widget_hide (widget);
-
-	widget = glade_xml_get_widget (priv->gxml, "dialog-action_area1");
-	gtk_button_box_set_layout (GTK_BUTTON_BOX (widget),
-				   GTK_BUTTONBOX_END);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdApply");
-	g_signal_connect (widget, "clicked", G_CALLBACK (tracker_preferences_cmd_apply),
-			  self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdCancel");
-	g_signal_connect (widget, "clicked", G_CALLBACK (tracker_preferences_cmd_cancel),
-			  self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdOK");
-	g_signal_connect (widget, "clicked", G_CALLBACK (tracker_preferences_cmd_ok),
-			  self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdAddIndexPath");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_add_index_path), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIndexPath");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_remove_index_path), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdAddCrawledPath");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_add_crawled_path), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveCrawledPath");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_remove_crawled_path), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdAddIndexMailbox");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_add_index_mailbox), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIndexMailbox");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_remove_index_mailbox), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdAddIgnorePath");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_add_ignore_path), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIgnorePath");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_remove_ignore_path), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdAddIgnorePattern");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_add_ignore_pattern), self);
-
-	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIgnorePattern");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (tracker_preferences_cmd_remove_ignore_pattern), self);
-
-	/* Init dbus */
-	GError *error = NULL;
-	g_type_init ();
-
-	priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
-	if (priv->connection == NULL) {
-		g_warning ("Unable to connect to dbus: %s\n", error->message);
-		g_error_free (error);
-		return;
-	}
+	TrackerPreferencesPrivate *priv;
+        gchar *filename;
 
-	priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->connection,
-						      DBUS_SERVICE_DBUS,
-						      DBUS_PATH_DBUS,
-						      DBUS_INTERFACE_DBUS);
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (object);
+      
+        filename = g_build_filename (TRACKER_DATADIR, "tracker-preferences.glade", NULL);
+	priv->gxml = glade_xml_new (filename, NULL, NULL);
 
-	if (!priv->dbus_proxy) {
-		g_warning ("could not create proxy");
-		return;
-	}
+	if (!priv->gxml) {
+		g_error ("Unable to find %s", filename);
+                g_free (filename);
+                return;
+        }
 
-	priv->tracker_proxy = dbus_g_proxy_new_for_name (priv->connection,
-							 TRACKER_DBUS_SERVICE,
-							 TRACKER_DBUS_PATH,
-							 TRACKER_DBUS_INTERFACE);
+        g_free (filename);
 
-	if (!priv->tracker_proxy) {
-		g_warning ("could not create proxy");
-		return;
-	}
+	priv->config = tracker_config_new ();
 
-	/* setup pages */
-	setup_page_general (self);
-	setup_page_files (self);
-	setup_page_emails (self);
-	setup_page_ignored_files (self);
-	setup_page_performance (self);
+        priv->is_first_time = TRUE;
 
-	gtk_widget_show (main_window);
+        create_ui (object);
 }
 
 static void
 tracker_preferences_finalize (GObject *object)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (object);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
+	TrackerPreferencesPrivate *priv;
 
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (object);
+
+	g_object_unref (priv->config);
 	g_object_unref (priv->gxml);
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	(G_OBJECT_CLASS (tracker_preferences_parent_class)->finalize) (object);
 }
 
 TrackerPreferences *
 tracker_preferences_new (void)
 {
-	TrackerPreferences *prefs;
-	prefs = g_object_new (TRACKER_TYPE_PREFERENCES, NULL);
-	return TRACKER_PREFERENCES (prefs);
+	return g_object_new (TRACKER_TYPE_PREFERENCES, NULL);
 }
 
-
 static void
-set_bool_option (TrackerPreferencesPrivate *priv, const gchar *name, gboolean value)
+set_bool_option (TrackerPreferencesPrivate *priv, 
+                 const gchar               *name, 
+                 gboolean                   value)
 {
 	dbus_g_proxy_begin_call (priv->tracker_proxy,
 				 "SetBoolOption",
@@ -263,9 +136,10 @@
 				 G_TYPE_INVALID);
 }
 
-
 static void
-set_int_option (TrackerPreferencesPrivate *priv, const gchar *name, int value)
+set_int_option (TrackerPreferencesPrivate *priv, 
+                const gchar               *name, 
+                gint                       value)
 {
 	dbus_g_proxy_begin_call (priv->tracker_proxy,
 				 "SetIntOption",
@@ -278,480 +152,413 @@
 }
 
 static void
-setup_page_general (TrackerPreferences *preferences)
+name_owner_changed (DBusGProxy  *proxy,
+                    const gchar *name,
+		    const gchar *prev_owner, 
+                    const gchar *new_owner,
+		    gpointer     data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (preferences);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
-
-	gint sleep = 45;
-	gchar *str_value = NULL;
-	gboolean value = FALSE;
-	GtkWidget *widget = NULL;
+        TrackerPreferencesPrivate *priv;
 
-	widget = glade_xml_get_widget (priv->gxml, "spnInitialSleep");
-	sleep = tracker_configuration_get_integer ("/General/InitialSleep", NULL);
-	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), sleep);
+	if (!g_str_equal (name, TRACKER_DBUS_SERVICE)) {
+		return;
+        }
 
-	widget = glade_xml_get_widget (priv->gxml, "chkEnableIndexing");
-	value = tracker_configuration_get_boolean ("/Indexing/EnableIndexing", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (data);
 
-	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
-	value = tracker_configuration_get_boolean ("/Watches/EnableWatching", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+	if (!priv->is_first_time) {
+		return;
+        }
 
-	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
-	str_value = tracker_configuration_get_string ("/Indexing/Language", NULL);
-	if (str_value == NULL) {
-		/* no value for language? Default to "en" */
-		str_value = g_strdup( "en" ) ;
-	}
+	if (g_str_equal (new_owner, "")) {
+		/* Tracker has exited */
+		gchar *command;
 
-	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+                command = g_build_filename (TRACKER_LIBEXECDIR, "trackerd", NULL);
 
-	gint i;
-	for (i = 0; i < 12; i++) {
-		if (strcasecmp (LanguageMap[i].language, str_value) == 0) {
-			gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
-			break;
-		}
+                if (!g_spawn_command_line_async (command, NULL)) {
+			g_warning ("Unable to execute command: %s", command);
+                }
+                
+                g_free (command);
+                
+		priv->is_first_time = FALSE;
+                
+		if (priv->should_quit) {
+			gtk_main_quit ();
+                }
 	}
-
-	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryIndex");
-	value = tracker_configuration_get_boolean ("/Indexing/BatteryIndex", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
-
-	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryInitialIndex");
-	value = tracker_configuration_get_boolean ("/Indexing/BatteryIndexInitial", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
 }
 
-static void
-setup_page_performance (TrackerPreferences *preferences)
+static gboolean
+str_slist_equal (GSList *a, 
+                 GSList *b)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (preferences);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
-
-	GtkWidget *widget = NULL;
-	gint value = 0;
-	gboolean bvalue = FALSE;
-
-	widget = glade_xml_get_widget (priv->gxml, "scaThrottle");
-	value = tracker_configuration_get_integer("/Indexing/Throttle", NULL);
-	gtk_range_set_value (GTK_RANGE (widget), value);
+	GSList *l;
 
-	widget = glade_xml_get_widget (priv->gxml, "optReducedMemory");
-	bvalue = tracker_configuration_get_boolean ("/General/LowMemoryMode", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bvalue);
+	if (g_slist_length (a) != g_slist_length (b)) {
+		return FALSE;
+        }
 
-	widget = glade_xml_get_widget (priv->gxml, "optNormal");
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !bvalue);
+	for (l = a; l; l = l->next) {
+                if (!g_slist_find_custom (b, l->data, (GCompareFunc) strcmp)) {
+                        return FALSE;
+                }
+	}
 
-	widget = glade_xml_get_widget (priv->gxml, "chkFastMerges");
-	bvalue = tracker_configuration_get_boolean ("/Indexing/FastMerges", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bvalue);
+	return TRUE;
+}
 
-	widget = glade_xml_get_widget (priv->gxml, "spnMaxText");
-	value = tracker_configuration_get_integer ("/Performance/MaxTextToIndex", NULL);
+static gboolean
+if_trackerd_start (TrackerPreferencesPrivate *priv)
+{
+	TrackerClient *client;
+	gchar *status;
 
-	value = value / 1024;
-	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
+	client = tracker_connect (FALSE);
 
-	widget = glade_xml_get_widget (priv->gxml, "spnMaxWords");
-	value = tracker_configuration_get_integer ("/Performance/MaxWordsToIndex", NULL);
+	if (!client) {
+		return FALSE;
+        }
 
-	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
+	status = tracker_get_status (client, NULL);
+	tracker_disconnect (client);
 
+	if (strcmp (status, "Shutdown") == 0) {
+		return FALSE;
+	} else {
+		return TRUE;
+        }
 }
 
 static void
-setup_page_files (TrackerPreferences *preferences)
+restart_tracker (GtkDialog *dialog, 
+                 gint       response, 
+                 gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (preferences);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
-
-	GSList *list = NULL, *entry = NULL;
-	gboolean value = FALSE;
-	GtkWidget *widget = NULL;
+        TrackerPreferencesPrivate *priv;
+        
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (data);
 
-	widget = glade_xml_get_widget (priv->gxml, "chkIndexContents");
-	value = tracker_configuration_get_boolean ("/Indexing/EnableFileContentIndexing",
-						   NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
-
-	widget = glade_xml_get_widget (priv->gxml, "chkGenerateThumbs");
-	value = tracker_configuration_get_boolean ("/Indexing/EnableThumbnails", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
-
-	widget = glade_xml_get_widget (priv->gxml, "chkSkipMountPoints");
-	value = tracker_configuration_get_boolean ("/Indexing/SkipMountPoints", NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
-
-	widget = glade_xml_get_widget (priv->gxml,
-				       "lstAdditionalPathIndexes");
-	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
-	list = tracker_configuration_get_list ("/Watches/WatchDirectoryRoots",
-					       G_TYPE_STRING, NULL);
+	gtk_widget_destroy (GTK_WIDGET (dialog));
 
-	widget = glade_xml_get_widget (priv->gxml, "chkIndexHomeDirectory");
-	entry = g_slist_find_custom (list, g_get_home_dir (), _strcmp);
+	if (response == GTK_RESPONSE_YES) {
+		dbus_g_proxy_add_signal (priv->dbus_proxy,
+					 "NameOwnerChanged",
+					 G_TYPE_STRING,
+					 G_TYPE_STRING,
+					 G_TYPE_STRING, G_TYPE_INVALID);
+		dbus_g_proxy_connect_signal (priv->dbus_proxy,
+					     "NameOwnerChanged",
+					     G_CALLBACK (name_owner_changed),
+					     data, NULL);
+		dbus_g_proxy_begin_call (priv->tracker_proxy,
+					 "Shutdown",
+					 NULL,
+					 NULL,
+					 NULL,
+					 G_TYPE_BOOLEAN,
+					 priv->should_reindex, G_TYPE_INVALID);
 
-	if (entry) {
-		list = g_slist_delete_link (list, entry);
-		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-	} else {
-		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+		priv->is_first_time = TRUE;
+		priv->should_restart = FALSE;
+		priv->should_reindex = FALSE;
+	} else if (priv->should_quit) {
+		gtk_main_quit ();
 	}
-
-	widget = glade_xml_get_widget (priv->gxml, "lstAdditionalPathIndexes");
-
-	initialize_listview (widget);
-	populate_list (widget, list);
-	g_slist_free (list);
-
-	widget = glade_xml_get_widget (priv->gxml, "lstCrawledPaths");
-	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
-	list = tracker_configuration_get_list ("/Watches/CrawlDirectory",
-					       G_TYPE_STRING, NULL);
-
-	initialize_listview (widget);
-	populate_list (widget, list);
-	g_slist_free (list);
 }
 
 static void
-setup_page_ignored_files (TrackerPreferences *preferences)
+model_append_to_list (TrackerPreferences  *preferences, 
+                      const gchar * const  item,
+                      const gchar * const  widget)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (preferences);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
+	TrackerPreferencesPrivate *priv;
+	GtkTreeIter iter;
+	GtkWidget *view;
+	GtkTreeModel *model;
 
-	GSList *list = NULL;
-	GtkWidget *widget = NULL;
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
 
-	/* Ignore Paths */
-	widget = glade_xml_get_widget (priv->gxml, "lstIgnorePaths");
-	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
-	list = tracker_configuration_get_list ("/Watches/NoWatchDirectory",
-					       G_TYPE_STRING, NULL);
+        view = glade_xml_get_widget (priv->gxml, widget);
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
-	initialize_listview (widget);
-	populate_list (widget, list);
+	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
+		do {
+			gchar *value;
 
-	g_slist_free (list);
+			gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 0, &value, -1);
 
-	/* Ignore File Patterns */
-	widget = glade_xml_get_widget (priv->gxml, "lstIgnoreFilePatterns");
-	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
-	list = tracker_configuration_get_list ("/Indexing/NoIndexFileTypes",
-					       G_TYPE_STRING, NULL);
-
-	initialize_listview (widget);
-	populate_list (widget, list);
+			if (!strcasecmp (item, value)) {
+                                g_free (value);
+				return;
+                        }
+		} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
+        }
 
-	g_slist_free (list);
+	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+	gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, item, -1);
 }
 
 static void
-setup_page_emails (TrackerPreferences *preferences)
+model_remove_selected_from_list (TrackerPreferences  *preferences,
+                                 const gchar * const  widget)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (preferences);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
+	TrackerPreferencesPrivate *priv;
+	GtkWidget *view;
+	GtkTreeModel *model;
+	GtkTreeSelection *selection;
+	GtkTreeIter iter;
 
-	GtkWidget *widget = NULL;
-	gboolean value = FALSE;
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
 
-	widget = glade_xml_get_widget (priv->gxml,
-				       "chkEnableEvolutionIndexing");
-	value = tracker_configuration_get_boolean ("/Emails/IndexEvolutionEmails",
-						   NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
-
-	widget = glade_xml_get_widget (priv->gxml,
-				       "chkEnableModestIndexing");
-	value = tracker_configuration_get_boolean ("/Emails/IndexModestEmails",
-						   NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+        view = glade_xml_get_widget (priv->gxml, widget);
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
 
+	if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
+		return;
+        }
 
-	widget = glade_xml_get_widget (priv->gxml,
-				       "chkEnableThunderbirdIndexing");
-	value = tracker_configuration_get_boolean ("/Emails/IndexThunderbirdEmails",
-						   NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+	gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 }
 
-static void
-tracker_preferences_cmd_quit (GtkWidget *widget, GdkEvent *event, gpointer data)
+static GSList *
+model_get_values (GtkTreeView *treeview)
 {
-	tracker_preferences_cmd_ok (NULL, data);
-}
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	GSList *list = NULL;
 
-static void
-tracker_preferences_cmd_help (GtkWidget *widget, gpointer data)
-{
-}
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
 
-static void
-name_owner_changed (DBusGProxy *proxy, const gchar *name,
-		    const gchar *prev_owner, const gchar *new_owner,
-		    gpointer data)
-{
-	if (!g_str_equal (name, TRACKER_DBUS_SERVICE))
-		return;
-
-	if (!first_time)
-		return;
+	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
+		do {
+			gchar *value;
 
-	if (g_str_equal (new_owner, "")) {
-		/* tracker has exited */
-		const gchar *command = TRACKER_BINDIR "/trackerd";
+			gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 0, &value, -1);
 
-		if (!g_spawn_command_line_async (command, NULL))
-			g_warning ("Unable to execute command: %s", command);
+			if (value) {
+				list = g_slist_prepend (list, value);
+			}
+		} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
+        }
 
-		first_time = FALSE;
+        list = g_slist_reverse (list);
 
-		if (flag_quit)
-			gtk_main_quit ();
-	}
+	return list;
 }
 
-static gboolean
-if_trackerd_start (TrackerPreferencesPrivate *priv)
+static void
+model_set_up (GtkWidget *treeview)
 {
-	gchar *status = NULL;
-	TrackerClient *client = NULL;
-
-	client = tracker_connect (FALSE);
-
-	if (!client)
-		return FALSE;
+	GtkListStore *store;
+	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *column;
 
-	status = tracker_get_status (client, NULL);
-	tracker_disconnect (client);
+	store = gtk_list_store_new (1, G_TYPE_STRING);
+	gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+				 GTK_TREE_MODEL (store));
+	g_object_unref (store);	
 
-	if (strcmp (status, "Shutdown") == 0)
-		return FALSE;
-	else
-		return TRUE;
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes ("Column 0", renderer,
+							   "text", 0,
+                                                           NULL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
 }
 
-
 static void
-restart_tracker (GtkDialog *dialog, gint response, gpointer data)
+model_populate (GtkWidget *treeview, 
+                GSList    *list)
 {
+	GtkTreeModel *store;
+	GSList *l;
 
-	gtk_widget_destroy (GTK_WIDGET (dialog));
+	store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
 
-	if (response == GTK_RESPONSE_YES) {
+	for (l = list; l; l = l->next) {
+                GtkTreeIter iter;
+                gchar *data;
 
-		TrackerPreferences *self = TRACKER_PREFERENCES (data);
-		TrackerPreferencesPrivate *priv = TRACKER_PREFERENCES_GET_PRIVATE (self);
+		if (!l->data) {
+                        continue;
+                }
 
-		first_time = TRUE;
-		dbus_g_proxy_add_signal (priv->dbus_proxy,
-					 "NameOwnerChanged",
-					 G_TYPE_STRING,
-					 G_TYPE_STRING,
-					 G_TYPE_STRING, G_TYPE_INVALID);
-		dbus_g_proxy_connect_signal (priv->dbus_proxy,
-					     "NameOwnerChanged",
-					     G_CALLBACK (name_owner_changed),
-					     self, NULL);
+                data = l->data;
 
-		dbus_g_proxy_begin_call (priv->tracker_proxy,
-					 "Shutdown",
-					 NULL,
-					 NULL,
-					 NULL,
-					 G_TYPE_BOOLEAN,
-					 flag_reindex, G_TYPE_INVALID);
-		flag_restart = FALSE;
-		flag_reindex = FALSE;
-
-	} else if (flag_quit) {
-		gtk_main_quit ();
+                gtk_list_store_append (GTK_LIST_STORE (store), &iter);
+                gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0, data, -1);
 	}
 }
 
 static void
-tracker_preferences_cmd_apply (GtkWidget *widget, gpointer data)
+cmd_help (GtkWidget *widget,
+          gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
+}
 
-	GSList *list = NULL;
-	GSList *list_old = NULL;
-	int ivalue, ivalue_old;
+static void
+cmd_apply (GtkWidget *widget, 
+           gpointer   data)
+{
+	TrackerPreferencesPrivate *priv;
+	GSList *list;
+	GSList *list_old;
+        gchar *language;
+        const gchar *language_old;
 	gboolean bvalue, bvalue_old;
-	gchar *str_value;
+	gint ivalue, ivalue_old;
 
-	/* save general settings */
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (data);
+
+	/* Save general settings */
 	widget = glade_xml_get_widget (priv->gxml, "spnInitialSleep");
 	ivalue = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
-	tracker_configuration_set_integer ("/General/InitialSleep", ivalue);
+	tracker_config_set_initial_sleep (priv->config, ivalue);
 
-	widget = glade_xml_get_widget (priv->gxml, "chkEnableIndexing");
+#ifdef ENABLE_DEPRECATED
+	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/EnableIndexing",
-							NULL);
+	bvalue_old = tracker_config_get_enable_watching (priv->config);
+
 	if (bvalue != bvalue_old) {
-		flag_restart = TRUE;
-		set_bool_option (priv, "EnableIndexing", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/EnableIndexing", bvalue);
+		priv->should_restart = TRUE;
+		set_bool_option (priv, "EnableWatching", bvalue);
+		tracker_config_set_enable_watching (priv->config, bvalue);
 	}
+#endif
 
-	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
+	widget = glade_xml_get_widget (priv->gxml, "chkEnableIndexing");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Watches/EnableWatching",
-							NULL);
+	bvalue_old = tracker_config_get_enable_indexing (priv->config);
+
 	if (bvalue != bvalue_old) {
-		flag_restart = TRUE;
+		priv->should_restart = TRUE;
 		set_bool_option (priv, "EnableIndexing", bvalue);
-		tracker_configuration_set_boolean ("/Watches/EnableWatching", bvalue);
+		tracker_config_set_enable_indexing (priv->config, bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
-	gint i = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
-	str_value = tracker_configuration_get_string ("/Indexing/Language", NULL);
-	if (str_value == NULL) {
-		/* no value for language? Default to "en" */
-		str_value = g_strdup( "en" ) ;
-	}
-	if (i != -1) {
-		if (strcmp (str_value, LanguageMap[i].language) != 0) {
-			flag_restart = TRUE;
-			flag_reindex = TRUE;
-		}
-		tracker_configuration_set_string ("/Indexing/Language",
-						  LanguageMap[i].language);
-	}
+        language = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
+        language_old = tracker_config_get_language (priv->config);
 
+        if (language && language_old && strcmp (language, language_old) == 0) {
+                /* Same, do nothing */
+        } else {
+                const gchar *code;
+
+                priv->should_restart = TRUE;
+                priv->should_reindex = TRUE;
+
+                /* Note, language can be NULL */
+                code = tracker_language_get_code_by_name (language);
+		tracker_config_set_language (priv->config, code);
+        }
+        
 	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryIndex");
-	bvalue = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/BatteryIndex",
-							NULL);
+	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	bvalue_old = tracker_config_get_disable_indexing_on_battery (priv->config);
+
 	if (bvalue != bvalue_old) {
 		set_bool_option (priv, "BatteryIndex", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/BatteryIndex", bvalue);
+                tracker_config_set_disable_indexing_on_battery (priv->config, bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryInitialIndex");
-	bvalue = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/BatteryIndexInitial",
-							NULL);
+	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+        bvalue_old = tracker_config_get_disable_indexing_on_battery_init (priv->config);
+
 	if (bvalue != bvalue_old) {
 		set_bool_option (priv, "BatteryIndexInitial", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/BatteryIndexInitial", bvalue);
+                tracker_config_set_disable_indexing_on_battery_init (priv->config, bvalue);
 	}
 
-	/* files settings */
+	/* Files settings */
 	widget = glade_xml_get_widget (priv->gxml, "chkIndexContents");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/EnableFileContentIndexing",
-							NULL);
+        bvalue_old = tracker_config_get_enable_content_indexing (priv->config);
+
 	if (bvalue != bvalue_old) {
-		flag_restart = TRUE;
-		flag_reindex = TRUE;
+		priv->should_restart = TRUE;
+		priv->should_reindex = TRUE;
 		set_bool_option (priv, "IndexFileContents", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/EnableFileContentIndexing",
-						   bvalue);
+                tracker_config_set_enable_content_indexing (priv->config, bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "chkGenerateThumbs");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/EnableThumbnails",
-							NULL);
+        bvalue_old = tracker_config_get_enable_thumbnails (priv->config);
+
 	if (bvalue != bvalue_old) {
-		flag_restart = TRUE;
-		flag_reindex = TRUE;
+		priv->should_restart = TRUE;
+		priv->should_reindex = TRUE;
 		set_bool_option (priv, "GenerateThumbs", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/EnableThumbnails", bvalue);
+                tracker_config_set_enable_thumbnails (priv->config, bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "chkSkipMountPoints");
 	bvalue = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/SkipMountPoints",
-							NULL);
+        bvalue_old = !tracker_config_get_index_mounted_directories (priv->config);
+
 	if (bvalue != bvalue_old) {
-		flag_restart = TRUE;
+		priv->should_restart = TRUE;
 		set_bool_option (priv, "SkipMountPoints", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/SkipMountPoints", bvalue);
+                tracker_config_set_index_mounted_directories (priv->config, !bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "lstAdditionalPathIndexes");
-	list = treeview_get_values (GTK_TREE_VIEW (widget));
+	list = model_get_values (GTK_TREE_VIEW (widget));
 
 	widget = glade_xml_get_widget (priv->gxml, "chkIndexHomeDirectory");
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
 		list = g_slist_prepend (list, g_strdup (g_get_home_dir ()));
 	}
-	list_old = tracker_configuration_get_list ("/Watches/WatchDirectoryRoots",
-						   G_TYPE_STRING, NULL);
+
+        list_old = tracker_config_get_watch_directory_roots (priv->config);
 	if (!str_slist_equal (list, list_old)) {
-		flag_restart = TRUE;
-		tracker_configuration_set_list ("/Watches/WatchDirectoryRoots", G_TYPE_STRING,
-						list);
+		priv->should_restart = TRUE;
+		tracker_config_set_watch_directory_roots (priv->config, list);
 	}
 
 	g_slist_free (list);
-	list = NULL;
-	g_slist_free (list_old);
-	list_old = NULL;
 
 	widget = glade_xml_get_widget (priv->gxml, "lstCrawledPaths");
-	list = treeview_get_values (GTK_TREE_VIEW (widget));
-	list_old = tracker_configuration_get_list ("/Watches/CrawlDirectory",
-						   G_TYPE_STRING, NULL);
+	list = model_get_values (GTK_TREE_VIEW (widget));
+
+        list_old = tracker_config_get_crawl_directory_roots (priv->config);
 	if (!str_slist_equal (list, list_old)) {
-		flag_restart = TRUE;
-		tracker_configuration_set_list ("/Watches/CrawlDirectory", G_TYPE_STRING,
-						list);
+		priv->should_restart = TRUE;
+		tracker_config_set_crawl_directory_roots (priv->config, list);
 	}
 
 	g_slist_free (list);
-	list = NULL;
-	g_slist_free (list_old);
-	list_old = NULL;
 
-	/* ignored files settings */
+	/* Ignored files settings */
 	widget = glade_xml_get_widget (priv->gxml, "lstIgnorePaths");
-	list = treeview_get_values (GTK_TREE_VIEW (widget));
-	list_old = tracker_configuration_get_list ("/Watches/NoWatchDirectory",
-						   G_TYPE_STRING, NULL);
+	list = model_get_values (GTK_TREE_VIEW (widget));
+
+        list_old = tracker_config_get_no_watch_directory_roots (priv->config);
 	if (!str_slist_equal (list, list_old)) {
-		flag_restart = TRUE;
-		tracker_configuration_set_list ("/Watches/NoWatchDirectory", G_TYPE_STRING,
-						list);
+		priv->should_restart = TRUE;
+		tracker_config_set_no_watch_directory_roots (priv->config, list);
 	}
 
 	g_slist_free (list);
-	list = NULL;
-	g_slist_free (list_old);
-	list_old = NULL;
 
 	widget = glade_xml_get_widget (priv->gxml, "lstIgnoreFilePatterns");
-	list = treeview_get_values (GTK_TREE_VIEW (widget));
-	list_old = tracker_configuration_get_list ("/Indexing/NoIndexFileTypes",
-						   G_TYPE_STRING, NULL);
+	list = model_get_values (GTK_TREE_VIEW (widget));
+
+        list_old = tracker_config_get_no_index_file_types (priv->config);
 	if (!str_slist_equal (list, list_old)) {
-		flag_restart = TRUE;
-		tracker_configuration_set_list ("/Indexing/NoIndexFileTypes", G_TYPE_STRING,
-						list);
+		priv->should_restart = TRUE;
+		tracker_config_set_no_index_file_types (priv->config, list);
 	}
 
 	g_slist_free (list);
-	list = NULL;
-	g_slist_free (list_old);
-	list_old = NULL;
 
 	/* Email settings */
+#ifdef ENABLE_DEPRECATED
 	widget = glade_xml_get_widget (priv->gxml, "chkEnableEvolutionIndexing");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 	bvalue_old = tracker_configuration_get_boolean ("/Emails/IndexEvolutionEmails",
@@ -779,61 +586,64 @@
 		set_bool_option (priv, "EnableThunderbird", bvalue);
 		tracker_configuration_set_boolean ("/Emails/IndexThunderbirdEmails", bvalue);
 	}
+#endif
 
 	/* Performance settings */
 	widget = glade_xml_get_widget (priv->gxml, "scaThrottle");
 	ivalue = gtk_range_get_value (GTK_RANGE (widget));
-	ivalue_old = tracker_configuration_get_integer ("/Indexing/Throttle", NULL);
+	ivalue_old = tracker_config_get_throttle (priv->config);
+
 	if (ivalue != ivalue_old) {
 		set_int_option (priv, "Throttle", ivalue);
-		tracker_configuration_set_integer ("/Indexing/Throttle", ivalue);
+		tracker_config_set_throttle (priv->config, ivalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "optReducedMemory");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/General/LowMemoryMode",
-							NULL);
+	bvalue_old = tracker_config_get_low_memory_mode (priv->config);
+
 	if (bvalue != bvalue_old) {
 		set_bool_option (priv, "LowMemoryMode", bvalue);
-		tracker_configuration_set_boolean ("/General/LowMemoryMode", bvalue);
+		tracker_config_set_low_memory_mode (priv->config, bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "chkFastMerges");
 	bvalue = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	bvalue_old = tracker_configuration_get_boolean ("/Indexing/FastMerges", NULL);
+	bvalue_old = tracker_config_get_fast_merges (priv->config);
+
 	if (bvalue != bvalue_old) {
 		set_bool_option (priv, "FastMerges", bvalue);
-		tracker_configuration_set_boolean ("/Indexing/FastMerges", bvalue);
+		tracker_config_set_fast_merges (priv->config, bvalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "spnMaxText");
 	ivalue = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget))*1024;
-	ivalue_old = tracker_configuration_get_integer ("/Performance/MaxTextToIndex",
-							NULL);
+	ivalue_old = tracker_config_get_max_text_to_index (priv->config);
+
 	if (ivalue != ivalue_old) {
 		set_int_option (priv, "MaxText", ivalue);
-		tracker_configuration_set_integer ("/Performance/MaxTextToIndex", ivalue);
+		tracker_config_set_max_text_to_index (priv->config, ivalue);
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "spnMaxWords");
 	ivalue = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
-	ivalue_old = tracker_configuration_get_integer ("/Performance/MaxWordsToIndex",
-							NULL);
+	ivalue_old = tracker_config_get_max_words_to_index (priv->config);
+
 	if (ivalue != ivalue_old) {
 		set_int_option (priv, "MaxWords", ivalue);
-		tracker_configuration_set_integer ("/Performance/MaxWordsToIndex", ivalue);
+		tracker_config_set_max_words_to_index (priv->config, ivalue);
 	}
 
 	/* save config to distk */
-	tracker_configuration_save ();
+	tracker_config_save (priv->config);
 
-	if (flag_restart && if_trackerd_start (priv)) {
+	if (priv->should_restart && if_trackerd_start (priv)) {
 		GtkWidget *dialog;
 		gchar *primary;
 		gchar *secondary;
 		gchar *button;
 
-		if (flag_reindex) {
+		if (priv->should_reindex) {
 			primary = g_strdup (_("Data must be reindexed"));
 			secondary = g_strdup (_("In order for your changes to "
 						"take effect, Tracker must reindex your "
@@ -855,7 +665,7 @@
 			button = g_strdup (_("_Restart"));
 		}
 
-		dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
+		dialog = gtk_message_dialog_new (GTK_WINDOW (priv->main_window),
 						 GTK_DIALOG_MODAL,
 						 GTK_MESSAGE_WARNING,
 						 GTK_BUTTONS_NONE,
@@ -876,306 +686,512 @@
 		gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 		gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
 
-		g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (restart_tracker), self);
+		g_signal_connect (G_OBJECT (dialog), "response", 
+                                  G_CALLBACK (restart_tracker), data);
 
 		gtk_widget_show (dialog);
-	} else if (flag_quit) {
-		tracker_configuration_free ();
+	} else if (priv->should_quit) {
 		gtk_main_quit ();
 	}
 }
 
 static void
-tracker_preferences_cmd_cancel (GtkWidget *widget, gpointer data)
+cmd_cancel (GtkWidget *widget, 
+            gpointer   data)
 {
-	tracker_configuration_free ();
 	gtk_main_quit ();
 }
 
 static void
-tracker_preferences_cmd_ok (GtkWidget *widget, gpointer data)
+cmd_ok (GtkWidget *widget, 
+        gpointer   data)
+{
+        TrackerPreferencesPrivate *priv;
+
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (data);
+
+	priv->should_quit = TRUE;
+
+	cmd_apply (widget, data);
+}
+
+static void
+cmd_quit (GtkWidget *widget, 
+          GdkEvent  *event, 
+          gpointer   data)
 {
-	flag_quit = TRUE;
-	tracker_preferences_cmd_apply (widget, data);
+	cmd_ok (NULL, data);
 }
 
 static void
-tracker_preferences_cmd_add_crawled_path (GtkWidget *widget, gpointer data)
+cmd_add_crawled_path (GtkWidget *widget,
+                      gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	gchar *path = tracker_preferences_select_folder ();
+	gchar *path;
+
+        path = tracker_preferences_select_folder ();
 
-	if (!path)
+	if (!path) {
 		return;
+        }
 
-	append_item_to_list (self, path, "lstCrawledPaths");
+	model_append_to_list (data, path, "lstCrawledPaths");
 
 	g_free (path);
 }
 
 static void
-tracker_preferences_cmd_remove_crawled_path (GtkWidget *widget, gpointer data)
+cmd_remove_crawled_path (GtkWidget *widget,
+                         gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	remove_selection_from_list (self, "lstCrawledPaths");
+	model_remove_selected_from_list (data, "lstCrawledPaths");
 }
 
 static void
-tracker_preferences_cmd_add_index_path (GtkWidget *widget, gpointer data)
+cmd_add_index_path (GtkWidget *widget, 
+                    gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (self);
+	TrackerPreferencesPrivate *priv;
+	gchar *path;
+        
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (data);
 
-	GtkWidget *item = NULL;
-	gchar *path = tracker_preferences_select_folder ();
-
-	if (!path)
+        path = tracker_preferences_select_folder ();
+	if (!path) {
 		return;
+        }
 
 	if (!strcasecmp (path, g_get_home_dir ())) {
+                GtkWidget *item;
+
 		item = glade_xml_get_widget (priv->gxml,
 					     "chkIndexHomeDirectory");
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE);
-	} else
-		append_item_to_list (self, path, "lstAdditionalPathIndexes");
+	} else {
+		model_append_to_list (data, path, "lstAdditionalPathIndexes");
+        }
 
 	g_free (path);
 }
 
 static void
-tracker_preferences_cmd_remove_index_path (GtkWidget *widget, gpointer data)
+cmd_remove_index_path (GtkWidget *widget, 
+                       gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	remove_selection_from_list (self, "lstAdditionalPathIndexes");
+	model_remove_selected_from_list (data, "lstAdditionalPathIndexes");
 }
 
 static void
-tracker_preferences_cmd_add_index_mailbox (GtkWidget *widget, gpointer data)
+cmd_add_index_mailbox (GtkWidget *widget, 
+                       gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
+	gchar *path;
 
-	gchar *path = tracker_preferences_select_folder ();
+        path = tracker_preferences_select_folder ();
 
-	if (!path)
+	if (!path) {
 		return;
+        }
+
+	model_append_to_list (data, path, "lstAdditionalMBoxIndexes");
 
-	append_item_to_list (self, path, "lstAdditionalMBoxIndexes");
 	g_free (path);
 }
 
 static void
-tracker_preferences_cmd_remove_index_mailbox (GtkWidget *widget, gpointer data)
+cmd_remove_index_mailbox (GtkWidget *widget,
+                          gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	remove_selection_from_list (self, "lstAdditionalMBoxIndexes");
+	model_remove_selected_from_list (data, "lstAdditionalMBoxIndexes");
 }
 
 static void
-tracker_preferences_cmd_add_ignore_path (GtkWidget *widget, gpointer data)
+cmd_add_ignore_path (GtkWidget *widget,
+                     gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
+	gchar *path;
 
-	gchar *path = tracker_preferences_select_folder ();
+        path = tracker_preferences_select_folder ();
 
-	if (!path)
+	if (!path) {
 		return;
+        }
+
+	model_append_to_list (data, path, "lstIgnorePaths");
 
-	append_item_to_list (self, path, "lstIgnorePaths");
 	g_free (path);
 }
 
 static void
-tracker_preferences_cmd_remove_ignore_path (GtkWidget *widget, gpointer data)
+cmd_remove_ignore_path (GtkWidget *widget,
+                        gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	remove_selection_from_list (self, "lstIgnorePaths");
+	model_remove_selected_from_list (data, "lstIgnorePaths");
 }
 
 static void
-tracker_preferences_cmd_add_ignore_pattern (GtkWidget *widget, gpointer data)
+cmd_add_ignore_pattern (GtkWidget *widget, 
+                        gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
+	gchar *pattern;
 
-	gchar *pattern = tracker_preferences_select_pattern ();
+        pattern = tracker_preferences_select_pattern ();
 
-	if (!pattern)
+	if (!pattern) {
 		return;
+        }
 
-	append_item_to_list (self, pattern, "lstIgnoreFilePatterns");
+	model_append_to_list (data, pattern, "lstIgnoreFilePatterns");
 }
 
 static void
-tracker_preferences_cmd_remove_ignore_pattern (GtkWidget *widget, gpointer data)
+cmd_remove_ignore_pattern (GtkWidget *widget,
+                           gpointer   data)
 {
-	TrackerPreferences *self = TRACKER_PREFERENCES (data);
-	remove_selection_from_list (self, "lstIgnoreFilePatterns");
+	model_remove_selected_from_list (data, "lstIgnoreFilePatterns");
 }
 
 static void
-append_item_to_list (TrackerPreferences *dialog, const gchar *const item,
-		     const gchar* const widget)
+setup_page_general (TrackerPreferences *preferences)
 {
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (dialog);
+	TrackerPreferencesPrivate *priv;
+	GtkWidget *widget;
+        const gchar *language;
+	gchar *default_language = NULL;
+        GSList *language_codes, *l;
+	gboolean value;
+	gint sleep;
 
-	GtkTreeIter iter;
-	GtkWidget *view = glade_xml_get_widget (priv->gxml, widget);
-	GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
 
-	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
-		do {
-			gchar *value = NULL;
-			gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 0,
-					    &value, -1);
+	widget = glade_xml_get_widget (priv->gxml, "spnInitialSleep");
+	sleep = tracker_config_get_initial_sleep (priv->config);
+	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), sleep);
 
-			if (!strcasecmp (item, value))
-				return;
-		} while (gtk_tree_model_iter_next
-			 (GTK_TREE_MODEL (model), &iter));
+	widget = glade_xml_get_widget (priv->gxml, "chkEnableIndexing");
+	value = tracker_config_get_enable_indexing (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
 
-	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-	gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, item, -1);
+#ifdef ENABLE_DEPRECATED
+	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
+	value = tracker_configuration_get_boolean ("/Watches/EnableWatching", NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+#else
+	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
+        gtk_widget_set_sensitive (widget, FALSE);
+#endif
+
+	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
+	language = tracker_config_get_language (priv->config);
+	if (!language) {
+		/* No value for language? Default to "en" */
+		language = default_language = tracker_language_get_default_code ();
+	}
+
+        /* Default to English */
+	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+        
+        language_codes = tracker_language_get_all_by_code ();
+        
+	for (l = language_codes; l; l = l->next) {
+		if (strcasecmp (language, l->data) == 0) {
+                        gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 
+                                                  g_slist_index (language_codes, l->data));
+                        break;
+                }
+	}
+
+        g_free (default_language);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryIndex");
+	value = tracker_config_get_disable_indexing_on_battery (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryInitialIndex");
+	value = tracker_config_get_disable_indexing_on_battery_init (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
 }
 
 static void
-remove_selection_from_list (TrackerPreferences *dialog,
-			    const gchar* const widget)
+setup_page_performance (TrackerPreferences *preferences)
 {
-	TrackerPreferencesPrivate *priv =
-		TRACKER_PREFERENCES_GET_PRIVATE (dialog);
+	TrackerPreferencesPrivate *priv;
+	GtkWidget *widget;
+	gint value;
+	gboolean bvalue;
 
-	GtkTreeIter iter;
-	GtkWidget *view = glade_xml_get_widget (priv->gxml, widget);
-	GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
-	GtkTreeSelection *selection =
-		gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
 
-	if (!gtk_tree_selection_get_selected (selection, &model, &iter))
-		return;
+	widget = glade_xml_get_widget (priv->gxml, "scaThrottle");
+	value = tracker_config_get_throttle (priv->config);
+	gtk_range_set_value (GTK_RANGE (widget), value);
 
-	gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-}
+	widget = glade_xml_get_widget (priv->gxml, "optReducedMemory");
+	bvalue = tracker_config_get_low_memory_mode (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bvalue);
 
-static GSList *
-treeview_get_values (GtkTreeView *treeview)
-{
-	GtkTreeIter iter;
-	GSList *list = NULL;
-	GtkTreeModel *model =
-		gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
+	widget = glade_xml_get_widget (priv->gxml, "optNormal");
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !bvalue);
 
-	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
-		do {
-			gchar *value = NULL;
-			gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 0,
-					    &value, -1);
+	widget = glade_xml_get_widget (priv->gxml, "chkFastMerges");
+	bvalue = tracker_config_get_fast_merges (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bvalue);
 
-			if (value) {
-				list = g_slist_prepend (list,
-							g_strdup (value));
-			}
-		} while (gtk_tree_model_iter_next
-			 (GTK_TREE_MODEL (model), &iter));
+	widget = glade_xml_get_widget (priv->gxml, "spnMaxText");
+	value = tracker_config_get_max_text_to_index (priv->config);
 
-	return list;
+	value /= 1024;
+	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
+
+	widget = glade_xml_get_widget (priv->gxml, "spnMaxWords");
+	value = tracker_config_get_max_words_to_index (priv->config);
+
+	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
 }
 
-static gint
-_strcmp (gconstpointer a, gconstpointer b)
+static void
+setup_page_files (TrackerPreferences *preferences)
 {
-	if (a == NULL && b != NULL)
-		return -1;
+	TrackerPreferencesPrivate *priv;
+	GtkWidget *widget;
+	GSList *list, *list_copy, *l;
+	gboolean value;
+
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkIndexContents");
+	value = tracker_config_get_enable_content_indexing (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkGenerateThumbs");
+        value = tracker_config_get_enable_thumbnails (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkSkipMountPoints");
+	value = !tracker_config_get_index_mounted_directories (priv->config);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
+
+	widget = glade_xml_get_widget (priv->gxml,
+				       "lstAdditionalPathIndexes");
+	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
+	list = tracker_config_get_watch_directory_roots (priv->config);
+        list_copy = tracker_gslist_copy_with_string_data (list);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkIndexHomeDirectory");
+        l = g_slist_find_custom (list_copy, g_get_home_dir (), (GCompareFunc) strcmp);
+
+        if (l) {
+                g_free (l->data);
+                list_copy = g_slist_delete_link (list_copy, l);
+
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+	} else {
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+	}
+
+	widget = glade_xml_get_widget (priv->gxml, "lstAdditionalPathIndexes");
+
+	model_set_up (widget);
+	model_populate (widget, list_copy);
 
-	if (a == NULL && b == NULL)
-		return 0;
+        g_slist_foreach (list_copy, (GFunc) g_free, NULL);
+        g_slist_free (list_copy);
 
-	if (a != NULL && b == NULL)
-		return 1;
+	widget = glade_xml_get_widget (priv->gxml, "lstCrawledPaths");
+	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
+	list = tracker_config_get_crawl_directory_roots (priv->config);
 
-	return strcmp (a, b);
+	model_set_up (widget);
+	model_populate (widget, list);
 }
 
 static void
-initialize_listview (GtkWidget *treeview)
+setup_page_ignored_files (TrackerPreferences *preferences)
 {
-	GtkListStore *store = NULL;
-	GtkCellRenderer *renderer = NULL;
-	GtkTreeViewColumn *column = NULL;
+	TrackerPreferencesPrivate *priv;
+	GtkWidget *widget;
+	GSList *list;
 
-	store = gtk_list_store_new (1, G_TYPE_STRING);
-	gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
-				 GTK_TREE_MODEL (store));
-	g_object_unref (store);	/* this will delete the store when the view is destroyed */
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
 
-	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes ("Column 0",
-							   renderer, "text",
-							   0, NULL);
-	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+	/* Ignore Paths */
+	widget = glade_xml_get_widget (priv->gxml, "lstIgnorePaths");
+	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
+	list = tracker_config_get_no_watch_directory_roots (priv->config);
+
+	model_set_up (widget);
+	model_populate (widget, list);
+
+	/* Ignore File Patterns */
+	widget = glade_xml_get_widget (priv->gxml, "lstIgnoreFilePatterns");
+	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
+	list = tracker_config_get_no_index_file_types (priv->config);
+
+	model_set_up (widget);
+	model_populate (widget, list);
 }
 
 static void
-populate_list (GtkWidget *treeview, GSList *list)
+setup_page_emails (TrackerPreferences *preferences)
 {
-	GtkTreeModel *store;
-	GSList *tmp;
+	TrackerPreferencesPrivate *priv;
+	GtkWidget *widget;
 
-	store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
 
-	for (tmp = list; tmp; tmp = tmp->next) {
-		if (tmp->data) {
-			GtkTreeIter iter;
-			gchar *data = tmp->data;
-
-			gtk_list_store_append (GTK_LIST_STORE (store), &iter);
-			gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0,
-					    data, -1);
-		}
-	}
+#ifdef ENABLE_DEPRECATED 
+	widget = glade_xml_get_widget (priv->gxml,
+				       "chkEnableEvolutionIndexing");
+	value = tracker_configuration_get_boolean ("/Emails/IndexEvolutionEmails",
+						   NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+
+	widget = glade_xml_get_widget (priv->gxml,
+				       "chkEnableModestIndexing");
+	value = tracker_configuration_get_boolean ("/Emails/IndexModestEmails",
+						   NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+
+
+	widget = glade_xml_get_widget (priv->gxml,
+				       "chkEnableThunderbirdIndexing");
+	value = tracker_configuration_get_boolean ("/Emails/IndexThunderbirdEmails",
+						   NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+#else 
+	widget = glade_xml_get_widget (priv->gxml,
+				       "chkEnableEvolutionIndexing");
+        gtk_widget_set_sensitive (widget, FALSE);
+
+	widget = glade_xml_get_widget (priv->gxml,
+				       "chkEnableModestIndexing");
+        gtk_widget_set_sensitive (widget, FALSE);
+
+	widget = glade_xml_get_widget (priv->gxml,
+				       "chkEnableThunderbirdIndexing");
+        gtk_widget_set_sensitive (widget, FALSE);
+#endif
 }
 
-static gboolean
-str_slist_equal (GSList *a, GSList *b)
+static void
+create_ui (TrackerPreferences *preferences)
 {
-	guint len_a = g_slist_length (a);
-	guint len_b = g_slist_length (b);
+        TrackerPreferencesPrivate *priv;
+	GError *error = NULL;
+        GtkWidget *widget;
 
-	if (len_a != len_b)
-		return FALSE;
+        priv = TRACKER_PREFERENCES_GET_PRIVATE (preferences);
+
+	priv->main_window = glade_xml_get_widget (priv->gxml, "dlgPreferences");
+
+	/* Hide window first to allow the preferences to reize itself without redrawing */
+	gtk_widget_hide (priv->main_window);
+
+	gtk_window_set_icon_name (GTK_WINDOW (priv->main_window), "tracker");
+	g_signal_connect (priv->main_window, "delete-event",
+			  G_CALLBACK (cmd_quit), preferences);
+
+	/* Setup signals */
+	widget = glade_xml_get_widget (priv->gxml, "cmdHelp");
+	g_signal_connect (widget, "clicked", 
+                          G_CALLBACK (cmd_help), preferences);
+	gtk_widget_hide (widget);
+
+	widget = glade_xml_get_widget (priv->gxml, "dialog-action_area1");
+	gtk_button_box_set_layout (GTK_BUTTON_BOX (widget),
+				   GTK_BUTTONBOX_END);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdApply");
+	g_signal_connect (widget, "clicked",
+                          G_CALLBACK (cmd_apply), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdCancel");
+	g_signal_connect (widget, "clicked", 
+                          G_CALLBACK (cmd_cancel), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdOK");
+	g_signal_connect (widget, "clicked", G_CALLBACK (cmd_ok),
+			  preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdAddIndexPath");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_add_index_path), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIndexPath");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_remove_index_path), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdAddCrawledPath");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_add_crawled_path), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveCrawledPath");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_remove_crawled_path),
+                          preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdAddIndexMailbox");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_add_index_mailbox), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIndexMailbox");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_remove_index_mailbox), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdAddIgnorePath");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_add_ignore_path), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIgnorePath");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_remove_ignore_path), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdAddIgnorePattern");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_add_ignore_pattern), preferences);
+
+	widget = glade_xml_get_widget (priv->gxml, "cmdRemoveIgnorePattern");
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (cmd_remove_ignore_pattern), preferences);
 
-	GSList *lst;
-	for (lst = a; lst; lst = lst->next) {
-		GSList *find = g_slist_find_custom (b, (const gchar *)(lst->data), _strcmp);
-		if (!find)
-			return FALSE;
+	/* Init dbus */
+	priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+	if (priv->connection == NULL) {
+		g_warning ("Unable to connect to dbus, %s",
+                           error->message);
+		g_error_free (error);
+		return;
 	}
 
-	return TRUE;
-}
+	priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->connection,
+						      DBUS_SERVICE_DBUS,
+						      DBUS_PATH_DBUS,
+						      DBUS_INTERFACE_DBUS);
 
-GType
-tracker_preferences_get_type (void)
-{
-	static GType type = 0;
+	if (!priv->dbus_proxy) {
+		g_warning ("Could not create proxy for '%s'", 
+                           DBUS_SERVICE_DBUS);
+		return;
+	}
 
-	if (type == 0) {
-		static const GTypeInfo info = {
-			sizeof (TrackerPreferencesClass),
-			NULL,	/* base_init */
-			NULL,	/* base_finalize */
-			(GClassInitFunc) tracker_preferences_class_init,	/* class_init */
-			NULL,	/* class_finalize */
-			NULL,	/* class_data */
-			sizeof (TrackerPreferences),
-			0,	/* n_preallocs */
-			tracker_preferences_init	/* instance_init */
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "TrackerPreferencesType",
-					       &info, 0);
+	priv->tracker_proxy = dbus_g_proxy_new_for_name (priv->connection,
+							 TRACKER_DBUS_SERVICE,
+							 TRACKER_DBUS_PATH,
+							 TRACKER_DBUS_INTERFACE);
+
+	if (!priv->tracker_proxy) {
+		g_warning ("Could not create proxy for '%s'", 
+                           TRACKER_DBUS_SERVICE);
+		return;
 	}
 
-	return type;
+	/* Setup pages */
+	setup_page_general (preferences);
+	setup_page_files (preferences);
+	setup_page_emails (preferences);
+	setup_page_ignored_files (preferences);
+	setup_page_performance (preferences);
+
+	gtk_widget_show (priv->main_window);
 }



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