aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-03-07 22:07:02 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-03-17 20:49:12 +0800
commit5a7097278a6f6eb2a984d9e0c742342135971c35 (patch)
tree6d3012298a9c09827aae60bb928208485f7f027a /calendar
parent3eef408912de9e67bdae61b22ae6aedf24085c1f (diff)
downloadgsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.tar
gsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.tar.gz
gsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.tar.bz2
gsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.tar.lz
gsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.tar.xz
gsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.tar.zst
gsoc2013-evolution-5a7097278a6f6eb2a984d9e0c742342135971c35.zip
EWeekView: Hide data members which have accessor functions.
It's a start...
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/e-week-view-main-item.c17
-rw-r--r--calendar/gui/e-week-view-titles-item.c9
-rw-r--r--calendar/gui/e-week-view.c281
-rw-r--r--calendar/gui/e-week-view.h22
-rw-r--r--calendar/gui/ea-week-view-cell.c125
-rw-r--r--calendar/gui/ea-week-view-main-item.c36
-rw-r--r--calendar/gui/gnome-cal.c16
-rw-r--r--calendar/gui/print.c28
8 files changed, 285 insertions, 249 deletions
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index 5897deb2bf..e4083fb953 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -74,11 +74,14 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
PangoFontMetrics *font_metrics;
PangoLayout *layout;
gboolean today = FALSE;
+ gboolean multi_week_view;
week_view = e_week_view_main_item_get_week_view (main_item);
model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
style = gtk_widget_get_style (GTK_WIDGET (week_view));
+ multi_week_view = e_week_view_get_multi_week_view (week_view);
+
/* Set up Pango prerequisites */
font_desc = pango_font_description_copy (style->font_desc);
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view));
@@ -119,7 +122,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_TODAY_BACKGROUND];
else if (!e_cal_model_get_work_day (model, weekday))
bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_MONTH_NONWORKING_DAY];
- else if (week_view->multi_week_view && (month % 2 == 0))
+ else if (multi_week_view && (month % 2 == 0))
bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS];
else
bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS];
@@ -162,7 +165,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
cr, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]);
}
- if (week_view->multi_week_view) {
+ if (multi_week_view) {
cairo_rectangle (
cr, x + 2, y + 1,
width - 5,
@@ -186,7 +189,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
* the 1st of each month, otherwise use "10". */
show_day_name = FALSE;
show_month_name = FALSE;
- if (!week_view->multi_week_view) {
+ if (!multi_week_view) {
show_day_name = TRUE;
show_month_name = TRUE;
} else if (day == 0 || day_of_month == 1) {
@@ -234,7 +237,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
if (selected) {
gdk_cairo_set_source_color (
cr, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]);
- } else if (week_view->multi_week_view) {
+ } else if (multi_week_view) {
if (today) {
gdk_cairo_set_source_color (
cr, &week_view->colors[E_WEEK_VIEW_COLOR_TODAY]);
@@ -277,7 +280,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
g_object_unref (layout);
/* Draw the line under the date. */
- if (!week_view->multi_week_view) {
+ if (!multi_week_view) {
cairo_save (cr);
gdk_cairo_set_source_color (
cr, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
@@ -378,13 +381,13 @@ week_view_main_item_draw (GnomeCanvasItem *canvas_item,
g_return_if_fail (week_view != NULL);
/* Step through each of the days. */
- date = week_view->first_day_shown;
+ e_week_view_get_first_day_shown (week_view, &date);
/* If no date has been set, we just use Dec 1999/January 2000. */
if (!g_date_valid (&date))
g_date_set_dmy (&date, 27, 12, 1999);
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days = e_week_view_get_weeks_shown (week_view) * 7;
for (day = 0; day < num_days; day++) {
e_week_view_get_day_position (
week_view, day,
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index 1a1dc30d0f..3081c5ed5d 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -132,6 +132,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
gchar buffer[128];
GtkAllocation allocation;
gboolean abbreviated;
+ gboolean compress_weekend;
gint weekday;
PangoLayout *layout;
@@ -139,6 +140,8 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
week_view = e_week_view_titles_item_get_week_view (titles_item);
g_return_if_fail (week_view != NULL);
+ compress_weekend = e_week_view_get_compress_weekend (week_view);
+
cairo_save (cr);
cairo_set_line_width (cr, 1.0);
@@ -172,7 +175,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
* next day. */
weekday = week_view->display_start_day;
for (col = 0; col < week_view->columns; col++) {
- if (weekday == 5 && week_view->compress_weekend)
+ if (weekday == 5 && compress_weekend)
g_snprintf (
buffer, sizeof (buffer), "%s/%s",
e_get_weekday_name (G_DATE_SATURDAY, TRUE),
@@ -190,7 +193,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
week_view->col_widths[col], allocation.height - 2);
cairo_clip (cr);
- if (weekday == 5 && week_view->compress_weekend)
+ if (weekday == 5 && compress_weekend)
date_width = week_view->abbr_day_widths[5]
+ week_view->slash_width
+ week_view->abbr_day_widths[6];
@@ -231,7 +234,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
cairo_fill (cr);
}
- if (weekday == 5 && week_view->compress_weekend)
+ if (weekday == 5 && compress_weekend)
weekday += 2;
else
weekday++;
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 24bf1f1091..c80d9f3a57 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -78,7 +78,26 @@
#define E_WEEK_VIEW_LAYOUT_TIMEOUT 100
struct _EWeekViewPrivate {
- gint placeholder;
+ /* The first day shown in the view. */
+ GDate first_day_shown;
+
+ /* If we are displaying multiple weeks in rows. If this is
+ * FALSE only one week is shown, with a different layout. */
+ gboolean multi_week_view;
+
+ /* How many weeks we are showing. This is only relevant if
+ * multi_week_view is TRUE. */
+ gint weeks_shown;
+
+ /* If Sat & Sun are compressed. Only applicable in month view,
+ * since they are always compressed into 1 cell in week view. */
+ gboolean compress_weekend;
+
+ /* Whether we show event end times. */
+ gboolean show_event_end_times;
+
+ /* Whether to update the base date when the time range changes. */
+ gboolean update_base_date;
};
typedef struct {
@@ -192,7 +211,7 @@ week_view_process_component (EWeekView *week_view,
gchar *rid = NULL;
/* If we don't have a valid date set yet, just return. */
- if (!g_date_valid (&week_view->first_day_shown))
+ if (!g_date_valid (&week_view->priv->first_day_shown))
return;
comp = e_cal_component_new ();
@@ -355,6 +374,7 @@ week_view_time_range_changed_cb (EWeekView *week_view,
{
GDate date, base_date;
gint day_offset, weekday, week_start_offset;
+ gint num_days;
gboolean update_adjustment_value = FALSE;
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
@@ -378,15 +398,15 @@ week_view_time_range_changed_cb (EWeekView *week_view,
/* See if we need to update the base date. */
if (!g_date_valid (&week_view->base_date)
- || week_view->update_base_date) {
+ || e_week_view_get_update_base_date (week_view)) {
week_view->base_date = base_date;
update_adjustment_value = TRUE;
}
/* See if we need to update the first day shown. */
- if (!g_date_valid (&week_view->first_day_shown)
- || g_date_compare (&week_view->first_day_shown, &base_date)) {
- week_view->first_day_shown = base_date;
+ if (!g_date_valid (&week_view->priv->first_day_shown)
+ || g_date_compare (&week_view->priv->first_day_shown, &base_date)) {
+ week_view->priv->first_day_shown = base_date;
start_time = time_add_day_with_zone (
start_time, -day_offset,
e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
@@ -416,9 +436,11 @@ week_view_time_range_changed_cb (EWeekView *week_view,
gtk_widget_queue_draw (week_view->main_canvas);
+ num_days = e_week_view_get_weeks_shown (week_view) * 7;
+
/* FIXME Preserve selection if possible */
if (week_view->selection_start_day == -1 ||
- (week_view->multi_week_view ? week_view->weeks_shown * 7 : 7) <= week_view->selection_start_day)
+ num_days <= week_view->selection_start_day)
e_calendar_view_set_selected_time_range (
E_CALENDAR_VIEW (week_view), start_time, start_time);
}
@@ -430,12 +452,15 @@ timezone_changed_cb (ECalModel *cal_model,
gpointer user_data)
{
ECalendarView *cal_view = (ECalendarView *) user_data;
+ GDate *first_day_shown;
struct icaltimetype tt = icaltime_null_time ();
time_t lower;
EWeekView *week_view = (EWeekView *) cal_view;
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+ first_day_shown = &week_view->priv->first_day_shown;
+
if (!cal_view->in_focus) {
e_week_view_free_events (week_view);
week_view->requires_update = TRUE;
@@ -443,14 +468,14 @@ timezone_changed_cb (ECalModel *cal_model,
}
/* If we don't have a valid date set yet, just return. */
- if (!g_date_valid (&week_view->first_day_shown))
+ if (!g_date_valid (first_day_shown))
return;
/* Recalculate the new start of the first week. We just use exactly
* the same time, but with the new timezone. */
- tt.year = g_date_get_year (&week_view->first_day_shown);
- tt.month = g_date_get_month (&week_view->first_day_shown);
- tt.day = g_date_get_day (&week_view->first_day_shown);
+ tt.year = g_date_get_year (first_day_shown);
+ tt.month = g_date_get_month (first_day_shown);
+ tt.day = g_date_get_day (first_day_shown);
lower = icaltime_as_timet_with_zone (tt, new_zone);
@@ -463,7 +488,7 @@ week_view_notify_week_start_day_cb (EWeekView *week_view)
{
GDate *first_day_shown;
- first_day_shown = &week_view->first_day_shown;
+ first_day_shown = &week_view->priv->first_day_shown;
e_week_view_recalc_display_start_day (week_view);
@@ -485,8 +510,9 @@ month_scroll_by_week_changed_cb (GSettings *settings,
g_return_if_fail (week_view != NULL);
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (week_view->multi_week_view && week_view->month_scroll_by_week != calendar_config_get_month_scroll_by_week ()) {
- week_view->multi_week_view = FALSE;
+ if (e_week_view_get_multi_week_view (week_view) &&
+ week_view->month_scroll_by_week != calendar_config_get_month_scroll_by_week ()) {
+ week_view->priv->multi_week_view = FALSE;
e_week_view_set_multi_week_view (week_view, TRUE);
}
}
@@ -1235,8 +1261,7 @@ week_view_set_selected_time_range (ECalendarView *cal_view,
}
/* Make sure the selection is valid. */
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
- num_days--;
+ num_days = (e_week_view_get_weeks_shown (week_view) * 7) - 1;
week_view->selection_start_day = CLAMP (
week_view->selection_start_day, 0, num_days);
week_view->selection_end_day = CLAMP (
@@ -1268,10 +1293,11 @@ week_view_get_visible_time_range (ECalendarView *cal_view,
EWeekView *week_view = E_WEEK_VIEW (cal_view);
/* If we don't have a valid date set yet, return FALSE. */
- if (!g_date_valid (&week_view->first_day_shown))
+ if (!g_date_valid (&week_view->priv->first_day_shown))
return FALSE;
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days = e_week_view_get_weeks_shown (week_view) * 7;
+
*start_time = week_view->day_starts[0];
*end_time = week_view->day_starts[num_days];
@@ -1447,6 +1473,10 @@ e_week_view_init (EWeekView *week_view)
gint i;
week_view->priv = E_WEEK_VIEW_GET_PRIVATE (week_view);
+ week_view->priv->weeks_shown = 6;
+ week_view->priv->compress_weekend = TRUE;
+ week_view->priv->show_event_end_times = TRUE;
+ week_view->priv->update_base_date = TRUE;
gtk_widget_set_can_focus (GTK_WIDGET (week_view), TRUE);
@@ -1462,19 +1492,14 @@ e_week_view_init (EWeekView *week_view)
week_view->spans = NULL;
- week_view->multi_week_view = FALSE;
week_view->month_scroll_by_week = FALSE;
week_view->scroll_by_week_notif_id = 0;
- week_view->update_base_date = TRUE;
- week_view->weeks_shown = 6;
week_view->rows = 6;
week_view->columns = 2;
- week_view->compress_weekend = TRUE;
- week_view->show_event_end_times = TRUE;
week_view->display_start_day = 0; /* Monday. */
g_date_clear (&week_view->base_date, 1);
- g_date_clear (&week_view->first_day_shown, 1);
+ g_date_clear (&week_view->priv->first_day_shown, 1);
week_view->row_height = 10;
week_view->rows_per_cell = 1;
@@ -1703,9 +1728,11 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
PangoContext *pango_context;
PangoFontMetrics *font_metrics;
- if (week_view->multi_week_view) {
- week_view->rows = week_view->weeks_shown * 2;
- week_view->columns = week_view->compress_weekend ? 6 : 7;
+ if (e_week_view_get_multi_week_view (week_view)) {
+ week_view->rows =
+ e_week_view_get_weeks_shown (week_view) * 2;
+ week_view->columns =
+ e_week_view_get_compress_weekend (week_view) ? 6 : 7;
} else {
week_view->rows = 6;
week_view->columns = 2;
@@ -1763,8 +1790,8 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
/* Calculate the number of rows of events in each cell, for the large
* cells and the compressed weekend cells. */
- if (week_view->multi_week_view) {
- week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD +
+ if (e_week_view_get_multi_week_view (week_view)) {
+ week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics))
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
+ E_WEEK_VIEW_DATE_B_PAD;
@@ -1799,14 +1826,14 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
week_view->time_format = E_WEEK_VIEW_TIME_NONE;
if (week_view->use_small_font && week_view->small_font_desc) {
- if (week_view->show_event_end_times
- && width / 2 > time_width * 2 + E_WEEK_VIEW_EVENT_TIME_SPACING)
+ if (e_week_view_get_show_event_end_times (week_view) &&
+ width / 2 > time_width * 2 + E_WEEK_VIEW_EVENT_TIME_SPACING)
week_view->time_format = E_WEEK_VIEW_TIME_BOTH_SMALL_MIN;
else if (width / 2 > time_width)
week_view->time_format = E_WEEK_VIEW_TIME_START_SMALL_MIN;
} else {
- if (week_view->show_event_end_times
- && width / 2 > time_width * 2 + E_WEEK_VIEW_EVENT_TIME_SPACING)
+ if (e_week_view_get_show_event_end_times (week_view) &&
+ width / 2 > time_width * 2 + E_WEEK_VIEW_EVENT_TIME_SPACING)
week_view->time_format = E_WEEK_VIEW_TIME_BOTH;
else if (width / 2 > time_width)
week_view->time_format = E_WEEK_VIEW_TIME_START;
@@ -1906,32 +1933,35 @@ e_week_view_set_selected_time_range_visible (EWeekView *week_view,
time_t start_time,
time_t end_time)
{
+ GDate *first_day_shown;
GDate date, end_date;
gint num_days;
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+ first_day_shown = &week_view->priv->first_day_shown;
+
time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
/* Set the selection to the given days. */
- week_view->selection_start_day = g_date_get_julian (&date)
- - g_date_get_julian (&week_view->first_day_shown);
+ week_view->selection_start_day =
+ g_date_get_julian (&date) -
+ g_date_get_julian (first_day_shown);
if (end_time == start_time
|| end_time <= time_add_day_with_zone (start_time, 1,
e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))))
week_view->selection_end_day = week_view->selection_start_day;
else {
time_to_gdate_with_zone (&end_date, end_time - 60, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
- week_view->selection_end_day = g_date_get_julian (&end_date)
- - g_date_get_julian (&week_view->first_day_shown);
+ week_view->selection_end_day =
+ g_date_get_julian (&end_date) -
+ g_date_get_julian (first_day_shown);
}
/* Make sure the selection is valid. */
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
- num_days--;
+ num_days = (e_week_view_get_weeks_shown (week_view) * 7) - 1;
week_view->selection_start_day = CLAMP (
- week_view->selection_start_day,
- 0, num_days);
+ week_view->selection_start_day, 0, num_days);
week_view->selection_end_day = CLAMP (
week_view->selection_end_day,
week_view->selection_start_day,
@@ -1945,7 +1975,7 @@ void
e_week_view_get_first_day_shown (EWeekView *week_view,
GDate *date)
{
- *date = week_view->first_day_shown;
+ *date = week_view->priv->first_day_shown;
}
/* This sets the first day shown in the view. It will be rounded down to the
@@ -1992,9 +2022,9 @@ e_week_view_set_first_day_shown (EWeekView *week_view,
}
/* See if we need to update the first day shown. */
- if (!g_date_valid (&week_view->first_day_shown)
- || g_date_compare (&week_view->first_day_shown, &base_date)) {
- week_view->first_day_shown = base_date;
+ if (!g_date_valid (&week_view->priv->first_day_shown)
+ || g_date_compare (&week_view->priv->first_day_shown, &base_date)) {
+ week_view->priv->first_day_shown = base_date;
start_tt.year = g_date_get_year (&base_date);
start_tt.month = g_date_get_month (&base_date);
@@ -2017,9 +2047,7 @@ e_week_view_set_first_day_shown (EWeekView *week_view,
- g_date_get_julian (&base_date);
/* Make sure the selection is valid. */
- num_days = week_view->multi_week_view
- ? week_view->weeks_shown * 7 : 7;
- num_days--;
+ num_days = (e_week_view_get_weeks_shown (week_view) * 7) - 1;
week_view->selection_start_day = CLAMP (
week_view->selection_start_day, 0, num_days);
week_view->selection_end_day = CLAMP (
@@ -2052,7 +2080,7 @@ e_week_view_recalc_day_starts (EWeekView *week_view,
gint num_days, day;
time_t tmp_time;
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days = e_week_view_get_weeks_shown (week_view) * 7;
tmp_time = lower;
week_view->day_starts[0] = tmp_time;
@@ -2069,7 +2097,7 @@ e_week_view_get_multi_week_view (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
- return week_view->multi_week_view;
+ return week_view->priv->multi_week_view;
}
void
@@ -2082,10 +2110,10 @@ e_week_view_set_multi_week_view (EWeekView *week_view,
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (week_view->multi_week_view == multi_week_view)
+ if (multi_week_view == week_view->priv->multi_week_view)
return;
- week_view->multi_week_view = multi_week_view;
+ week_view->priv->multi_week_view = multi_week_view;
if (multi_week_view) {
gtk_widget_show (week_view->titles_canvas);
@@ -2120,10 +2148,10 @@ e_week_view_set_multi_week_view (EWeekView *week_view,
e_week_view_recalc_display_start_day (week_view);
e_week_view_recalc_cell_sizes (week_view);
- if (g_date_valid (&week_view->first_day_shown))
+ if (g_date_valid (&week_view->priv->first_day_shown))
e_week_view_set_first_day_shown (
week_view,
- &week_view->first_day_shown);
+ &week_view->priv->first_day_shown);
}
gboolean
@@ -2131,7 +2159,7 @@ e_week_view_get_update_base_date (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
- return week_view->update_base_date;
+ return week_view->priv->update_base_date;
}
void
@@ -2140,7 +2168,7 @@ e_week_view_set_update_base_date (EWeekView *week_view,
{
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- week_view->update_base_date = update_base_date;
+ week_view->priv->update_base_date = update_base_date;
}
gint
@@ -2148,7 +2176,11 @@ e_week_view_get_weeks_shown (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), 1);
- return week_view->weeks_shown;
+ /* Give a sensible answer for single-week view. */
+ if (!e_week_view_get_multi_week_view (week_view))
+ return 1;
+
+ return week_view->priv->weeks_shown;
}
void
@@ -2163,12 +2195,12 @@ e_week_view_set_weeks_shown (EWeekView *week_view,
weeks_shown = MIN (weeks_shown, E_WEEK_VIEW_MAX_WEEKS);
- if (week_view->weeks_shown == weeks_shown)
+ if (weeks_shown == week_view->priv->weeks_shown)
return;
- week_view->weeks_shown = weeks_shown;
+ week_view->priv->weeks_shown = weeks_shown;
- if (week_view->multi_week_view) {
+ if (e_week_view_get_multi_week_view (week_view)) {
if (week_view->month_scroll_by_week) {
page_increment = 1;
page_size = 1;
@@ -2184,8 +2216,10 @@ e_week_view_set_weeks_shown (EWeekView *week_view,
e_week_view_recalc_cell_sizes (week_view);
- if (g_date_valid (&week_view->first_day_shown))
- e_week_view_set_first_day_shown (week_view, &week_view->first_day_shown);
+ if (g_date_valid (&week_view->priv->first_day_shown))
+ e_week_view_set_first_day_shown (
+ week_view,
+ &week_view->priv->first_day_shown);
e_week_view_update_query (week_view);
}
@@ -2196,7 +2230,7 @@ e_week_view_get_compress_weekend (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
- return week_view->compress_weekend;
+ return week_view->priv->compress_weekend;
}
void
@@ -2207,13 +2241,13 @@ e_week_view_set_compress_weekend (EWeekView *week_view,
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (week_view->compress_weekend == compress_weekend)
+ if (compress_weekend == week_view->priv->compress_weekend)
return;
- week_view->compress_weekend = compress_weekend;
+ week_view->priv->compress_weekend = compress_weekend;
/* The option only affects the month view. */
- if (!week_view->multi_week_view)
+ if (!e_week_view_get_multi_week_view (week_view))
return;
e_week_view_recalc_cell_sizes (week_view);
@@ -2225,8 +2259,10 @@ e_week_view_set_compress_weekend (EWeekView *week_view,
* do a reshape. */
if (need_reload) {
/* Recalculate the days shown and reload if necessary. */
- if (g_date_valid (&week_view->first_day_shown))
- e_week_view_set_first_day_shown (week_view, &week_view->first_day_shown);
+ if (g_date_valid (&week_view->priv->first_day_shown))
+ e_week_view_set_first_day_shown (
+ week_view,
+ &week_view->priv->first_day_shown);
} else {
week_view->events_need_reshape = TRUE;
e_week_view_check_layout (week_view);
@@ -2244,7 +2280,7 @@ e_week_view_get_show_event_end_times (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), TRUE);
- return week_view->show_event_end_times;
+ return week_view->priv->show_event_end_times;
}
void
@@ -2253,10 +2289,10 @@ e_week_view_set_show_event_end_times (EWeekView *week_view,
{
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (week_view->show_event_end_times == show_event_end_times)
+ if (show_event_end_times == week_view->priv->show_event_end_times)
return;
- week_view->show_event_end_times = show_event_end_times;
+ week_view->priv->show_event_end_times = show_event_end_times;
e_week_view_recalc_cell_sizes (week_view);
week_view->events_need_reshape = TRUE;
e_week_view_check_layout (week_view);
@@ -2282,9 +2318,13 @@ e_week_view_recalc_display_start_day (EWeekView *week_view)
* is Sunday. */
display_start_day = week_start_day;
- if (display_start_day == 6
- && (!week_view->multi_week_view || week_view->compress_weekend))
- display_start_day = 5;
+ if (display_start_day == 6) {
+ if (!e_week_view_get_multi_week_view (week_view))
+ display_start_day = 5;
+
+ if (e_week_view_get_compress_weekend (week_view))
+ display_start_day = 5;
+ }
if (week_view->display_start_day != display_start_day) {
week_view->display_start_day = display_start_day;
@@ -2450,10 +2490,10 @@ e_week_view_get_day_position (EWeekView *week_view,
e_week_view_layout_get_day_position (
day,
- week_view->multi_week_view,
- week_view->weeks_shown,
+ e_week_view_get_multi_week_view (week_view),
+ e_week_view_get_weeks_shown (week_view),
week_view->display_start_day,
- week_view->compress_weekend,
+ e_week_view_get_compress_weekend (week_view),
&cell_x, &cell_y, &cell_h);
*day_x = week_view->col_offsets[cell_x];
@@ -2504,13 +2544,14 @@ e_week_view_get_span_position (EWeekView *week_view,
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
- if (!e_week_view_layout_get_span_position (event, span,
- week_view->rows_per_cell,
- week_view->rows_per_compressed_cell,
- week_view->display_start_day,
- week_view->multi_week_view,
- week_view->compress_weekend,
- &num_days)) {
+ if (!e_week_view_layout_get_span_position (
+ event, span,
+ week_view->rows_per_cell,
+ week_view->rows_per_compressed_cell,
+ week_view->display_start_day,
+ e_week_view_get_multi_week_view (week_view),
+ e_week_view_get_compress_weekend (week_view),
+ &num_days)) {
return FALSE;
}
@@ -2799,11 +2840,11 @@ e_week_view_convert_position_to_day (EWeekView *week_view,
return -1;
/* Now convert the grid position to a week and day. */
- if (week_view->multi_week_view) {
+ if (e_week_view_get_multi_week_view (week_view)) {
week = grid_y / 2;
day = grid_x;
- if (week_view->compress_weekend) {
+ if (e_week_view_get_compress_weekend (week_view)) {
weekend_col = (5 + 7 - week_view->display_start_day) % 7;
if (grid_x > weekend_col
|| (grid_x == weekend_col && grid_y % 2 == 1))
@@ -2817,7 +2858,7 @@ e_week_view_convert_position_to_day (EWeekView *week_view,
e_week_view_layout_get_day_position (
day, FALSE, 1,
week_view->display_start_day,
- week_view->compress_weekend,
+ e_week_view_get_compress_weekend (week_view),
&day_x, &day_y, &rows);
if (grid_x == day_x && grid_y >= day_y && grid_y < day_y + rows)
@@ -2907,7 +2948,7 @@ e_week_view_free_events (EWeekView *week_view)
}
/* Clear the number of rows used per day. */
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days = e_week_view_get_weeks_shown (week_view) * 7;
for (day = 0; day <= num_days; day++) {
week_view->rows_per_day[day] = 0;
}
@@ -2935,15 +2976,7 @@ e_week_view_add_event (ECalComponent *comp,
add_event_data = data;
/* Check that the event times are valid. */
- num_days = add_event_data->week_view->multi_week_view ? add_event_data->week_view->weeks_shown * 7 : 7;
-
- /*if (start > end || start >= add_event_data->week_view->day_starts[num_days] || end <= add_event_data->week_view->day_starts[0]) {
- g_print ("%s: week_view:%p\n", G_STRFUNC, add_event_data->week_view);
- g_print ("\tstart: %s", ctime (&start));
- g_print ("\tend: %s", ctime (&end));
- g_print ("\tday_starts[0]: %s", ctime (&add_event_data->week_view->day_starts[0]));
- g_print ("\tday_starts[%d]: %s\n", num_days, ctime (&add_event_data->week_view->day_starts[num_days]));
- }*/
+ num_days = e_week_view_get_weeks_shown (add_event_data->week_view) * 7;
g_return_val_if_fail (start <= end, TRUE);
g_return_val_if_fail (start < add_event_data->week_view->day_starts[num_days], TRUE);
@@ -3012,14 +3045,15 @@ e_week_view_check_layout (EWeekView *week_view)
e_week_view_ensure_events_sorted (week_view);
if (week_view->events_need_layout)
- week_view->spans = e_week_view_layout_events
- (week_view->events, week_view->spans,
- week_view->multi_week_view,
- week_view->weeks_shown,
- week_view->compress_weekend,
- week_view->display_start_day,
- week_view->day_starts,
- week_view->rows_per_day);
+ week_view->spans = e_week_view_layout_events (
+ week_view->events,
+ week_view->spans,
+ e_week_view_get_multi_week_view (week_view),
+ e_week_view_get_weeks_shown (week_view),
+ e_week_view_get_compress_weekend (week_view),
+ week_view->display_start_day,
+ week_view->day_starts,
+ week_view->rows_per_day);
if (week_view->events_need_layout || week_view->events_need_reshape)
e_week_view_reshape_events (week_view);
@@ -3103,12 +3137,13 @@ e_week_view_reshape_events (EWeekView *week_view)
}
/* Reshape the jump buttons and show/hide them as appropriate. */
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days = e_week_view_get_weeks_shown (week_view) * 7;
for (day = 0; day < num_days; day++) {
is_weekend = ((week_view->display_start_day + day) % 7 >= 5) ? TRUE : FALSE;
- if (!is_weekend || (week_view->multi_week_view
- && !week_view->compress_weekend))
+ if (!is_weekend || (
+ e_week_view_get_multi_week_view (week_view)
+ && !e_week_view_get_compress_weekend (week_view)))
max_rows = week_view->rows_per_cell;
else
max_rows = week_view->rows_per_compressed_cell;
@@ -3988,20 +4023,14 @@ e_week_view_event_move (ECalendarView *cal_view,
if (is_all_day)
current_end_day--;
- if (current_start_day < 0) {
+ if (current_start_day < 0)
+ return TRUE;
+
+ if (current_end_day >= e_week_view_get_weeks_shown (week_view) * 7)
return TRUE;
- }
- if (week_view->multi_week_view) {
- if (current_end_day >= week_view->weeks_shown * 7) {
- return TRUE;
- }
- }else {
- if (current_end_day >= 7) {
- return TRUE;
- }
- }
e_week_view_change_event_time (week_view, start_dt, end_dt, is_all_day);
+
return TRUE;
}
@@ -4565,13 +4594,13 @@ e_week_view_do_key_press (GtkWidget *widget,
stop_emission = TRUE;
switch (keyval) {
case GDK_KEY_Page_Up:
- if (!week_view->multi_week_view)
+ if (!e_week_view_get_multi_week_view (week_view))
e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_UP);
else
e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_PAGE_UP);
break;
case GDK_KEY_Page_Down:
- if (!week_view->multi_week_view)
+ if (!e_week_view_get_multi_week_view (week_view))
e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_DOWN);
else
e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
@@ -4637,20 +4666,14 @@ static gint
e_week_view_get_adjust_days_for_move_up (EWeekView *week_view,
gint current_day)
{
- if (week_view->multi_week_view)
- return -7;
- else
- return 0;
+ return e_week_view_get_multi_week_view (week_view) ? -7 : 0;
}
static gint
e_week_view_get_adjust_days_for_move_down (EWeekView *week_view,
gint current_day)
{
- if (week_view->multi_week_view)
- return 7;
- else
- return 0;
+ return e_week_view_get_multi_week_view (week_view) ? 7 : 0;
}
static gint
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 7199254eaf..ae528b3298 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -204,30 +204,10 @@ struct _EWeekView {
/* The base date, where the adjustment value is 0. */
GDate base_date;
- /* The first day shown in the view. */
- GDate first_day_shown;
-
- /* If we are displaying multiple weeks in rows. If this is FALSE only
- * one week is shown, with a different layout. */
- gboolean multi_week_view;
-
/* TRUE when requires scrolling by a week in a multi_week_view */
gboolean month_scroll_by_week;
guint scroll_by_week_notif_id;
- gboolean update_base_date;
-
- /* How many weeks we are showing. This is only relevant if
- * display_month is TRUE. */
- gint weeks_shown;
-
- /* If Sat & Sun are compressed. Only applicable in month view, since
- * they are always compressed into 1 cell in the week view. */
- gboolean compress_weekend;
-
- /* Whether we use show event end times. */
- gboolean show_event_end_times;
-
/* The first day of the week we display, 0 (Monday) to 6 (Sunday).
* This will usually be week_start_day, but if the weekend is
* compressed, and week_start_day is Sunday we have to use Saturday. */
@@ -387,7 +367,7 @@ void e_week_view_set_update_base_date (EWeekView *week_view,
gboolean update_base_date);
/* The number of weeks shown in the multi-week view. */
-gint e_week_view_get_weeks_shown (EWeekView *week_view);
+gint e_week_view_get_weeks_shown (EWeekView *week_view);
void e_week_view_set_weeks_shown (EWeekView *week_view,
gint weeks_shown);
diff --git a/calendar/gui/ea-week-view-cell.c b/calendar/gui/ea-week-view-cell.c
index d888b47774..6ef8e15f14 100644
--- a/calendar/gui/ea-week-view-cell.c
+++ b/calendar/gui/ea-week-view-cell.c
@@ -70,8 +70,8 @@ e_week_view_cell_class_init (EWeekViewCellClass *class)
EWeekViewCell *
e_week_view_cell_new (EWeekView *week_view,
- gint row,
- gint column)
+ gint row,
+ gint column)
{
GObject *object;
EWeekViewCell *cell;
@@ -345,17 +345,18 @@ atk_component_interface_init (AtkComponentIface *iface)
static void
component_interface_get_extents (AtkComponent *component,
- gint *x,
- gint *y,
- gint *width,
- gint *height,
- AtkCoordType coord_type)
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type)
{
GObject *g_obj;
AtkObject *atk_obj;
EWeekViewCell *cell;
EWeekView *week_view;
GtkWidget *main_canvas;
+ gboolean compress_weekend;
gint week_view_width, week_view_height;
gint scroll_x, scroll_y;
gint start_day;
@@ -373,6 +374,8 @@ component_interface_get_extents (AtkComponent *component,
week_view = cell->week_view;
main_canvas = cell->week_view->main_canvas;
+ compress_weekend = e_week_view_get_compress_weekend (week_view);
+
atk_obj = atk_gobject_accessible_for_object (G_OBJECT (main_canvas));
atk_component_get_extents (
ATK_COMPONENT (atk_obj),
@@ -383,85 +386,85 @@ component_interface_get_extents (AtkComponent *component,
GNOME_CANVAS (week_view->main_canvas),
&scroll_x, &scroll_y);
start_day = week_view->display_start_day;
- if (week_view->multi_week_view) {
- if (week_view->compress_weekend && (cell->column == (5 - start_day))) {
- *height = week_view->row_heights[cell->row*2];
+ if (e_week_view_get_multi_week_view (week_view)) {
+ if (compress_weekend && (cell->column == (5 - start_day))) {
+ *height = week_view->row_heights[cell->row*2];
*width = week_view->col_widths[cell->column];
*x += week_view->col_offsets[cell->column] - scroll_x;
*y += week_view->row_offsets[cell->row*2]- scroll_y;
- } else if (week_view->compress_weekend && (cell->column == (6 - start_day))) {
- *height = week_view->row_heights[cell->row*2];
- *width = week_view->col_widths[cell->column - 1];
- *x += week_view->col_offsets[cell->column - 1]- scroll_x;
- *y += week_view->row_offsets[cell->row*2 + 1]- scroll_y;
- } else if (week_view->compress_weekend && (cell->column > (6 - start_day))) {
- *height = week_view->row_heights[cell->row*2]*2;
- *width = week_view->col_widths[cell->column - 1];
- *x += week_view->col_offsets[cell->column - 1] - scroll_x;
- *y += week_view->row_offsets[cell->row*2]- scroll_y;
+ } else if (compress_weekend && (cell->column == (6 - start_day))) {
+ *height = week_view->row_heights[cell->row*2];
+ *width = week_view->col_widths[cell->column - 1];
+ *x += week_view->col_offsets[cell->column - 1]- scroll_x;
+ *y += week_view->row_offsets[cell->row*2 + 1]- scroll_y;
+ } else if (compress_weekend && (cell->column > (6 - start_day))) {
+ *height = week_view->row_heights[cell->row*2]*2;
+ *width = week_view->col_widths[cell->column - 1];
+ *x += week_view->col_offsets[cell->column - 1] - scroll_x;
+ *y += week_view->row_offsets[cell->row*2]- scroll_y;
} else {
*height = week_view->row_heights[cell->row*2]*2;
- *width = week_view->col_widths[cell->column];
+ *width = week_view->col_widths[cell->column];
*x += week_view->col_offsets[cell->column] - scroll_x;
*y += week_view->row_offsets[cell->row*2]- scroll_y;
}
} else {
if (start_day < 3) {
if (cell->column < 3) {
- *height = week_view->row_heights[cell->column*2]*2;
- *width = week_view->col_widths[0];
- *x += week_view->col_offsets[0] - scroll_x;
- *y += week_view->row_offsets[cell->column*2]- scroll_y;
+ *height = week_view->row_heights[cell->column*2]*2;
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2]- scroll_y;
} else {
if (cell->column == 5 - start_day) {
- *height = week_view->row_heights[(cell->column - 3)*2];
- *width = week_view->col_widths[1];
- *x += week_view->col_offsets[1] - scroll_x;
- *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 3)*2];
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y;
} else if (cell->column == 6 - start_day) {
- *height = week_view->row_heights[(cell->column - 4)*2];
- *width = week_view->col_widths[1];
- *x += week_view->col_offsets[1] - scroll_x;
- *y += week_view->row_offsets[(cell->column - 3)*2 - 1]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 4)*2];
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 3)*2 - 1]- scroll_y;
} else if (cell->column > 6 - start_day) {
- *height = week_view->row_heights[(cell->column - 4)*2]*2;
- *width = week_view->col_widths[1];
- *x += week_view->col_offsets[1] - scroll_x;
- *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 4)*2]*2;
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y;
} else {
- *height = week_view->row_heights[(cell->column - 3)*2]*2;
- *width = week_view->col_widths[1];
- *x += week_view->col_offsets[1] - scroll_x;
- *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 3)*2]*2;
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y;
}
}
} else if (cell->column < 4) {
if (cell->column == 5 - start_day) {
- *height = week_view->row_heights[cell->column*2];
- *width = week_view->col_widths[0];
- *x += week_view->col_offsets[0] - scroll_x;
- *y += week_view->row_offsets[cell->column*2]- scroll_y;
+ *height = week_view->row_heights[cell->column*2];
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2]- scroll_y;
} else if (cell->column == 6 - start_day) {
- *height = week_view->row_heights[(cell->column - 1)*2];
- *width = week_view->col_widths[0];
- *x += week_view->col_offsets[0] - scroll_x;
- *y += week_view->row_offsets[cell->column*2 - 1]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 1)*2];
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2 - 1]- scroll_y;
} else if (cell->column > 6 - start_day) {
- *height = week_view->row_heights[(cell->column - 1)*2]*2;
- *width = week_view->col_widths[0];
- *x += week_view->col_offsets[0] - scroll_x;
- *y += week_view->row_offsets[(cell->column - 1)*2]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 1)*2]*2;
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 1)*2]- scroll_y;
} else {
- *height = week_view->row_heights[(cell->column)*2]*2;
- *width = week_view->col_widths[0];
- *x += week_view->col_offsets[0] - scroll_x;
- *y += week_view->row_offsets[cell->column*2]- scroll_y;
+ *height = week_view->row_heights[(cell->column)*2]*2;
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2]- scroll_y;
}
} else {
- *height = week_view->row_heights[(cell->column - 4)*2]*2;
- *width = week_view->col_widths[1];
- *x += week_view->col_offsets[1] - scroll_x;
- *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y;
+ *height = week_view->row_heights[(cell->column - 4)*2]*2;
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y;
}
}
}
diff --git a/calendar/gui/ea-week-view-main-item.c b/calendar/gui/ea-week-view-main-item.c
index 816660cb3f..3aa571d3a9 100644
--- a/calendar/gui/ea-week-view-main-item.c
+++ b/calendar/gui/ea-week-view-main-item.c
@@ -372,10 +372,7 @@ ea_week_view_main_item_get_n_children (AtkObject *accessible)
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
- if (week_view->multi_week_view)
- return 7 * week_view->weeks_shown;
- else
- return 7;
+ return e_week_view_get_weeks_shown (week_view) * 7;
}
static AtkObject *
@@ -529,6 +526,7 @@ ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
GObject *g_obj;
EWeekViewMainItem *main_item;
EWeekView *week_view;
+ gint weeks_shown;
g_return_val_if_fail (ea_main_item, -1);
@@ -539,9 +537,9 @@ ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
- if (row >= 0 && row < week_view->weeks_shown &&
- column >= 0 && column < 7)
+ if (row >= 0 && row < weeks_shown && column >= 0 && column < 7)
return row * 7 + column;
return -1;
@@ -619,6 +617,7 @@ ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item)
EWeekViewMainItem *main_item;
EWeekView *week_view;
EaCellTable *cell_data;
+ gint weeks_shown;
g_return_val_if_fail (ea_main_item, NULL);
@@ -629,12 +628,13 @@ ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item)
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
cell_data = g_object_get_data (
G_OBJECT (ea_main_item),
"ea-week-view-cell-table");
if (!cell_data) {
- cell_data = ea_cell_table_create (week_view->weeks_shown, 7, TRUE);
+ cell_data = ea_cell_table_create (weeks_shown, 7, TRUE);
g_object_set_data (
G_OBJECT (ea_main_item),
"ea-week-view-cell-table", cell_data);
@@ -766,7 +766,7 @@ table_interface_get_n_rows (AtkTable *table)
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
- return week_view->weeks_shown;
+ return e_week_view_get_weeks_shown (week_view);
}
static gint
@@ -862,6 +862,7 @@ table_interface_is_row_selected (AtkTable *table,
EWeekViewMainItem *main_item;
EWeekView *week_view;
EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint weeks_shown;
atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
g_obj = atk_gobject_accessible_get_object (atk_gobj);
@@ -870,11 +871,12 @@ table_interface_is_row_selected (AtkTable *table,
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
if (week_view->selection_start_day == -1)
/* no selection */
return FALSE;
- if ((row < 0) && (row + 1 > week_view->weeks_shown))
+ if ((row < 0) && (row + 1 > weeks_shown))
return FALSE;
if (((week_view->selection_start_day < row * 7) &&
(week_view->selection_end_day < row * 7)) ||
@@ -903,6 +905,7 @@ table_interface_is_column_selected (AtkTable *table,
EWeekViewMainItem *main_item;
EWeekView *week_view;
EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint weeks_shown;
atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
g_obj = atk_gobject_accessible_get_object (atk_gobj);
@@ -911,12 +914,13 @@ table_interface_is_column_selected (AtkTable *table,
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
if ((column <0) || (column >6))
return FALSE;
else {
gint i;
- for (i = 0; i < week_view->weeks_shown; i++)
+ for (i = 0; i < weeks_shown; i++)
if ((column + i *7>= week_view->selection_start_day) &&
(column + i *7<= week_view->selection_end_day))
return TRUE;
@@ -1040,6 +1044,7 @@ table_interface_add_column_selection (AtkTable *table,
EWeekViewMainItem *main_item;
EWeekView *week_view;
EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint weeks_shown;
atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
g_obj = atk_gobject_accessible_get_object (atk_gobj);
@@ -1048,11 +1053,12 @@ table_interface_add_column_selection (AtkTable *table,
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
/* FIXME: we need multi-selection */
week_view->selection_start_day = column;
- week_view->selection_end_day = (week_view->weeks_shown - 1) * 7 + column;
+ week_view->selection_end_day = (weeks_shown - 1) * 7 + column;
gtk_widget_queue_draw (week_view->main_canvas);
return TRUE;
@@ -1157,6 +1163,7 @@ table_interface_get_row_description (AtkTable *table,
EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
const gchar *description;
EaCellTable *cell_data;
+ gint weeks_shown;
atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
g_obj = atk_gobject_accessible_get_object (atk_gobj);
@@ -1165,8 +1172,9 @@ table_interface_get_row_description (AtkTable *table,
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
- if (row < 0 || row >= week_view->weeks_shown)
+ if (row < 0 || row >= weeks_shown)
return NULL;
cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
if (!cell_data)
@@ -1213,6 +1221,7 @@ selection_interface_add_selection (AtkSelection *selection,
EWeekViewMainItem *main_item;
EWeekView *week_view;
EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+ gint weeks_shown;
atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
g_obj = atk_gobject_accessible_get_object (atk_gobj);
@@ -1221,8 +1230,9 @@ selection_interface_add_selection (AtkSelection *selection,
main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
week_view = e_week_view_main_item_get_week_view (main_item);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
- if (i < 0 || i > week_view->weeks_shown * 7 -1)
+ if (i < 0 || i > weeks_shown * 7 -1)
return FALSE;
/*FIXME: multi-selection is needed */
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index f2ee620942..bcf0fb7ce7 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -221,6 +221,7 @@ update_adjustment (GnomeCalendar *gcal,
EWeekView *week_view)
{
GDate date;
+ GDate first_day_shown;
ECalModel *model;
gint week_offset;
struct icaltimetype start_tt = icaltime_null_time ();
@@ -229,8 +230,10 @@ update_adjustment (GnomeCalendar *gcal,
icaltimezone *timezone;
gdouble value;
+ e_week_view_get_first_day_shown (week_view, &first_day_shown);
+
/* If we don't have a valid date set yet, just return. */
- if (!g_date_valid (&week_view->first_day_shown))
+ if (!g_date_valid (&first_day_shown))
return;
value = gtk_adjustment_get_value (adjustment);
@@ -241,7 +244,7 @@ update_adjustment (GnomeCalendar *gcal,
g_date_add_days (&date, week_offset * 7);
/* Convert the old & new first days shown to julian values. */
- old_first_day_julian = g_date_get_julian (&week_view->first_day_shown);
+ old_first_day_julian = g_date_get_julian (&first_day_shown);
new_first_day_julian = g_date_get_julian (&date);
/* If we are already showing the date, just return. */
@@ -1022,7 +1025,7 @@ get_times_for_views (GnomeCalendar *gcal,
display_start = (week_view->display_start_day + 1) % 7;
if (!range_selected && (
- !week_view->multi_week_view ||
+ !e_week_view_get_multi_week_view (week_view) ||
!week_view->month_scroll_by_week))
*start_time = time_month_begin_with_zone (
*start_time, timezone);
@@ -2203,7 +2206,7 @@ gnome_calendar_update_date_navigator (GnomeCalendar *gcal)
GnomeCalendarPrivate *priv;
ECalModel *model;
time_t start, end;
- gint week_start_day;
+ GDateWeekday week_start_day;
GDate start_date, end_date;
icaltimezone *timezone;
@@ -2230,8 +2233,9 @@ gnome_calendar_update_date_navigator (GnomeCalendar *gcal)
if (priv->current_view_type == GNOME_CAL_MONTH_VIEW) {
EWeekView *week_view = E_WEEK_VIEW (priv->views[priv->current_view_type]);
- if (week_start_day == 0
- && (!week_view->multi_week_view || week_view->compress_weekend))
+ if (week_start_day == G_DATE_MONDAY &&
+ (!e_week_view_get_multi_week_view (week_view) ||
+ e_week_view_get_compress_weekend (week_view)))
g_date_add_days (&start_date, 1);
}
time_to_gdate_with_zone (&end_date, end, timezone);
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index c9e48a520c..0e60f84e29 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -2277,15 +2277,20 @@ print_month_summary (GtkPrintContext *context,
GnomeCalendarViewType view_type;
ECalendarView *calendar_view;
EWeekView *week_view;
+ GDate first_day_shown;
+ gboolean multi_week_view;
+ gint weeks_shown;
view_type = gnome_calendar_get_view (gcal);
calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
week_view = E_WEEK_VIEW (calendar_view);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
+ multi_week_view = e_week_view_get_multi_week_view (week_view);
+ e_week_view_get_first_day_shown (week_view, &first_day_shown);
- if (week_view && week_view->multi_week_view
- && !(week_view->weeks_shown >= 4 &&
- g_date_valid (&week_view->first_day_shown))) {
- weeks = week_view->weeks_shown;
+ if (multi_week_view && !(weeks_shown >= 4 &&
+ g_date_valid (&first_day_shown))) {
+ weeks = weeks_shown;
date = whence;
}
}
@@ -3374,16 +3379,21 @@ print_calendar (GnomeCalendar *gcal,
GnomeCalendarViewType view_type;
ECalendarView *calendar_view;
EWeekView *week_view;
+ GDate date;
+ gboolean multi_week_view;
+ gint weeks_shown;
view_type = gnome_calendar_get_view (gcal);
calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
week_view = E_WEEK_VIEW (calendar_view);
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
+ multi_week_view = e_week_view_get_multi_week_view (week_view);
+ e_week_view_get_first_day_shown (week_view, &date);
- if (week_view && week_view->multi_week_view &&
- week_view->weeks_shown >= 4 &&
- g_date_valid (&week_view->first_day_shown)) {
+ if (multi_week_view &&
+ weeks_shown >= 4 &&
+ g_date_valid (&date)) {
- GDate date = week_view->first_day_shown;
struct icaltimetype start_tt;
g_date_add_days (&date, 7);
@@ -3395,7 +3405,7 @@ print_calendar (GnomeCalendar *gcal,
start_tt.day = g_date_get_day (&date);
start = icaltime_as_timet (start_tt);
- } else if (week_view && week_view->multi_week_view) {
+ } else if (multi_week_view) {
start = week_view->day_starts[0];
}
}