From 2219b51a72c7c598777a64f1b39f329c12a7e9c6 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 8 Jul 2000 07:18:47 +0000 Subject: Add mouse wheel scrolling support to the calendar day and week views svn path=/trunk/; revision=3971 --- calendar/gui/e-day-view.c | 48 +++++++++++++++++++++++++++++++++++++++++++++- calendar/gui/e-week-view.c | 14 ++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) (limited to 'calendar/gui') diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index ab789437e7..a0dfb177bb 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -133,6 +133,11 @@ static gboolean e_day_view_on_main_canvas_button_press (GtkWidget *widget, static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget, GdkEventButton *event, EDayView *day_view); + +static gboolean e_day_view_on_time_canvas_button_press (GtkWidget *widget, + GdkEventButton *event, + EDayView *day_view); + static void e_day_view_update_calendar_selection_time (EDayView *day_view); static gboolean e_day_view_on_main_canvas_motion (GtkWidget *widget, GdkEventMotion *event, @@ -759,7 +764,11 @@ e_day_view_init (EDayView *day_view) 0, 1, 1, 2, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (day_view->time_canvas); - + gtk_signal_connect_after (GTK_OBJECT (day_view->time_canvas), + "button_press_event", + GTK_SIGNAL_FUNC (e_day_view_on_time_canvas_button_press), + day_view); + canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->time_canvas)->root); day_view->time_canvas_item = @@ -1906,6 +1915,20 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, gint event_x, event_y, scroll_x, scroll_y, row, day, event_num; EDayViewPosition pos; + /* Handle scroll wheel events */ + if (event->button == 4 || event->button == 5) { + GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; + gfloat new_value; + + new_value = adj->value + ((event->button == 4) ? + -adj->page_increment / 2: + adj->page_increment / 2); + new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); + gtk_adjustment_set_value (adj, new_value); + + return TRUE; + } + /* Convert the coords to the main canvas window, or return if the window is not found. */ if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, @@ -1956,6 +1979,29 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, } +static gboolean +e_day_view_on_time_canvas_button_press (GtkWidget *widget, + GdkEventButton *event, + EDayView *day_view) +{ + /* Handle scroll wheel events */ + if (event->button == 4 || event->button == 5) { + GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; + gfloat new_value; + + new_value = adj->value + ((event->button == 4) ? + -adj->page_increment / 2: + adj->page_increment / 2); + new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); + gtk_adjustment_set_value (adj, new_value); + + return TRUE; + } + + return FALSE; +} + + static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, gint event_num, diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index db27ef3404..ee237abffb 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -1355,6 +1355,20 @@ e_week_view_on_button_press (GtkWidget *widget, g_print ("In e_week_view_on_button_press\n"); #endif + /* Handle scroll wheel events */ + if (event->button == 4 || event->button == 5) { + GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment; + gfloat new_value; + + new_value = adj->value + ((event->button == 4) ? + -adj->page_increment: + adj->page_increment); + new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); + gtk_adjustment_set_value (adj, new_value); + + return TRUE; + } + /* If an event is pressed just return. */ if (week_view->pressed_event_num != -1) return FALSE; -- cgit v1.2.3