From 7d20b8fd5fd28a90852c737f35cef7ba03a2c116 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Nov 2010 14:44:23 -0400 Subject: Utilize the new ESourceSelector:primary-selection property. --- modules/calendar/e-cal-shell-sidebar.c | 45 ++++++++++------------------------ 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'modules/calendar/e-cal-shell-sidebar.c') diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 965cc9fa60..66a1102cb7 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -406,31 +406,12 @@ static void cal_shell_sidebar_primary_selection_changed_cb (ECalShellSidebar *cal_shell_sidebar, ESourceSelector *selector) { - EShell *shell; - EShellView *shell_view; - EShellWindow *shell_window; - EShellSidebar *shell_sidebar; - EShellSettings *shell_settings; ESource *source; - /* XXX ESourceSelector needs a "primary-selection-uid" property - * so we can just bind the property with GConfBridge. */ - - source = e_source_selector_peek_primary_selection (selector); + source = e_source_selector_get_primary_selection (selector); if (source == NULL) return; - shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); - - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); - - e_shell_settings_set_string ( - shell_settings, "cal-primary-calendar", - e_source_peek_uid (source)); - cal_shell_sidebar_set_default (cal_shell_sidebar, source); } @@ -451,7 +432,6 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window, GSList *list, *iter; GObject *object; const gchar *key; - gchar *uid; priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); @@ -477,19 +457,20 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window, G_CALLBACK (cal_shell_sidebar_primary_selection_changed_cb), shell_sidebar); - source = NULL; - uid = e_shell_settings_get_string ( - shell_settings, "cal-primary-calendar"); - if (uid != NULL) - source = e_source_list_peek_source_by_uid (source_list, uid); - if (source == NULL) - source = e_source_list_peek_source_any (source_list); - if (source != NULL) - e_source_selector_set_primary_selection (selector, source); - g_free (uid); + g_object_bind_property_full ( + shell_settings, "cal-primary-calendar", + 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_object_ref (source_list), + (GDestroyNotify) g_object_unref); list = calendar_config_get_calendars_selected (); for (iter = list; iter != NULL; iter = iter->next) { + gchar *uid; + uid = iter->data; source = e_source_list_peek_source_by_uid (source_list, uid); g_free (uid); @@ -733,7 +714,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar); selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); - source = e_source_selector_peek_primary_selection (selector); + source = e_source_selector_get_primary_selection (selector); if (source != NULL) { ECal *client; -- cgit v1.2.3