From 6a2b0904893199ceb5b291405721845fd17a08db Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 5 Aug 2009 21:24:53 -0400 Subject: More refactoring of settings management. --- calendar/gui/calendar-config.c | 16 ----- calendar/gui/calendar-config.h | 2 - calendar/gui/e-day-view.c | 42 ++++++++++- calendar/gui/e-week-view.c | 25 +++++++ calendar/gui/gnome-cal.c | 95 ++++-------------------- modules/calendar/e-cal-shell-content.c | 108 ---------------------------- modules/calendar/e-cal-shell-view-private.c | 2 - 7 files changed, 80 insertions(+), 210 deletions(-) diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index b1f38c74cb..4099f5fd4b 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -381,14 +381,6 @@ calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func, } /* The positions of the panes in the normal and month views. */ -gint -calendar_config_get_hpane_pos (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_HPANE_POS, NULL); -} - void calendar_config_set_hpane_pos (gint hpane_pos) { @@ -397,14 +389,6 @@ calendar_config_set_hpane_pos (gint hpane_pos) gconf_client_set_int (config, CALENDAR_CONFIG_HPANE_POS, hpane_pos, NULL); } -gint -calendar_config_get_month_hpane_pos (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_MONTH_HPANE_POS, NULL); -} - void calendar_config_set_month_hpane_pos (gint hpane_pos) { diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index dddffe6a92..9a8a1dc2f8 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -108,10 +108,8 @@ gboolean calendar_config_get_dnav_show_week_no (void); guint calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func, gpointer data); /* The positions of the panes in the normal and month views. */ -gint calendar_config_get_hpane_pos (void); void calendar_config_set_hpane_pos (gint hpane_pos); -gint calendar_config_get_month_hpane_pos (void); void calendar_config_set_month_hpane_pos (gint hpane_pos); /* The current list of task lists selected */ diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 7fc7bfac90..03b1b9cb51 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -611,9 +611,49 @@ day_view_constructed (GObject *object) model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); shell_settings = e_cal_model_get_shell_settings (model); - e_mutual_binding_new ( + e_binding_new ( G_OBJECT (shell_settings), "cal-day-view-show-week-numbers", G_OBJECT (day_view->week_number_label), "visible"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-marcus-bains-show-line", + G_OBJECT (day_view), "marcus-bains-show-line"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-marcus-bains-day-view-color", + G_OBJECT (day_view), "marcus-bains-day-view-color"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-marcus-bains-time-bar-color", + G_OBJECT (day_view), "marcus-bains-time-bar-color"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-time-divisions", + G_OBJECT (day_view), "mins-per-row"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-week-start-day", + G_OBJECT (day_view), "week-start-day"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-work-day-end-hour", + G_OBJECT (day_view), "work-day-end-hour"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-work-day-end-minute", + G_OBJECT (day_view), "work-day-end-minute"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-work-day-start-hour", + G_OBJECT (day_view), "work-day-start-hour"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-work-day-start-minute", + G_OBJECT (day_view), "work-day-start-minute"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-working-days-bitset", + G_OBJECT (day_view), "working-days"); } static void diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 5d08ee84de..97034f8e01 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -295,6 +295,30 @@ week_view_get_property (GObject *object, G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } +static void +week_view_constructed (GObject *object) +{ + ECalModel *model; + EWeekView *week_view; + EShellSettings *shell_settings; + + week_view = E_WEEK_VIEW (object); + model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)); + shell_settings = e_cal_model_get_shell_settings (model); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-compress-weekend", + G_OBJECT (week_view), "compress-weekend"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-show-event-end-times", + G_OBJECT (week_view), "show-event-end-times"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-week-start-day", + G_OBJECT (week_view), "week-start-day"); +} + static void week_view_cursor_key_up (EWeekView *week_view) { @@ -366,6 +390,7 @@ e_week_view_class_init (EWeekViewClass *class) object_class = G_OBJECT_CLASS (class); object_class->set_property = week_view_set_property; object_class->get_property = week_view_get_property; + object_class->constructed = week_view_constructed; gtk_object_class = GTK_OBJECT_CLASS (class); gtk_object_class->destroy = e_week_view_destroy; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 9c099e8938..6283e6b8dd 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -325,6 +325,15 @@ view_done_cb (ECalModel *model, #endif } +static void +gnome_calendar_update_time_range (GnomeCalendar *gcal) +{ + time_t start_time; + + start_time = gcal->priv->base_view_time; + gnome_calendar_set_selected_time_range (gcal, start_time); +} + static void gnome_calendar_set_shell_settings (GnomeCalendar *gcal, EShellSettings *shell_settings) @@ -422,10 +431,6 @@ gnome_calendar_constructed (GObject *object) e_calendar_view_set_timezone (calendar_view, gcal->priv->zone); gcal->priv->views[GNOME_CAL_DAY_VIEW] = calendar_view; - e_binding_new ( - G_OBJECT (gcal), "week-start-day", - G_OBJECT (calendar_view), "week-start-day"); - g_signal_connect_swapped ( calendar_view, "selection-changed", G_CALLBACK (view_selection_changed_cb), gcal); @@ -438,9 +443,9 @@ gnome_calendar_constructed (GObject *object) e_calendar_view_set_timezone (calendar_view, gcal->priv->zone); gcal->priv->views[GNOME_CAL_WORK_WEEK_VIEW] = calendar_view; - e_binding_new ( - G_OBJECT (gcal), "week-start-day", - G_OBJECT (calendar_view), "week-start-day"); + g_signal_connect_swapped ( + calendar_view, "notify::working-days", + G_CALLBACK (gnome_calendar_update_time_range), gcal); /* Week View */ calendar_view = e_week_view_new (model); @@ -448,10 +453,6 @@ gnome_calendar_constructed (GObject *object) e_calendar_view_set_timezone (calendar_view, gcal->priv->zone); gcal->priv->views[GNOME_CAL_WEEK_VIEW] = calendar_view; - e_binding_new ( - G_OBJECT (gcal), "week-start-day", - G_OBJECT (calendar_view), "week-start-day"); - g_signal_connect_swapped ( calendar_view, "selection-changed", G_CALLBACK (view_selection_changed_cb), gcal); @@ -470,10 +471,6 @@ gnome_calendar_constructed (GObject *object) e_calendar_view_set_timezone (calendar_view, gcal->priv->zone); gcal->priv->views[GNOME_CAL_MONTH_VIEW] = calendar_view; - e_binding_new ( - G_OBJECT (gcal), "week-start-day", - G_OBJECT (calendar_view), "week-start-day"); - g_signal_connect_swapped ( calendar_view, "selection-changed", G_CALLBACK (view_selection_changed_cb), gcal); @@ -499,6 +496,8 @@ gnome_calendar_constructed (GObject *object) e_binding_new ( G_OBJECT (shell_settings), "cal-week-start-day", G_OBJECT (gcal), "week-start-day"); + + gnome_calendar_update_time_range (gcal); } /* Class initialization function for the gnome calendar */ @@ -1147,49 +1146,6 @@ gnome_calendar_set_search_query (GnomeCalendar *gcal, update_todo_view (gcal); } -/* Returns the current time, for the ECalendarItem. */ -static struct tm -get_current_time (ECalendarItem *calitem, gpointer data) -{ - GnomeCalendar *cal = data; - struct tm tmp_tm = { 0 }; - struct icaltimetype tt; - - g_return_val_if_fail (cal != NULL, tmp_tm); - g_return_val_if_fail (GNOME_IS_CALENDAR (cal), tmp_tm); - - tt = icaltime_from_timet_with_zone (time (NULL), FALSE, - cal->priv->zone); - - /* Now copy it to the struct tm and return it. */ - tmp_tm = icaltimetype_to_tm (&tt); - - return tmp_tm; -} - -static void -set_working_days (GnomeCalendar *calendar) -{ - time_t start_time; - gint ii; - - /* Only do this if views exist */ - for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++) - if (gnome_calendar_get_calendar_view (calendar, ii) == NULL) - return; - - start_time = calendar->priv->base_view_time; - gnome_calendar_set_selected_time_range (calendar, start_time); -} - -static void -working_days_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) -{ - GnomeCalendar *calendar = data; - - set_working_days (calendar); -} - static void set_timezone (GnomeCalendar *calendar) { @@ -1371,24 +1327,6 @@ update_marcus_bains_line_cb (GnomeCalendar *gcal) return TRUE; } -static void -setup_config (GnomeCalendar *calendar) -{ - GnomeCalendarPrivate *priv; - guint not; - - priv = calendar->priv; - - /* Working Days */ - set_working_days (calendar); - not = calendar_config_add_notification_working_days (working_days_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->hpane_pos_month_view = calendar_config_get_month_hpane_pos (); -} - static void setup_widgets (GnomeCalendar *gcal) { @@ -1441,7 +1379,6 @@ gnome_calendar_init (GnomeCalendar *gcal) priv->range_selected = FALSE; priv->lview_select_daten_range = TRUE; - setup_config (gcal); setup_widgets (gcal); priv->calendar_menu = e_cal_menu_new("org.gnome.evolution.calendar.view"); @@ -2274,10 +2211,6 @@ gnome_calendar_set_date_navigator (GnomeCalendar *gcal, gcal->priv->date_navigator = date_navigator; calitem = date_navigator->calitem; - e_calendar_item_set_get_time_callback ( - calitem, (ECalendarItemGetTimeCallback) - get_current_time, gcal, NULL); - g_signal_connect ( calitem, "selection-changed", G_CALLBACK (gnome_calendar_on_date_navigator_selection_changed), diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c index 6e7269ecae..7a8e659cbb 100644 --- a/modules/calendar/e-cal-shell-content.c +++ b/modules/calendar/e-cal-shell-content.c @@ -455,114 +455,6 @@ cal_shell_content_constructed (GObject *object) key = "/apps/evolution/calendar/display/vpane_position"; gconf_bridge_bind_property_delayed (bridge, key, object, "position"); - /* Bind day view properties to EShellSettings. */ - - view_type = GNOME_CAL_DAY_VIEW; - calendar_view = gnome_calendar_get_calendar_view (calendar, view_type); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-marcus-bains-show-line", - G_OBJECT (calendar_view), "marcus-bains-show-line"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-marcus-bains-day-view-color", - G_OBJECT (calendar_view), "marcus-bains-day-view-color"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-marcus-bains-time-bar-color", - G_OBJECT (calendar_view), "marcus-bains-time-bar-color"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-time-divisions", - G_OBJECT (calendar_view), "mins-per-row"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-end-hour", - G_OBJECT (calendar_view), "work-day-end-hour"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-end-minute", - G_OBJECT (calendar_view), "work-day-end-minute"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-start-hour", - G_OBJECT (calendar_view), "work-day-start-hour"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-start-minute", - G_OBJECT (calendar_view), "work-day-start-minute"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-working-days-bitset", - G_OBJECT (calendar_view), "working-days"); - - /* Bind work week view properties to EShellSettings. */ - - view_type = GNOME_CAL_WORK_WEEK_VIEW; - calendar_view = gnome_calendar_get_calendar_view (calendar, view_type); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-marcus-bains-show-line", - G_OBJECT (calendar_view), "marcus-bains-show-line"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-marcus-bains-day-view-color", - G_OBJECT (calendar_view), "marcus-bains-day-view-color"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-marcus-bains-time-bar-color", - G_OBJECT (calendar_view), "marcus-bains-time-bar-color"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-time-divisions", - G_OBJECT (calendar_view), "mins-per-row"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-end-hour", - G_OBJECT (calendar_view), "work-day-end-hour"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-end-minute", - G_OBJECT (calendar_view), "work-day-end-minute"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-start-hour", - G_OBJECT (calendar_view), "work-day-start-hour"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-work-day-start-minute", - G_OBJECT (calendar_view), "work-day-start-minute"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-working-days-bitset", - G_OBJECT (calendar_view), "working-days"); - - /* Bind week view properties to EShellSettings. */ - - view_type = GNOME_CAL_WEEK_VIEW; - calendar_view = gnome_calendar_get_calendar_view (calendar, view_type); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-compress-weekend", - G_OBJECT (calendar_view), "compress-weekend"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-show-event-end-times", - G_OBJECT (calendar_view), "show-event-end-times"); - - /* Bind month view properties to EShellSettings. */ - - view_type = GNOME_CAL_MONTH_VIEW; - calendar_view = gnome_calendar_get_calendar_view (calendar, view_type); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-compress-weekend", - G_OBJECT (calendar_view), "compress-weekend"); - - e_binding_new ( - G_OBJECT (shell_settings), "cal-show-event-end-times", - G_OBJECT (calendar_view), "show-event-end-times"); - g_object_unref (memo_model); g_object_unref (task_model); } diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 44aad3db5e..49c07ca70f 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -300,12 +300,10 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) /* KILL-BONOBO FIXME -- Need to connect to the "user-created" * signal for each ECalendarView. */ -#if 0 /* KILL-BONOBO */ g_signal_connect_swapped ( calendar, "dates-shown-changed", G_CALLBACK (e_cal_shell_view_update_sidebar), cal_shell_view); -#endif g_signal_connect_swapped ( model, "notify::timezone", -- cgit v1.2.3