From 4cd045fb40ee5fcad3c5f86b9ecff5d4c21963cd Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 29 Oct 2003 14:05:34 +0000 Subject: set the timezone for all clients (timezone_changed_cb): callback for 2003-10-29 JP Rosevear * gui/gnome-cal.c (set_timezone): set the timezone for all clients (timezone_changed_cb): callback for changes (setup_config): setup the configuration (setup_widgets): setup up configuration managers for the list view, task list and date navigator (gnome_calendar_init): setup config (gnome_calendar_destroy): destroy configuration managers and notifications (gnome_calendar_update_config_settings): remove dead bits * gui/e-mini-calendar-config.[hc]: manage configuration of an e-calendar * gui/e-day-view-config.h: remove extraneous comment, type the parent class correctly * gui/e-week-view-config.h: ditto * gui/e-day-view-config.c (e_day_view_config_class_init): type the class correctly (set_timezone): set timezone (timezone_changed_cb): timezone changed callback (e_day_view_config_set_view): track timezone changes * gui/e-week-view-config.c: ditto * gui/e-cell-date-edit-config.[hc]: manage configuration of a date edit cell * gui/e-calendar-table-config.[hc]: manage configuration of a e-calendar-table * gui/e-cal-list-view.c (get_current_time_cb): use the view timezone to compute * gui/e-cal-list-view-config.[hc]: manage configuration of a list view * gui/calendar-config.h: update protos * gui/calendar-config.c (calendar_config_add_notification_timezone): notify of timezone change (calendar_config_add_notification_dnav_show_week_no): notify of show week number setting change * gui/calendar-component.c (calendar_component_peek): remove bad comma * gui/Makefile.am: build new config classes svn path=/trunk/; revision=23114 --- calendar/gui/gnome-cal.c | 130 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 91 insertions(+), 39 deletions(-) (limited to 'calendar/gui/gnome-cal.c') diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index da0bacdd91..f1925ad365 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -51,6 +51,9 @@ #include "e-week-view.h" #include "e-week-view-config.h" #include "e-cal-list-view.h" +#include "e-cal-list-view-config.h" +#include "e-mini-calendar-config.h" +#include "e-calendar-table-config.h" #include "evolution-calendar.h" #include "gnome-cal.h" #include "calendar-component.h" @@ -105,9 +108,12 @@ struct _GnomeCalendarPrivate { GtkWidget *hpane; GtkWidget *notebook; GtkWidget *vpane; + ECalendar *date_navigator; + EMiniCalendarConfig *date_navigator_config; GtkWidget *todo; - + ECalendarTableConfig *todo_config; + GtkWidget *day_view; GtkWidget *work_week_view; GtkWidget *week_view; @@ -125,6 +131,8 @@ struct _GnomeCalendarPrivate { ECalView *views[GNOME_CAL_LAST_VIEW]; GObject *configs[GNOME_CAL_LAST_VIEW]; GnomeCalendarViewType current_view_type; + GList *notifications; + gboolean range_selected; /* These are the saved positions of the panes. They are multiples of @@ -826,6 +834,67 @@ table_selection_change_cb (ETable *etable, gpointer data) gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals[TASKPAD_SELECTION_CHANGED]); } +static void +set_timezone (GnomeCalendar *calendar) +{ + GnomeCalendarPrivate *priv; + char *location; + GList *l; + + priv = calendar->priv; + + location = calendar_config_get_timezone (); + priv->zone = icaltimezone_get_builtin_timezone (location); + g_free (location); + + if (!priv->zone) + priv->zone = icaltimezone_get_utc_timezone (); + + for (l = priv->clients_list; l != NULL; l = l->next) { + CalClient *client = l->data; + + if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) + /* FIXME Error checking */ + cal_client_set_default_timezone (client, priv->zone, NULL); + } + + if (priv->task_pad_client + && cal_client_get_load_state (priv->task_pad_client) == CAL_CLIENT_LOAD_LOADED) { + /* FIXME Error Checking */ + cal_client_set_default_timezone (priv->task_pad_client, + priv->zone, NULL); + } +} + +static void +timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + GnomeCalendar *calendar = data; + + set_timezone (calendar); +} + +static void +setup_config (GnomeCalendar *calendar) +{ + GnomeCalendarPrivate *priv; + guint not; + + priv = calendar->priv; + + /* Timezone */ + set_timezone (calendar); + + not = calendar_config_add_notification_timezone (timezone_changed_cb, calendar); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Pane positions */ + priv->hpane_pos = calendar_config_get_hpane_pos (); + priv->vpane_pos = calendar_config_get_vpane_pos (); + priv->hpane_pos_month_view = calendar_config_get_month_hpane_pos (); + priv->vpane_pos_month_view = calendar_config_get_month_vpane_pos (); +} + static void setup_widgets (GnomeCalendar *gcal) { @@ -875,6 +944,7 @@ setup_widgets (GnomeCalendar *gcal) /* The ECalendar. */ w = e_calendar_new (); priv->date_navigator = E_CALENDAR (w); + priv->date_navigator_config = e_mini_calendar_config_new (priv->date_navigator); e_calendar_item_set_days_start_week_sel (priv->date_navigator->calitem, 9); e_calendar_item_set_max_days_sel (priv->date_navigator->calitem, 42); gtk_widget_show (w); @@ -891,7 +961,7 @@ setup_widgets (GnomeCalendar *gcal) /* The ToDo list. */ priv->todo = e_calendar_table_new (); - calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->todo)); + priv->todo_config = e_calendar_table_config_new (E_CALENDAR_TABLE (priv->todo)); gtk_paned_pack2 (GTK_PANED (priv->vpane), priv->todo, TRUE, TRUE); gtk_widget_show (priv->todo); @@ -960,6 +1030,7 @@ setup_widgets (GnomeCalendar *gcal) priv->views[GNOME_CAL_MONTH_VIEW] = E_CAL_VIEW (priv->month_view); priv->configs[GNOME_CAL_MONTH_VIEW] = e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_MONTH_VIEW])); priv->views[GNOME_CAL_LIST_VIEW] = E_CAL_VIEW (priv->list_view); + priv->configs[GNOME_CAL_MONTH_VIEW] = e_cal_list_view_config_new (E_CAL_LIST_VIEW (priv->views[GNOME_CAL_LIST_VIEW])); priv->configs[GNOME_CAL_LIST_VIEW] = NULL; for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { @@ -969,6 +1040,7 @@ setup_widgets (GnomeCalendar *gcal) gtk_widget_show (GTK_WIDGET (priv->views[i])); } + gnome_calendar_update_config_settings (gcal, TRUE); } @@ -989,7 +1061,9 @@ gnome_calendar_init (GnomeCalendar *gcal) priv->current_view_type = GNOME_CAL_DAY_VIEW; priv->range_selected = FALSE; + setup_config (gcal); setup_widgets (gcal); + priv->dn_queries = NULL; priv->sexp = g_strdup ("#t"); /* Match all */ @@ -1034,7 +1108,8 @@ gnome_calendar_destroy (GtkObject *object) if (priv) { GList *l; - + int i; + /* disconnect from signals on all the clients */ for (l = priv->clients_list; l != NULL; l = l->next) { g_signal_handlers_disconnect_matched (l->data, G_SIGNAL_MATCH_DATA, @@ -1043,12 +1118,24 @@ gnome_calendar_destroy (GtkObject *object) g_hash_table_destroy (priv->clients); g_list_free (priv->clients_list); - + free_categories (priv->cal_categories); priv->cal_categories = NULL; free_categories (priv->tasks_categories); priv->tasks_categories = NULL; + + for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { + if (priv->configs[i]) + g_object_unref (priv->configs[i]); + priv->configs[i] = NULL; + } + g_object_unref (priv->date_navigator_config); + g_object_unref (priv->todo_config); + + for (l = priv->notifications; l; l = l->next) + calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); + priv->notifications = NULL; /* Save the TaskPad layout. */ filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()), @@ -2254,46 +2341,11 @@ gnome_calendar_update_config_settings (GnomeCalendar *gcal, gboolean initializing) { GnomeCalendarPrivate *priv; - char *location; - GList *l; - int i; g_return_if_fail (GNOME_IS_CALENDAR (gcal)); priv = gcal->priv; - calendar_config_configure_e_calendar (E_CALENDAR (priv->date_navigator)); - - calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->todo)); - - location = calendar_config_get_timezone (); - priv->zone = icaltimezone_get_builtin_timezone (location); - - for (l = priv->clients_list; l != NULL; l = l->next) { - CalClient *client = l->data; - - if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) - /* FIXME Error checking */ - cal_client_set_default_timezone (client, priv->zone, NULL); - } - - if (priv->task_pad_client - && cal_client_get_load_state (priv->task_pad_client) == CAL_CLIENT_LOAD_LOADED) { - /* FIXME Error Checking */ - cal_client_set_default_timezone (priv->task_pad_client, - priv->zone, NULL); - } - - for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) - e_cal_view_set_timezone (E_CAL_VIEW (priv->views[i]), priv->zone); - - if (initializing) { - priv->hpane_pos = calendar_config_get_hpane_pos (); - priv->vpane_pos = calendar_config_get_vpane_pos (); - priv->hpane_pos_month_view = calendar_config_get_month_hpane_pos (); - priv->vpane_pos_month_view = calendar_config_get_month_vpane_pos (); - } - /* The range of days shown may have changed, so we update the date navigator if needed. */ gnome_calendar_update_date_navigator (gcal); -- cgit v1.2.3