diff options
Diffstat (limited to 'calendar/gui/e-day-view.c')
-rw-r--r-- | calendar/gui/e-day-view.c | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 05f4d1ca64..141d4d33c0 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -182,8 +182,6 @@ static void e_day_view_top_scroll (EDayView *day_view, static void e_day_view_update_top_scroll (EDayView *day_view, gboolean scroll_to_top); -static gboolean e_day_view_check_if_new_event_fits (EDayView *day_view); - static void e_day_view_on_canvas_realized (GtkWidget *widget, EDayView *day_view); @@ -987,6 +985,10 @@ e_day_view_init (EDayView *day_view) /* * Scrollbar. */ + day_view->mc_hscrollbar = gtk_hscrollbar_new (GTK_LAYOUT (day_view->main_canvas)->hadjustment); + gtk_table_attach (GTK_TABLE (day_view), day_view->mc_hscrollbar, 1, 2, 2, 3, GTK_FILL, 0, 0, 0); + gtk_widget_show (day_view->mc_hscrollbar); + day_view->tc_vscrollbar = gtk_vscrollbar_new (GTK_LAYOUT (day_view->top_canvas)->vadjustment); gtk_table_attach (GTK_TABLE (day_view), day_view->tc_vscrollbar, 2, 3, 0, 1, 0, GTK_FILL, 0, 0); @@ -1461,28 +1463,19 @@ e_day_view_style_set (GtkWidget *widget, pango_font_metrics_unref (font_metrics); } -/* This recalculates the sizes of each column. */ static void -e_day_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) +e_day_view_recalc_main_canvas_size (EDayView *day_view) { - EDayView *day_view; gint day, scroll_y; gboolean need_reshape; -#if 0 - g_print ("In e_day_view_size_allocate\n"); -#endif - day_view = E_DAY_VIEW (widget); - - (*GTK_WIDGET_CLASS (e_day_view_parent_class)->size_allocate) (widget, allocation); - - e_day_view_recalc_cell_sizes (day_view); - /* Set the scroll region of the top canvas */ e_day_view_update_top_scroll (day_view, TRUE); need_reshape = e_day_view_update_scroll_regions (day_view); + e_day_view_recalc_cell_sizes (day_view); + /* Scroll to the start of the working day, if this is the initial allocation. */ if (day_view->scroll_to_work_day) { @@ -1503,6 +1496,17 @@ e_day_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } } +/* This recalculates the sizes of each column. */ +static void +e_day_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) +{ +#if 0 + g_print ("In e_day_view_size_allocate\n"); +#endif + (*GTK_WIDGET_CLASS (e_day_view_parent_class)->size_allocate) (widget, allocation); + + e_day_view_recalc_main_canvas_size (E_DAY_VIEW (widget)); +} static void e_day_view_recalc_cell_sizes (EDayView *day_view) @@ -1529,6 +1533,8 @@ e_day_view_recalc_cell_sizes (EDayView *day_view) get divided evenly. Note that we use one more element than the number of columns, to make it easy to get the column widths. */ width = day_view->main_canvas->allocation.width; + if (day_view->days_shown == 1) + width = MAX (width, day_view->max_cols * (E_DAY_VIEW_MIN_DAY_COL_WIDTH + E_DAY_VIEW_GAP_WIDTH) - E_DAY_VIEW_MIN_DAY_COL_WIDTH - 1); width /= day_view->days_shown; offset = 0; for (day = 0; day <= day_view->days_shown; day++) { @@ -2673,12 +2679,21 @@ e_day_view_update_scroll_regions (EDayView *day_view) gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->main_canvas), NULL, NULL, &old_x2, &old_y2); new_x2 = day_view->main_canvas->allocation.width - 1; + + if (day_view->days_shown == 1) + new_x2 = MAX (new_x2, day_view->max_cols * (E_DAY_VIEW_MIN_DAY_COL_WIDTH + E_DAY_VIEW_GAP_WIDTH) - E_DAY_VIEW_MIN_DAY_COL_WIDTH - 1); + if (old_x2 != new_x2 || old_y2 != new_y2) { need_reshape = TRUE; gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->main_canvas), 0, 0, new_x2, new_y2); } + if (new_x2 <= day_view->main_canvas->allocation.width - 1) + gtk_widget_hide (day_view->mc_hscrollbar); + else + gtk_widget_show (day_view->mc_hscrollbar); + return need_reshape; } @@ -4262,13 +4277,13 @@ e_day_view_add_event (ECalComponent *comp, return TRUE; } - /* This lays out the short (less than 1 day) events in the columns. Any long events are simply skipped. */ void e_day_view_check_layout (EDayView *day_view) { gint day, rows_in_top_display; + gint max_cols = -1; /* Don't bother if we aren't visible. */ if (!E_CALENDAR_VIEW (day_view)->in_focus) @@ -4278,11 +4293,17 @@ e_day_view_check_layout (EDayView *day_view) e_day_view_ensure_events_sorted (day_view); for (day = 0; day < day_view->days_shown; day++) { - if (day_view->need_layout[day]) - e_day_view_layout_day_events (day_view->events[day], + if (day_view->need_layout[day]) { + gint cols; + + cols = e_day_view_layout_day_events (day_view->events[day], day_view->rows, day_view->mins_per_row, - day_view->cols_per_row[day]); + day_view->cols_per_row[day], + day_view->days_shown == 1 ? -1 : E_DAY_VIEW_MULTI_DAY_MAX_COLUMNS); + + max_cols = MAX (cols, max_cols); + } if (day_view->need_layout[day] || day_view->need_reshape[day]) { @@ -4308,13 +4329,17 @@ e_day_view_check_layout (EDayView *day_view) } } - if (day_view->long_events_need_layout || day_view->long_events_need_reshape) e_day_view_reshape_long_events (day_view); day_view->long_events_need_layout = FALSE; day_view->long_events_need_reshape = FALSE; + + if (max_cols != -1 && max_cols != day_view->max_cols) { + day_view->max_cols = max_cols; + e_day_view_recalc_main_canvas_size (day_view); + } } @@ -4927,13 +4952,6 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event) if (day_view->selection_start_day == -1) return FALSE; - /* Check if there is room for a new event to be typed in. If there - isn't we don't want to add an event as we will then add a new - event for every key press. */ - if (!e_day_view_check_if_new_event_fits (day_view)) { - return FALSE; - } - /* We only want to start an edit with a return key or a simple character. */ if ((keyval != GDK_Return) && @@ -5581,33 +5599,6 @@ e_day_view_top_scroll (EDayView *day_view, gtk_adjustment_set_value (adj, new_value); } -static gboolean -e_day_view_check_if_new_event_fits (EDayView *day_view) -{ - gint day, start_row, end_row, row; - - day = day_view->selection_start_day; - start_row = day_view->selection_start_row; - end_row = day_view->selection_end_row; - - /* Long events always fit, since we keep adding rows to the top - canvas. */ - if (day != day_view->selection_end_day) - return TRUE; - if (start_row == 0 && end_row == day_view->rows) - return TRUE; - - /* If any of the rows already have E_DAY_VIEW_MAX_COLUMNS columns, - return FALSE. */ - for (row = start_row; row <= end_row; row++) { - if (day_view->cols_per_row[day][row] >= E_DAY_VIEW_MAX_COLUMNS) - return FALSE; - } - - return TRUE; -} - - void e_day_view_ensure_rows_visible (EDayView *day_view, gint start_row, |