aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-06-05 22:59:29 +0800
committerMilan Crha <mcrha@redhat.com>2014-06-05 22:59:29 +0800
commit6e9e7b067618a22795db3d9a97f60705b8046353 (patch)
treed5049d2833f0b75de95030452fafed13a06a44e3 /modules/calendar
parent2e71c861438a25ceac5811d9d3aa528691e71410 (diff)
downloadgsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.tar
gsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.tar.gz
gsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.tar.bz2
gsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.tar.lz
gsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.tar.xz
gsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.tar.zst
gsoc2013-evolution-6e9e7b067618a22795db3d9a97f60705b8046353.zip
Ignore false GSettings key change notifications
Similar to GObject::notify, the GSettings::changed can be emitted even if a key didn't change. It's up to the user (aka evolution) to test for real changes, thus let's do it. It may have certain performance positive impact too.
Diffstat (limited to 'modules/calendar')
-rw-r--r--modules/calendar/e-cal-shell-backend.c12
-rw-r--r--modules/calendar/e-task-shell-view-private.c24
-rw-r--r--modules/calendar/e-task-shell-view-private.h2
3 files changed, 35 insertions, 3 deletions
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index 0a9c80fb3d..65f88022d8 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -666,7 +666,17 @@ static void
cal_shell_backend_use_system_timezone_changed_cb (GSettings *settings,
const gchar *key)
{
- g_signal_emit_by_name (settings, "changed::timezone", timezone);
+ /* the '-1' is a trick to emit the change the first time */
+ static gint old_value = -1;
+ gboolean value;
+
+ value = g_settings_get_boolean (settings, key);
+
+ if ((value ? 1 : 0) != old_value) {
+ old_value = value ? 1 : 0;
+
+ g_signal_emit_by_name (settings, "changed::timezone", timezone);
+ }
}
static void
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index 863fd0136e..5a26284575 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -88,7 +88,21 @@ task_shell_view_hide_completed_tasks_changed_cb (GSettings *settings,
const gchar *key,
ETaskShellView *task_shell_view)
{
- task_shell_view_process_completed_tasks (task_shell_view);
+ GVariant *new_value, *old_value;
+
+ new_value = g_settings_get_value (settings, key);
+ old_value = g_hash_table_lookup (task_shell_view->priv->old_settings, key);
+
+ if (!new_value || !old_value || !g_variant_equal (new_value, old_value)) {
+ if (new_value)
+ g_hash_table_insert (task_shell_view->priv->old_settings, g_strdup (key), new_value);
+ else
+ g_hash_table_remove (task_shell_view->priv->old_settings, key);
+
+ task_shell_view_process_completed_tasks (task_shell_view);
+ } else if (new_value) {
+ g_variant_unref (new_value);
+ }
}
static void
@@ -210,6 +224,8 @@ task_shell_view_notify_view_id_cb (EShellView *shell_view)
void
e_task_shell_view_private_init (ETaskShellView *task_shell_view)
{
+ task_shell_view->priv->old_settings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
+
e_signal_connect_notify (
task_shell_view, "notify::view-id",
G_CALLBACK (task_shell_view_notify_view_id_cb), NULL);
@@ -553,7 +569,11 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view)
void
e_task_shell_view_private_finalize (ETaskShellView *task_shell_view)
{
- /* XXX Nothing to do? */
+ if (task_shell_view->priv->old_settings) {
+ g_hash_table_destroy (task_shell_view->priv->old_settings);
+ task_shell_view->priv->old_settings = NULL;
+ }
+
}
void
diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h
index b2a1511c9a..d29bd2e771 100644
--- a/modules/calendar/e-task-shell-view-private.h
+++ b/modules/calendar/e-task-shell-view-private.h
@@ -120,6 +120,8 @@ struct _ETaskShellViewPrivate {
guint update_completed_timeout;
guint confirm_purge : 1;
+
+ GHashTable *old_settings;
};
void e_task_shell_view_private_init