From c33335bc72d9db97248ea5c5dc6da9cbfdb16e2c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 24 Apr 2009 19:11:03 +0200 Subject: [PATCH] Use system timezone in Evolution ** Fix for bug #381132 --- calendar/ChangeLog | 18 + .../gui/apps_evolution_calendar.schemas.in | 12 + calendar/gui/calendar-config-keys.h | 1 + calendar/gui/calendar-config.c | 40 +- calendar/gui/calendar-config.h | 6 + calendar/gui/dialogs/cal-prefs-dialog.c | 34 +- calendar/gui/dialogs/cal-prefs-dialog.glade | 374 +++++++++++------- calendar/gui/dialogs/cal-prefs-dialog.h | 2 + plugins/startup-wizard/ChangeLog | 9 + ...g-gnome-evolution-startup-wizard.eplug.xml | 1 - plugins/startup-wizard/startup-wizard.c | 58 +-- 11 files changed, 364 insertions(+), 191 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 39de5bdd1d..6d4023c97f 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,21 @@ +2009-04-24 Milan Crha + + ** Part of fix for bug #381132 + + * 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: (update_system_tz_widgets), + (use_system_tz_changed), (setup_changes), (show_config), + (calendar_prefs_dialog_construct): + * gui/calendar-config-keys.h: + * gui/calendar-config.h: + * gui/calendar-config.c: (calendar_config_get_use_system_timezone), + (calendar_config_set_use_system_timezone), + (calendar_config_add_notification_use_system_timezone), + (calendar_config_get_timezone), (calendar_config_get_timezone_stored): + Be able to set system timezone as calendar's time zone. + 2009-04-24 Milan Crha ** Fix for bug #205804 diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in index be21c2930c..acf9550874 100644 --- a/calendar/gui/apps_evolution_calendar.schemas.in +++ b/calendar/gui/apps_evolution_calendar.schemas.in @@ -15,6 +15,18 @@ + + /schemas/apps/evolution/calendar/display/use_system_timezone + /apps/evolution/calendar/display/use_system_timezone + evolution-calendar + bool + true + + Use system timezone + Check this to use system timezone in Evolution. + + + /schemas/apps/evolution/calendar/display/day_second_zone /apps/evolution/calendar/display/day_second_zone diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h index 9d744eeb8e..691b4f0281 100644 --- a/calendar/gui/calendar-config-keys.h +++ b/calendar/gui/calendar-config-keys.h @@ -28,6 +28,7 @@ G_BEGIN_DECLS #define CALENDAR_CONFIG_PREFIX "/apps/evolution/calendar" /* Display settings */ +#define CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/use_system_timezone" #define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone" #define CALENDAR_CONFIG_SELECTED_CALENDARS CALENDAR_CONFIG_PREFIX "/display/selected_calendars" #define CALENDAR_CONFIG_PRIMARY_CALENDAR CALENDAR_CONFIG_PREFIX "/display/primary_calendar" 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 (); diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index a7ee394f52..667962e1db 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -73,8 +73,14 @@ char *calendar_config_get_primary_calendar (void); void calendar_config_set_primary_calendar (const char *primary_uid); guint calendar_config_add_notification_primary_calendar (GConfClientNotifyFunc func, gpointer data); +/* Use system timezone; if TRUE, then influences also the current timezone functions. */ +gboolean calendar_config_get_use_system_timezone (void); +void calendar_config_set_use_system_timezone (gboolean use); +guint calendar_config_add_notification_use_system_timezone (GConfClientNotifyFunc func, gpointer data); + /* The current timezone, e.g. "Europe/London". */ gchar* calendar_config_get_timezone (void); +gchar* calendar_config_get_timezone_stored (void); icaltimezone *calendar_config_get_icaltimezone (void); void calendar_config_set_timezone (const gchar *timezone); guint calendar_config_add_notification_timezone (GConfClientNotifyFunc func, gpointer data); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index edb802fd10..60678d93e1 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -479,6 +479,30 @@ template_url_changed (GtkEntry *entry, CalendarPrefsDialog *prefs) calendar_config_set_free_busy_template (gtk_entry_get_text (entry)); } +static void +update_system_tz_widgets (CalendarPrefsDialog *prefs) +{ + icaltimezone *zone; + + zone = e_cal_util_get_system_timezone (); + if (zone) { + char *tmp = g_strdup_printf ("(%s)", icaltimezone_get_display_name (zone)); + gtk_label_set_text (GTK_LABEL (prefs->system_tz_label), tmp); + g_free (tmp); + } else { + gtk_label_set_text (GTK_LABEL (prefs->system_tz_label), "(UTC)"); + } + + gtk_widget_set_sensitive (prefs->timezone, !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs->use_system_tz_check))); +} + +static void +use_system_tz_changed (GtkWidget *check, CalendarPrefsDialog *prefs) +{ + calendar_config_set_use_system_timezone (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check))); + update_system_tz_widgets (prefs); +} + static void setup_changes (CalendarPrefsDialog *prefs) { @@ -487,6 +511,7 @@ setup_changes (CalendarPrefsDialog *prefs) for (i = 0; i < 7; i ++) g_signal_connect (G_OBJECT (prefs->working_days[i]), "toggled", G_CALLBACK (working_days_changed), prefs); + g_signal_connect (G_OBJECT (prefs->use_system_tz_check), "toggled", G_CALLBACK (use_system_tz_changed), prefs); g_signal_connect (G_OBJECT (prefs->timezone), "changed", G_CALLBACK (timezone_changed), prefs); g_signal_connect (G_OBJECT (prefs->day_second_zone), "clicked", G_CALLBACK (day_second_zone_clicked), prefs); @@ -620,8 +645,13 @@ show_config (CalendarPrefsDialog *prefs) CalUnits units; int interval; + /* Use system timezone */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->use_system_tz_check), calendar_config_get_use_system_timezone ()); + gtk_widget_set_sensitive (prefs->system_tz_label, FALSE); + update_system_tz_widgets (prefs); + /* Timezone. */ - location = calendar_config_get_timezone (); + location = calendar_config_get_timezone_stored (); zone = icaltimezone_get_builtin_timezone (location); e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (prefs->timezone), zone); g_free (location); @@ -762,6 +792,8 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs) e_config_add_items ((EConfig *) ec, l, NULL, NULL, eccp_free, prefs); /* General tab */ + prefs->use_system_tz_check = glade_xml_get_widget (gui, "use-system-tz-check"); + prefs->system_tz_label = glade_xml_get_widget (gui, "system-tz-label"); prefs->timezone = glade_xml_get_widget (gui, "timezone"); prefs->day_second_zone = glade_xml_get_widget (gui, "day_second_zone"); for (i = 0; i < 7; i++) diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index 23406d5963..867abdbb22 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -96,144 +96,12 @@ True - 4 + 5 2 False 6 6 - - - True - make_timezone_entry - 0 - 0 - Thu, 13 Jan 2005 04:18:03 GMT - - - - - - 1 - 2 - 0 - 1 - fill - - - - - - True - Time _zone: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - timezone - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - False - 6 - - - - True - True - _12 hour (AM/PM) - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - True - _24 hour - True - GTK_RELIEF_NORMAL - True - False - False - True - use_12_hour - - - 0 - False - False - - - - - 1 - 2 - 2 - 3 - fill - fill - - - - - - True - Time format: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 2 - 3 - fill - - - - True @@ -256,8 +124,8 @@ 0 1 - 3 - 4 + 4 + 5 fill @@ -310,6 +178,111 @@ + + 1 + 2 + 4 + 5 + fill + fill + + + + + + True + Time format: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + Adjust for daylight sa_ving time + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + False + 6 + + + + True + True + _12 hour (AM/PM) + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _24 hour + True + GTK_RELIEF_NORMAL + True + False + False + True + use_12_hour + + + 0 + False + False + + + 1 2 @@ -319,6 +292,136 @@ fill + + + + True + True + Adjust for daylight sa_ving time + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + make_timezone_entry + 0 + 0 + Thu, 13 Jan 2005 04:18:03 GMT + + + + + + 1 + 2 + 1 + 2 + fill + + + + + + True + Time _zone: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + timezone + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + False + 0 + + + + True + True + Use s_ystem time zone + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + True + + + + + + True + (system/tz) + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 5 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 1 + 2 + 0 + 1 + fill + + 0 @@ -1246,6 +1349,7 @@ Days False + True diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h index 945c1d6e16..559eacced7 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ b/calendar/gui/dialogs/cal-prefs-dialog.h @@ -43,6 +43,8 @@ struct _CalendarPrefsDialog { GConfClient *gconf; /* General tab */ + GtkWidget *use_system_tz_check; + GtkWidget *system_tz_label; GtkWidget *timezone; GtkWidget *day_second_zone; GtkWidget *working_days[7]; diff --git a/plugins/startup-wizard/ChangeLog b/plugins/startup-wizard/ChangeLog index 2147b10a0a..4ac3bcfce9 100644 --- a/plugins/startup-wizard/ChangeLog +++ b/plugins/startup-wizard/ChangeLog @@ -1,3 +1,12 @@ +2009-04-24 Milan Crha + + ** Part of fix for bug #381132 + + * org-gnome-evolution-startup-wizard.eplug.xml: + * startup-wizard.c: (startup_wizard_timezone_page), + (startup_wizard_commit), (startup_wizard_abort): + Do not setup timezone, set a system timezone instead. + 2009-01-21 Milan Crha * Makefile.am: Use also EVOLUTION_CALENDAR_CFLAGS. diff --git a/plugins/startup-wizard/org-gnome-evolution-startup-wizard.eplug.xml b/plugins/startup-wizard/org-gnome-evolution-startup-wizard.eplug.xml index 1197633a23..e52cd6a71e 100644 --- a/plugins/startup-wizard/org-gnome-evolution-startup-wizard.eplug.xml +++ b/plugins/startup-wizard/org-gnome-evolution-startup-wizard.eplug.xml @@ -17,7 +17,6 @@ - diff --git a/plugins/startup-wizard/startup-wizard.c b/plugins/startup-wizard/startup-wizard.c index f9594364d9..6289a63489 100644 --- a/plugins/startup-wizard/startup-wizard.c +++ b/plugins/startup-wizard/startup-wizard.c @@ -24,7 +24,6 @@ #include #include #include -#include "widgets/e-timezone-dialog/e-timezone-dialog.h" #include "e-util/e-error.h" #include "e-util/e-import.h" #include "shell/es-event.h" @@ -32,10 +31,7 @@ #include "mail/em-account-editor.h" #include "calendar/gui/calendar-config.h" -#define IMPORT_TIMEZONE_DIALOG "StartupWizard::TimezoneDialog" - void startup_wizard (EPlugin *ep, ESEventTargetUpgrade *target); -GtkWidget *startup_wizard_timezone_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data); GtkWidget *startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data); gboolean startup_wizard_check (EPlugin *ep, EConfigHookPageCheckData *check_data); void startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target); @@ -97,25 +93,6 @@ startup_wizard (EPlugin *ep, ESEventTargetUpgrade *target) gtk_main (); } -GtkWidget * -startup_wizard_timezone_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data) -{ - ETimezoneDialog *etd; - GtkWidget *page; - - etd = e_timezone_dialog_new (); - g_object_set_data (G_OBJECT (hook_data->config), IMPORT_TIMEZONE_DIALOG, etd); - - page = gnome_druid_page_standard_new_with_vals (_("Timezone"), NULL, NULL); - e_timezone_dialog_reparent (etd, GNOME_DRUID_PAGE_STANDARD (page)->vbox); - - e_timezone_dialog_set_timezone (etd, NULL); - - gnome_druid_append_page (GNOME_DRUID (hook_data->parent), GNOME_DRUID_PAGE (page)); - - return GTK_WIDGET (page); -} - GtkWidget * startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data) { @@ -208,22 +185,13 @@ import_done(EImport *ei, void *d) void startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target) { - EConfig *ec = ((EConfigTarget *)target)->config; - ETimezoneDialog *etd; - icaltimezone *zone; + char *location; - /* Set Timezone */ - etd = g_object_get_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG); - if (etd) { - zone = e_timezone_dialog_get_timezone (E_TIMEZONE_DIALOG (etd)); - if (zone) - calendar_config_set_timezone (icaltimezone_get_display_name (zone)); - - /* Need to do this otherwise the timezone widget gets destroyed but the - timezone object isn't, and we can get a crash like #22047. */ - g_object_unref (etd); - g_object_set_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG, NULL); - } + /* Use System Timezone by default */ + calendar_config_set_use_system_timezone (TRUE); + location = e_cal_util_get_system_timezone_location (); + calendar_config_set_timezone (location); + g_free (location); if (import_importers) { import_iterator = import_importers; @@ -246,20 +214,6 @@ startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target) void startup_wizard_abort (EPlugin *ep, EMConfigTargetAccount *target) { - EConfig *ec = ((EConfigTarget *)target)->config; - ETimezoneDialog *etd; - - /* We're doing an _exit(), so i dont see why we're bothering to do - any cleanup whatsoever here ... */ - - etd = g_object_get_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG); - if (etd) { - /* Need to do this otherwise the timezone widget gets destroyed but the - timezone object isn't, and we can get a crash like #22047. */ - g_object_unref (etd); - g_object_set_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG, NULL); - } - gtk_main_quit (); _exit (0); }