diff options
author | Milan Crha <mcrha@redhat.com> | 2014-06-05 22:59:29 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-06-05 22:59:29 +0800 |
commit | 6e9e7b067618a22795db3d9a97f60705b8046353 (patch) | |
tree | d5049d2833f0b75de95030452fafed13a06a44e3 /modules/calendar/e-task-shell-view-private.c | |
parent | 2e71c861438a25ceac5811d9d3aa528691e71410 (diff) | |
download | gsoc2013-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/e-task-shell-view-private.c')
-rw-r--r-- | modules/calendar/e-task-shell-view-private.c | 24 |
1 files changed, 22 insertions, 2 deletions
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 |