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 | |
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')
-rw-r--r-- | modules/calendar/Makefile.am | 2 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-backend.c | 70 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-settings.c | 906 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-settings.h | 33 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-sidebar.c | 90 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-private.c | 55 | ||||
-rw-r--r-- | modules/calendar/e-calendar-preferences.c | 639 | ||||
-rw-r--r-- | modules/calendar/e-calendar-preferences.h | 2 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-sidebar.c | 67 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-sidebar.c | 67 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-private.c | 78 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-private.h | 6 |
12 files changed, 650 insertions, 1365 deletions
diff --git a/modules/calendar/Makefile.am b/modules/calendar/Makefile.am index e8ec2af362..540d61a88f 100644 --- a/modules/calendar/Makefile.am +++ b/modules/calendar/Makefile.am @@ -27,8 +27,6 @@ module_calendar_la_SOURCES = \ e-cal-shell-content.h \ e-cal-shell-migrate.c \ e-cal-shell-migrate.h \ - e-cal-shell-settings.c \ - e-cal-shell-settings.h \ e-cal-shell-sidebar.c \ e-cal-shell-sidebar.h \ e-cal-shell-view.c \ diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c index ec7af990e5..95ecf398e8 100644 --- a/modules/calendar/e-cal-shell-backend.c +++ b/modules/calendar/e-cal-shell-backend.c @@ -41,7 +41,6 @@ #include "e-cal-shell-content.h" #include "e-cal-shell-migrate.h" -#include "e-cal-shell-settings.h" #include "e-cal-shell-sidebar.h" #include "e-cal-shell-view.h" @@ -67,26 +66,25 @@ cal_shell_backend_new_event (ECalClient *cal_client, gboolean all_day) { ECalComponent *comp; - EShellSettings *shell_settings; + GSettings *settings; CompEditor *editor; - shell_settings = e_shell_get_shell_settings (shell); + settings = g_settings_new ("org.gnome.evolution.calendar"); editor = event_editor_new (cal_client, shell, flags); comp = cal_comp_event_new_with_current_time ( cal_client, all_day, - e_shell_settings_get_boolean ( - shell_settings, "cal-use-default-reminder"), - e_shell_settings_get_int ( - shell_settings, "cal-default-reminder-interval"), - e_shell_settings_get_int ( /* enum, actually */ - shell_settings, "cal-default-reminder-units")); + g_settings_get_boolean (settings, "use-default-reminder"), + g_settings_get_int (settings, "default-reminder-interval"), + g_settings_get_enum (settings, "default-reminder-units")); e_cal_component_commit_sequence (comp); comp_editor_edit_comp (editor, comp); gtk_window_present (GTK_WINDOW (editor)); g_object_unref (comp); + + g_object_unref (settings); } static void @@ -391,7 +389,6 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, const gchar *uri) { EShell *shell; - EShellSettings *shell_settings; CompEditor *editor; CompEditorFlags flags = 0; EClient *client; @@ -399,6 +396,7 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, ECalComponent *comp; ESource *source; ESourceRegistry *registry; + GSettings *settings; SoupURI *soup_uri; icalcomponent *icalcomp; icalproperty *icalprop; @@ -414,9 +412,6 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); client_cache = e_shell_get_client_cache (shell); - shell_settings = e_shell_get_shell_settings (shell); - - zone = e_shell_settings_get_pointer (shell_settings, "cal-timezone"); if (strncmp (uri, "calendar:", 9) != 0) return FALSE; @@ -433,6 +428,26 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, g_date_clear (&start_date, 1); g_date_clear (&end_date, 1); + settings = g_settings_new ("org.gnome.evolution.calendar"); + + if (g_settings_get_boolean (settings, "use-system-timezone")) + zone = e_cal_util_get_system_timezone (); + else { + gchar *location; + + location = g_settings_get_string (settings, "timezone"); + + if (location != NULL) { + zone = icaltimezone_get_builtin_timezone (location); + g_free (location); + } + } + + if (zone == NULL) + zone = icaltimezone_get_utc_timezone (); + + g_object_unref (settings); + while (*cp != '\0') { gchar *header; gchar *content; @@ -642,11 +657,19 @@ ensure_alarm_notify_is_running (void) } static void +cal_shell_backend_use_system_timezone_changed_cb (GSettings *settings, + const gchar *key) +{ + g_signal_emit_by_name (settings, "changed::timezone", timezone); +} + +static void cal_shell_backend_constructed (GObject *object) { EShell *shell; EShellBackend *shell_backend; GtkWidget *preferences_window; + GSettings *settings; shell_backend = E_SHELL_BACKEND (object); shell = e_shell_backend_get_shell (shell_backend); @@ -663,8 +686,6 @@ cal_shell_backend_constructed (GObject *object) cal_shell_backend_init_importers (); - e_cal_shell_backend_init_settings (shell); - /* Setup preference widget factories */ preferences_window = e_shell_get_preferences_window (shell); @@ -677,11 +698,22 @@ cal_shell_backend_constructed (GObject *object) e_calendar_preferences_new, 600); - g_object_bind_property ( - e_shell_get_shell_settings (shell), "cal-prefer-new-item", + settings = g_settings_new ("org.gnome.evolution.calendar"); + + g_settings_bind ( + settings, "prefer-new-item", shell_backend, "prefer-new-item", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); + + /* Changing whether or not to use the system timezone may change + * Evolution's current timezone. Need to emit "changed" signals + * for both keys. */ + g_signal_connect ( + settings, "changed::use-system-timezone", + G_CALLBACK (cal_shell_backend_use_system_timezone_changed_cb), + NULL); + + g_object_unref (settings); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_cal_shell_backend_parent_class)->constructed (object); diff --git a/modules/calendar/e-cal-shell-settings.c b/modules/calendar/e-cal-shell-settings.c deleted file mode 100644 index d3288401f5..0000000000 --- a/modules/calendar/e-cal-shell-settings.c +++ /dev/null @@ -1,906 +0,0 @@ -/* - * e-cal-shell-settings.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-cal-shell-settings.h" - -#include <libecal/libecal.h> - -#include <e-util/e-util.h> -#include <e-util/e-util-enumtypes.h> - -#define CALENDAR_SCHEMA "org.gnome.evolution.calendar" -#define EDS_CALENDAR_CONTACTS_SCHEMA "org.gnome.evolution-data-server.calendar" - -static gboolean -transform_string_to_icaltimezone (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gboolean use_system_timezone; - const gchar *location = NULL; - icaltimezone *timezone = NULL; - - shell_settings = E_SHELL_SETTINGS (user_data); - - use_system_timezone = e_shell_settings_get_boolean ( - shell_settings, "cal-use-system-timezone"); - - if (use_system_timezone) - timezone = e_cal_util_get_system_timezone (); - else - location = g_value_get_string (source_value); - - if (location != NULL && *location != '\0') - timezone = icaltimezone_get_builtin_timezone (location); - - if (timezone == NULL) - timezone = icaltimezone_get_utc_timezone (); - - g_value_set_pointer (target_value, timezone); - - return TRUE; -} - -static gboolean -transform_icaltimezone_to_string (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gboolean use_system_timezone; - const gchar *location = NULL; - gchar *location_str = NULL; - icaltimezone *timezone; - - shell_settings = E_SHELL_SETTINGS (user_data); - - use_system_timezone = e_shell_settings_get_boolean ( - shell_settings, "cal-use-system-timezone"); - - if (use_system_timezone) { - location_str = e_shell_settings_get_string ( - shell_settings, "cal-timezone-string"); - location = location_str; - } else { - timezone = g_value_get_pointer (source_value); - - if (timezone != NULL) - location = icaltimezone_get_location (timezone); - } - - if (location == NULL) - location = "UTC"; - - g_value_set_string (target_value, location); - - g_free (location_str); - - return TRUE; -} - -static gboolean -transform_weekdays_settings_to_evolution (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - GDateWeekday weekday; - - /* XXX At some point, Evolution changed its weekday numbering - * from 0 = Sunday to 0 = Monday, but did not migrate the - * "week_start_day" key. Both enumerations are of course - * different from GDateWeekday. We should have saved the - * weekday as a string instead. */ - - /* This is purposefully verbose for better readability. */ - - /* setting numbering */ - switch (g_value_get_int (source_value)) { - case 0: - weekday = G_DATE_SUNDAY; - break; - case 1: - weekday = G_DATE_MONDAY; - break; - case 2: - weekday = G_DATE_TUESDAY; - break; - case 3: - weekday = G_DATE_WEDNESDAY; - break; - case 4: - weekday = G_DATE_THURSDAY; - break; - case 5: - weekday = G_DATE_FRIDAY; - break; - case 6: - weekday = G_DATE_SATURDAY; - break; - default: - return FALSE; - } - - /* Evolution numbering */ - g_value_set_enum (target_value, weekday); - - return TRUE; -} - -static gboolean -transform_weekdays_evolution_to_settings (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - GDateWeekday weekday; - - /* XXX At some point, Evolution changed its weekday numbering - * from 0 = Sunday to 0 = Monday, but did not migrate the - * "week_start_day" key. Both enumerations are of course - * different from GDateWeekday. We should have saved the - * weekday as a string instead. */ - - /* This is purposefully verbose for better readability. */ - - /* Evolution numbering */ - weekday = g_value_get_enum (source_value); - - /* setting numbering */ - switch (weekday) { - case G_DATE_MONDAY: - g_value_set_int (target_value, 1); - break; - case G_DATE_TUESDAY: - g_value_set_int (target_value, 2); - break; - case G_DATE_WEDNESDAY: - g_value_set_int (target_value, 3); - break; - case G_DATE_THURSDAY: - g_value_set_int (target_value, 4); - break; - case G_DATE_FRIDAY: - g_value_set_int (target_value, 5); - break; - case G_DATE_SATURDAY: - g_value_set_int (target_value, 6); - break; - case G_DATE_SUNDAY: - g_value_set_int (target_value, 0); - break; - default: - return FALSE; - } - - return TRUE; -} - -/* Working day flags */ -enum { - WORKING_DAY_SUNDAY = 1 << 0, - WORKING_DAY_MONDAY = 1 << 1, - WORKING_DAY_TUESDAY = 1 << 2, - WORKING_DAY_WEDNESDAY = 1 << 3, - WORKING_DAY_THURSDAY = 1 << 4, - WORKING_DAY_FRIDAY = 1 << 5, - WORKING_DAY_SATURDAY = 1 << 6 -}; - -static gboolean -transform_working_days_bitset_to_sunday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_SUNDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_sunday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_SUNDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_SUNDAY) | bit); - - return TRUE; -} - -static gboolean -transform_working_days_bitset_to_monday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_MONDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_monday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_MONDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_MONDAY) | bit); - - return TRUE; -} - -static gboolean -transform_working_days_bitset_to_tuesday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_TUESDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_tuesday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_TUESDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_TUESDAY) | bit); - - return TRUE; -} - -static gboolean -transform_working_days_bitset_to_wednesday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_WEDNESDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_wednesday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_WEDNESDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_WEDNESDAY) | bit); - - return TRUE; -} - -static gboolean -transform_working_days_bitset_to_thursday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_THURSDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_thursday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_THURSDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_THURSDAY) | bit); - - return TRUE; -} - -static gboolean -transform_working_days_bitset_to_friday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_FRIDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_friday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_FRIDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_FRIDAY) | bit); - - return TRUE; -} - -static gboolean -transform_working_days_bitset_to_saturday (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - gint bitset; - gboolean working_day; - - bitset = g_value_get_int (source_value); - working_day = ((bitset & WORKING_DAY_SATURDAY) != 0); - g_value_set_boolean (target_value, working_day); - - return TRUE; -} - -static gboolean -transform_working_days_saturday_to_bitset (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - EShellSettings *shell_settings; - gint bitset, bit; - - shell_settings = E_SHELL_SETTINGS (user_data); - - bitset = e_shell_settings_get_int ( - shell_settings, "cal-working-days-bitset"); - - bit = g_value_get_boolean (source_value) ? WORKING_DAY_SATURDAY : 0; - g_value_set_int (target_value, (bitset & ~WORKING_DAY_SATURDAY) | bit); - - return TRUE; -} - -static void -cal_use_system_timezone_changed_cb (GObject *shell_settings) -{ - g_object_notify (shell_settings, "cal-timezone-string"); -} - -void -e_cal_shell_backend_init_settings (EShell *shell) -{ - EShellSettings *shell_settings; - - shell_settings = e_shell_get_shell_settings (shell); - - e_shell_settings_install_property_for_key ( - "cal-ba-reminder-interval", - EDS_CALENDAR_CONTACTS_SCHEMA, - "contacts-reminder-interval"); - - e_shell_settings_install_property_for_key ( - "cal-ba-reminder-units-string", - EDS_CALENDAR_CONTACTS_SCHEMA, - "contacts-reminder-units"); - - e_shell_settings_install_property_for_key ( - "cal-compress-weekend", - CALENDAR_SCHEMA, - "compress-weekend"); - - e_shell_settings_install_property_for_key ( - "cal-confirm-delete", - CALENDAR_SCHEMA, - "confirm-delete"); - - e_shell_settings_install_property_for_key ( - "cal-confirm-purge", - CALENDAR_SCHEMA, - "confirm-purge"); - - e_shell_settings_install_property_for_key ( - "cal-default-reminder-interval", - CALENDAR_SCHEMA, - "default-reminder-interval"); - - /* Do not bind to this. - * Use "cal-default-reminder-units" instead. */ - e_shell_settings_install_property_for_key ( - "cal-default-reminder-units-string", - CALENDAR_SCHEMA, - "default-reminder-units"); - - e_shell_settings_install_property_for_key ( - "cal-free-busy-template", - CALENDAR_SCHEMA, - "publish-template"); - - e_shell_settings_install_property_for_key ( - "cal-hide-completed-tasks", - CALENDAR_SCHEMA, - "hide-completed-tasks"); - - /* Do not bind to this. - * Use "cal-hide-completed-tasks-units" instead. */ - e_shell_settings_install_property_for_key ( - "cal-hide-completed-tasks-units-string", - CALENDAR_SCHEMA, - "hide-completed-tasks-units"); - - e_shell_settings_install_property_for_key ( - "cal-hide-completed-tasks-value", - CALENDAR_SCHEMA, - "hide-completed-tasks-value"); - - e_shell_settings_install_property_for_key ( - "cal-marcus-bains-day-view-color", - CALENDAR_SCHEMA, - "marcus-bains-color-dayview"); - - e_shell_settings_install_property_for_key ( - "cal-marcus-bains-time-bar-color", - CALENDAR_SCHEMA, - "marcus-bains-color-timebar"); - - e_shell_settings_install_property_for_key ( - "cal-marcus-bains-show-line", - CALENDAR_SCHEMA, - "marcus-bains-line"); - - e_shell_settings_install_property_for_key ( - "cal-month-scroll-by-week", - CALENDAR_SCHEMA, - "month-scroll-by-week"); - - e_shell_settings_install_property_for_key ( - "cal-primary-calendar", - CALENDAR_SCHEMA, - "primary-calendar"); - - e_shell_settings_install_property_for_key ( - "cal-primary-memo-list", - CALENDAR_SCHEMA, - "primary-memos"); - - e_shell_settings_install_property_for_key ( - "cal-primary-task-list", - CALENDAR_SCHEMA, - "primary-tasks"); - - e_shell_settings_install_property_for_key ( - "cal-recur-events-italic", - CALENDAR_SCHEMA, - "recur-events-italic"); - - e_shell_settings_install_property_for_key ( - "cal-search-range-years", - CALENDAR_SCHEMA, - "search-range-years"); - - e_shell_settings_install_property_for_key ( - "cal-show-event-end-times", - CALENDAR_SCHEMA, - "show-event-end"); - - e_shell_settings_install_property_for_key ( - "cal-show-week-numbers", - CALENDAR_SCHEMA, - "show-week-numbers"); - - e_shell_settings_install_property_for_key ( - "cal-tasks-highlight-due-today", - CALENDAR_SCHEMA, - "task-due-today-highlight"); - - e_shell_settings_install_property_for_key ( - "cal-tasks-color-due-today", - CALENDAR_SCHEMA, - "task-due-today-color"); - - e_shell_settings_install_property_for_key ( - "cal-tasks-highlight-overdue", - CALENDAR_SCHEMA, - "task-overdue-highlight"); - - e_shell_settings_install_property_for_key ( - "cal-tasks-color-overdue", - CALENDAR_SCHEMA, - "task-overdue-color"); - - e_shell_settings_install_property_for_key ( - "cal-time-divisions", - CALENDAR_SCHEMA, - "time-divisions"); - - /* Do not bind to this. Use "cal-timezone" instead. */ - e_shell_settings_install_property_for_key ( - "cal-timezone-string", - CALENDAR_SCHEMA, - "timezone"); - - e_shell_settings_install_property_for_key ( - "cal-use-24-hour-format", - CALENDAR_SCHEMA, - "use-24hour-format"); - - e_shell_settings_install_property_for_key ( - "cal-use-ba-reminder", - EDS_CALENDAR_CONTACTS_SCHEMA, - "contacts-reminder-enabled"); - - e_shell_settings_install_property_for_key ( - "cal-use-default-reminder", - CALENDAR_SCHEMA, - "use-default-reminder"); - - e_shell_settings_install_property_for_key ( - "cal-use-system-timezone", - CALENDAR_SCHEMA, - "use-system-timezone"); - - /* Do not bind to this. Use "cal-week-start-day" instead. */ - e_shell_settings_install_property_for_key ( - "cal-week-start-day-setting", - CALENDAR_SCHEMA, - "week-start-day"); - - e_shell_settings_install_property_for_key ( - "cal-work-day-end-hour", - CALENDAR_SCHEMA, - "day-end-hour"); - - e_shell_settings_install_property_for_key ( - "cal-work-day-end-minute", - CALENDAR_SCHEMA, - "day-end-minute"); - - e_shell_settings_install_property_for_key ( - "cal-work-day-start-hour", - CALENDAR_SCHEMA, - "day-start-hour"); - - e_shell_settings_install_property_for_key ( - "cal-work-day-start-minute", - CALENDAR_SCHEMA, - "day-start-minute"); - - e_shell_settings_install_property_for_key ( - "cal-working-days-bitset", - CALENDAR_SCHEMA, - "working-days"); - - e_shell_settings_install_property_for_key ( - "cal-prefer-new-item", - CALENDAR_SCHEMA, - "prefer-new-item"); - - /* These properties use transform functions to convert - * GSettings values to forms more useful to Evolution. - */ - - e_shell_settings_install_property ( - g_param_spec_enum ( - "cal-ba-reminder-units", - NULL, - NULL, - E_TYPE_DURATION_TYPE, - E_DURATION_MINUTES, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-ba-reminder-units-string", - shell_settings, "cal-ba-reminder-units", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_enum_nick_to_value, - e_binding_transform_enum_value_to_nick, - NULL, (GDestroyNotify) NULL); - - e_shell_settings_install_property ( - g_param_spec_enum ( - "cal-default-reminder-units", - NULL, - NULL, - E_TYPE_DURATION_TYPE, - E_DURATION_MINUTES, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-default-reminder-units-string", - shell_settings, "cal-default-reminder-units", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_enum_nick_to_value, - e_binding_transform_enum_value_to_nick, - NULL, (GDestroyNotify) NULL); - - e_shell_settings_install_property ( - g_param_spec_enum ( - "cal-hide-completed-tasks-units", - NULL, - NULL, - E_TYPE_DURATION_TYPE, - E_DURATION_MINUTES, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-hide-completed-tasks-units-string", - shell_settings, "cal-hide-completed-tasks-units", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_enum_nick_to_value, - e_binding_transform_enum_value_to_nick, - NULL, (GDestroyNotify) NULL); - - e_shell_settings_install_property ( - g_param_spec_pointer ( - "cal-timezone", - NULL, - NULL, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-timezone-string", - shell_settings, "cal-timezone", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_string_to_icaltimezone, - transform_icaltimezone_to_string, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_enum ( - "cal-week-start-day", - NULL, - NULL, - E_TYPE_DATE_WEEKDAY, - G_DATE_MONDAY, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-week-start-day-setting", - shell_settings, "cal-week-start-day", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_weekdays_settings_to_evolution, - transform_weekdays_evolution_to_settings, - NULL, (GDestroyNotify) NULL); - - /* XXX These are my favorite. Storing a bit array in GSettings - * instead of separate boolean keys. Brilliant move. */ - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-sunday", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-sunday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_sunday, - transform_working_days_sunday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-monday", - NULL, - NULL, - TRUE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-monday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_monday, - transform_working_days_monday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-tuesday", - NULL, - NULL, - TRUE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-tuesday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_tuesday, - transform_working_days_tuesday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-wednesday", - NULL, - NULL, - TRUE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-wednesday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_wednesday, - transform_working_days_wednesday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-thursday", - NULL, - NULL, - TRUE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-thursday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_thursday, - transform_working_days_thursday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-friday", - NULL, - NULL, - TRUE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-friday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_friday, - transform_working_days_friday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - e_shell_settings_install_property ( - g_param_spec_boolean ( - "cal-working-days-saturday", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "cal-working-days-bitset", - shell_settings, "cal-working-days-saturday", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_working_days_bitset_to_saturday, - transform_working_days_saturday_to_bitset, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); - - g_signal_connect ( - shell_settings, "notify::cal-use-system-timezone", - G_CALLBACK (cal_use_system_timezone_changed_cb), NULL); -} diff --git a/modules/calendar/e-cal-shell-settings.h b/modules/calendar/e-cal-shell-settings.h deleted file mode 100644 index 5f7293bbed..0000000000 --- a/modules/calendar/e-cal-shell-settings.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * e-cal-shell-settings.h - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_CAL_SHELL_SETTINGS_H -#define E_CAL_SHELL_SETTINGS_H - -#include <shell/e-shell.h> - -G_BEGIN_DECLS - -void e_cal_shell_backend_init_settings (EShell *shell); - -G_END_DECLS - -#endif /* E_CAL_SHELL_SETTINGS_H */ diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index ad5327f34e..5a5fa5c5ac 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -121,6 +121,43 @@ connect_closure_free (ConnectClosure *closure) g_slice_free (ConnectClosure, closure); } +static gboolean +cal_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 * +cal_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 cal_shell_sidebar_emit_client_added (ECalShellSidebar *cal_shell_sidebar, EClient *client) @@ -359,28 +396,17 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window, EShellSidebar *shell_sidebar) { ECalShellSidebarPrivate *priv; - EShell *shell; - EShellBackend *shell_backend; - EShellSettings *shell_settings; ESourceRegistry *registry; ESourceSelector *selector; GSettings *settings; GtkTreeModel *model; - GObject *object; priv = E_CAL_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_CAL_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 (cal_shell_sidebar_row_changed_cb), @@ -391,24 +417,25 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window, G_CALLBACK (cal_shell_sidebar_primary_selection_changed_cb), shell_sidebar); - 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 (registry), - (GDestroyNotify) g_object_unref); - /* Bind GObject properties to settings keys. */ settings = g_settings_new ("org.gnome.evolution.calendar"); - object = G_OBJECT (priv->paned); - g_settings_bind (settings, "date-navigator-pane-position", object, "vposition", G_SETTINGS_BIND_DEFAULT); + g_settings_bind_with_mapping ( + settings, "primary-calendar", + selector, "primary-selection", + G_SETTINGS_BIND_DEFAULT, + cal_shell_sidebar_map_uid_to_source, + cal_shell_sidebar_map_source_to_uid, + g_object_ref (registry), + (GDestroyNotify) g_object_unref); - g_object_unref (G_OBJECT (settings)); + g_settings_bind ( + settings, "date-navigator-pane-position", + priv->paned, "vposition", + G_SETTINGS_BIND_DEFAULT); + + g_object_unref (settings); } static void @@ -500,7 +527,6 @@ cal_shell_sidebar_constructed (GObject *object) EShellWindow *shell_window; EShellBackend *shell_backend; EShellSidebar *shell_sidebar; - EShellSettings *shell_settings; EClientCache *client_cache; ECalendarItem *calitem; GtkWidget *container; @@ -516,9 +542,7 @@ cal_shell_sidebar_constructed (GObject *object) shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_backend = e_shell_view_get_shell_backend (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell = e_shell_backend_get_shell (shell_backend); - shell_settings = e_shell_get_shell_settings (shell); container = GTK_WIDGET (shell_sidebar); @@ -576,16 +600,6 @@ cal_shell_sidebar_constructed (GObject *object) priv->date_navigator = g_object_ref (widget); gtk_widget_show (widget); - g_object_bind_property ( - shell_settings, "cal-show-week-numbers", - calitem, "show-week-numbers", - G_BINDING_SYNC_CREATE); - - g_object_bind_property ( - shell_settings, "cal-week-start-day", - calitem, "week-start-day", - G_BINDING_SYNC_CREATE); - /* Restore widget state from the last session once * the shell view is fully initialized and visible. */ g_signal_connect ( diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 4561ad35dd..144245514d 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -503,15 +503,7 @@ system_timezone_monitor_changed (GFileMonitor *handle, GFileMonitorEvent event, gpointer user_data) { - ECalShellView *view = E_CAL_SHELL_VIEW (user_data); - ECalShellViewPrivate *priv = view->priv; - ECalShellContent *cal_shell_content; - icaltimezone *timezone = NULL, *current_zone = NULL; - EShellSettings *settings; - EShellBackend *shell_backend; - EShell *shell; - ECalModel *model; - const gchar *location; + GSettings *settings; if (event != G_FILE_MONITOR_EVENT_CHANGED && event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT && @@ -519,25 +511,9 @@ system_timezone_monitor_changed (GFileMonitor *handle, event != G_FILE_MONITOR_EVENT_CREATED) return; - cal_shell_content = priv->cal_shell_content; - model = e_cal_shell_content_get_model (cal_shell_content); - current_zone = e_cal_model_get_timezone (model); - timezone = e_cal_util_get_system_timezone (); - - if (!g_strcmp0 ( - icaltimezone_get_tzid (timezone), - icaltimezone_get_tzid (current_zone))) - return; - - shell_backend = e_shell_view_get_shell_backend ((EShellView *) view); - shell = e_shell_backend_get_shell (shell_backend); - settings = e_shell_get_shell_settings (shell); - location = icaltimezone_get_location (timezone); - if (location == NULL) - location = "UTC"; - - g_object_set (settings, "cal-timezone-string", location, NULL); - g_object_set (settings, "cal-timezone", timezone, NULL); + settings = g_settings_new ("org.gnome.evolution.calendar"); + g_signal_emit_by_name (settings, "changed::timezone", "timezone"); + g_object_unref (settings); } static void @@ -555,10 +531,10 @@ init_timezone_monitors (ECalShellView *view) g_object_unref (file); if (priv->monitors[i]) - g_signal_connect_object ( + g_signal_connect ( priv->monitors[i], "changed", G_CALLBACK (system_timezone_monitor_changed), - view, 0); + NULL); } } @@ -1211,18 +1187,19 @@ e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view) static gint cal_searching_get_search_range_years (ECalShellView *cal_shell_view) { - EShellBackend *backend; - EShellSettings *shell_settings; - gint value; + GSettings *settings; + gint search_range_years; + + settings = g_settings_new ("org.gnome.evolution.calendar"); - backend = e_shell_view_get_shell_backend (E_SHELL_VIEW (cal_shell_view)); - shell_settings = e_shell_get_shell_settings (e_shell_backend_get_shell (backend)); + search_range_years = + g_settings_get_int (settings, "search-range-years"); + if (search_range_years <= 0) + search_range_years = 10; - value = e_shell_settings_get_int (shell_settings, "cal-search-range-years"); - if (value <= 0) - value = 10; + g_object_unref (settings); - return value; + return search_range_years; } static gint diff --git a/modules/calendar/e-calendar-preferences.c b/modules/calendar/e-calendar-preferences.c index 0079b2cf95..48c50e3500 100644 --- a/modules/calendar/e-calendar-preferences.c +++ b/modules/calendar/e-calendar-preferences.c @@ -47,30 +47,130 @@ G_DEFINE_DYNAMIC_TYPE ( GTK_TYPE_VBOX) static gboolean -transform_time_divisions_to_index (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer not_used) +calendar_preferences_map_string_to_integer (GValue *value, + GVariant *variant, + gpointer user_data) { - gboolean success = TRUE; + GEnumClass *enum_class = G_ENUM_CLASS (user_data); + GEnumValue *enum_value; + const gchar *nick; + + /* XXX GSettings should know how to bind enum settings to + * integer properties. I filed a bug asking for this: + * https://bugzilla.gnome.org/show_bug.cgi?id=695217 */ + + nick = g_variant_get_string (variant, NULL); + enum_value = g_enum_get_value_by_nick (enum_class, nick); + g_return_val_if_fail (enum_value != NULL, FALSE); + g_value_set_int (value, enum_value->value); + + return TRUE; +} + +static GVariant * +calendar_preferences_map_integer_to_string (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + GEnumClass *enum_class = G_ENUM_CLASS (user_data); + GEnumValue *enum_value; + + /* XXX GSettings should know how to bind enum settings to + * integer properties. I filed a bug asking for this: + * https://bugzilla.gnome.org/show_bug.cgi?id=695217 */ + + enum_value = g_enum_get_value (enum_class, g_value_get_int (value)); + g_return_val_if_fail (enum_value != NULL, NULL); + + return g_variant_new_string (enum_value->value_nick); +} + +static gboolean +calendar_preferences_map_string_to_icaltimezone (GValue *value, + GVariant *variant, + gpointer user_data) +{ + GSettings *settings; + const gchar *location = NULL; + icaltimezone *timezone = NULL; + + settings = g_settings_new ("org.gnome.evolution.calendar"); + + if (g_settings_get_boolean (settings, "use-system-timezone")) + timezone = e_cal_util_get_system_timezone (); + else + location = g_variant_get_string (variant, NULL); + + if (location != NULL && *location != '\0') + timezone = icaltimezone_get_builtin_timezone (location); + + if (timezone == NULL) + timezone = icaltimezone_get_utc_timezone (); + + g_value_set_pointer (value, timezone); + + g_object_unref (settings); + + return TRUE; +} - g_return_val_if_fail (G_IS_BINDING (binding), FALSE); +static GVariant * +calendar_preferences_map_icaltimezone_to_string (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + GVariant *variant; + GSettings *settings; + const gchar *location = NULL; + gchar *location_str = NULL; + icaltimezone *timezone; + + settings = g_settings_new ("org.gnome.evolution.calendar"); + + if (g_settings_get_boolean (settings, "use-system-timezone")) { + location_str = g_settings_get_string (settings, "timezone"); + location = location_str; + } else { + timezone = g_value_get_pointer (value); + + if (timezone != NULL) + location = icaltimezone_get_location (timezone); + } + + if (location == NULL) + location = "UTC"; + + variant = g_variant_new_string (location); + + g_free (location_str); + + g_object_unref (settings); + + return variant; +} - switch (g_value_get_int (source_value)) { +static gboolean +calendar_preferences_map_time_divisions_to_index (GValue *value, + GVariant *variant, + gpointer user_data) +{ + gboolean success = TRUE; + + switch (g_variant_get_int32 (variant)) { case 60: - g_value_set_int (target_value, 0); + g_value_set_int (value, 0); break; case 30: - g_value_set_int (target_value, 1); + g_value_set_int (value, 1); break; case 15: - g_value_set_int (target_value, 2); + g_value_set_int (value, 2); break; case 10: - g_value_set_int (target_value, 3); + g_value_set_int (value, 3); break; case 5: - g_value_set_int (target_value, 4); + g_value_set_int (value, 4); break; default: success = FALSE; @@ -79,37 +179,69 @@ transform_time_divisions_to_index (GBinding *binding, return success; } -static gboolean -transform_index_to_time_divisions (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer not_used) +static GVariant * +calendar_preferences_map_index_to_time_divisions (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) { - gboolean success = TRUE; - - switch (g_value_get_int (source_value)) { + switch (g_value_get_int (value)) { case 0: - g_value_set_int (target_value, 60); - break; + return g_variant_new_int32 (60); case 1: - g_value_set_int (target_value, 30); - break; + return g_variant_new_int32 (30); case 2: - g_value_set_int (target_value, 15); - break; + return g_variant_new_int32 (15); case 3: - g_value_set_int (target_value, 10); - break; + return g_variant_new_int32 (10); case 4: - g_value_set_int (target_value, 5); - break; + return g_variant_new_int32 (5); default: - success = FALSE; + break; + } + + return NULL; +} + +static gboolean +calendar_preferences_map_string_to_gdk_color (GValue *value, + GVariant *variant, + gpointer user_data) +{ + GdkColor color; + const gchar *string; + gboolean success = FALSE; + + string = g_variant_get_string (variant, NULL); + if (gdk_color_parse (string, &color)) { + g_value_set_boxed (value, &color); + success = TRUE; } return success; } +static GVariant * +calendar_preferences_map_gdk_color_to_string (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + GVariant *variant; + const GdkColor *color; + + color = g_value_get_boxed (value); + if (color == NULL) { + variant = g_variant_new_string (""); + } else { + gchar *string; + + string = gdk_color_to_string (color); + variant = g_variant_new_string (string); + g_free (string); + } + + return variant; +} + static void calendar_preferences_dispose (GObject *object) { @@ -125,11 +257,6 @@ calendar_preferences_dispose (GObject *object) prefs->registry = NULL; } - if (prefs->shell_settings != NULL) { - g_object_unref (prefs->shell_settings); - prefs->shell_settings = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_calendar_preferences_parent_class)->dispose (object); } @@ -276,8 +403,12 @@ static void start_of_day_changed (GtkWidget *widget, ECalendarPreferences *prefs) { - gint start_hour, start_minute, end_hour, end_minute; EDateEdit *start, *end; + GSettings *settings; + gint start_hour; + gint start_minute; + gint end_hour; + gint end_minute; start = E_DATE_EDIT (prefs->start_of_day); end = E_DATE_EDIT (prefs->end_of_day); @@ -294,20 +425,24 @@ start_of_day_changed (GtkWidget *widget, return; } - e_shell_settings_set_int ( - prefs->shell_settings, - "cal-work-day-start-hour", start_hour); - e_shell_settings_set_int ( - prefs->shell_settings, - "cal-work-day-start-minute", start_minute); + settings = g_settings_new ("org.gnome.evolution.calendar"); + + g_settings_set_int (settings, "day-start-hour", start_hour); + g_settings_set_int (settings, "day-start-minute", start_minute); + + g_object_unref (settings); } static void end_of_day_changed (GtkWidget *widget, ECalendarPreferences *prefs) { - gint start_hour, start_minute, end_hour, end_minute; EDateEdit *start, *end; + GSettings *settings; + gint start_hour; + gint start_minute; + gint end_hour; + gint end_minute; start = E_DATE_EDIT (prefs->start_of_day); end = E_DATE_EDIT (prefs->end_of_day); @@ -324,30 +459,16 @@ end_of_day_changed (GtkWidget *widget, return; } - e_shell_settings_set_int ( - prefs->shell_settings, - "cal-work-day-end-hour", end_hour); - e_shell_settings_set_int ( - prefs->shell_settings, - "cal-work-day-end-minute", end_minute); -} - -static void -notify_with_tray_toggled (GtkToggleButton *toggle, - ECalendarPreferences *prefs) -{ - GSettings *settings; + settings = g_settings_new ("org.gnome.evolution.calendar"); - g_return_if_fail (toggle != NULL); + g_settings_set_int (settings, "day-end-hour", end_hour); + g_settings_set_int (settings, "day-end-minute", end_minute); - settings = g_settings_new ("org.gnome.evolution.calendar"); - g_settings_set_boolean (settings, "notify-with-tray", gtk_toggle_button_get_active (toggle)); g_object_unref (settings); } static void -update_system_tz_widgets (EShellSettings *shell_settings, - GParamSpec *pspec, +update_system_tz_widgets (GtkCheckButton *button, ECalendarPreferences *prefs) { GtkWidget *widget; @@ -383,16 +504,11 @@ setup_changes (ECalendarPreferences *prefs) g_signal_connect ( prefs->end_of_day, "changed", G_CALLBACK (end_of_day_changed), prefs); - - g_signal_connect ( - prefs->notify_with_tray, "toggled", - G_CALLBACK (notify_with_tray_toggled), prefs); } static void show_alarms_config (ECalendarPreferences *prefs) { - GSettings *settings; GtkWidget *widget; widget = e_alarm_selector_new (prefs->registry); @@ -401,19 +517,15 @@ show_alarms_config (ECalendarPreferences *prefs) _("Selected Calendars for Alarms")); gtk_container_add (GTK_CONTAINER (prefs->scrolled_window), widget); gtk_widget_show (widget); - - settings = g_settings_new ("org.gnome.evolution.calendar"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->notify_with_tray), g_settings_get_boolean (settings, "notify-with-tray")); - g_object_unref (settings); } /* Shows the current config settings in the dialog. */ static void show_config (ECalendarPreferences *prefs) { - EShellSettings *shell_settings; + GSettings *settings; - shell_settings = prefs->shell_settings; + settings = g_settings_new ("org.gnome.evolution.calendar"); /* Day's second zone */ update_day_second_zone_caption (prefs); @@ -421,21 +533,19 @@ show_config (ECalendarPreferences *prefs) /* Start of Day. */ e_date_edit_set_time_of_day ( E_DATE_EDIT (prefs->start_of_day), - e_shell_settings_get_int ( - shell_settings, "cal-work-day-start-hour"), - e_shell_settings_get_int ( - shell_settings, "cal-work-day-start-minute")); + g_settings_get_int (settings, "day-start-hour"), + g_settings_get_int (settings, "day-start-minute")); /* End of Day. */ e_date_edit_set_time_of_day ( E_DATE_EDIT (prefs->end_of_day), - e_shell_settings_get_int ( - shell_settings, "cal-work-day-end-hour"), - e_shell_settings_get_int ( - shell_settings, "cal-work-day-end-minute")); + g_settings_get_int (settings, "day-end-hour"), + g_settings_get_int (settings, "day-end-minute")); /* Alarms list */ show_alarms_config (prefs); + + g_object_unref (settings); } /* plugin meta-data */ @@ -468,7 +578,8 @@ calendar_preferences_construct (ECalendarPreferences *prefs, { ECalConfig *ec; ECalConfigTargetPrefs *target; - EShellSettings *shell_settings; + GSettings *settings; + GSettings *eds_settings; gboolean locale_supports_12_hour_format; gint i; GtkWidget *toplevel; @@ -476,15 +587,14 @@ calendar_preferences_construct (ECalendarPreferences *prefs, GtkWidget *table; GSList *l; - shell_settings = prefs->shell_settings; + settings = g_settings_new ("org.gnome.evolution.calendar"); locale_supports_12_hour_format = calendar_config_locale_supports_12_hour_format (); /* Force 24 hour format for locales which don't support 12 hour format */ - if (!locale_supports_12_hour_format - && !e_shell_settings_get_boolean (shell_settings, "cal-use-24-hour-format")) - e_shell_settings_set_boolean (shell_settings, "cal-use-24-hour-format", TRUE); + if (!locale_supports_12_hour_format) + g_settings_set_boolean (settings, "use-24hour-format", TRUE); /* Make sure our custom widget classes are registered with * GType before we load the GtkBuilder definition file. */ @@ -508,317 +618,307 @@ calendar_preferences_construct (ECalendarPreferences *prefs, e_config_add_items ((EConfig *) ec, l, eccp_free, prefs); widget = e_builder_get_widget (prefs->builder, "use-system-tz-check"); - g_object_bind_property ( - shell_settings, "cal-use-system-timezone", + g_settings_bind ( + settings, "use-system-timezone", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); g_signal_connect ( - shell_settings, "notify::cal-use-system-timezone", + widget, "toggled", G_CALLBACK (update_system_tz_widgets), prefs); - update_system_tz_widgets (shell_settings, NULL, prefs); + update_system_tz_widgets (GTK_CHECK_BUTTON (widget), prefs); widget = e_builder_get_widget (prefs->builder, "timezone"); - g_object_bind_property ( - shell_settings, "cal-timezone", + g_settings_bind_with_mapping ( + settings, "timezone", widget, "timezone", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-use-system-timezone", + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_string_to_icaltimezone, + calendar_preferences_map_icaltimezone_to_string, + NULL, (GDestroyNotify) NULL); + g_settings_bind ( + settings, "use-system-timezone", widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE | - G_BINDING_INVERT_BOOLEAN); + G_SETTINGS_BIND_DEFAULT | + G_SETTINGS_BIND_INVERT_BOOLEAN); /* General tab */ prefs->day_second_zone = e_builder_get_widget (prefs->builder, "day_second_zone"); widget = e_builder_get_widget (prefs->builder, "sun_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-sunday", + g_settings_bind ( + settings, "work-day-sunday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "mon_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-monday", + g_settings_bind ( + settings, "work-day-monday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "tue_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-tuesday", + g_settings_bind ( + settings, "work-day-tuesday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "wed_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-wednesday", + g_settings_bind ( + settings, "work-day-wednesday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "thu_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-thursday", + g_settings_bind ( + settings, "work-day-thursday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "fri_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-friday", + g_settings_bind ( + settings, "work-day-friday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "sat_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-saturday", + g_settings_bind ( + settings, "work-day-saturday", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "week_start_day"); - g_object_bind_property_full ( - shell_settings, "cal-week-start-day", + g_settings_bind ( + settings, "week-start-day-name", widget, "active-id", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_enum_value_to_nick, - e_binding_transform_enum_nick_to_value, - NULL, (GDestroyNotify) NULL); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "start_of_day"); prefs->start_of_day = widget; /* XXX delete this */ if (locale_supports_12_hour_format) - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", + g_settings_bind ( + settings, "use-24hour-format", widget, "use-24-hour-format", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "end_of_day"); prefs->end_of_day = widget; /* XXX delete this */ if (locale_supports_12_hour_format) - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", + g_settings_bind ( + settings, "use-24hour-format", widget, "use-24-hour-format", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "use_12_hour"); gtk_widget_set_sensitive (widget, locale_supports_12_hour_format); - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", + g_settings_bind ( + settings, "use-24hour-format", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE | - G_BINDING_INVERT_BOOLEAN); + G_SETTINGS_BIND_DEFAULT | + G_SETTINGS_BIND_INVERT_BOOLEAN); widget = e_builder_get_widget (prefs->builder, "use_24_hour"); gtk_widget_set_sensitive (widget, locale_supports_12_hour_format); - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", + g_settings_bind ( + settings, "use-24hour-format", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "confirm_delete"); - g_object_bind_property ( - shell_settings, "cal-confirm-delete", + g_settings_bind ( + settings, "confirm-delete", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "default_reminder"); - g_object_bind_property ( - shell_settings, "cal-use-default-reminder", + g_settings_bind ( + settings, "use-default-reminder", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "default_reminder_interval"); - g_object_bind_property ( - shell_settings, "cal-default-reminder-interval", + g_settings_bind ( + settings, "default-reminder-interval", widget, "value", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-use-default-reminder", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "use-default-reminder", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "default_reminder_units"); - g_object_bind_property ( - shell_settings, "cal-default-reminder-units", + g_settings_bind_with_mapping ( + settings, "default-reminder-units", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-use-default-reminder", + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_string_to_integer, + calendar_preferences_map_integer_to_string, + g_type_class_ref (E_TYPE_DURATION_TYPE), + (GDestroyNotify) g_type_class_unref); + g_settings_bind ( + settings, "use-default-reminder", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); + + /* These settings control the "Birthdays & Anniversaries" backend. */ + + eds_settings = + g_settings_new ("org.gnome.evolution-data-server.calendar"); widget = e_builder_get_widget (prefs->builder, "ba_reminder"); - g_object_bind_property ( - shell_settings, "cal-use-ba-reminder", + g_settings_bind ( + eds_settings, "contacts-reminder-enabled", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "ba_reminder_interval"); - g_object_bind_property ( - shell_settings, "cal-ba-reminder-interval", + g_settings_bind ( + eds_settings, "contacts-reminder-interval", widget, "value", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-use-ba-reminder", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + eds_settings, "contacts-reminder-enabled", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "ba_reminder_units"); - g_object_bind_property ( - shell_settings, "cal-ba-reminder-units", + g_settings_bind_with_mapping ( + eds_settings, "contacts-reminder-units", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-use-ba-reminder", + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_string_to_integer, + calendar_preferences_map_integer_to_string, + g_type_class_ref (E_TYPE_DURATION_TYPE), + (GDestroyNotify) g_type_class_unref); + g_settings_bind ( + eds_settings, "contacts-reminder-enabled", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); + + g_object_unref (eds_settings); /* Display tab */ widget = e_builder_get_widget (prefs->builder, "time_divisions"); - g_object_bind_property_full ( - shell_settings, "cal-time-divisions", + g_settings_bind_with_mapping ( + settings, "time-divisions", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_time_divisions_to_index, - transform_index_to_time_divisions, + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_time_divisions_to_index, + calendar_preferences_map_index_to_time_divisions, NULL, (GDestroyNotify) NULL); widget = e_builder_get_widget (prefs->builder, "show_end_times"); - g_object_bind_property ( - shell_settings, "cal-show-event-end-times", + g_settings_bind ( + settings, "show-event-end", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "compress_weekend"); - g_object_bind_property ( - shell_settings, "cal-compress-weekend", + g_settings_bind ( + settings, "compress-weekend", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "show_week_numbers"); - g_object_bind_property ( - shell_settings, "cal-show-week-numbers", + g_settings_bind ( + settings, "show-week-numbers", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "recur_events_italic"); - g_object_bind_property ( - shell_settings, "cal-recur-events-italic", + g_settings_bind ( + settings, "recur-events-italic", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "month_scroll_by_week"); - g_object_bind_property ( - shell_settings, "cal-month-scroll-by-week", + g_settings_bind ( + settings, "month-scroll-by-week", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "tasks_due_today_highlight"); - g_object_bind_property ( - shell_settings, "cal-tasks-highlight-due-today", + g_settings_bind ( + settings, "task-due-today-highlight", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "tasks_due_today_color"); - g_object_bind_property_full ( - shell_settings, "cal-tasks-color-due-today", + g_settings_bind_with_mapping ( + settings, "task-due-today-color", widget, "color", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - e_binding_transform_color_to_string, + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_string_to_gdk_color, + calendar_preferences_map_gdk_color_to_string, NULL, (GDestroyNotify) NULL); - g_object_bind_property ( - shell_settings, "cal-tasks-highlight-due-today", + g_settings_bind ( + settings, "task-due-today-highlight", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "tasks_overdue_highlight"); - g_object_bind_property ( - shell_settings, "cal-tasks-highlight-overdue", + g_settings_bind ( + settings, "task-overdue-highlight", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "tasks_overdue_color"); - g_object_bind_property_full ( - shell_settings, "cal-tasks-color-overdue", + g_settings_bind_with_mapping ( + settings, "task-overdue-color", widget, "color", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - e_binding_transform_color_to_string, - (GDestroyNotify) NULL, NULL); - g_object_bind_property ( - shell_settings, "cal-tasks-highlight-overdue", + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_string_to_gdk_color, + calendar_preferences_map_gdk_color_to_string, + NULL, (GDestroyNotify) NULL); + g_settings_bind ( + settings, "task-overdue-highlight", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "tasks_hide_completed"); - g_object_bind_property ( - shell_settings, "cal-hide-completed-tasks", + g_settings_bind ( + settings, "hide-completed-tasks", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "tasks_hide_completed_interval"); - g_object_bind_property ( - shell_settings, "cal-hide-completed-tasks-value", + g_settings_bind ( + settings, "hide-completed-tasks-value", widget, "value", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-hide-completed-tasks", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "hide-completed-tasks", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "tasks_hide_completed_units"); - g_object_bind_property ( - shell_settings, "cal-hide-completed-tasks-units", + g_settings_bind_with_mapping ( + settings, "hide-completed-tasks-units", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-hide-completed-tasks", + G_SETTINGS_BIND_DEFAULT, + calendar_preferences_map_string_to_integer, + calendar_preferences_map_integer_to_string, + g_type_class_ref (E_TYPE_DURATION_TYPE), + (GDestroyNotify) g_type_class_unref); + g_settings_bind ( + settings, "hide-completed-tasks", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); /* Alarms tab */ - prefs->notify_with_tray = e_builder_get_widget (prefs->builder, "notify_with_tray"); + widget = e_builder_get_widget (prefs->builder, "notify_with_tray"); + g_settings_bind ( + settings, "notify-with-tray", + widget, "active", + G_SETTINGS_BIND_DEFAULT); + prefs->scrolled_window = e_builder_get_widget (prefs->builder, "calendar-source-scrolled-window"); /* Free/Busy tab */ widget = e_builder_get_widget (prefs->builder, "template_url"); - g_object_bind_property ( - shell_settings, "cal-free-busy-template", + g_settings_bind ( + settings, "publish-template", widget, "text", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); /* date/time format */ table = e_builder_get_widget (prefs->builder, "datetime_format_table"); @@ -860,6 +960,8 @@ calendar_preferences_construct (ECalendarPreferences *prefs, show_config (prefs); /* FIXME: weakref? */ setup_changes (prefs); + + g_object_unref (settings); } void @@ -876,20 +978,17 @@ e_calendar_preferences_new (EPreferencesWindow *window) { EShell *shell; ESourceRegistry *registry; - EShellSettings *shell_settings; ECalendarPreferences *preferences; shell = e_preferences_window_get_shell (window); registry = e_shell_get_registry (shell); - shell_settings = e_shell_get_shell_settings (shell); g_return_val_if_fail (E_IS_SHELL (shell), NULL); preferences = g_object_new (E_TYPE_CALENDAR_PREFERENCES, NULL); preferences->registry = g_object_ref (registry); - preferences->shell_settings = g_object_ref (shell_settings); /* FIXME Kill this function. */ calendar_preferences_construct (preferences, shell); diff --git a/modules/calendar/e-calendar-preferences.h b/modules/calendar/e-calendar-preferences.h index d1e8ede3b7..3920cd1916 100644 --- a/modules/calendar/e-calendar-preferences.h +++ b/modules/calendar/e-calendar-preferences.h @@ -56,7 +56,6 @@ struct _ECalendarPreferences { GtkBuilder *builder; ESourceRegistry *registry; - EShellSettings *shell_settings; /* General tab */ GtkWidget *day_second_zone; @@ -67,7 +66,6 @@ struct _ECalendarPreferences { GtkWidget *ba_reminder_units; /* Alarms tab */ - GtkWidget *notify_with_tray; GtkWidget *scrolled_window; }; diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index 2998c94c32..597838cbee 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -118,6 +118,43 @@ connect_closure_free (ConnectClosure *closure) g_slice_free (ConnectClosure, closure); } +static gboolean +memo_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 * +memo_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 memo_shell_sidebar_emit_client_added (EMemoShellSidebar *memo_shell_sidebar, EClient *client) @@ -356,26 +393,17 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window, EShellSidebar *shell_sidebar) { EMemoShellSidebarPrivate *priv; - EShell *shell; - EShellBackend *shell_backend; - EShellSettings *shell_settings; ESourceRegistry *registry; ESourceSelector *selector; + GSettings *settings; GtkTreeModel *model; priv = E_MEMO_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_MEMO_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 (memo_shell_sidebar_row_changed_cb), @@ -386,15 +414,20 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window, G_CALLBACK (memo_shell_sidebar_primary_selection_changed_cb), shell_sidebar); - g_object_bind_property_full ( - shell_settings, "cal-primary-memo-list", + /* Bind GObject properties to settings keys. */ + + settings = g_settings_new ("org.gnome.evolution.calendar"); + + g_settings_bind_with_mapping ( + settings, "primary-memos", 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, + memo_shell_sidebar_map_uid_to_source, + memo_shell_sidebar_map_source_to_uid, g_object_ref (registry), (GDestroyNotify) g_object_unref); + + g_object_unref (settings); } static void 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 diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c index 87a843d622..b204711977 100644 --- a/modules/calendar/e-task-shell-view-private.c +++ b/modules/calendar/e-task-shell-view-private.c @@ -45,11 +45,14 @@ task_shell_view_model_row_appended_cb (ETaskShellView *task_shell_view, } static gboolean -task_shell_view_process_completed_tasks (ETaskShellView *task_shell_view) +task_shell_view_process_completed_tasks_cb (gpointer user_data) { ETaskShellContent *task_shell_content; + ETaskShellView *task_shell_view; ETaskTable *task_table; + task_shell_view = E_TASK_SHELL_VIEW (user_data); + task_shell_view->priv->update_completed_timeout = 0; task_shell_content = task_shell_view->priv->task_shell_content; @@ -65,7 +68,7 @@ task_shell_view_process_completed_tasks (ETaskShellView *task_shell_view) } static void -task_shell_view_schedule_process_completed_tasks (ETaskShellView *task_shell_view) +task_shell_view_process_completed_tasks (ETaskShellView *task_shell_view) { guint source_id; @@ -75,13 +78,21 @@ task_shell_view_schedule_process_completed_tasks (ETaskShellView *task_shell_vie g_source_remove (source_id); source_id = g_timeout_add_seconds ( - 1, (GSourceFunc) task_shell_view_process_completed_tasks, + 1, task_shell_view_process_completed_tasks_cb, task_shell_view); task_shell_view->priv->update_completed_timeout = source_id; } static void +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); +} + +static void task_shell_view_table_popup_event_cb (EShellView *shell_view, GdkEvent *button_event) { @@ -244,7 +255,6 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) ETaskShellViewPrivate *priv = task_shell_view->priv; ETaskShellContent *task_shell_content; ETaskShellSidebar *task_shell_sidebar; - EShellSettings *shell_settings; EShellBackend *shell_backend; EShellContent *shell_content; EShellSidebar *shell_sidebar; @@ -261,9 +271,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) shell_content = e_shell_view_get_shell_content (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); 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_window_add_action_group (shell_window, "tasks"); e_shell_window_add_action_group (shell_window, "tasks-filter"); @@ -273,6 +281,8 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) priv->task_shell_content = g_object_ref (shell_content); priv->task_shell_sidebar = g_object_ref (shell_sidebar); + priv->settings = g_settings_new ("org.gnome.evolution.calendar"); + task_shell_content = E_TASK_SHELL_CONTENT (shell_content); task_table = e_task_shell_content_get_task_table (task_shell_content); model = e_task_table_get_model (task_table); @@ -365,11 +375,10 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) task_shell_view); /* Listen for configuration changes. */ - g_object_bind_property ( - shell_settings, "cal-confirm-purge", + g_settings_bind ( + priv->settings, "confirm-purge", task_shell_view, "confirm-purge", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); /* Keep the ECalModel in sync with the sidebar. */ g_object_bind_property ( @@ -378,18 +387,21 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) G_BINDING_SYNC_CREATE); /* Hide Completed Tasks (enable/units/value) */ - g_signal_connect_object ( - shell_settings, "notify::cal-hide-completed-tasks", - G_CALLBACK (task_shell_view_schedule_process_completed_tasks), - task_shell_view, G_CONNECT_SWAPPED); - g_signal_connect_object ( - shell_settings, "notify::cal-hide-completed-tasks-units", - G_CALLBACK (task_shell_view_schedule_process_completed_tasks), - task_shell_view, G_CONNECT_SWAPPED); - g_signal_connect_object ( - shell_settings, "notify::cal-hide-completed-tasks-value", - G_CALLBACK (task_shell_view_schedule_process_completed_tasks), - task_shell_view, G_CONNECT_SWAPPED); + handler_id = g_signal_connect ( + priv->settings, "changed::hide-completed-tasks", + G_CALLBACK (task_shell_view_hide_completed_tasks_changed_cb), + task_shell_view); + priv->settings_hide_completed_tasks_handler_id = handler_id; + handler_id = g_signal_connect ( + priv->settings, "changed::hide-completed-tasks-units", + G_CALLBACK (task_shell_view_hide_completed_tasks_changed_cb), + task_shell_view); + priv->settings_hide_completed_tasks_units_handler_id = handler_id; + handler_id = g_signal_connect ( + priv->settings, "changed::hide-completed-tasks-value", + G_CALLBACK (task_shell_view_hide_completed_tasks_changed_cb), + task_shell_view); + priv->settings_hide_completed_tasks_value_handler_id = handler_id; e_task_shell_view_actions_init (task_shell_view); e_task_shell_view_update_sidebar (task_shell_view); @@ -416,11 +428,33 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view) priv->backend_error_handler_id = 0; } + if (priv->settings_hide_completed_tasks_handler_id > 0) { + g_signal_handler_disconnect ( + priv->settings, + priv->settings_hide_completed_tasks_handler_id); + priv->settings_hide_completed_tasks_handler_id = 0; + } + + if (priv->settings_hide_completed_tasks_units_handler_id > 0) { + g_signal_handler_disconnect ( + priv->settings, + priv->settings_hide_completed_tasks_units_handler_id); + priv->settings_hide_completed_tasks_units_handler_id = 0; + } + + if (priv->settings_hide_completed_tasks_value_handler_id > 0) { + g_signal_handler_disconnect ( + priv->settings, + priv->settings_hide_completed_tasks_value_handler_id); + priv->settings_hide_completed_tasks_units_handler_id = 0; + } + g_clear_object (&priv->task_shell_backend); g_clear_object (&priv->task_shell_content); g_clear_object (&priv->task_shell_sidebar); g_clear_object (&priv->client_cache); + g_clear_object (&priv->settings); if (task_shell_view->priv->activity != NULL) { /* XXX Activity is not cancellable. */ diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h index 8906215221..3360928864 100644 --- a/modules/calendar/e-task-shell-view-private.h +++ b/modules/calendar/e-task-shell-view-private.h @@ -89,6 +89,12 @@ struct _ETaskShellViewPrivate { EClientCache *client_cache; gulong backend_error_handler_id; + /* org.gnome.evolution.calendar */ + GSettings *settings; + gulong settings_hide_completed_tasks_handler_id; + gulong settings_hide_completed_tasks_units_handler_id; + gulong settings_hide_completed_tasks_value_handler_id; + EActivity *activity; guint update_timeout; guint update_completed_timeout; |