From b7fc5caefe4aded8d0ffd7088ecbbf1f370b995e Mon Sep 17 00:00:00 2001 From: Sankarasivasubramanian Pasupathilingam Date: Fri, 12 Sep 2008 16:19:36 +0000 Subject: License Changes from GPL to LGPL svn path=/trunk/; revision=36313 --- calendar/gui/calendar-config.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 2b704db903..60c128b0cd 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -1,24 +1,24 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Authors : - * Damon Chaplin - * Rodrigo Moya - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * 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 General Public License for more details. + * 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 + * + * + * Authors: + * Damon Chaplin + * Rodrigo Moya + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA */ /* -- cgit v1.2.3 From 97e48e352419d360934a46a05c944d604fd968e9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 10 Jan 2009 23:41:27 +0000 Subject: ** Fixes bug #567276 2009-01-10 Matthew Barnes ** Fixes bug #567276 * addressbook/gui/widgets/e-addressbook-view.c: * addressbook/printing/test-print.c: * calendar/gui/calendar-commands.c: * calendar/gui/control-factory.c: * calendar/gui/e-itip-control.c: * calendar/gui/gnome-cal.c: * calendar/gui/goto.c: * calendar/gui/memos-control.c: * calendar/gui/print.c: * calendar/gui/tasks-control.c: * calendar/gui/alarm-notify/alarm-queue.c: * calendar/gui/dialogs/schedule-page.c: * widgets/menus/gal-view-menus.c: Remove unneeded #include . * calendar/gui/calendar-config.c: * calendar/gui/calendar-config.h: Removed unused function calendar_config_check_timezone_set(). * widgets/misc/test-color.c: We don't ship this. Remove it. svn path=/trunk/; revision=37030 --- calendar/gui/calendar-config.c | 61 ------------------------------------------ 1 file changed, 61 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 60c128b0cd..484695fee8 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -47,13 +46,6 @@ static GConfClient *config = NULL; /* Store the zones here, this is not destroyed as the ical timezones */ static GHashTable *custom_zones = NULL; -static void on_timezone_set (GnomeDialog *dialog, - int button, - ETimezoneDialog *etd); -static gboolean on_timezone_dialog_delete_event (GnomeDialog *dialog, - GdkEvent *event, - ETimezoneDialog *etd); - static void do_cleanup (void) { @@ -1240,59 +1232,6 @@ calendar_config_set_confirm_purge (gboolean confirm) gconf_client_set_bool (config, CALENDAR_CONFIG_PROMPT_PURGE, confirm, NULL); } -void -calendar_config_check_timezone_set (void) -{ - ETimezoneDialog *timezone_dialog; - GtkWidget *dialog; - GList *elem; - char *zone; - - zone = calendar_config_get_timezone (); - if (zone && zone[0]) - return; - - /* Show timezone dialog. */ - timezone_dialog = e_timezone_dialog_new (); - dialog = e_timezone_dialog_get_toplevel (timezone_dialog); - - /* Hide the cancel button, which is the 2nd button. */ - elem = g_list_nth (GNOME_DIALOG (dialog)->buttons, 1); - gtk_widget_hide (elem->data); - - g_signal_connect (dialog, "clicked", - G_CALLBACK (on_timezone_set), timezone_dialog); - g_signal_connect (dialog, "delete-event", - G_CALLBACK (on_timezone_dialog_delete_event), timezone_dialog); - - gtk_widget_show (dialog); -} - - -static void -on_timezone_set (GnomeDialog *dialog, - int button, - ETimezoneDialog *etd) -{ - icaltimezone *zone; - - zone = e_timezone_dialog_get_timezone (etd); - if (zone) - calendar_config_set_timezone (icaltimezone_get_location (zone)); - - g_object_unref (etd); -} - - -static gboolean -on_timezone_dialog_delete_event (GnomeDialog *dialog, - GdkEvent *event, - ETimezoneDialog *etd) -{ - g_object_unref (etd); - return TRUE; -} - /** * calendar_config_get_tasks_due_today_color: -- cgit v1.2.3 From 1df00c7d517794881faefd45b3ae230a6b0d8204 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 12 Jan 2009 14:49:16 +0000 Subject: ** Fix for bug #563364 2009-01-12 Milan Crha ** Fix for bug #563364 * gui/e-day-view-time-item.h: (EDayViewTimeItem): * gui/e-day-view-time-item.c: (e_day_view_time_item_class_init), (e_day_view_time_item_init), (e_day_view_time_item_finalize), (e_day_view_time_item_get_column_width), (edvti_draw_zone), (e_day_view_time_item_draw), (edvti_second_zone_changed_cb), (edvti_on_select_zone), (edvti_on_set_zone), (e_day_view_time_item_show_popup_menu): Show two timezones in the day view's time column. * gui/apps_evolution_calendar.schemas.in: * gui/calendar-config-keys.h: * gui/calendar-config.h: * gui/calendar-config.c: (calendar_config_get_day_second_zones), (calendar_config_free_day_second_zones), (calendar_config_set_day_second_zone), (calendar_config_get_day_second_zone), (calendar_config_select_day_second_zone), (calendar_config_add_notification_day_second_zone): Access configuration for the second day time zone. * gui/dialogs/cal-prefs-dialog.glade: * gui/dialogs/cal-prefs-dialog.h: (struct _CalendarPrefsDialog): * gui/dialogs/cal-prefs-dialog.c: (update_day_second_zone_caption), (on_set_day_second_zone), (on_select_day_second_zone), (day_second_zone_clicked), (setup_changes), (show_config), (calendar_prefs_dialog_construct): Manage the second day zone in a Preferences dialog. svn path=/trunk/; revision=37060 --- calendar/gui/calendar-config.c | 129 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 484695fee8..f4efd7e95e 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -1567,3 +1567,132 @@ calendar_config_get_dir_path (void) return path; } + +/* contains list of strings, locations, recently used as the second timezone in a day view. + Free with calendar_config_free_day_second_zones. */ +GSList * +calendar_config_get_day_second_zones (void) +{ + GSList *res; + + calendar_config_init (); + + res = gconf_client_get_list (config, CALENDAR_CONFIG_DAY_SECOND_ZONES_LIST, GCONF_VALUE_STRING, NULL); + + return res; +} + +/* frees list from calendar_config_get_day_second_zones */ +void +calendar_config_free_day_second_zones (GSList *zones) +{ + if (zones) { + g_slist_foreach (zones, (GFunc)g_free, NULL); + g_slist_free (zones); + } +} + +/* keeps max 'day_second_zones_max' zones, if 'location' is already in a list, then it'll became first there */ +void +calendar_config_set_day_second_zone (const char *location) +{ + calendar_config_init (); + + if (location && *location) { + GSList *lst, *l; + GError *error = NULL; + int max_zones; + + /* configurable max number of timezones to remember */ + max_zones = gconf_client_get_int (config, CALENDAR_CONFIG_DAY_SECOND_ZONES_MAX, &error); + + if (error) { + g_error_free (error); + max_zones = -1; + } + + if (max_zones <= 0) + max_zones = 5; + + lst = calendar_config_get_day_second_zones (); + for (l = lst; l; l = l->next) { + if (l->data && g_str_equal (l->data, location)) { + if (l != lst) { + /* isn't first in the list */ + char *val = l->data; + + lst = g_slist_remove (lst, val); + lst = g_slist_prepend (lst, val); + } + break; + } + } + + if (!l) { + /* not in the list yet */ + lst = g_slist_prepend (lst, g_strdup (location)); + } + + while (g_slist_length (lst) > max_zones) { + l = g_slist_last (lst); + g_free (l->data); + lst = g_slist_delete_link (lst, l); + } + + gconf_client_set_list (config, CALENDAR_CONFIG_DAY_SECOND_ZONES_LIST, GCONF_VALUE_STRING, lst, NULL); + + calendar_config_free_day_second_zones (lst); + } + + gconf_client_set_string (config, CALENDAR_CONFIG_DAY_SECOND_ZONE, location ? location : "", NULL); +} + +/* location of the second time zone user has selected. Free with g_free. */ +char * +calendar_config_get_day_second_zone (void) +{ + calendar_config_init (); + + return gconf_client_get_string (config, CALENDAR_CONFIG_DAY_SECOND_ZONE, NULL); +} + +void +calendar_config_select_day_second_zone (void) +{ + icaltimezone *zone = NULL; + ETimezoneDialog *tzdlg; + GtkWidget *dialog; + char *second_location; + + second_location = calendar_config_get_day_second_zone (); + if (second_location && *second_location) + zone = icaltimezone_get_builtin_timezone (second_location); + g_free (second_location); + + if (!zone) + zone = calendar_config_get_icaltimezone (); + + tzdlg = e_timezone_dialog_new (); + e_timezone_dialog_set_timezone (tzdlg, zone); + + dialog = e_timezone_dialog_get_toplevel (tzdlg); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + zone = e_timezone_dialog_get_timezone (tzdlg); + calendar_config_set_day_second_zone (zone ? icaltimezone_get_location (zone) : NULL); + } + + g_object_unref (tzdlg); +} + +guint +calendar_config_add_notification_day_second_zone (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + calendar_config_init (); + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_SECOND_ZONE, func, data, NULL, NULL); + + return id; +} -- cgit v1.2.3 From ae26a9a5fb34beb48e4161c8f145b0fb2d3cb3a9 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 19 Jan 2009 13:10:36 +0000 Subject: ** Fix for bug #200254 2009-01-19 Milan Crha ** Fix for bug #200254 * gui/apps_evolution_calendar.schemas.in: * gui/dialogs/cal-prefs-dialog.glade: * gui/dialogs/cal-prefs-dialog.h: (struct _CalendarPrefsDialog): * gui/dialogs/cal-prefs-dialog.c: (dview_show_week_no_toggled), (setup_changes), (show_config), (calendar_prefs_dialog_construct): * gui/calendar-config-keys.h: * gui/calendar-config.h: * gui/calendar-config.c: (calendar_config_get_dview_show_week_no), (calendar_config_set_dview_show_week_no), (calendar_config_add_notification_dview_show_week_no): New option whether to show week number in Day and Work Week view. * gui/e-day-view.h: (struct _EDayView), (e_day_view_get_show_week_number), (e_day_view_set_show_week_number): * gui/e-day-view.c: (dview_show_week_no_changed_cb), (e_day_view_init), (e_day_view_destroy), (e_day_view_recalc_day_starts), (e_day_view_get_show_week_number), (e_day_view_set_show_week_number): New widget showing week number of the first day in a view. svn path=/trunk/; revision=37096 --- calendar/gui/calendar-config.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index f4efd7e95e..4e6f853db0 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -678,6 +678,36 @@ calendar_config_add_notification_marcus_bains (GConfClientNotifyFunc func, gpoin *not_tcolor = gconf_client_notify_add (config, CALENDAR_CONFIG_MARCUS_BAINS_COLOR_TIMEBAR, func, data, NULL, NULL); } +/* Whether we show week number in the Day View. */ +gboolean +calendar_config_get_dview_show_week_no (void) +{ + calendar_config_init (); + + return gconf_client_get_bool (config, CALENDAR_CONFIG_DV_WEEK_NUMBER, NULL); +} + + +void +calendar_config_set_dview_show_week_no (gboolean show_week_no) +{ + calendar_config_init (); + + gconf_client_set_bool (config, CALENDAR_CONFIG_DV_WEEK_NUMBER, show_week_no, NULL); +} + +guint +calendar_config_add_notification_dview_show_week_no (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + calendar_config_init (); + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_DV_WEEK_NUMBER, func, data, NULL, NULL); + + return id; +} + /* Whether we show week numbers in the Date Navigator. */ gboolean calendar_config_get_dnav_show_week_no (void) -- cgit v1.2.3 From d63754acb1a37037ce09251c00fefa5e689f780b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 19 Jan 2009 14:14:56 +0000 Subject: ** Part of fix for bug #260853 2009-01-19 Milan Crha ** Part of fix for bug #260853 * gui/calendar-config-keys.h: * gui/calendar-config.h: (calendar_config_get_ba_reminder), (calendar_config_set_ba_reminder): * gui/calendar-config.c: (calendar_config_get_ba_reminder), (calendar_config_set_ba_reminder), (string_to_units), (calendar_config_get_default_reminder_units): * gui/dialogs/cal-prefs-dialog.glade: * gui/dialogs/cal-prefs-dialog.h: (struct _CalendarPrefsDialog): * gui/dialogs/cal-prefs-dialog.c: (ba_reminder_toggled), (ba_reminder_interval_changed), (ba_reminder_units_changed), (setup_changes), (show_config), (calendar_prefs_dialog_construct): User interface and related function to allow use change setup of the alarm for Birthdays and Anniversaries calendar. svn path=/trunk/; revision=37098 --- calendar/gui/calendar-config.c | 77 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 7 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 4e6f853db0..d8579edd61 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -106,6 +106,22 @@ units_to_string (CalUnits units) } } +/* opposite function to 'units_to_string' */ +static CalUnits +string_to_units (const char *units) +{ + CalUnits res; + + if (units && !strcmp (units, "days")) + res = CAL_DAYS; + else if (units && !strcmp (units, "hours")) + res = CAL_HOURS; + else + res = CAL_MINUTES; + + return res; +} + /* * Calendar Settings. */ @@ -1454,13 +1470,7 @@ calendar_config_get_default_reminder_units (void) calendar_config_init (); units = gconf_client_get_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL); - - if (units && !strcmp (units, "days")) - cu = CAL_DAYS; - else if (units && !strcmp (units, "hours")) - cu = CAL_HOURS; - else - cu = CAL_MINUTES; + cu = string_to_units (units); g_free (units); return cu; @@ -1480,6 +1490,59 @@ calendar_config_set_default_reminder_units (CalUnits units) gconf_client_set_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, units_to_string(units), NULL); } +/** + * calendar_config_get_ba_reminder: + * Retrieves setup of the Birthdays & Anniversaries reminder. + * + * @interval: Retrieves the interval setup for the reminder; can be NULL. + * @units: Retrieves units for the interval; can be NULL. + * + * Returns whether the reminder is on or off. The values for interval and/or units + * are retrieved even when returns FALSE. + **/ +gboolean +calendar_config_get_ba_reminder (int *interval, CalUnits *units) +{ + calendar_config_init (); + + if (interval) { + *interval = gconf_client_get_int (config, CALENDAR_CONFIG_BA_REMINDER_INTERVAL, NULL); + } + + if (units) { + char *str; + + str = gconf_client_get_string (config, CALENDAR_CONFIG_BA_REMINDER_UNITS, NULL); + *units = string_to_units (str); + g_free (str); + } + + return gconf_client_get_bool (config, CALENDAR_CONFIG_BA_REMINDER, NULL); +} + +/** + * calendar_config_set_ba_reminder: + * Stores new values for Birthdays & Anniversaries reminder to GConf. Only those, which are not NULL. + * + * @enabled: The enabled state; can be NULL. + * @interval: The reminder interval; can be NULL. + * @units: The units of the reminder; can be NULL. + **/ +void +calendar_config_set_ba_reminder (gboolean *enabled, int *interval, CalUnits *units) +{ + calendar_config_init (); + + if (enabled) + gconf_client_set_bool (config, CALENDAR_CONFIG_BA_REMINDER, *enabled, NULL); + + if (interval) + gconf_client_set_int (config, CALENDAR_CONFIG_BA_REMINDER_INTERVAL, *interval, NULL); + + if (units) + gconf_client_set_string (config, CALENDAR_CONFIG_BA_REMINDER_UNITS, units_to_string (*units), NULL); +} + /** * calendar_config_get_hide_completed_tasks_sexp: * -- cgit v1.2.3 From 38c8ce1aac739a3e74448ff5ed7fa2e003a9cc28 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 2 Feb 2009 03:39:24 +0000 Subject: Fix compiler warnings. svn path=/trunk/; revision=37206 --- calendar/gui/calendar-config.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index d8579edd61..1f18b94458 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -244,7 +244,8 @@ calendar_config_get_icaltimezone (void) icalproperty *tz_prop, *offset_to; icaltimezone *st_zone = NULL; int offset; - char *n_tzid, *tzid; + const char *tzid; + char *n_tzid; tzid = icaltimezone_get_tzid (zone); n_tzid = g_strconcat (tzid, "-(Standard)", NULL); @@ -296,7 +297,7 @@ calendar_config_get_icaltimezone (void) /* Sets the timezone. If set to NULL it defaults to UTC. FIXME: Should check it is being set to a valid timezone. */ void -calendar_config_set_timezone (gchar *timezone) +calendar_config_set_timezone (const gchar *timezone) { calendar_config_init (); -- cgit v1.2.3 From bd8d2c529fe15e979dd2d33be2fa36c2358f0a96 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 4 Mar 2009 15:41:36 +0000 Subject: ** Fix for bug #573122 2009-03-04 Milan Crha ** Fix for bug #573122 * gui/dialogs/cal-prefs-dialog.c: (timezone_changed), (show_config): * gui/calendar-config.c: (calendar_config_get_icaltimezone): * gui/e-cal-model.c: (ecm_value_at): Do not pass NULL to icalcomponent_get_first_component. svn path=/trunk/; revision=37366 --- calendar/gui/calendar-config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 1f18b94458..6a7cf94ee7 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -233,8 +233,7 @@ calendar_config_get_icaltimezone (void) zone = icaltimezone_get_builtin_timezone (location); icalcomp = icaltimezone_get_component (zone); - - if (!(dl_comp = icalcomponent_get_first_component (icalcomp, ICAL_XDAYLIGHT_COMPONENT))) { + if (!icalcomp || !(dl_comp = icalcomponent_get_first_component (icalcomp, ICAL_XDAYLIGHT_COMPONENT))) { g_free (location); return zone; } -- cgit v1.2.3 From 501da8aa29d496ef765a3afb5ac1b3fc1361c7e2 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 24 Apr 2009 16:58:15 +0200 Subject: Get rid of "Adjust for daylight saving time" option ** Fix for bug #577615 * gui/dialogs/cal-prefs-dialog.h: (struct _CalendarPrefsDialog): * gui/dialogs/cal-prefs-dialog.c: (timezone_changed), (daylight_saving_changed), (setup_changes), (show_config), (calendar_prefs_dialog_construct): * gui/dialogs/cal-prefs-dialog.glade: * gui/apps_evolution_calendar.schemas.in: * gui/calendar-config-keys.h: * gui/calendar-config.h: * gui/calendar-config.c: (set_standard_offsets), (calendar_config_get_icaltimezone), (calendar_config_get_daylight_saving), (calendar_config_set_daylight_saving), (calendar_config_add_notification_daylight_saving): Get rid of "Adjust for daylight saving time" option. --- calendar/gui/calendar-config.c | 111 ----------------------------------------- 1 file changed, 111 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 6a7cf94ee7..103d92f640 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -43,9 +43,6 @@ static GConfClient *config = NULL; -/* Store the zones here, this is not destroyed as the ical timezones */ -static GHashTable *custom_zones = NULL; - static void do_cleanup (void) { @@ -197,27 +194,6 @@ calendar_config_get_timezone (void) return gconf_client_get_string (config, CALENDAR_CONFIG_TIMEZONE, NULL); } -static void -set_standard_offsets (icalcomponent *zone_comp, int offset) -{ - icalcomponent *dl_comp, *s_comp; - icalproperty *offset_from, *offset_to; - - /* Set the offset of the standard component to all the daylight components also */ - for (dl_comp = icalcomponent_get_first_component (zone_comp, ICAL_XDAYLIGHT_COMPONENT); dl_comp != NULL; - dl_comp = icalcomponent_get_next_component (zone_comp, ICAL_XDAYLIGHT_COMPONENT)) { - offset_to = icalcomponent_get_first_property (dl_comp, ICAL_TZOFFSETTO_PROPERTY); - icalproperty_set_tzoffsetto (offset_to, offset); - } - - /* Set the tzto offset of the standard component to tzfrom */ - for (s_comp = icalcomponent_get_first_component (zone_comp, ICAL_XSTANDARD_COMPONENT); s_comp != NULL; - s_comp = icalcomponent_get_next_component (zone_comp, ICAL_XSTANDARD_COMPONENT)) { - offset_from = icalcomponent_get_first_property (s_comp, ICAL_TZOFFSETFROM_PROPERTY); - icalproperty_set_tzoffsetfrom (offset_from, offset); - } -} - icaltimezone * calendar_config_get_icaltimezone (void) { @@ -228,71 +204,13 @@ calendar_config_get_icaltimezone (void) location = calendar_config_get_timezone (); if (location) { - icalcomponent *icalcomp, *dl_comp; - zone = icaltimezone_get_builtin_timezone (location); - icalcomp = icaltimezone_get_component (zone); - - if (!icalcomp || !(dl_comp = icalcomponent_get_first_component (icalcomp, ICAL_XDAYLIGHT_COMPONENT))) { - g_free (location); - return zone; - } - - if (!calendar_config_get_daylight_saving () && zone) { - icalcomponent *zone_comp, *s_comp; - icalproperty *tz_prop, *offset_to; - icaltimezone *st_zone = NULL; - int offset; - const char *tzid; - char *n_tzid; - - tzid = icaltimezone_get_tzid (zone); - n_tzid = g_strconcat (tzid, "-(Standard)", NULL); - - if (!custom_zones) { - custom_zones = g_hash_table_new (g_str_hash, g_str_equal); - } else if ((st_zone = g_hash_table_lookup (custom_zones, n_tzid))) { - g_free (n_tzid); - g_free (location); - return st_zone; - } - - zone_comp = icalcomponent_new_clone (icalcomp); - s_comp = icalcomponent_get_first_component (zone_comp, ICAL_XSTANDARD_COMPONENT); - - if (!s_comp) { - g_free (n_tzid); - icalcomponent_free (zone_comp); - g_free (location); - return zone; - } - - offset_to = icalcomponent_get_first_property (s_comp, ICAL_TZOFFSETTO_PROPERTY); - offset = icalproperty_get_tzoffsetto (offset_to); - - set_standard_offsets (zone_comp, offset); - - tz_prop = icalcomponent_get_first_property (zone_comp, ICAL_TZID_PROPERTY); - if (tz_prop) { - icalcomponent_remove_property (zone_comp, tz_prop); - } - - tz_prop = icalproperty_new_tzid (n_tzid); - icalcomponent_add_property (zone_comp, tz_prop); - - st_zone = icaltimezone_new (); - icaltimezone_set_component (st_zone, zone_comp); - - zone = st_zone; - g_hash_table_insert (custom_zones, n_tzid, zone); - } g_free (location); } return zone; } - /* Sets the timezone. If set to NULL it defaults to UTC. FIXME: Should check it is being set to a valid timezone. */ void @@ -318,35 +236,6 @@ calendar_config_add_notification_timezone (GConfClientNotifyFunc func, gpointer return id; } -gboolean -calendar_config_get_daylight_saving (void) -{ - calendar_config_init (); - - return gconf_client_get_bool (config, CALENDAR_CONFIG_DAYLIGHT_SAVING, NULL); - -} - -void -calendar_config_set_daylight_saving (gboolean daylight_saving) -{ - calendar_config_init (); - - gconf_client_set_bool (config, CALENDAR_CONFIG_DAYLIGHT_SAVING, daylight_saving, NULL); -} - -guint -calendar_config_add_notification_daylight_saving (GConfClientNotifyFunc func, gpointer data) -{ - guint id; - - calendar_config_init (); - - id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAYLIGHT_SAVING, func, data, NULL, NULL); - - return id; -} - /* Whether we use 24-hour format or 12-hour format (AM/PM). */ gboolean calendar_config_get_24_hour_format (void) -- cgit v1.2.3 From c33335bc72d9db97248ea5c5dc6da9cbfdb16e2c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 24 Apr 2009 19:11:03 +0200 Subject: Use system timezone in Evolution ** Fix for bug #381132 --- calendar/gui/calendar-config.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'calendar/gui/calendar-config.c') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 103d92f640..65864ea272 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -39,8 +39,6 @@ #include "calendar-config-keys.h" #include "calendar-config.h" - - static GConfClient *config = NULL; static void @@ -182,12 +180,50 @@ calendar_config_add_notification_primary_calendar (GConfClientNotifyFunc func, g return id; } +gboolean +calendar_config_get_use_system_timezone (void) +{ + calendar_config_init (); + + return gconf_client_get_bool (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, NULL); +} + +void +calendar_config_set_use_system_timezone (gboolean use) +{ + calendar_config_init (); + + if (calendar_config_get_use_system_timezone () != use) { + gconf_client_set_bool (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, use, NULL); + gconf_client_notify (config, CALENDAR_CONFIG_TIMEZONE); + + /* FIXME: notify CALENDAR_CONFIG_TIMEZONE change on system timezone change + itself too, when using system timezone. How to receive such change? */ + } +} + +guint +calendar_config_add_notification_use_system_timezone (GConfClientNotifyFunc func, gpointer data) +{ + calendar_config_init (); + + return gconf_client_notify_add (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, func, data, NULL, NULL); +} /* The current timezone, e.g. "Europe/London". It may be NULL, in which case you should assume UTC (though Evolution will show the timezone-setting dialog the next time a calendar or task folder is selected). */ gchar * calendar_config_get_timezone (void) +{ + if (calendar_config_get_use_system_timezone ()) + return e_cal_util_get_system_timezone_location (); + + return calendar_config_get_timezone_stored (); +} + +gchar * +calendar_config_get_timezone_stored (void) { calendar_config_init (); -- cgit v1.2.3