[tracker/gsettings-rebased: 7/8] miner-fs: Use GSettings for configuration storage.
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gsettings-rebased: 7/8] miner-fs: Use GSettings for configuration storage.
- Date: Tue, 8 Mar 2011 14:58:56 +0000 (UTC)
commit a2c1a927aa0edf1a3fe14339c18f22f526df9876
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Feb 17 18:13:31 2011 +0100
miner-fs: Use GSettings for configuration storage.
src/miners/fs/tracker-config.c | 960 +++++++---------------
src/miners/fs/tracker-config.h | 7 +-
src/tracker-preferences/tracker-config.vapi | 2 +-
src/tracker-preferences/tracker-preferences.vala | 2 +-
4 files changed, 303 insertions(+), 668 deletions(-)
---
diff --git a/src/miners/fs/tracker-config.c b/src/miners/fs/tracker-config.c
index 2f86af0..e962354 100644
--- a/src/miners/fs/tracker-config.c
+++ b/src/miners/fs/tracker-config.c
@@ -28,17 +28,10 @@
#include <libtracker-common/tracker-keyfile-object.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-type-utils.h>
+#include <libtracker-common/tracker-enum-types.h>
#include "tracker-config.h"
-#define TRACKER_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CONFIG, TrackerConfigPrivate))
-
-/* GKeyFile defines */
-#define GROUP_GENERAL "General"
-#define GROUP_MONITORS "Monitors"
-#define GROUP_INDEXING "Indexing"
-#define GROUP_CRAWLING "Crawling"
-
/* Default values */
#define DEFAULT_VERBOSITY 0
#define DEFAULT_INITIAL_SLEEP 15 /* 0->1000 */
@@ -53,20 +46,6 @@
#define DEFAULT_REMOVABLE_DAYS_THRESHOLD 3 /* 1->365 / 0 */
typedef struct {
- /* General */
- gint verbosity;
- gint initial_sleep;
-
- /* Monitors */
- gboolean enable_monitors;
-
- /* Indexing */
- gint throttle;
- gboolean index_on_battery;
- gboolean index_on_battery_first_time;
- gboolean index_removable_devices;
- gboolean index_optical_discs;
- gint low_disk_space_limit;
GSList *index_recursive_directories;
GSList *index_recursive_directories_unfiltered;
GSList *index_single_directories;
@@ -74,8 +53,6 @@ typedef struct {
GSList *ignored_directories;
GSList *ignored_directories_with_content;
GSList *ignored_files;
- gint crawling_interval;
- gint removable_days_threshold;
/* Convenience data */
GSList *ignored_directory_patterns;
@@ -101,13 +78,6 @@ static void config_get_property (GObject *object,
GParamSpec *pspec);
static void config_finalize (GObject *object);
static void config_constructed (GObject *object);
-static void config_changed (TrackerConfigFile *file);
-static void config_load (TrackerConfig *config,
- gboolean use_defaults);
-static gboolean config_save (TrackerConfig *config);
-static void config_create_with_defaults (TrackerConfig *config,
- GKeyFile *key_file,
- gboolean overwrite);
enum {
PROP_0,
@@ -135,122 +105,116 @@ enum {
PROP_REMOVABLE_DAYS_THRESHOLD
};
-static ObjectToKeyFile conversions[] = {
- /* General */
- { G_TYPE_INT, "verbosity", GROUP_GENERAL, "Verbosity" },
- { G_TYPE_INT, "initial-sleep", GROUP_GENERAL, "InitialSleep" },
- /* Monitors */
- { G_TYPE_BOOLEAN, "enable-monitors", GROUP_MONITORS, "EnableMonitors" },
- /* Indexing */
- { G_TYPE_INT, "throttle", GROUP_INDEXING, "Throttle" },
- { G_TYPE_BOOLEAN, "index-on-battery", GROUP_INDEXING, "IndexOnBattery" },
- { G_TYPE_BOOLEAN, "index-on-battery-first-time", GROUP_INDEXING, "IndexOnBatteryFirstTime" },
- { G_TYPE_BOOLEAN, "index-removable-devices", GROUP_INDEXING, "IndexRemovableMedia" },
- { G_TYPE_BOOLEAN, "index-optical-discs", GROUP_INDEXING, "IndexOpticalDiscs" },
- { G_TYPE_INT, "low-disk-space-limit", GROUP_INDEXING, "LowDiskSpaceLimit" },
- { G_TYPE_POINTER, "index-recursive-directories", GROUP_INDEXING, "IndexRecursiveDirectories" },
- { G_TYPE_POINTER, "index-single-directories", GROUP_INDEXING, "IndexSingleDirectories" },
- { G_TYPE_POINTER, "ignored-directories", GROUP_INDEXING, "IgnoredDirectories" },
- { G_TYPE_POINTER, "ignored-directories-with-content", GROUP_INDEXING, "IgnoredDirectoriesWithContent" },
- { G_TYPE_POINTER, "ignored-files", GROUP_INDEXING, "IgnoredFiles" },
- { G_TYPE_INT, "crawling-interval", GROUP_INDEXING, "CrawlingInterval" },
- { G_TYPE_INT, "removable-days-threshold", GROUP_INDEXING, "RemovableDaysThreshold" }
+static TrackerConfigMigrationEntry migration[] = {
+ { G_TYPE_ENUM, "General", "Verbosity", "verbosity" },
+ { G_TYPE_INT, "General", "InitialSleep", "initial-sleep" },
+ { G_TYPE_BOOLEAN, "Monitors", "EnableMonitors", "enable-monitors" },
+ { G_TYPE_INT, "Indexing", "Throttle", "throttle" },
+ { G_TYPE_BOOLEAN, "Indexing", "IndexOnBattery", "index-on-battery" },
+ { G_TYPE_BOOLEAN, "Indexing", "IndexOnBatteryFirstTime", "index-on-battery-first-time" },
+ { G_TYPE_BOOLEAN, "Indexing", "IndexRemovableMedia", "index-removable-devices" },
+ { G_TYPE_BOOLEAN, "Indexing", "IndexOpticalDiscs", "index-optical-discs" },
+ { G_TYPE_INT, "Indexing", "LowDiskSpaceLimit", "low-disk-space-limit" },
+ { G_TYPE_POINTER, "Indexing", "IndexRecursiveDirectories", "index-recursive-directories" },
+ { G_TYPE_POINTER, "Indexing", "IndexSingleDirectories", "index-single-directories" },
+ { G_TYPE_POINTER, "Indexing", "IgnoredDirectories", "ignored-directories" },
+ { G_TYPE_POINTER, "Indexing", "IgnoredDirectoriesWithContent", "ignored-directories-with-content" },
+ { G_TYPE_POINTER, "Indexing", "IgnoredFiles", "ignored-files" },
+ { G_TYPE_INT, "Indexing", "CrawlingInterval", "crawling-interval" },
+ { G_TYPE_INT, "Indexing", "RemovableDaysThreshold", "removable-days-threshold" },
+ { 0 }
};
-G_DEFINE_TYPE (TrackerConfig, tracker_config, TRACKER_TYPE_CONFIG_FILE);
+G_DEFINE_TYPE (TrackerConfig, tracker_config, G_TYPE_SETTINGS)
static void
tracker_config_class_init (TrackerConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- TrackerConfigFileClass *config_file_class = TRACKER_CONFIG_FILE_CLASS (klass);
object_class->set_property = config_set_property;
object_class->get_property = config_get_property;
object_class->finalize = config_finalize;
object_class->constructed = config_constructed;
- config_file_class->changed = config_changed;
-
/* General */
g_object_class_install_property (object_class,
PROP_VERBOSITY,
- g_param_spec_int ("verbosity",
- "Log verbosity",
- " Log verbosity (0=errors, 1=minimal, 2=detailed, 3=debug)",
- 0,
- 3,
- DEFAULT_VERBOSITY,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_enum ("verbosity",
+ "Log verbosity",
+ "Log verbosity (0=errors, 1=minimal, 2=detailed, 3=debug)",
+ TRACKER_TYPE_VERBOSITY,
+ TRACKER_VERBOSITY_ERRORS,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INITIAL_SLEEP,
g_param_spec_int ("initial-sleep",
"Initial sleep",
- " Time in seconds before crawling filesystem (0->1000)",
+ "Time in seconds before crawling filesystem (0->1000)",
0,
1000,
DEFAULT_INITIAL_SLEEP,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
/* Monitors */
g_object_class_install_property (object_class,
PROP_ENABLE_MONITORS,
g_param_spec_boolean ("enable-monitors",
"Enable monitors",
- " Set to false to completely disable any monitoring",
+ "Set to false to completely disable any monitoring",
DEFAULT_ENABLE_MONITORS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
/* Indexing */
g_object_class_install_property (object_class,
PROP_THROTTLE,
g_param_spec_int ("throttle",
"Throttle",
- " Sets the indexing speed (0->20, where 20=slowest speed)",
+ "Sets the indexing speed (0->20, where 20=slowest speed)",
0,
20,
DEFAULT_THROTTLE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INDEX_ON_BATTERY,
g_param_spec_boolean ("index-on-battery",
"Index on battery",
- " Set to true to index while running on battery",
+ "Set to true to index while running on battery",
DEFAULT_INDEX_ON_BATTERY,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INDEX_ON_BATTERY_FIRST_TIME,
g_param_spec_boolean ("index-on-battery-first-time",
"Index on battery first time",
- " Set to true to index while running on battery for the first time only",
+ "Set to true to index while running on battery for the first time only",
DEFAULT_INDEX_ON_BATTERY_FIRST_TIME,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INDEX_REMOVABLE_DEVICES,
g_param_spec_boolean ("index-removable-devices",
"index removable devices",
- " Set to true to enable traversing mounted directories for removable devices\n"
- " (this includes optical discs)",
+ "Set to true to enable traversing mounted directories for removable devices\n"
+ "(this includes optical discs)",
DEFAULT_INDEX_REMOVABLE_DEVICES,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INDEX_OPTICAL_DISCS,
g_param_spec_boolean ("index-optical-discs",
"index optical discs",
- " Set to true to enable traversing CDs, DVDs, and generally optical media\n"
- " (if removable devices are not indexed, optical discs won't be either)",
+ "Set to true to enable traversing CDs, DVDs, and generally optical media\n"
+ "(if removable devices are not indexed, optical discs won't be either)",
DEFAULT_INDEX_OPTICAL_DISCS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_LOW_DISK_SPACE_LIMIT,
g_param_spec_int ("low-disk-space-limit",
"Low disk space limit",
- " Pause indexer when disk space is <= this value\n"
- " (0->100, value is in % of $HOME file system, -1=disable pausing)",
+ "Pause indexer when disk space is <= this value\n"
+ "(0->100, value is in % of $HOME file system, -1=disable pausing)",
-1,
100,
DEFAULT_LOW_DISK_SPACE_LIMIT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INDEX_RECURSIVE_DIRECTORIES,
g_param_spec_pointer ("index-recursive-directories",
@@ -266,32 +230,32 @@ tracker_config_class_init (TrackerConfigClass *klass)
" &TEMPLATES\n"
" &VIDEOS\n"
" If $HOME is the default below, it is because $HOME/.config/user-dirs.default was missing.",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_INDEX_SINGLE_DIRECTORIES,
g_param_spec_pointer ("index-single-directories",
"Index single directories",
" List of directories to index but not sub-directories for changes (separator=;)\n"
" Special values used for IndexRecursiveDirectories can also be used here",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IGNORED_DIRECTORIES,
g_param_spec_pointer ("ignored-directories",
"Ignored directories",
" List of directories to NOT crawl for indexing (separator=;)",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IGNORED_DIRECTORIES_WITH_CONTENT,
g_param_spec_pointer ("ignored-directories-with-content",
"Ignored directories with content",
" List of directories to NOT crawl for indexing based on child files (separator=;)",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IGNORED_FILES,
g_param_spec_pointer ("ignored-files",
"Ignored files",
" List of files to NOT index (separator=;)",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_CRAWLING_INTERVAL,
g_param_spec_int ("crawling-interval",
@@ -304,7 +268,7 @@ tracker_config_class_init (TrackerConfigClass *klass)
-2,
365,
DEFAULT_CRAWLING_INTERVAL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_REMOVABLE_DAYS_THRESHOLD,
g_param_spec_int ("removable-days-threshold",
@@ -315,7 +279,7 @@ tracker_config_class_init (TrackerConfigClass *klass)
0,
365,
DEFAULT_REMOVABLE_DAYS_THRESHOLD,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (TrackerConfigPrivate));
}
@@ -323,6 +287,7 @@ tracker_config_class_init (TrackerConfigClass *klass)
static void
tracker_config_init (TrackerConfig *object)
{
+ object->priv = G_TYPE_INSTANCE_GET_PRIVATE (object, TRACKER_TYPE_CONFIG, TrackerConfigPrivate);
}
static void
@@ -335,7 +300,7 @@ config_set_property (GObject *object,
/* General */
case PROP_VERBOSITY:
tracker_config_set_verbosity (TRACKER_CONFIG (object),
- g_value_get_int (value));
+ g_value_get_enum (value));
break;
case PROP_INITIAL_SLEEP:
tracker_config_set_initial_sleep (TRACKER_CONFIG (object),
@@ -413,63 +378,61 @@ config_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- TrackerConfigPrivate *priv;
-
- priv = TRACKER_CONFIG_GET_PRIVATE (object);
+ TrackerConfig *config = TRACKER_CONFIG (object);
switch (param_id) {
/* General */
case PROP_VERBOSITY:
- g_value_set_int (value, priv->verbosity);
+ g_value_set_enum (value, tracker_config_get_verbosity (config));
break;
case PROP_INITIAL_SLEEP:
- g_value_set_int (value, priv->initial_sleep);
+ g_value_set_int (value, tracker_config_get_initial_sleep (config));
break;
/* Montors */
case PROP_ENABLE_MONITORS:
- g_value_set_boolean (value, priv->enable_monitors);
+ g_value_set_boolean (value, tracker_config_get_enable_monitors (config));
break;
/* Indexing */
case PROP_THROTTLE:
- g_value_set_int (value, priv->throttle);
+ g_value_set_int (value, tracker_config_get_throttle (config));
break;
case PROP_INDEX_ON_BATTERY:
- g_value_set_boolean (value, priv->index_on_battery);
+ g_value_set_boolean (value, tracker_config_get_index_on_battery (config));
break;
case PROP_INDEX_ON_BATTERY_FIRST_TIME:
- g_value_set_boolean (value, priv->index_on_battery_first_time);
+ g_value_set_boolean (value, tracker_config_get_index_on_battery_first_time (config));
break;
case PROP_INDEX_REMOVABLE_DEVICES:
- g_value_set_boolean (value, priv->index_removable_devices);
+ g_value_set_boolean (value, tracker_config_get_index_removable_devices (config));
break;
case PROP_INDEX_OPTICAL_DISCS:
- g_value_set_boolean (value, priv->index_optical_discs);
+ g_value_set_boolean (value, tracker_config_get_index_optical_discs (config));
break;
case PROP_LOW_DISK_SPACE_LIMIT:
- g_value_set_int (value, priv->low_disk_space_limit);
+ g_value_set_int (value, tracker_config_get_low_disk_space_limit (config));
break;
case PROP_INDEX_RECURSIVE_DIRECTORIES:
- g_value_set_pointer (value, priv->index_recursive_directories);
+ g_value_set_pointer (value, tracker_config_get_index_recursive_directories (config));
break;
case PROP_INDEX_SINGLE_DIRECTORIES:
- g_value_set_pointer (value, priv->index_single_directories);
+ g_value_set_pointer (value, tracker_config_get_index_single_directories (config));
break;
case PROP_IGNORED_DIRECTORIES:
- g_value_set_pointer (value, priv->ignored_directories);
+ g_value_set_pointer (value, tracker_config_get_ignored_directories (config));
break;
case PROP_IGNORED_DIRECTORIES_WITH_CONTENT:
- g_value_set_pointer (value, priv->ignored_directories_with_content);
+ g_value_set_pointer (value, tracker_config_get_ignored_directories_with_content (config));
break;
case PROP_IGNORED_FILES:
- g_value_set_pointer (value, priv->ignored_files);
+ g_value_set_pointer (value, tracker_config_get_ignored_files (config));
break;
case PROP_CRAWLING_INTERVAL:
- g_value_set_int (value, priv->crawling_interval);
+ g_value_set_int (value, tracker_config_get_crawling_interval (config));
break;
case PROP_REMOVABLE_DAYS_THRESHOLD:
- g_value_set_int (value, priv->removable_days_threshold);
+ g_value_set_int (value, tracker_config_get_removable_days_threshold (config));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -482,7 +445,7 @@ config_finalize (GObject *object)
{
TrackerConfigPrivate *priv;
- priv = TRACKER_CONFIG_GET_PRIVATE (object);
+ priv = TRACKER_CONFIG (object)->priv;
g_slist_foreach (priv->ignored_file_patterns,
(GFunc) g_pattern_spec_free,
@@ -528,213 +491,81 @@ config_finalize (GObject *object)
(G_OBJECT_CLASS (tracker_config_parent_class)->finalize) (object);
}
-static void
-config_constructed (GObject *object)
+static gboolean
+settings_get_dir_mapping (GVariant *value,
+ gpointer *result,
+ gpointer user_data)
{
- (G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
+ gchar **strv;
+ gboolean is_recursive;
+ GSList *dirs, *l;
+ gsize len;
- config_load (TRACKER_CONFIG (object), TRUE);
-}
+ strv = (gchar **) g_variant_get_strv (value, &len);
+ dirs = tracker_string_list_to_gslist (strv, len);
+ g_free (strv);
-static void
-config_changed (TrackerConfigFile *file)
-{
- /* Reload config */
- config_load (TRACKER_CONFIG (file), FALSE);
-}
+ is_recursive = GPOINTER_TO_INT (user_data);
-static void
-config_create_with_defaults (TrackerConfig *config,
- GKeyFile *key_file,
- gboolean overwrite)
-{
- gboolean added_home_recursively = FALSE;
- gint i;
+ if (dirs) {
+ GSList *filtered;
- g_message ("Loading defaults into GKeyFile...");
+ filtered = tracker_path_list_filter_duplicates (dirs, ".", is_recursive);
- for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
- gboolean has_key;
+ g_slist_foreach (dirs, (GFunc) g_free, NULL);
+ g_slist_free (dirs);
- has_key = g_key_file_has_key (key_file,
- conversions[i].group,
- conversions[i].key,
- NULL);
- if (!overwrite && has_key) {
- continue;
+ dirs = filtered;
+ }
+
+ for (l = dirs; l; l = l->next) {
+ const gchar *path_to_use;
+
+ /* Must be a special dir */
+ if (strcmp (l->data, "&DESKTOP") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+ } else if (strcmp (l->data, "&DOCUMENTS") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+ } else if (strcmp (l->data, "&DOWNLOAD") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+ } else if (strcmp (l->data, "&MUSIC") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
+ } else if (strcmp (l->data, "&PICTURES") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+ } else if (strcmp (l->data, "&PUBLIC_SHARE") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
+ } else if (strcmp (l->data, "&TEMPLATES") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
+ } else if (strcmp (l->data, "&VIDEOS") == 0) {
+ path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
+ } else {
+ path_to_use = NULL;
}
- switch (conversions[i].type) {
- case G_TYPE_INT:
- g_key_file_set_integer (key_file,
- conversions[i].group,
- conversions[i].key,
- tracker_keyfile_object_default_int (config,
- conversions[i].property));
- break;
-
- case G_TYPE_BOOLEAN:
- g_key_file_set_boolean (key_file,
- conversions[i].group,
- conversions[i].key,
- tracker_keyfile_object_default_boolean (config,
- conversions[i].property));
- break;
-
- case G_TYPE_POINTER:
- /* Special case string lists */
- if (g_strcmp0 (conversions[i].property, "index-recursive-directories") == 0) {
- /* Since we can't know if
- * $HOME/.config/user-dirs.dirs exists
- * or not, we check that the GLib API
- * returns meaningful data.
- */
- GUserDirectory dir;
- GSList *paths = NULL;
- GStrv string_list;
-
- for (dir = 0; dir < G_USER_N_DIRECTORIES; dir++) {
- const gchar *path;
-
- path = g_get_user_special_dir (dir);
- if (path == NULL || *path == '\0') {
- continue;
- }
-
- switch (dir) {
- case G_USER_DIRECTORY_DESKTOP:
- path = "&DESKTOP";
- break;
- case G_USER_DIRECTORY_DOCUMENTS:
- path = "&DOCUMENTS";
- break;
- case G_USER_DIRECTORY_DOWNLOAD:
- path = "&DOWNLOAD";
- break;
- case G_USER_DIRECTORY_MUSIC:
- path = "&MUSIC";
- break;
- case G_USER_DIRECTORY_PICTURES:
- path = "&PICTURES";
- break;
- case G_USER_DIRECTORY_VIDEOS:
- path = "&VIDEOS";
- break;
-
- /* We are not interested in
- * TEMPLATES or PUBLIC_SHAREs
- */
- case G_USER_DIRECTORY_PUBLIC_SHARE:
- case G_USER_DIRECTORY_TEMPLATES:
- case G_USER_N_DIRECTORIES:
- continue;
- }
-
- paths = g_slist_prepend (paths, (gpointer) path);
- }
-
- paths = g_slist_reverse (paths);
-
- /* If we only found DESKTOP which is
- * always defined it seems, then add
- * $HOME.
- */
- if (g_slist_length (paths) < 2) {
- g_slist_free (paths);
- paths = g_slist_prepend (NULL, (gpointer) "$HOME");
- added_home_recursively = TRUE;
- }
-
- string_list = tracker_gslist_to_string_list (paths);
- g_slist_free (paths);
-
- g_key_file_set_string_list (key_file,
- conversions[i].group,
- conversions[i].key,
- (const gchar * const *) string_list,
- g_strv_length (string_list));
-
- g_strfreev (string_list);
- } else if (g_strcmp0 (conversions[i].property, "index-single-directories") == 0) {
- GSList *paths = NULL;
- GStrv string_list;
-
- if (!added_home_recursively) {
- paths = g_slist_prepend (paths, (gpointer) "$HOME");
- }
-
- string_list = tracker_gslist_to_string_list (paths);
- g_slist_free (paths);
-
- g_key_file_set_string_list (key_file,
- conversions[i].group,
- conversions[i].key,
- (const gchar * const *) string_list,
- g_strv_length (string_list));
-
- g_strfreev (string_list);
- } else if (g_strcmp0 (conversions[i].property, "ignored-directories") == 0) {
- const gchar *string_list[] = {
- "po", "CVS", "core-dumps", "lost+found",
- NULL
- };
-
- g_key_file_set_string_list (key_file,
- conversions[i].group,
- conversions[i].key,
- string_list,
- G_N_ELEMENTS (string_list));
- } else if (g_strcmp0 (conversions[i].property, "ignored-directories-with-content") == 0) {
- const gchar *string_list[] = {
- "backup.metadata",
- NULL
- };
-
- g_key_file_set_string_list (key_file,
- conversions[i].group,
- conversions[i].key,
- string_list,
- G_N_ELEMENTS (string_list));
- } else if (g_strcmp0 (conversions[i].property, "ignored-files") == 0) {
- const gchar *string_list[] = {
- "*~", "*.o", "*.la", "*.lo", "*.loT", "*.in",
- "*.csproj", "*.m4", "*.rej", "*.gmo", "*.orig",
- "*.pc", "*.omf", "*.aux", "*.tmp", "*.po",
- "*.vmdk", "*.vm*", "*.nvram", "*.part",
- "*.rcore", "lzo", "autom4te", "conftest",
- "confstat", "Makefile", "SCCS", "litmain.sh",
- "libtool", "config.status", "confdefs.h",
- NULL
- };
-
- g_key_file_set_string_list (key_file,
- conversions[i].group,
- conversions[i].key,
- string_list,
- G_N_ELEMENTS (string_list));
- } else {
- const gchar *string_list[] = { NULL };
+ if (path_to_use) {
+ g_free (l->data);
+ l->data = g_strdup (path_to_use);
+ }
+ }
- g_key_file_set_string_list (key_file,
- conversions[i].group,
- conversions[i].key,
- string_list,
- G_N_ELEMENTS (string_list));
- }
+ *result = dirs;
- break;
+ return TRUE;
+}
- default:
- g_assert_not_reached ();
- }
+static gboolean
+settings_get_strv_mapping (GVariant *value,
+ gpointer *result,
+ gpointer user_data)
+{
+ gchar **strv;
+ gsize len;
- g_key_file_set_comment (key_file,
- conversions[i].group,
- conversions[i].key,
- tracker_keyfile_object_blurb (config,
- conversions[i].property),
- NULL);
- }
+ strv = (gchar **) g_variant_get_strv (value, &len);
+ *result = tracker_string_list_to_gslist (strv, len);
+ g_free (strv);
+
+ return TRUE;
}
static void
@@ -745,7 +576,7 @@ config_set_ignored_file_conveniences (TrackerConfig *config)
GSList *paths = NULL;
GSList *patterns = NULL;
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
g_slist_foreach (priv->ignored_file_patterns,
(GFunc) g_pattern_spec_free,
@@ -786,7 +617,7 @@ config_set_ignored_directory_conveniences (TrackerConfig *config)
GSList *patterns = NULL;
GSList *paths = NULL;
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
g_slist_foreach (priv->ignored_directory_patterns,
(GFunc) g_pattern_spec_free,
@@ -820,348 +651,228 @@ config_set_ignored_directory_conveniences (TrackerConfig *config)
}
static void
-config_load (TrackerConfig *config,
- gboolean use_defaults)
+config_constructed (GObject *object)
{
- TrackerConfigFile *file;
- gint i;
-
- file = TRACKER_CONFIG_FILE (config);
-
- if (use_defaults) {
- config_create_with_defaults (config, file->key_file, FALSE);
- }
-
- if (!file->file_exists) {
- tracker_config_file_save (file);
- }
-
- for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
- gboolean has_key;
-
- has_key = g_key_file_has_key (file->key_file,
- conversions[i].group,
- conversions[i].key,
- NULL);
-
- switch (conversions[i].type) {
- case G_TYPE_INT:
- tracker_keyfile_object_load_int (G_OBJECT (file),
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key);
- break;
-
- case G_TYPE_BOOLEAN:
- tracker_keyfile_object_load_boolean (G_OBJECT (file),
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key);
- break;
-
- case G_TYPE_POINTER: {
- GSList *new_dirs, *old_dirs, *l;
- gboolean is_recursive = TRUE;
- gboolean equal;
-
- if (strcmp (conversions[i].property, "index-recursive-directories") == 0 ||
- strcmp (conversions[i].property, "index-single-directories") == 0 ||
- strcmp (conversions[i].property, "ignored-directories") == 0) {
- is_recursive = strcmp (conversions[i].property, "index-recursive-directories") == 0;
- tracker_keyfile_object_load_directory_list (G_OBJECT (file),
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key,
- is_recursive,
- &new_dirs);
-
- for (l = new_dirs; l; l = l->next) {
- const gchar *path_to_use;
-
- /* Must be a special dir */
- if (strcmp (l->data, "&DESKTOP") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
- } else if (strcmp (l->data, "&DOCUMENTS") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
- } else if (strcmp (l->data, "&DOWNLOAD") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
- } else if (strcmp (l->data, "&MUSIC") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
- } else if (strcmp (l->data, "&PICTURES") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
- } else if (strcmp (l->data, "&PUBLIC_SHARE") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
- } else if (strcmp (l->data, "&TEMPLATES") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
- } else if (strcmp (l->data, "&VIDEOS") == 0) {
- path_to_use = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
- } else {
- path_to_use = NULL;
- }
-
- if (path_to_use) {
- g_free (l->data);
- l->data = g_strdup (path_to_use);
- }
- }
- } else {
- tracker_keyfile_object_load_string_list (G_OBJECT (file),
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key,
- &new_dirs);
- }
-
- g_object_get (config, conversions[i].property, &old_dirs, NULL);
+ TrackerConfigFile *config_file;
+ TrackerConfigPrivate *priv;
- equal = tracker_gslist_with_string_data_equal (new_dirs, old_dirs);
+ (G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
- if (!equal) {
- g_object_set (config, conversions[i].property, new_dirs, NULL);
- }
+ priv = TRACKER_CONFIG (object)->priv;
+ g_settings_delay (G_SETTINGS (object));
- g_slist_foreach (new_dirs, (GFunc) g_free, NULL);
- g_slist_free (new_dirs);
+ /* Migrate keyfile-based configuration */
+ config_file = tracker_config_file_new ();
- break;
- }
- }
+ if (config_file) {
+ tracker_config_file_migrate (config_file, G_SETTINGS (object), migration);
+ g_object_unref (config_file);
}
- config_set_ignored_file_conveniences (config);
- config_set_ignored_directory_conveniences (config);
-}
-
-static gboolean
-config_save (TrackerConfig *config)
-{
- TrackerConfigFile *file;
- gint i;
-
- file = TRACKER_CONFIG_FILE (config);
+ /* Get cached values */
+ priv->index_recursive_directories = g_settings_get_mapped (G_SETTINGS (object),
+ "index-recursive-directories",
+ settings_get_dir_mapping,
+ GUINT_TO_POINTER (TRUE));
- if (!file->key_file) {
- g_critical ("Could not save config, GKeyFile was NULL, has the config been loaded?");
+ priv->index_single_directories = g_settings_get_mapped (G_SETTINGS (object),
+ "index-single-directories",
+ settings_get_dir_mapping,
+ GUINT_TO_POINTER (FALSE));
- return FALSE;
- }
-
- g_message ("Setting details to GKeyFile object...");
-
- for (i = 0; i < G_N_ELEMENTS (conversions); i++) {
- switch (conversions[i].type) {
- case G_TYPE_INT:
- tracker_keyfile_object_save_int (file,
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key);
- break;
-
- case G_TYPE_BOOLEAN:
- tracker_keyfile_object_save_boolean (file,
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key);
- break;
-
- case G_TYPE_POINTER:
- if (strcmp (conversions[i].property, "index-recursive-directories") == 0 ||
- strcmp (conversions[i].property, "index-single-directories") == 0) {
- GSList *dirs, *l;
-
- g_object_get (config, conversions[i].property, &dirs, NULL);
-
- for (l = dirs; l; l = l->next) {
- const gchar *path_to_use;
-
- /* FIXME: This doesn't work
- * perfectly, what if DESKTOP
- * and DOCUMENTS are in the
- * same place? Then this
- * breaks. Need a better
- * solution at some point.
- */
- if (g_strcmp0 (l->data, g_get_home_dir ()) == 0) {
- /* Home dir gets straight into configuration,
- * regardless of having XDG dirs pointing to it.
- */
- path_to_use = "$HOME";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)) == 0) {
- path_to_use = "&DESKTOP";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS)) == 0) {
- path_to_use = "&DOCUMENTS";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD)) == 0) {
- path_to_use = "&DOWNLOAD";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_MUSIC)) == 0) {
- path_to_use = "&MUSIC";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)) == 0) {
- path_to_use = "&PICTURES";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE)) == 0) {
- path_to_use = "&PUBLIC_SHARE";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES)) == 0) {
- path_to_use = "&TEMPLATES";
- } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS)) == 0) {
- path_to_use = "&VIDEOS";
- } else {
- path_to_use = NULL;
- }
-
- if (path_to_use) {
- g_free (l->data);
- l->data = g_strdup (path_to_use);
- }
- }
- }
+ priv->ignored_directories = g_settings_get_mapped (G_SETTINGS (object),
+ "ignored-directories",
+ settings_get_dir_mapping,
+ GUINT_TO_POINTER (FALSE));
- tracker_keyfile_object_save_string_list (file,
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key);
- break;
+ priv->ignored_directories_with_content = g_settings_get_mapped (G_SETTINGS (object),
+ "ignored-directories-with-content",
+ settings_get_strv_mapping, NULL);
- default:
- g_assert_not_reached ();
- break;
- }
- }
+ priv->ignored_files = g_settings_get_mapped (G_SETTINGS (object),
+ "ignored-files",
+ settings_get_strv_mapping, NULL);
- return tracker_config_file_save (file);
+ config_set_ignored_file_conveniences (TRACKER_CONFIG (object));
+ config_set_ignored_directory_conveniences (TRACKER_CONFIG (object));
}
TrackerConfig *
tracker_config_new (void)
{
- return g_object_new (TRACKER_TYPE_CONFIG, NULL);
+ return g_object_new (TRACKER_TYPE_CONFIG,
+ "schema", "org.freedesktop.Tracker.Miner.FileSystem",
+ "path", "/org/freedesktop/tracker/miners/fs/",
+ NULL);
}
-
-TrackerConfig *
-tracker_config_new_with_domain (const gchar *domain)
+static gchar **
+directories_to_strv (GSList *dirs)
{
- return g_object_new (TRACKER_TYPE_CONFIG, "domain", domain, NULL);
+ gchar **strv;
+ guint i = 0;
+ GSList *l;
+
+ strv = g_new0 (gchar*, g_slist_length (dirs) + 1);
+
+ for (l = dirs; l; l = l->next) {
+ const gchar *path_to_use;
+
+ /* FIXME: This doesn't work
+ * perfectly, what if DESKTOP
+ * and DOCUMENTS are in the
+ * same place? Then this
+ * breaks. Need a better
+ * solution at some point.
+ */
+ if (g_strcmp0 (l->data, g_get_home_dir ()) == 0) {
+ /* Home dir gets straight into configuration,
+ * regardless of having XDG dirs pointing to it.
+ */
+ path_to_use = "$HOME";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)) == 0) {
+ path_to_use = "&DESKTOP";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS)) == 0) {
+ path_to_use = "&DOCUMENTS";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD)) == 0) {
+ path_to_use = "&DOWNLOAD";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_MUSIC)) == 0) {
+ path_to_use = "&MUSIC";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)) == 0) {
+ path_to_use = "&PICTURES";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE)) == 0) {
+ path_to_use = "&PUBLIC_SHARE";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES)) == 0) {
+ path_to_use = "&TEMPLATES";
+ } else if (g_strcmp0 (l->data, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS)) == 0) {
+ path_to_use = "&VIDEOS";
+ } else {
+ path_to_use = l->data;
+ }
+
+ strv[i] = g_strdup (path_to_use);
+ i++;
+ }
+
+ return strv;
}
gboolean
tracker_config_save (TrackerConfig *config)
{
+ TrackerConfigPrivate *priv;
+ gchar **strv;
+
g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
- return config_save (config);
+ priv = config->priv;
+
+ /* Store cached values */
+ strv = tracker_gslist_to_string_list (priv->ignored_directories_with_content);
+ g_settings_set_strv (G_SETTINGS (config),
+ "ignored-directories-with-content",
+ (const gchar * const *) strv);
+ g_strfreev (strv);
+
+ strv = tracker_gslist_to_string_list (priv->ignored_files);
+ g_settings_set_strv (G_SETTINGS (config),
+ "ignored-files",
+ (const gchar * const *) strv);
+ g_strfreev (strv);
+
+ strv = tracker_gslist_to_string_list (priv->ignored_directories);
+ g_settings_set_strv (G_SETTINGS (config),
+ "ignored-directories",
+ (const gchar * const *) strv);
+ g_strfreev (strv);
+
+ strv = directories_to_strv (priv->index_recursive_directories);
+ g_settings_set_strv (G_SETTINGS (config),
+ "index-recursive-directories",
+ (const gchar * const *) strv);
+ g_strfreev (strv);
+
+ strv = directories_to_strv (priv->index_single_directories);
+ g_settings_set_strv (G_SETTINGS (config),
+ "index-single-directories",
+ (const gchar * const *) strv);
+ g_strfreev (strv);
+
+ /* And then apply the config */
+ g_settings_apply (G_SETTINGS (config));
+ return TRUE;
}
gint
tracker_config_get_verbosity (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_VERBOSITY);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->verbosity;
+ return g_settings_get_enum (G_SETTINGS (config), "verbosity");
}
gint
tracker_config_get_initial_sleep (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_INITIAL_SLEEP);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->initial_sleep;
+ return g_settings_get_int (G_SETTINGS (config), "initial-sleep");
}
gboolean
tracker_config_get_enable_monitors (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_ENABLE_MONITORS);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->enable_monitors;
+ return g_settings_get_boolean (G_SETTINGS (config), "enable-monitors");
}
gint
tracker_config_get_throttle (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_THROTTLE);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->throttle;
+ return g_settings_get_int (G_SETTINGS (config), "throttle");
}
gboolean
tracker_config_get_index_on_battery (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_INDEX_ON_BATTERY);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->index_on_battery;
+ return g_settings_get_boolean (G_SETTINGS (config), "index-on-battery");
}
gboolean
tracker_config_get_index_on_battery_first_time (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_INDEX_ON_BATTERY_FIRST_TIME);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->index_on_battery_first_time;
+ return g_settings_get_boolean (G_SETTINGS (config), "index-on-battery-first-time");
}
gboolean
tracker_config_get_index_removable_devices (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_INDEX_REMOVABLE_DEVICES);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->index_removable_devices;
+ return g_settings_get_boolean (G_SETTINGS (config), "index-removable-devices");
}
gboolean
tracker_config_get_index_optical_discs (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_INDEX_OPTICAL_DISCS);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->index_optical_discs;
+ return g_settings_get_boolean (G_SETTINGS (config), "index-optical-discs");
}
gint
tracker_config_get_low_disk_space_limit (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), DEFAULT_LOW_DISK_SPACE_LIMIT);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->low_disk_space_limit;
+ return g_settings_get_int (G_SETTINGS (config), "low-disk-space-limit");
}
GSList *
@@ -1171,7 +882,7 @@ tracker_config_get_index_recursive_directories (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->index_recursive_directories;
}
@@ -1183,7 +894,7 @@ tracker_config_get_index_recursive_directories_unfiltered (TrackerConfig *config
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->index_recursive_directories_unfiltered;
}
@@ -1195,7 +906,7 @@ tracker_config_get_index_single_directories (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->index_single_directories;
}
@@ -1207,7 +918,7 @@ tracker_config_get_index_single_directories_unfiltered (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->index_single_directories_unfiltered;
}
@@ -1219,7 +930,7 @@ tracker_config_get_ignored_directories (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_directories;
}
@@ -1231,7 +942,7 @@ tracker_config_get_ignored_directories_with_content (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_directories_with_content;
}
@@ -1243,7 +954,7 @@ tracker_config_get_ignored_files (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_files;
}
@@ -1251,42 +962,27 @@ tracker_config_get_ignored_files (TrackerConfig *config)
gint
tracker_config_get_crawling_interval (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), 0);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->crawling_interval;
+ return g_settings_get_int (G_SETTINGS (config), "crawling-interval");
}
gint
tracker_config_get_removable_days_threshold (TrackerConfig *config)
{
- TrackerConfigPrivate *priv;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), 0);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- return priv->removable_days_threshold;
+ return g_settings_get_int (G_SETTINGS (config), "removable-days-threshold");
}
void
tracker_config_set_verbosity (TrackerConfig *config,
gint value)
{
- TrackerConfigPrivate *priv;
g_return_if_fail (TRACKER_IS_CONFIG (config));
- if (!tracker_keyfile_object_validate_int (config, "verbosity", value)) {
- return;
- }
-
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->verbosity = value;
+ g_settings_set_enum (G_SETTINGS (config), "verbosity", value);
g_object_notify (G_OBJECT (config), "verbosity");
}
@@ -1294,17 +990,9 @@ void
tracker_config_set_initial_sleep (TrackerConfig *config,
gint value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- if (!tracker_keyfile_object_validate_int (config, "initial-sleep", value)) {
- return;
- }
-
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->initial_sleep = value;
+ g_settings_set_int (G_SETTINGS (config), "initial-sleep", value);
g_object_notify (G_OBJECT (config), "initial-sleep");
}
@@ -1312,13 +1000,9 @@ void
tracker_config_set_enable_monitors (TrackerConfig *config,
gboolean value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->enable_monitors = value;
+ g_settings_set_boolean (G_SETTINGS (config), "enable-monitors", value);
g_object_notify (G_OBJECT (config), "enable-monitors");
}
@@ -1326,17 +1010,9 @@ void
tracker_config_set_throttle (TrackerConfig *config,
gint value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- if (!tracker_keyfile_object_validate_int (config, "throttle", value)) {
- return;
- }
-
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->throttle = value;
+ g_settings_set_int (G_SETTINGS (config), "throttle", value);
g_object_notify (G_OBJECT (config), "throttle");
}
@@ -1344,13 +1020,9 @@ void
tracker_config_set_index_on_battery (TrackerConfig *config,
gboolean value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->index_on_battery = value;
+ g_settings_set_boolean (G_SETTINGS (config), "index-on-battery", value);
g_object_notify (G_OBJECT (config), "index-on-battery");
}
@@ -1358,13 +1030,9 @@ void
tracker_config_set_index_on_battery_first_time (TrackerConfig *config,
gboolean value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->index_on_battery_first_time = value;
+ g_settings_set_boolean (G_SETTINGS (config), "index-on-battery-first-time", value);
g_object_notify (G_OBJECT (config), "index-on-battery-first-time");
}
@@ -1372,13 +1040,9 @@ void
tracker_config_set_index_removable_devices (TrackerConfig *config,
gboolean value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->index_removable_devices = value;
+ g_settings_set_boolean (G_SETTINGS (config), "index-removable-devices", value);
g_object_notify (G_OBJECT (config), "index-removable-devices");
}
@@ -1386,13 +1050,9 @@ void
tracker_config_set_index_optical_discs (TrackerConfig *config,
gboolean value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->index_optical_discs = value;
+ g_settings_set_boolean (G_SETTINGS (config), "index-optical-discs", value);
g_object_notify (G_OBJECT (config), "index-optical-discs");
}
@@ -1400,17 +1060,9 @@ void
tracker_config_set_low_disk_space_limit (TrackerConfig *config,
gint value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- if (!tracker_keyfile_object_validate_int (config, "low-disk-space-limit", value)) {
- return;
- }
-
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->low_disk_space_limit = value;
+ g_settings_set_int (G_SETTINGS (config), "low-disk-space-limit", value);
g_object_notify (G_OBJECT (config), "low-disk-space-limit");
}
@@ -1420,7 +1072,7 @@ rebuild_filtered_lists (TrackerConfig *config)
TrackerConfigPrivate *priv;
GSList *old_list;
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
/* Filter single directories first, checking duplicates */
old_list = priv->index_single_directories;
@@ -1489,7 +1141,7 @@ tracker_config_set_index_recursive_directories (TrackerConfig *config,
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
l = priv->index_recursive_directories_unfiltered;
@@ -1522,7 +1174,7 @@ tracker_config_set_index_single_directories (TrackerConfig *config,
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
l = priv->index_single_directories_unfiltered;
@@ -1555,7 +1207,7 @@ tracker_config_set_ignored_directories (TrackerConfig *config,
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
l = priv->ignored_directories;
@@ -1591,7 +1243,7 @@ tracker_config_set_ignored_directories_with_content (TrackerConfig *config,
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
l = priv->ignored_directories_with_content;
@@ -1624,7 +1276,7 @@ tracker_config_set_ignored_files (TrackerConfig *config,
g_return_if_fail (TRACKER_IS_CONFIG (config));
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
l = priv->ignored_files;
@@ -1654,17 +1306,9 @@ void
tracker_config_set_crawling_interval (TrackerConfig *config,
gint interval)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- if (!tracker_keyfile_object_validate_int (config, "crawling-interval", interval)) {
- return;
- }
-
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->crawling_interval = interval;
+ g_settings_set_int (G_SETTINGS (config), "crawling-interval", interval);
g_object_notify (G_OBJECT (config), "crawling-interval");
}
@@ -1672,17 +1316,9 @@ void
tracker_config_set_removable_days_threshold (TrackerConfig *config,
gint value)
{
- TrackerConfigPrivate *priv;
-
g_return_if_fail (TRACKER_IS_CONFIG (config));
- if (!tracker_keyfile_object_validate_int (config, "removable-days-threshold", value)) {
- return;
- }
-
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
-
- priv->removable_days_threshold = value;
+ g_settings_set_int (G_SETTINGS (config), "removable-days-threshold", value);
g_object_notify (G_OBJECT (config), "removable-days-threshold");
}
@@ -1697,7 +1333,7 @@ tracker_config_get_ignored_directory_patterns (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_directory_patterns;
}
@@ -1709,7 +1345,7 @@ tracker_config_get_ignored_file_patterns (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_file_patterns;
}
@@ -1721,7 +1357,7 @@ tracker_config_get_ignored_directory_paths (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_directory_paths;
}
@@ -1733,7 +1369,7 @@ tracker_config_get_ignored_file_paths (TrackerConfig *config)
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- priv = TRACKER_CONFIG_GET_PRIVATE (config);
+ priv = config->priv;
return priv->ignored_file_paths;
}
diff --git a/src/miners/fs/tracker-config.h b/src/miners/fs/tracker-config.h
index 5327c5c..5f629a3 100644
--- a/src/miners/fs/tracker-config.h
+++ b/src/miners/fs/tracker-config.h
@@ -37,18 +37,17 @@ typedef struct TrackerConfig TrackerConfig;
typedef struct TrackerConfigClass TrackerConfigClass;
struct TrackerConfig {
- TrackerConfigFile parent;
+ GSettings parent;
+ gpointer priv;
};
struct TrackerConfigClass {
- TrackerConfigFileClass parent_class;
+ GSettingsClass parent_class;
};
GType tracker_config_get_type (void) G_GNUC_CONST;
TrackerConfig *tracker_config_new (void);
-TrackerConfig *tracker_config_new_with_domain (const gchar *domain);
-
gboolean tracker_config_save (TrackerConfig *config);
gint tracker_config_get_verbosity (TrackerConfig *config);
diff --git a/src/tracker-preferences/tracker-config.vapi b/src/tracker-preferences/tracker-config.vapi
index 0e5d114..3cca1f0 100644
--- a/src/tracker-preferences/tracker-config.vapi
+++ b/src/tracker-preferences/tracker-config.vapi
@@ -22,7 +22,7 @@
namespace Tracker {
[CCode (cheader_filename = "miners/fs/tracker-config.h")]
public class Config : GLib.Object {
- public Config.with_domain (string domain);
+ public Config ();
public int verbosity { get; set; }
public int initial_sleep { get; set; }
diff --git a/src/tracker-preferences/tracker-preferences.vala b/src/tracker-preferences/tracker-preferences.vala
index aba7bd6..1ca2b87 100644
--- a/src/tracker-preferences/tracker-preferences.vala
+++ b/src/tracker-preferences/tracker-preferences.vala
@@ -336,7 +336,7 @@ static int main (string[] args) {
Intl.textdomain (GETTEXT_PACKAGE);
try {
- config = new Config.with_domain ("tracker-miner-fs");
+ config = new Config ();
var builder = new Builder ();
builder.add_from_file (TRACKER_DATADIR + Path.DIR_SEPARATOR_S + "tracker-preferences.ui");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]