aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-03-10 00:47:50 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-03-17 20:49:11 +0800
commit9318c790b4d0e8b90cde2b52dc801e9a2f2f7b02 (patch)
tree5e1240dd7e597174741a79946c0fb2bfcb3d6a0e /calendar
parent8091b6ebab8b9cbad721cfe73c638d7bfc1a495e (diff)
downloadgsoc2013-evolution-9318c790b4d0e8b90cde2b52dc801e9a2f2f7b02.tar.gz
gsoc2013-evolution-9318c790b4d0e8b90cde2b52dc801e9a2f2f7b02.tar.zst
gsoc2013-evolution-9318c790b4d0e8b90cde2b52dc801e9a2f2f7b02.zip
EDayView: Move "work-day-*" properties to ECalModel.
EWeekView would like to use them too, please.
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/e-cal-model.c303
-rw-r--r--calendar/gui/e-cal-model.h7
-rw-r--r--calendar/gui/e-day-view-main-item.c2
-rw-r--r--calendar/gui/e-day-view.c457
-rw-r--r--calendar/gui/e-day-view.h13
-rw-r--r--calendar/gui/gnome-cal.c4
6 files changed, 437 insertions, 349 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index b94c7090a8..1213ff190d 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -97,6 +97,10 @@ struct _ECalModelPrivate {
/* First day of the week: 0 (Monday) to 6 (Sunday) */
gint week_start_day;
+ /* Work days. Indices are based on GDateWeekday.
+ * The first element (G_DATE_BAD_WEEKDAY) is unused. */
+ gboolean work_days[G_DATE_SUNDAY + 1];
+
/* Work day timespan */
gint work_day_start_hour;
gint work_day_start_minute;
@@ -160,6 +164,13 @@ enum {
PROP_USE_24_HOUR_FORMAT,
PROP_USE_DEFAULT_REMINDER,
PROP_WEEK_START_DAY,
+ PROP_WORK_DAY_MONDAY,
+ PROP_WORK_DAY_TUESDAY,
+ PROP_WORK_DAY_WEDNESDAY,
+ PROP_WORK_DAY_THURSDAY,
+ PROP_WORK_DAY_FRIDAY,
+ PROP_WORK_DAY_SATURDAY,
+ PROP_WORK_DAY_SUNDAY,
PROP_WORK_DAY_END_HOUR,
PROP_WORK_DAY_END_MINUTE,
PROP_WORK_DAY_START_HOUR,
@@ -265,6 +276,55 @@ cal_model_set_property (GObject *object,
g_value_get_int (value));
return;
+ case PROP_WORK_DAY_MONDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_MONDAY,
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WORK_DAY_TUESDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_TUESDAY,
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WORK_DAY_WEDNESDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_WEDNESDAY,
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WORK_DAY_THURSDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_THURSDAY,
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WORK_DAY_FRIDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_FRIDAY,
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WORK_DAY_SATURDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_SATURDAY,
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WORK_DAY_SUNDAY:
+ e_cal_model_set_work_day (
+ E_CAL_MODEL (object),
+ G_DATE_SUNDAY,
+ g_value_get_boolean (value));
+ return;
+
case PROP_WORK_DAY_END_HOUR:
e_cal_model_set_work_day_end_hour (
E_CAL_MODEL (object),
@@ -370,6 +430,55 @@ cal_model_get_property (GObject *object,
E_CAL_MODEL (object)));
return;
+ case PROP_WORK_DAY_MONDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_MONDAY));
+ return;
+
+ case PROP_WORK_DAY_TUESDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_TUESDAY));
+ return;
+
+ case PROP_WORK_DAY_WEDNESDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_WEDNESDAY));
+ return;
+
+ case PROP_WORK_DAY_THURSDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_THURSDAY));
+ return;
+
+ case PROP_WORK_DAY_FRIDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_FRIDAY));
+ return;
+
+ case PROP_WORK_DAY_SATURDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_SATURDAY));
+ return;
+
+ case PROP_WORK_DAY_SUNDAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_work_day (
+ E_CAL_MODEL (object), G_DATE_SUNDAY));
+ return;
+
case PROP_WORK_DAY_END_HOUR:
g_value_set_int (
value,
@@ -634,6 +743,90 @@ e_cal_model_class_init (ECalModelClass *class)
g_object_class_install_property (
object_class,
+ PROP_WORK_DAY_MONDAY,
+ g_param_spec_boolean (
+ "work-day-monday",
+ "Work Day: Monday",
+ "Whether Monday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_TUESDAY,
+ g_param_spec_boolean (
+ "work-day-tuesday",
+ "Work Day: Tuesday",
+ "Whether Tuesday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_WEDNESDAY,
+ g_param_spec_boolean (
+ "work-day-wednesday",
+ "Work Day: Wednesday",
+ "Whether Wednesday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_THURSDAY,
+ g_param_spec_boolean (
+ "work-day-thursday",
+ "Work Day: Thursday",
+ "Whether Thursday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_FRIDAY,
+ g_param_spec_boolean (
+ "work-day-friday",
+ "Work Day: Friday",
+ "Whether Friday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_SATURDAY,
+ g_param_spec_boolean (
+ "work-day-saturday",
+ "Work Day: Saturday",
+ "Whether Saturday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_SUNDAY,
+ g_param_spec_boolean (
+ "work-day-sunday",
+ "Work Day: Sunday",
+ "Whether Sunday is a work day",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_WORK_DAY_END_HOUR,
g_param_spec_int (
"work-day-end-hour",
@@ -2017,6 +2210,116 @@ e_cal_model_set_week_start_day (ECalModel *model,
g_object_notify (G_OBJECT (model), "week-start-day");
}
+gboolean
+e_cal_model_get_work_day (ECalModel *model,
+ GDateWeekday weekday)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE);
+ g_return_val_if_fail (g_date_valid_weekday (weekday), FALSE);
+
+ return model->priv->work_days[weekday];
+}
+
+void
+e_cal_model_set_work_day (ECalModel *model,
+ GDateWeekday weekday,
+ gboolean work_day)
+{
+ const gchar *property_name = NULL;
+
+ g_return_if_fail (E_IS_CAL_MODEL (model));
+ g_return_if_fail (g_date_valid_weekday (weekday));
+
+ if (work_day == model->priv->work_days[weekday])
+ return;
+
+ model->priv->work_days[weekday] = work_day;
+
+ switch (weekday) {
+ case G_DATE_MONDAY:
+ property_name = "work-day-monday";
+ break;
+ case G_DATE_TUESDAY:
+ property_name = "work-day-tuesday";
+ break;
+ case G_DATE_WEDNESDAY:
+ property_name = "work-day-wednesday";
+ break;
+ case G_DATE_THURSDAY:
+ property_name = "work-day-thursday";
+ break;
+ case G_DATE_FRIDAY:
+ property_name = "work-day-friday";
+ break;
+ case G_DATE_SATURDAY:
+ property_name = "work-day-saturday";
+ break;
+ case G_DATE_SUNDAY:
+ property_name = "work-day-sunday";
+ break;
+ default:
+ g_warn_if_reached ();
+ }
+
+ g_object_notify (G_OBJECT (model), property_name);
+}
+
+/**
+ * e_cal_model_get_work_day_first:
+ * @model: an #ECalModel
+ *
+ * Returns the first work day with respect to #ECalModel:work-week-start.
+ * If no work days are set, the function returns %G_DATE_BAD_WEEKDAY.
+ *
+ * Returns: first work day of the week, or %G_DATE_BAD_WEEKDAY
+ **/
+GDateWeekday
+e_cal_model_get_work_day_first (ECalModel *model)
+{
+ GDateWeekday weekday;
+ gint ii;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), G_DATE_BAD_WEEKDAY);
+
+ weekday = e_cal_model_get_week_start_day (model) + 1;
+
+ for (ii = 0; ii < 7; ii++) {
+ if (e_cal_model_get_work_day (model, weekday))
+ return weekday;
+ weekday = e_weekday_get_next (weekday);
+ }
+
+ return G_DATE_BAD_WEEKDAY;
+}
+
+/**
+ * e_cal_model_get_work_day_last:
+ * @model: an #ECalModel
+ *
+ * Returns the last work day with respect to #ECalModel:work-week-start.
+ * If no work days are set, the function returns %G_DATE_BAD_WEEKDAY.
+ *
+ * Returns: last work day of the week, or %G_DATE_BAD_WEEKDAY
+ **/
+GDateWeekday
+e_cal_model_get_work_day_last (ECalModel *model)
+{
+ GDateWeekday weekday;
+ gint ii;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), G_DATE_BAD_WEEKDAY);
+
+ weekday = e_cal_model_get_week_start_day (model) + 1;
+
+ for (ii = 0; ii < 7; ii++) {
+ weekday = e_weekday_get_prev (weekday);
+ if (e_cal_model_get_work_day (model, weekday))
+ return weekday;
+ }
+
+ return G_DATE_BAD_WEEKDAY;
+}
+
gint
e_cal_model_get_work_day_end_hour (ECalModel *model)
{
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index 9164d9c06e..610b227f2f 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -223,6 +223,13 @@ void e_cal_model_set_use_default_reminder
gint e_cal_model_get_week_start_day (ECalModel *model);
void e_cal_model_set_week_start_day (ECalModel *model,
gint week_start_day);
+gboolean e_cal_model_get_work_day (ECalModel *model,
+ GDateWeekday weekday);
+void e_cal_model_set_work_day (ECalModel *model,
+ GDateWeekday weekday,
+ gboolean work_day);
+GDateWeekday e_cal_model_get_work_day_first (ECalModel *model);
+GDateWeekday e_cal_model_get_work_day_last (ECalModel *model);
gint e_cal_model_get_work_day_end_hour
(ECalModel *model);
void e_cal_model_set_work_day_end_hour
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 9d6b07aa13..70437cafcc 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -1077,7 +1077,7 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item,
day_x = day_view->day_offsets[day] - x;
day_w = day_view->day_widths[day];
- if (e_day_view_get_work_day (day_view, weekday)) {
+ if (e_cal_model_get_work_day (model, weekday)) {
if (can_draw_in_region (draw_region, day_x, 0 - y, day_w, work_day_start_y - (0 - y))) {
cairo_save (cr);
gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 1aa55155b1..0bc8cc9045 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -95,7 +95,14 @@
#define E_DAY_VIEW_MAX_ROWS_AT_TOP 6
struct _EDayViewPrivate {
- gint placeholder;
+ ECalModel *model;
+ gulong notify_work_day_monday_handler_id;
+ gulong notify_work_day_tuesday_handler_id;
+ gulong notify_work_day_wednesday_handler_id;
+ gulong notify_work_day_thursday_handler_id;
+ gulong notify_work_day_friday_handler_id;
+ gulong notify_work_day_saturday_handler_id;
+ gulong notify_work_day_sunday_handler_id;
};
typedef struct {
@@ -409,14 +416,7 @@ enum {
PROP_0,
PROP_MARCUS_BAINS_SHOW_LINE,
PROP_MARCUS_BAINS_DAY_VIEW_COLOR,
- PROP_MARCUS_BAINS_TIME_BAR_COLOR,
- PROP_WORK_DAY_MONDAY,
- PROP_WORK_DAY_TUESDAY,
- PROP_WORK_DAY_WEDNESDAY,
- PROP_WORK_DAY_THURSDAY,
- PROP_WORK_DAY_FRIDAY,
- PROP_WORK_DAY_SATURDAY,
- PROP_WORK_DAY_SUNDAY
+ PROP_MARCUS_BAINS_TIME_BAR_COLOR
};
G_DEFINE_TYPE (EDayView, e_day_view, E_TYPE_CALENDAR_VIEW)
@@ -455,10 +455,25 @@ day_view_notify_time_divisions_cb (EDayView *day_view)
static void
day_view_notify_week_start_day_cb (EDayView *day_view)
{
- /* XXX Write a EWorkWeekView subclass, like EMonthView. */
+ /* FIXME Write an EWorkWeekView subclass, like EMonthView. */
+
+ if (day_view->work_week_view)
+ e_day_view_recalc_work_week (day_view);
+}
+
+static void
+day_view_notify_work_day_cb (ECalModel *model,
+ GParamSpec *pspec,
+ EDayView *day_view)
+{
+ /* FIXME Write an EWorkWeekView subclass, like EMonthView. */
if (day_view->work_week_view)
e_day_view_recalc_work_week (day_view);
+
+ /* We have to do this, as the new working days may have no effect on
+ * the days shown, but we still want the background color to change. */
+ gtk_widget_queue_draw (day_view->main_canvas);
}
static void
@@ -685,55 +700,6 @@ day_view_set_property (GObject *object,
E_DAY_VIEW (object),
g_value_get_string (value));
return;
-
- case PROP_WORK_DAY_MONDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_MONDAY,
- g_value_get_boolean (value));
- return;
-
- case PROP_WORK_DAY_TUESDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_TUESDAY,
- g_value_get_boolean (value));
- return;
-
- case PROP_WORK_DAY_WEDNESDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_WEDNESDAY,
- g_value_get_boolean (value));
- return;
-
- case PROP_WORK_DAY_THURSDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_THURSDAY,
- g_value_get_boolean (value));
- return;
-
- case PROP_WORK_DAY_FRIDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_FRIDAY,
- g_value_get_boolean (value));
- return;
-
- case PROP_WORK_DAY_SATURDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_SATURDAY,
- g_value_get_boolean (value));
- return;
-
- case PROP_WORK_DAY_SUNDAY:
- e_day_view_set_work_day (
- E_DAY_VIEW (object),
- G_DATE_SUNDAY,
- g_value_get_boolean (value));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -766,62 +732,6 @@ day_view_get_property (GObject *object,
e_day_view_marcus_bains_get_time_bar_color (
E_DAY_VIEW (object)));
return;
-
- case PROP_WORK_DAY_MONDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_MONDAY));
- return;
-
- case PROP_WORK_DAY_TUESDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_TUESDAY));
- return;
-
- case PROP_WORK_DAY_WEDNESDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_WEDNESDAY));
- return;
-
- case PROP_WORK_DAY_THURSDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_THURSDAY));
- return;
-
- case PROP_WORK_DAY_FRIDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_FRIDAY));
- return;
-
- case PROP_WORK_DAY_SATURDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_SATURDAY));
- return;
-
- case PROP_WORK_DAY_SUNDAY:
- g_value_set_boolean (
- value,
- e_day_view_get_work_day (
- E_DAY_VIEW (object),
- G_DATE_SUNDAY));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -887,6 +797,57 @@ day_view_dispose (GObject *object)
day_view->grabbed_pointer = NULL;
}
+ if (day_view->priv->notify_work_day_monday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_monday_handler_id);
+ day_view->priv->notify_work_day_monday_handler_id = 0;
+ }
+
+ if (day_view->priv->notify_work_day_tuesday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_tuesday_handler_id);
+ day_view->priv->notify_work_day_tuesday_handler_id = 0;
+ }
+
+ if (day_view->priv->notify_work_day_wednesday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_wednesday_handler_id);
+ day_view->priv->notify_work_day_wednesday_handler_id = 0;
+ }
+
+ if (day_view->priv->notify_work_day_thursday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_thursday_handler_id);
+ day_view->priv->notify_work_day_thursday_handler_id = 0;
+ }
+
+ if (day_view->priv->notify_work_day_friday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_friday_handler_id);
+ day_view->priv->notify_work_day_friday_handler_id = 0;
+ }
+
+ if (day_view->priv->notify_work_day_saturday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_saturday_handler_id);
+ day_view->priv->notify_work_day_saturday_handler_id = 0;
+ }
+
+ if (day_view->priv->notify_work_day_sunday_handler_id > 0) {
+ g_signal_handler_disconnect (
+ day_view->priv->model,
+ day_view->priv->notify_work_day_sunday_handler_id);
+ day_view->priv->notify_work_day_sunday_handler_id = 0;
+ }
+
+ g_clear_object (&day_view->priv->model);
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_day_view_parent_class)->dispose (object);
}
@@ -896,6 +857,7 @@ day_view_constructed (GObject *object)
{
EDayView *day_view;
ECalModel *model;
+ gulong handler_id;
day_view = E_DAY_VIEW (object);
@@ -904,6 +866,47 @@ day_view_constructed (GObject *object)
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ /* Keep our own model reference so we can
+ * disconnect signal handlers in dispose(). */
+ day_view->priv->model = g_object_ref (model);
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-monday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_monday_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-tuesday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_tuesday_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-wednesday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_wednesday_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-thursday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_thursday_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-friday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_friday_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-saturday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_saturday_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ model, "notify::work-day-sunday",
+ G_CALLBACK (day_view_notify_work_day_cb), day_view);
+ day_view->priv->notify_work_day_sunday_handler_id = handler_id;
+
+ /* FIXME Should be doing something similar for these handlers. */
+
g_signal_connect_swapped (
day_view, "notify::time-divisions",
G_CALLBACK (day_view_notify_time_divisions_cb), day_view);
@@ -1565,90 +1568,6 @@ e_day_view_class_init (EDayViewClass *class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_MONDAY,
- g_param_spec_boolean (
- "work-day-monday",
- "Work Day: Monday",
- "Whether Monday is a work day",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_TUESDAY,
- g_param_spec_boolean (
- "work-day-tuesday",
- "Work Day: Tuesday",
- "Whether Tuesday is a work day",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_WEDNESDAY,
- g_param_spec_boolean (
- "work-day-wednesday",
- "Work Day: Wednesday",
- "Whether Wednesday is a work day",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_THURSDAY,
- g_param_spec_boolean (
- "work-day-thursday",
- "Work Day: Thursday",
- "Whether Thursday is a work day",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_FRIDAY,
- g_param_spec_boolean (
- "work-day-friday",
- "Work Day: Friday",
- "Whether Friday is a work day",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_SATURDAY,
- g_param_spec_boolean (
- "work-day-saturday",
- "Work Day: Saturday",
- "Whether Saturday is a work day",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_WORK_DAY_SUNDAY,
- g_param_spec_boolean (
- "work-day-sunday",
- "Work Day: Sunday",
- "Whether Sunday is a work day",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
/* init the accessibility support for e_day_view */
e_day_view_a11y_init ();
}
@@ -3056,7 +2975,7 @@ e_day_view_find_work_week_start (EDayView *day_view,
weekday = g_date_get_weekday (&date);
/* Calculate the first working day of the week. */
- first_work_day = e_day_view_get_first_work_day (day_view);
+ first_work_day = e_cal_model_get_work_day_first (model);
if (first_work_day == G_DATE_BAD_WEEKDAY)
first_work_day = e_cal_model_get_week_start_day (model) + 1;
@@ -3161,149 +3080,21 @@ e_day_view_set_days_shown (EDayView *day_view,
e_day_view_update_query (day_view);
}
-gboolean
-e_day_view_get_work_day (EDayView *day_view,
- GDateWeekday weekday)
-{
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE);
- g_return_val_if_fail (g_date_valid_weekday (weekday), FALSE);
-
- return day_view->work_days[weekday];
-}
-
-void
-e_day_view_set_work_day (EDayView *day_view,
- GDateWeekday weekday,
- gboolean work_day)
-{
- g_return_if_fail (E_IS_DAY_VIEW (day_view));
- g_return_if_fail (g_date_valid_weekday (weekday));
-
- if (work_day == day_view->work_days[weekday])
- return;
-
- day_view->work_days[weekday] = work_day;
-
- if (day_view->work_week_view)
- e_day_view_recalc_work_week (day_view);
-
- /* We have to do this, as the new working days may have no effect on
- * the days shown, but we still want the background color to change. */
- gtk_widget_queue_draw (day_view->main_canvas);
-
- switch (weekday) {
- case G_DATE_MONDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-monday");
- break;
- case G_DATE_TUESDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-tuesday");
- break;
- case G_DATE_WEDNESDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-wednesday");
- break;
- case G_DATE_THURSDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-thursday");
- break;
- case G_DATE_FRIDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-friday");
- break;
- case G_DATE_SATURDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-saturday");
- break;
- case G_DATE_SUNDAY:
- g_object_notify (
- G_OBJECT (day_view),
- "work-day-sunday");
- break;
- default:
- g_warn_if_reached ();
- }
-}
-
-/**
- * e_day_view_get_first_work_day:
- * @day_view: an #EDayView
- *
- * Returns the first work day of the week with respect to the week start day.
- * If no work days are set, the function returns %G_DATE_BAD_WEEKDAY.
- *
- * Returns: first work day of the week, or %G_DATE_BAD_WEEKDAY
- **/
-GDateWeekday
-e_day_view_get_first_work_day (EDayView *day_view)
-{
- ECalModel *model;
- GDateWeekday weekday;
- gint ii;
-
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), G_DATE_BAD_WEEKDAY);
-
- model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
- weekday = e_cal_model_get_week_start_day (model) + 1;
-
- for (ii = 0; ii < 7; ii++) {
- if (e_day_view_get_work_day (day_view, weekday))
- return weekday;
- weekday = e_weekday_get_next (weekday);
- }
-
- return G_DATE_BAD_WEEKDAY;
-}
-
-/**
- * e_day_view_get_last_work_day:
- * @day_view: an #EDayView
- *
- * Returns the last work day of the week with respect to the week start day.
- * If no work days are set, the function returns %G_DATE_BAD_WEEKDAY.
- *
- * Returns: last work day of the week, or %G_DATE_BAD_WEEKDAY
- **/
-GDateWeekday
-e_day_view_get_last_work_day (EDayView *day_view)
-{
- ECalModel *model;
- GDateWeekday weekday;
- gint ii;
-
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), G_DATE_BAD_WEEKDAY);
-
- model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
- weekday = e_cal_model_get_week_start_day (model) + 1;
-
- for (ii = 0; ii < 7; ii++) {
- weekday = e_weekday_get_prev (weekday);
- if (e_day_view_get_work_day (day_view, weekday))
- return weekday;
- }
-
- return G_DATE_BAD_WEEKDAY;
-}
-
static void
e_day_view_recalc_work_week_days_shown (EDayView *day_view)
{
+ ECalModel *model;
GDateWeekday first_work_day;
GDateWeekday last_work_day;
gint days_shown;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
/* Find the first working day in the week. */
- first_work_day = e_day_view_get_first_work_day (day_view);
+ first_work_day = e_cal_model_get_work_day_first (model);
if (first_work_day != G_DATE_BAD_WEEKDAY) {
- last_work_day = e_day_view_get_last_work_day (day_view);
+ last_work_day = e_cal_model_get_work_day_last (model);
/* Now calculate the days we need to show to include all the
* working days in the week. Add 1 to make it inclusive. */
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 665cae811d..add238d8b6 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -276,10 +276,6 @@ struct _EDayView {
gint last_hour_shown;
gint last_minute_shown;
- /* Work days. Indices are based on GDateWeekday.
- * The first element (G_DATE_BAD_WEEKDAY) is unused. */
- gboolean work_days[G_DATE_SUNDAY + 1];
-
/* Whether we show the Marcus Bains Line in the main canvas and time canvas. */
gboolean marcus_bains_show_line;
gchar *marcus_bains_day_view_color;
@@ -481,15 +477,6 @@ gint e_day_view_get_days_shown (EDayView *day_view);
void e_day_view_set_days_shown (EDayView *day_view,
gint days_shown);
-/* This specifies the work days in the week. */
-gboolean e_day_view_get_work_day (EDayView *day_view,
- GDateWeekday weekday);
-void e_day_view_set_work_day (EDayView *day_view,
- GDateWeekday weekday,
- gboolean work_day);
-GDateWeekday e_day_view_get_first_work_day (EDayView *day_view);
-GDateWeekday e_day_view_get_last_work_day (EDayView *day_view);
-
/* Whether we display the Marcus Bains Line in the main canvas and time
* canvas. */
void e_day_view_marcus_bains_update (EDayView *day_view);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index a16c782550..f2ee620942 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -963,10 +963,10 @@ get_times_for_views (GnomeCalendar *gcal,
weekday = g_date_get_weekday (&date);
/* Find the first working day of the week. */
- first_work_day = e_day_view_get_first_work_day (day_view);
+ first_work_day = e_cal_model_get_work_day_first (model);
if (first_work_day != G_DATE_BAD_WEEKDAY) {
- last_work_day = e_day_view_get_last_work_day (day_view);
+ last_work_day = e_cal_model_get_work_day_last (model);
/* Now calculate the days we need to show to include
* all the working days in the week. Add 1 to make it