[tracker] tracker-extract: Fix TrackerConfig not handling change notification
- From: Xavier Claessens <xclaesse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-extract: Fix TrackerConfig not handling change notification
- Date: Thu, 20 Feb 2014 02:35:09 +0000 (UTC)
commit 167b293418708e749f23f7c2e55c7134b4839335
Author: Xavier Claessens <xavier claessens collabora co uk>
Date: Wed Feb 5 16:10:06 2014 -0500
tracker-extract: Fix TrackerConfig not handling change notification
https://bugzilla.gnome.org/show_bug.cgi?id=719802
src/tracker-extract/tracker-config.c | 90 +++++++++++-----------------------
src/tracker-extract/tracker-config.h | 7 +--
2 files changed, 29 insertions(+), 68 deletions(-)
---
diff --git a/src/tracker-extract/tracker-config.c b/src/tracker-extract/tracker-config.c
index e3e2a4d..69bf841 100644
--- a/src/tracker-extract/tracker-config.c
+++ b/src/tracker-extract/tracker-config.c
@@ -113,25 +113,21 @@ config_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
+ TrackerConfig *config = TRACKER_CONFIG (object);
+
switch (param_id) {
+ /* General */
+ /* NOTE: We handle these because we have to be able
+ * to save these based on command line overrides.
+ */
case PROP_VERBOSITY:
- g_settings_set_enum (G_SETTINGS (object), "verbosity",
- g_value_get_enum (value));
+ tracker_config_set_verbosity (config, g_value_get_enum (value));
break;
+ /* We don't care about the others... we don't save anyway. */
case PROP_SCHED_IDLE:
- g_settings_set_enum (G_SETTINGS (object), "sched-idle",
- g_value_get_enum (value));
- break;
-
case PROP_MAX_BYTES:
- g_settings_set_int (G_SETTINGS (object), "max-bytes",
- g_value_get_int (value));
- break;
-
case PROP_MAX_MEDIA_ART_WIDTH:
- g_settings_set_int (G_SETTINGS (object), "max-media-art-width",
- g_value_get_int (value));
break;
default:
@@ -146,25 +142,27 @@ config_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
+ TrackerConfig *config = TRACKER_CONFIG (object);
+
switch (param_id) {
case PROP_VERBOSITY:
g_value_set_enum (value,
- g_settings_get_enum (G_SETTINGS (object), "verbosity"));
+ tracker_config_get_verbosity (config));
break;
case PROP_SCHED_IDLE:
g_value_set_enum (value,
- g_settings_get_enum (G_SETTINGS (object), "sched-idle"));
+ tracker_config_get_sched_idle (config));
break;
case PROP_MAX_BYTES:
g_value_set_int (value,
- g_settings_get_int (G_SETTINGS (object), "max-bytes"));
+ tracker_config_get_max_bytes (config));
break;
case PROP_MAX_MEDIA_ART_WIDTH:
g_value_set_int (value,
- g_settings_get_int (G_SETTINGS (object), "max-media-art-width"));
+ tracker_config_get_max_media_art_width (config));
break;
default:
@@ -187,10 +185,19 @@ static void
config_constructed (GObject *object)
{
TrackerConfigFile *config_file;
+ GSettings *settings;
(G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object);
- g_settings_delay (G_SETTINGS (object));
+ settings = G_SETTINGS (object);
+
+ g_settings_delay (settings);
+
+ /* Set up bindings */
+ g_settings_bind (settings, "verbosity", object, "verbosity", G_SETTINGS_BIND_GET_NO_CHANGES);
+ g_settings_bind (settings, "sched-idle", object, "sched-idle", G_SETTINGS_BIND_GET);
+ g_settings_bind (settings, "max-bytes", object, "max-bytes", G_SETTINGS_BIND_GET);
+ g_settings_bind (settings, "max-media-art-width", object, "max-media-art-width", G_SETTINGS_BIND_GET);
/* Migrate keyfile-based configuration */
config_file = tracker_config_file_new ();
@@ -213,13 +220,9 @@ tracker_config_new (void)
gint
tracker_config_get_verbosity (TrackerConfig *config)
{
- gint verbosity;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), TRACKER_VERBOSITY_ERRORS);
- g_object_get (config, "verbosity", &verbosity, NULL);
-
- return verbosity;
+ return g_settings_get_enum (G_SETTINGS (config), "verbosity");
}
void
@@ -228,7 +231,7 @@ tracker_config_set_verbosity (TrackerConfig *config,
{
g_return_if_fail (TRACKER_IS_CONFIG (config));
- g_object_set (G_OBJECT (config), "verbosity", value, NULL);
+ g_settings_set_enum (G_SETTINGS (config), "verbosity", value);
}
gint
@@ -239,55 +242,18 @@ tracker_config_get_sched_idle (TrackerConfig *config)
return g_settings_get_enum (G_SETTINGS (config), "sched-idle");
}
-void
-tracker_config_set_sched_idle (TrackerConfig *config,
- gint value)
-{
-
- g_return_if_fail (TRACKER_IS_CONFIG (config));
-
- g_settings_set_enum (G_SETTINGS (config), "sched-idle", value);
- g_object_notify (G_OBJECT (config), "sched-idle");
-}
-
gint
tracker_config_get_max_bytes (TrackerConfig *config)
{
- gint max_bytes;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), 0);
- g_object_get (config, "max-bytes", &max_bytes, NULL);
-
- return max_bytes;
-}
-
-void
-tracker_config_set_max_bytes (TrackerConfig *config,
- gint value)
-{
- g_return_if_fail (TRACKER_IS_CONFIG (config));
-
- g_object_set (G_OBJECT (config), "max-bytes", value, NULL);
+ return g_settings_get_int (G_SETTINGS (config), "max-bytes");
}
gint
tracker_config_get_max_media_art_width (TrackerConfig *config)
{
- gint max_media_art_width;
-
g_return_val_if_fail (TRACKER_IS_CONFIG (config), 0);
- g_object_get (config, "max-media-art-width", &max_media_art_width, NULL);
-
- return max_media_art_width;
-}
-
-void
-tracker_config_set_max_media_art_width (TrackerConfig *config,
- gint value)
-{
- g_return_if_fail (TRACKER_IS_CONFIG (config));
-
- g_object_set (G_OBJECT (config), "max-media-art-width", value, NULL);
+ return g_settings_get_int (G_SETTINGS (config), "max-media-art-width");
}
diff --git a/src/tracker-extract/tracker-config.h b/src/tracker-extract/tracker-config.h
index 725bef2..96b7a4c 100644
--- a/src/tracker-extract/tracker-config.h
+++ b/src/tracker-extract/tracker-config.h
@@ -52,14 +52,9 @@ gint tracker_config_get_verbosity (TrackerConfig *config);
gint tracker_config_get_sched_idle (TrackerConfig *config);
gint tracker_config_get_max_bytes (TrackerConfig *config);
gint tracker_config_get_max_media_art_width (TrackerConfig *config);
+
void tracker_config_set_verbosity (TrackerConfig *config,
gint value);
-void tracker_config_set_sched_idle (TrackerConfig *config,
- gint value);
-void tracker_config_set_max_bytes (TrackerConfig *config,
- gint value);
-void tracker_config_set_max_media_art_width (TrackerConfig *config,
- gint value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]