From 541d52701f8225e45651b405fd44a7fa4aa417da Mon Sep 17 00:00:00 2001 From: Damon Chaplin Date: Wed, 20 Jun 2001 06:10:41 +0000 Subject: added code to show the timezone dialog if the user hasn't set a default 2001-06-20 Damon Chaplin * gui/calendar-commands.c (calendar_control_activate): * gui/gnome-cal.[hc]: added code to show the timezone dialog if the user hasn't set a default timezone yet. * gui/dialogs/e-timezone-dialog.c (e_timezone_dialog_add_timezones): set the "None" item string before adding it to the combo, to stop the combo putting "None" in the entry initially. svn path=/trunk/; revision=10324 --- calendar/ChangeLog | 10 +++++ calendar/gui/calendar-commands.c | 2 + calendar/gui/dialogs/e-timezone-dialog.c | 2 +- calendar/gui/dialogs/e-timezone-dialog.glade | 2 +- calendar/gui/gnome-cal.c | 61 ++++++++++++++++++++++++++++ calendar/gui/gnome-cal.h | 3 ++ 6 files changed, 78 insertions(+), 2 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index e6cd1fc7f2..2c3c7977ee 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,13 @@ +2001-06-20 Damon Chaplin + + * gui/calendar-commands.c (calendar_control_activate): + * gui/gnome-cal.[hc]: added code to show the timezone dialog if the + user hasn't set a default timezone yet. + + * gui/dialogs/e-timezone-dialog.c (e_timezone_dialog_add_timezones): + set the "None" item string before adding it to the combo, to stop the + combo putting "None" in the entry initially. + 2001-06-19 Damon Chaplin * gui/dialogs/event-page.c: if the timezones of the start and end of diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index b63946cc53..d2b706a13d 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -448,6 +448,8 @@ calendar_control_activate (BonoboControl *control, gnome_calendar_setup_view_menus (gcal, uic); bonobo_ui_component_thaw (uic, NULL); + + gnome_calendar_check_timezone_set (gcal); } void diff --git a/calendar/gui/dialogs/e-timezone-dialog.c b/calendar/gui/dialogs/e-timezone-dialog.c index 199abbeb3f..ad9acfb528 100644 --- a/calendar/gui/dialogs/e-timezone-dialog.c +++ b/calendar/gui/dialogs/e-timezone-dialog.c @@ -186,9 +186,9 @@ e_timezone_dialog_add_timezones (ETimezoneDialog *etd) /* Put the "None" and "UTC" entries at the top of the combo's list. When "None" is selected we want the field to be cleared. */ listitem = gtk_list_item_new_with_label (_("None")); + gtk_combo_set_item_string (combo, GTK_ITEM (listitem), ""); gtk_widget_show (listitem); gtk_container_add (GTK_CONTAINER (combo->list), listitem); - gtk_combo_set_item_string (combo, GTK_ITEM (listitem), ""); /* Note: We don't translate timezone names at the moment. */ listitem = gtk_list_item_new_with_label ("UTC"); diff --git a/calendar/gui/dialogs/e-timezone-dialog.glade b/calendar/gui/dialogs/e-timezone-dialog.glade index 2b2019dfc2..15254056c7 100644 --- a/calendar/gui/dialogs/e-timezone-dialog.glade +++ b/calendar/gui/dialogs/e-timezone-dialog.glade @@ -25,7 +25,7 @@ False True False - False + True True diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 73ac19aabc..e15a746aa6 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -43,6 +43,7 @@ #include "widgets/misc/e-filter-bar.h" #include "dialogs/alarm-notify-dialog.h" #include "dialogs/event-editor.h" +#include "dialogs/e-timezone-dialog.h" #include "e-calendar-table.h" #include "e-day-view.h" #include "e-week-view.h" @@ -1920,3 +1921,63 @@ gnome_calendar_update_view_buttons (GnomeCalendar *gcal) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_signal_handler_unblock_by_data (GTK_OBJECT (button), gcal); } + + +static void +on_timezone_set (GnomeDialog *dialog, int button, ETimezoneDialog *etd) +{ + char *zone; + + zone = e_timezone_dialog_get_timezone (etd); + + if (zone && zone[0]) { + calendar_config_set_timezone (zone); + + calendar_config_write (); + update_all_config_settings (); + e_tasks_update_all_config_settings (); + } + + gtk_object_unref (GTK_OBJECT (etd)); +} + + +static gboolean +on_timezone_dialog_delete_event (GnomeDialog *dialog, GdkEvent *event, + ETimezoneDialog *etd) +{ + gtk_object_unref (GTK_OBJECT (etd)); + return TRUE; +} + + +void +gnome_calendar_check_timezone_set (GnomeCalendar *gcal) +{ + 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); + + gtk_signal_connect (GTK_OBJECT (dialog), "clicked", + GTK_SIGNAL_FUNC (on_timezone_set), + timezone_dialog); + gtk_signal_connect (GTK_OBJECT (dialog), "delete-event", + GTK_SIGNAL_FUNC (on_timezone_dialog_delete_event), + timezone_dialog); + + gtk_widget_show (dialog); +} + diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 9ff25c50f5..908e680133 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -123,6 +123,9 @@ void gnome_calendar_get_current_time_range (GnomeCalendar *gcal, void gnome_calendar_update_config_settings (GnomeCalendar *gcal, gboolean initializing); +/* Shows the timezone dialog if the user hasn't set a default timezone. */ +void gnome_calendar_check_timezone_set (GnomeCalendar *gcal); + void gnome_calendar_set_view_buttons (GnomeCalendar *gcal, GtkWidget *day_button, GtkWidget *work_week_button, -- cgit v1.2.3