[evolution-patches] 41935



Two patches to fix gal and calendar parts of 41935.  Scroll handling
changed, its no longer the 4/5 buttons.

-JP
-- 
JP Rosevear <jpr ximian com>
Ximian, Inc.
? 41930.patch
? 41935.patch
? 43029.patch
? leak.patch
? ref-count.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1764
diff -u -r1.1764 ChangeLog
--- ChangeLog	14 May 2003 18:45:53 -0000	1.1764
+++ ChangeLog	15 May 2003 20:20:06 -0000
@@ -1,3 +1,18 @@
+2003-05-15  JP Rosevear  <jpr ximian com>
+
+	Fixes #41935
+	
+	* gui/e-week-view.c (e_week_view_init): listen for scroll events
+	on the canvas
+	(e_week_view_on_button_press): don't scroll here
+	(e_week_view_on_scroll): scroll here
+
+	* gui/e-day-view.c (e_day_view_init): listen for scroll events on
+	the time and main canvases
+	(e_day_view_on_main_canvas_button_press): don't scroll here
+	(e_day_view_on_main_canvas_scroll): scroll here 
+	(e_day_view_on_time_canvas_scroll): and here
+
 2003-05-14  JP Rosevear  <jpr ximian com>
 
 	* gui/e-tasks.c (e_tasks_destroy): guard against multiple destroys
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.190
diff -u -r1.190 e-day-view.c
--- gui/e-day-view.c	14 May 2003 18:45:55 -0000	1.190
+++ gui/e-day-view.c	15 May 2003 20:20:08 -0000
@@ -188,10 +188,13 @@
 static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget,
 							  GdkEventButton *event,
 							  EDayView *day_view);
+static gboolean e_day_view_on_main_canvas_scroll (GtkWidget *widget,
+						  GdkEventScroll *scroll,
+						  EDayView *day_view);
 
-static gboolean e_day_view_on_time_canvas_button_press (GtkWidget *widget,
-							GdkEventButton *event,
-							EDayView *day_view);
+static gboolean e_day_view_on_time_canvas_scroll (GtkWidget *widget,
+						  GdkEventScroll *scroll,
+						  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,
@@ -448,10 +451,6 @@
 						 time_t		 start_time);
 static void e_day_view_recalc_work_week		(EDayView	*day_view);
 static void e_day_view_recalc_work_week_days_shown	(EDayView	*day_view);
-static gboolean e_day_view_set_event_font_cb	(EDayView	*day_view,
-						 gint		 day,
-						 gint		 event_num,
-						 gpointer	 data);
 
 static void selection_clear_event (GtkWidget *invisible,
 				   GdkEventSelection *event,
@@ -697,6 +696,10 @@
 				  G_CALLBACK (e_day_view_on_main_canvas_button_release),
 				  day_view);
 	g_signal_connect_after (day_view->main_canvas,
+				  "scroll_event",
+				  G_CALLBACK (e_day_view_on_main_canvas_scroll),
+				  day_view);
+	g_signal_connect_after (day_view->main_canvas,
 				  "motion_notify_event",
 				  G_CALLBACK (e_day_view_on_main_canvas_motion),
 				  day_view);
@@ -792,8 +795,8 @@
 			  0, 1, 1, 2,
 			  GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 	gtk_widget_show (day_view->time_canvas);
-	g_signal_connect_after (day_view->time_canvas, "button_press_event",
-				G_CALLBACK (e_day_view_on_time_canvas_button_press), day_view);
+	g_signal_connect_after (day_view->time_canvas, "scroll_event",
+				G_CALLBACK (e_day_view_on_time_canvas_scroll), day_view);
 
 	canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->time_canvas)->root);
 
@@ -3112,18 +3115,6 @@
 	g_print ("In e_day_view_on_main_canvas_button_press\n");
 #endif
 
-	/* Handle scroll wheel events */
-	if (event->button == 4) {
-		/* The wheel has been moved up, so scroll the canvas down. */
-		e_day_view_scroll (day_view, E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
-		return TRUE;
-	}
-	if (event->button == 5) {
-		/* The wheel has been moved down, so scroll the canvas up. */
-		e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
-		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,
@@ -3187,24 +3178,39 @@
 	return TRUE;
 }
 
-
 static gboolean
-e_day_view_on_time_canvas_button_press (GtkWidget      *widget,
-					GdkEventButton *event,
-					EDayView       *day_view)
+e_day_view_on_main_canvas_scroll (GtkWidget *widget,
+				  GdkEventScroll *scroll,
+				  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);
+	switch (scroll->direction) {
+	case GDK_SCROLL_UP:
+		e_day_view_scroll (day_view, E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
+		return TRUE;
+	case GDK_SCROLL_DOWN:
+		e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
+		return TRUE;
+	default:
+	}
+
+	return FALSE;
+}
 
+
+static gboolean
+e_day_view_on_time_canvas_scroll (GtkWidget      *widget,
+				  GdkEventScroll *scroll,
+				  EDayView       *day_view)
+{
+	
+	switch (scroll->direction) {
+	case GDK_SCROLL_UP:
+		e_day_view_scroll (day_view, E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
+		return TRUE;
+	case GDK_SCROLL_DOWN:
+		e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
 		return TRUE;
+	default:
 	}
 
 	return FALSE;
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.160
diff -u -r1.160 e-week-view.c
--- gui/e-week-view.c	14 May 2003 18:45:55 -0000	1.160
+++ gui/e-week-view.c	15 May 2003 20:20:10 -0000
@@ -122,6 +122,9 @@
 static gboolean e_week_view_on_button_release (GtkWidget *widget,
 					       GdkEventButton *event,
 					       EWeekView *week_view);
+static gboolean e_week_view_on_scroll (GtkWidget *widget,
+				       GdkEventScroll *scroll,
+				       EWeekView *week_view);
 static gboolean e_week_view_on_motion (GtkWidget *widget,
 				       GdkEventMotion *event,
 				       EWeekView *week_view);
@@ -384,6 +387,8 @@
 				G_CALLBACK (e_week_view_on_button_press), week_view);
 	g_signal_connect_after (week_view->main_canvas, "button_release_event",
 				G_CALLBACK (e_week_view_on_button_release), week_view);
+	g_signal_connect_after (week_view->main_canvas, "scroll_event",
+				G_CALLBACK (e_week_view_on_scroll), week_view);
 	g_signal_connect_after (week_view->main_canvas, "motion_notify_event",
 				G_CALLBACK (e_week_view_on_motion), week_view);
 
@@ -2203,20 +2208,6 @@
 		g_print (" item is pressed\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;
-	}
-
 	/* Convert the mouse position to a week & day. */
 	x = event->x;
 	y = event->y;
@@ -2291,6 +2282,31 @@
 	}
 
 	return FALSE;
+}
+
+static gboolean
+e_week_view_on_scroll (GtkWidget *widget,
+		       GdkEventScroll *scroll,
+		       EWeekView *week_view)
+{
+	GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment;
+	gfloat new_value;
+	
+	switch (scroll->direction){
+	case GDK_SCROLL_UP:
+		new_value = adj->value - adj->page_increment;
+		break;
+	case GDK_SCROLL_DOWN:
+		new_value = adj->value + adj->page_increment;
+		break;
+	default:
+		return FALSE;
+	}
+	
+	new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
+	gtk_adjustment_set_value (adj, new_value);
+	
+	return TRUE;
 }
 
 
? autom4te.cache
? gal-41935.patch
? docs/gal-api.html
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.773
diff -u -r1.773 ChangeLog
--- ChangeLog	14 May 2003 00:41:31 -0000	1.773
+++ ChangeLog	15 May 2003 20:20:14 -0000
@@ -1,3 +1,10 @@
+2003-05-15  JP Rosevear  <jpr ximian com>
+
+	* gal/widgets/e-scroll-frame.c (e_scroll_frame_class_init):
+	override the scroll method rather than the button release
+	(e_scroll_frame_scroll): scroll based on a GdkEventScroll 
+	[bug #41935, the gal part]
+
 2003-05-13  Chris Toshok  <toshok ximian com>
 
 	[ fixes several utf8/pango related problems, including bugs
Index: gal/widgets/e-scroll-frame.c
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/e-scroll-frame.c,v
retrieving revision 1.17
diff -u -r1.17 e-scroll-frame.c
--- gal/widgets/e-scroll-frame.c	4 Feb 2003 19:16:55 -0000	1.17
+++ gal/widgets/e-scroll-frame.c	15 May 2003 20:20:14 -0000
@@ -133,7 +133,7 @@
 static void e_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition);
 static void e_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
 static gint e_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event);
-static gint e_scroll_frame_button_press (GtkWidget *widget, GdkEventButton *event);
+static gint e_scroll_frame_scroll (GtkWidget *widget, GdkEventScroll *scroll);
 static void e_scroll_frame_add (GtkContainer *container, GtkWidget *widget);
 static void e_scroll_frame_remove (GtkContainer *container, GtkWidget *widget);
 static void e_scroll_frame_forall (GtkContainer *container, gboolean include_internals,
@@ -183,7 +183,7 @@
 	widget_class->size_request = e_scroll_frame_size_request;
 	widget_class->size_allocate = e_scroll_frame_size_allocate;
 	widget_class->expose_event = e_scroll_frame_expose;
-	widget_class->button_press_event = e_scroll_frame_button_press;
+	widget_class->scroll_event = e_scroll_frame_scroll;
 	
 	container_class->add = e_scroll_frame_add;
 	container_class->remove = e_scroll_frame_remove;
@@ -796,32 +796,37 @@
 
 /* Button press handler for the scroll frame widget */
 static gint
-e_scroll_frame_button_press (GtkWidget *widget, GdkEventButton *event)
+e_scroll_frame_scroll (GtkWidget *widget, GdkEventScroll *scroll)
 {
+	GtkAdjustment *adj;
+	gfloat new_value;
+
 	g_return_val_if_fail (widget != NULL, FALSE);
 	g_return_val_if_fail (E_IS_SCROLL_FRAME (widget), FALSE);
-	g_return_val_if_fail (event != NULL, FALSE);
+	g_return_val_if_fail (scroll != NULL, FALSE);
 
 	/* This is to handle mouse wheel scrolling */
-	if (event->button == 4 || event->button == 5) {
-		GtkAdjustment *adj;
-		gfloat new_value;
-
-		g_object_get (widget,
-			      (event->state & GDK_CONTROL_MASK) ?
-			      "hadjustment" : "vadjustment", 
-			      &adj,
-			      NULL);
-		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;
+	switch (scroll->direction) {
+	case GDK_SCROLL_UP:
+		g_object_get (widget, "vadjustment", &adj, NULL);
+		new_value = adj->value - (adj->page_increment / 2);
+		break;
+	case GDK_SCROLL_DOWN:
+		g_object_get (widget, "vadjustment", &adj, NULL);
+		new_value = adj->value + (adj->page_increment / 2);
+		break;
+	case GDK_SCROLL_LEFT:
+		g_object_get (widget, "hadjustment", &adj, NULL);
+		new_value = adj->value - (adj->page_increment / 2);
+		break;
+	case GDK_SCROLL_RIGHT:
+		g_object_get (widget, "hadjustment", &adj, NULL);
+		new_value = adj->value + (adj->page_increment / 2);
+		break;
 	}
 
-	return FALSE;
+	new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
+	gtk_adjustment_set_value (adj, new_value);
 }
 
 /* Expose handler for the scroll frame widget */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]