aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-week-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/e-week-view.c')
-rw-r--r--calendar/gui/e-week-view.c132
1 files changed, 68 insertions, 64 deletions
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 33071fa4c9..ab38f92c1a 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -564,63 +564,14 @@ static void
e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
EWeekView *week_view;
- gint width, height, time_width;
gdouble old_x2, old_y2, new_x2, new_y2;
- GdkFont *font;
week_view = E_WEEK_VIEW (widget);
- font = widget->style->font;
(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
e_week_view_recalc_cell_sizes (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
- + font->ascent + font->descent
- + E_WEEK_VIEW_DATE_B_PAD;
- } else {
- week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD
- + font->ascent + font->descent
- + E_WEEK_VIEW_DATE_LINE_T_PAD + 1
- + E_WEEK_VIEW_DATE_LINE_B_PAD;
- }
-
- height = week_view->row_heights[0];
- week_view->rows_per_cell = (height * 2 - week_view->events_y_offset)
- / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING);
- week_view->rows_per_cell = MIN (week_view->rows_per_cell,
- E_WEEK_VIEW_MAX_ROWS_PER_CELL);
-
- week_view->rows_per_compressed_cell =
- (height - week_view->events_y_offset)
- / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING);
- week_view->rows_per_compressed_cell = MIN (week_view->rows_per_compressed_cell,
- E_WEEK_VIEW_MAX_ROWS_PER_CELL);
-
- /* Determine which time format to use, based on the width of the cells.
- We only allow the time to take up about half of the width. */
- width = week_view->col_widths[0];
-
- week_view->time_format = E_WEEK_VIEW_TIME_NONE;
- if (week_view->use_small_font && week_view->small_font) {
- time_width = week_view->digit_width * 2
- + week_view->small_digit_width * 2;
- if (width / 2 > time_width * 2 + week_view->space_width)
- 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 {
- time_width = week_view->digit_width * 4
- + week_view->colon_width;
- if (width / 2 > time_width * 2 + week_view->space_width)
- week_view->time_format = E_WEEK_VIEW_TIME_BOTH;
- else if (width / 2 > time_width)
- week_view->time_format = E_WEEK_VIEW_TIME_START;
- }
-
/* Set the scroll region of the top canvas to its allocated size. */
gnome_canvas_get_scroll_region (GNOME_CANVAS (week_view->titles_canvas),
NULL, NULL, &old_x2, &old_y2);
@@ -652,8 +603,11 @@ e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
static void
e_week_view_recalc_cell_sizes (EWeekView *week_view)
{
- gfloat width, height, offset;
+ gfloat canvas_width, canvas_height, offset;
gint row, col;
+ GtkWidget *widget;
+ GdkFont *font;
+ gint width, height, time_width;
if (week_view->multi_week_view) {
week_view->rows = week_view->weeks_shown * 2;
@@ -668,12 +622,12 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
number of columns, to make it easy to get the column widths.
We also add one to the width so that the right border of the last
column is off the edge of the displayed area. */
- width = week_view->main_canvas->allocation.width + 1;
- width /= week_view->columns;
+ canvas_width = week_view->main_canvas->allocation.width + 1;
+ canvas_width /= week_view->columns;
offset = 0;
for (col = 0; col <= week_view->columns; col++) {
week_view->col_offsets[col] = floor (offset + 0.5);
- offset += width;
+ offset += canvas_width;
}
/* Calculate the cell widths based on the offsets. */
@@ -683,12 +637,12 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
}
/* Now do the same for the row heights. */
- height = week_view->main_canvas->allocation.height + 1;
- height /= week_view->rows;
+ canvas_height = week_view->main_canvas->allocation.height + 1;
+ canvas_height /= week_view->rows;
offset = 0;
for (row = 0; row <= week_view->rows; row++) {
week_view->row_offsets[row] = floor (offset + 0.5);
- offset += height;
+ offset += canvas_height;
}
/* Calculate the cell heights based on the offsets. */
@@ -696,6 +650,60 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
week_view->row_heights[row] = week_view->row_offsets[row + 1]
- week_view->row_offsets[row];
}
+
+
+ /* If the font hasn't been set yet just return. */
+ widget = GTK_WIDGET (week_view);
+ if (!widget->style || ! widget->style->font)
+ return;
+
+ font = widget->style->font;
+
+ /* 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
+ + font->ascent + font->descent
+ + E_WEEK_VIEW_DATE_B_PAD;
+ } else {
+ week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD
+ + font->ascent + font->descent
+ + E_WEEK_VIEW_DATE_LINE_T_PAD + 1
+ + E_WEEK_VIEW_DATE_LINE_B_PAD;
+ }
+
+ height = week_view->row_heights[0];
+ week_view->rows_per_cell = (height * 2 - week_view->events_y_offset)
+ / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING);
+ week_view->rows_per_cell = MIN (week_view->rows_per_cell,
+ E_WEEK_VIEW_MAX_ROWS_PER_CELL);
+
+ week_view->rows_per_compressed_cell =
+ (height - week_view->events_y_offset)
+ / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING);
+ week_view->rows_per_compressed_cell = MIN (week_view->rows_per_compressed_cell,
+ E_WEEK_VIEW_MAX_ROWS_PER_CELL);
+
+ /* Determine which time format to use, based on the width of the cells.
+ We only allow the time to take up about half of the width. */
+ width = week_view->col_widths[0];
+
+ week_view->time_format = E_WEEK_VIEW_TIME_NONE;
+ if (week_view->use_small_font && week_view->small_font) {
+ time_width = week_view->digit_width * 2
+ + week_view->small_digit_width * 2;
+ if (width / 2 > time_width * 2 + week_view->space_width)
+ 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 {
+ time_width = week_view->digit_width * 4
+ + week_view->colon_width;
+ if (width / 2 > time_width * 2 + week_view->space_width)
+ week_view->time_format = E_WEEK_VIEW_TIME_BOTH;
+ else if (width / 2 > time_width)
+ week_view->time_format = E_WEEK_VIEW_TIME_START;
+ }
}
@@ -1175,10 +1183,6 @@ e_week_view_recalc_day_starts (EWeekView *week_view,
tmp_time = lower;
week_view->day_starts[0] = tmp_time;
for (day = 1; day <= num_days; day++) {
- /* FIXME: There is a bug in time_add_day(). */
-#if 0
- g_print ("Day:%i - %s\n", day, ctime (&tmp_time));
-#endif
tmp_time = time_add_day (tmp_time, 1);
week_view->day_starts[day] = tmp_time;
}
@@ -1297,7 +1301,9 @@ e_week_view_set_compress_weekend (EWeekView *week_view,
if (!week_view->multi_week_view)
return;
- /* FIXME: Need to update layout. */
+ e_week_view_recalc_cell_sizes (week_view);
+ week_view->events_need_reshape = TRUE;
+ e_week_view_check_layout (week_view);
}
@@ -1567,7 +1573,7 @@ e_week_view_on_button_press (GtkWidget *widget,
{
gint x, y, day;
-#if 1
+#if 0
g_print ("In e_week_view_on_button_press\n");
#endif
@@ -1589,8 +1595,6 @@ e_week_view_on_button_press (GtkWidget *widget,
if (week_view->pressed_event_num != -1)
return FALSE;
- g_print ("In e_week_view_on_button_press 2\n");
-
/* Convert the mouse position to a week & day. */
x = event->x;
y = event->y;