diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-03 23:20:09 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-03-17 20:49:12 +0800 |
commit | 95a0ae4afb72b534c991fbcd774733a93f256514 (patch) | |
tree | 32293990fecd6a4a6401370e2a5aa355c6454022 /modules/calendar/e-task-shell-sidebar.c | |
parent | 23b89997658a8eb8bd2e1d9d20234a6978880aae (diff) | |
download | gsoc2013-evolution-95a0ae4afb72b534c991fbcd774733a93f256514.tar.gz gsoc2013-evolution-95a0ae4afb72b534c991fbcd774733a93f256514.tar.zst gsoc2013-evolution-95a0ae4afb72b534c991fbcd774733a93f256514.zip |
Remove ECalShellSettings.
EShellSettings predates GSettings and is no longer necessary.
GSettings allows binding GObject properties to GSettings keys,
with optional mapping functions. That fulfills the purpose of
EShellSettings.
Diffstat (limited to 'modules/calendar/e-task-shell-sidebar.c')
-rw-r--r-- | modules/calendar/e-task-shell-sidebar.c | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index ef767cf31c..d611b1969a 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -118,6 +118,43 @@ connect_closure_free (ConnectClosure *closure) g_slice_free (ConnectClosure, closure); } +static gboolean +task_shell_sidebar_map_uid_to_source (GValue *value, + GVariant *variant, + gpointer user_data) +{ + ESourceRegistry *registry; + ESource *source; + const gchar *uid; + + registry = E_SOURCE_REGISTRY (user_data); + uid = g_variant_get_string (variant, NULL); + source = e_source_registry_ref_source (registry, uid); + g_value_take_object (value, source); + + return (source != NULL); +} + +static GVariant * +task_shell_sidebar_map_source_to_uid (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + GVariant *variant = NULL; + ESource *source; + + source = g_value_get_object (value); + + if (source != NULL) { + const gchar *uid; + + uid = e_source_get_uid (source); + variant = g_variant_new_string (uid); + } + + return variant; +} + static void task_shell_sidebar_emit_client_added (ETaskShellSidebar *task_shell_sidebar, EClient *client) @@ -356,26 +393,17 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window, EShellSidebar *shell_sidebar) { ETaskShellSidebarPrivate *priv; - EShell *shell; - EShellBackend *shell_backend; - EShellSettings *shell_settings; ESourceRegistry *registry; ESourceSelector *selector; + GSettings *settings; GtkTreeModel *model; priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); - - shell_backend = e_shell_view_get_shell_backend (shell_view); - g_return_if_fail (E_IS_TASK_SHELL_BACKEND (shell_backend)); - selector = E_SOURCE_SELECTOR (priv->selector); + registry = e_source_selector_get_registry (selector); model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector)); - registry = e_shell_get_registry (shell); - g_signal_connect_swapped ( model, "row-changed", G_CALLBACK (task_shell_sidebar_row_changed_cb), @@ -386,15 +414,20 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window, G_CALLBACK (task_shell_sidebar_primary_selection_changed_cb), shell_sidebar); - g_object_bind_property_full ( - shell_settings, "cal-primary-task-list", + /* Bind GObject properties to settings keys. */ + + settings = g_settings_new ("org.gnome.evolution.calendar"); + + g_settings_bind_with_mapping ( + settings, "primary-tasks", selector, "primary-selection", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - (GBindingTransformFunc) e_binding_transform_uid_to_source, - (GBindingTransformFunc) e_binding_transform_source_to_uid, + G_SETTINGS_BIND_DEFAULT, + task_shell_sidebar_map_uid_to_source, + task_shell_sidebar_map_source_to_uid, g_object_ref (registry), (GDestroyNotify) g_object_unref); + + g_object_unref (settings); } static void |