aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-day-view.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-08-19 00:59:50 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-08-19 00:59:50 +0800
commit4ffe29bdee5468655dadc306f2761e2ca5469c38 (patch)
tree28f5abf6ec354844815368c96125d1f5189ec656 /calendar/gui/e-day-view.c
parent947e43871f38e1eb87f7556cec7992acb231e842 (diff)
downloadgsoc2013-evolution-4ffe29bdee5468655dadc306f2761e2ca5469c38.tar.gz
gsoc2013-evolution-4ffe29bdee5468655dadc306f2761e2ca5469c38.tar.zst
gsoc2013-evolution-4ffe29bdee5468655dadc306f2761e2ca5469c38.zip
Centralize week-start-day tracking in calendar views.
Track the value in ECalModel instead of in GnomeCalendar, EDayView and EWeekView.
Diffstat (limited to 'calendar/gui/e-day-view.c')
-rw-r--r--calendar/gui/e-day-view.c99
1 files changed, 26 insertions, 73 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index ffd980e23a..cda3d1f92c 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -438,7 +438,6 @@ enum {
PROP_MARCUS_BAINS_DAY_VIEW_COLOR,
PROP_MARCUS_BAINS_TIME_BAR_COLOR,
PROP_MINS_PER_ROW,
- PROP_WEEK_START_DAY,
PROP_WORK_DAY_END_HOUR,
PROP_WORK_DAY_END_MINUTE,
PROP_WORK_DAY_START_HOUR,
@@ -449,6 +448,15 @@ enum {
G_DEFINE_TYPE (EDayView, e_day_view, E_TYPE_CALENDAR_VIEW)
static void
+day_view_notify_week_start_day_cb (EDayView *day_view)
+{
+ /* XXX Write a EWorkWeekView subclass, like EMonthView. */
+
+ if (day_view->work_week_view)
+ e_day_view_recalc_work_week (day_view);
+}
+
+static void
day_view_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -479,12 +487,6 @@ day_view_set_property (GObject *object,
g_value_get_int (value));
return;
- case PROP_WEEK_START_DAY:
- e_day_view_set_week_start_day (
- E_DAY_VIEW (object),
- g_value_get_int (value));
- return;
-
case PROP_WORK_DAY_END_HOUR:
e_day_view_set_work_day_end_hour (
E_DAY_VIEW (object),
@@ -554,13 +556,6 @@ day_view_get_property (GObject *object,
E_DAY_VIEW (object)));
return;
- case PROP_WEEK_START_DAY:
- g_value_set_int (
- value,
- e_day_view_get_week_start_day (
- E_DAY_VIEW (object)));
- return;
-
case PROP_WORK_DAY_END_HOUR:
g_value_set_int (
value,
@@ -632,10 +627,6 @@ day_view_constructed (GObject *object)
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");
@@ -654,6 +645,10 @@ day_view_constructed (GObject *object)
e_binding_new (
G_OBJECT (shell_settings), "cal-working-days-bitset",
G_OBJECT (day_view), "working-days");
+
+ g_signal_connect_swapped (
+ model, "notify::week-start-day",
+ G_CALLBACK (day_view_notify_week_start_day_cb), day_view);
}
static void
@@ -736,18 +731,6 @@ e_day_view_class_init (EDayViewClass *class)
g_object_class_install_property (
object_class,
- PROP_WEEK_START_DAY,
- g_param_spec_int (
- "week-start-day",
- "Week Start Day",
- NULL,
- 0, /* Monday */
- 6, /* Sunday */
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
PROP_WORK_DAY_END_HOUR,
g_param_spec_int (
"work-day-end-hour",
@@ -1103,7 +1086,6 @@ e_day_view_init (EDayView *day_view)
day_view->work_day_end_hour = 17;
day_view->work_day_end_minute = 0;
day_view->show_event_end_times = TRUE;
- day_view->week_start_day = 0;
day_view->scroll_to_work_day = TRUE;
day_view->marcus_bains_show_line = TRUE;
@@ -2459,10 +2441,15 @@ e_day_view_find_work_week_start (EDayView *day_view,
time_t start_time)
{
GDate date;
+ ECalModel *model;
+ gint week_start_day;
gint weekday, day, i;
guint offset;
struct icaltimetype tt = icaltime_null_time ();
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
/* The start of the work-week is the first working day after the
@@ -2474,7 +2461,7 @@ e_day_view_find_work_week_start (EDayView *day_view,
/* Calculate the first working day of the week, 0 (Sun) to 6 (Sat).
It will automatically default to the week start day if no days
are set as working days. */
- day = (day_view->week_start_day + 1) % 7;
+ day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << day))
break;
@@ -2784,11 +2771,16 @@ e_day_view_set_working_days (EDayView *day_view,
static void
e_day_view_recalc_work_week_days_shown (EDayView *day_view)
{
+ ECalModel *model;
+ gint week_start_day;
gint first_day, last_day, i, days_shown;
gboolean has_working_days = FALSE;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
/* Find the first working day in the week, 0 (Sun) to 6 (Sat). */
- first_day = (day_view->week_start_day + 1) % 7;
+ first_day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << first_day)) {
has_working_days = TRUE;
@@ -2799,7 +2791,7 @@ e_day_view_recalc_work_week_days_shown (EDayView *day_view)
if (has_working_days) {
/* Now find the last working day of the week, backwards. */
- last_day = day_view->week_start_day % 7;
+ last_day = week_start_day % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << last_day))
break;
@@ -3012,34 +3004,6 @@ e_day_view_set_show_times_cb (EDayView *day_view,
return TRUE;
}
-/* The first day of the week, 0 (Monday) to 6 (Sunday). */
-gint
-e_day_view_get_week_start_day (EDayView *day_view)
-{
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0);
-
- return day_view->week_start_day;
-}
-
-void
-e_day_view_set_week_start_day (EDayView *day_view,
- gint week_start_day)
-{
- g_return_if_fail (E_IS_DAY_VIEW (day_view));
- g_return_if_fail (week_start_day >= 0);
- g_return_if_fail (week_start_day < 7);
-
- if (day_view->week_start_day == week_start_day)
- return;
-
- day_view->week_start_day = week_start_day;
-
- if (day_view->work_week_view)
- e_day_view_recalc_work_week (day_view);
-
- g_object_notify (G_OBJECT (day_view), "week-start-day");
-}
-
static void
e_day_view_recalc_work_week (EDayView *day_view)
{
@@ -3738,22 +3702,11 @@ e_day_view_on_event_double_click (EDayView *day_view,
}
static void
-popup_destroyed_cb (gpointer data, GObject *where_object_was)
-{
- EDayView *day_view = data;
-
- day_view->popup_event_day = -1;
- day_view->popup_event_num = -1;
-}
-
-static void
e_day_view_show_popup_menu (EDayView *day_view,
GdkEventButton *event,
gint day,
gint event_num)
{
- GtkMenu *popup;
-
day_view->popup_event_day = day;
day_view->popup_event_num = event_num;