[evolution-patches] seek review for bug 46847 (Add day/week view widget in the event tab loop)



Hi Rodrigo,

This the patch for bug #46847 (http://bugzilla.ximian.com/show_bug.cgi?id=46847)

In this patch:
When tab through the events in day/week view, the day/view widget has a chance to get focus in one loop. This is needed by a11y and it is also compliant with Outlook.

Thanks,
Bolian Yin
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1838
diff -u -r1.1838 ChangeLog
--- ChangeLog	24 Jul 2003 16:02:53 -0000	1.1838
+++ ChangeLog	28 Jul 2003 01:49:49 -0000
@@ -1,3 +1,15 @@
+2003-07-28  Bolian Yin <bolian yin sun com>
+                                                                                                               
+        Fixes #46847
+                                                                                                               
+        * gui/e-day-view.c (e_day_view_get_next_tab_event, e_day_view_focus):
+         add day view widget in the tab loop of events.
+        * gui/e-week-view.c (e_week_view_get_next_tab_event, e_week_view_focus):
+         add week view widget in the tab loop of events.
+                                                                                                               
+        Also: add some comments in gui/e-day-view.c and gui/e-week-view.c
+              remove two compile warnings in gui/e-day-view.c
+                                                                                                               
 2003-07-24  Rodrigo Moya <rodrigo ximian com>
 
 	* gui/e-cal-view.[ch] (e_cal_view_delete_selected_occurrence):
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.209
diff -u -r1.209 e-day-view.c
--- gui/e-day-view.c	23 Jul 2003 15:52:08 -0000	1.209
+++ gui/e-day-view.c	28 Jul 2003 01:50:23 -0000
@@ -5126,6 +5126,13 @@
 					    &new_day, &new_event_num))
 		return FALSE;
 
+	if ((new_day == -1) && (new_event_num == -1)) {
+		/* focus should go to the day view widget itself
+		 */
+		gtk_widget_grab_focus (GTK_WIDGET(day_view));
+		return TRUE;
+	}
+
 	if (new_day != E_DAY_VIEW_LONG_EVENT && new_day != -1) {
 		if (e_day_view_get_event_rows (day_view, new_day, new_event_num,
 					       &start_row, &end_row))
@@ -5139,6 +5146,20 @@
 	return TRUE;
 }
 
+/**
+ * e_day_view_get_extreme_event
+ * @day_view: the day view widget operates on
+ * @start_day, @end_day: range of search, both inclusive
+ * @first: %TURE indicate to return the data for the first event in the range,
+ *         %FALSE to return data for the last event in the range.
+ * @day_out: out value, day of the event found. -1 for no event found.
+ * @event_num_out: out value, event number of the event found.
+ *                  -1 for no event found.
+ *
+ * Get day and event_num value for the first or last event found in the day range.
+ *
+ * Return value: %TRUE, if a event found.
+ **/
 static gboolean
 e_day_view_get_extreme_event (EDayView *day_view, gint start_day,
 			      gint end_day, gboolean first,
@@ -5175,6 +5196,18 @@
 	return FALSE;
 }
 
+/**
+ * e_day_view_get_extreme_long_event
+ * @day_view: the day view widget operates on
+ * @first: %TURE indicate to return the data for the first event in the range,
+ *         %FALSE to return data for the last event in the range.
+ * @event_num_out: out value, event number of the event found.
+ *                  -1 for no event found.
+ *
+ * Similar to e_day_view_get_extreme_event, but run for long events.
+ *
+ * Return value: %TRUE, if a event found.
+ **/
 static gboolean
 e_day_view_get_extreme_long_event (EDayView *day_view, gboolean first,
 				   gint *day_out, gint *event_num_out)
@@ -5197,6 +5230,20 @@
 	return FALSE;
 }
 
+/**
+ * e_day_view_get_next_tab_event
+ * @day_view: the day view widget operates on
+ * @direction: GTK_DIR_TAB_BACKWARD or GTK_DIR_TAB_FORWARD
+ * @day_out: out value, day of the event found. -1 for no event found.
+ * @event_num_out: out value, event number of the event found.
+ *                  -1 for no event found.
+ *
+ * Decide on which event the focus should go next. 
+ * if ((day_out == -1) && (event_num_out == -1)) is true, focus should go
+ * to day_view widget itself.
+ *
+ * Return value: %TRUE, if a event found.
+ **/
 static gboolean
 e_day_view_get_next_tab_event (EDayView *day_view, GtkDirectionType direction,
 			       gint *day_out, gint *event_num_out)
@@ -5231,36 +5278,53 @@
 	/* not current editing event, set to first long event if there is one
 	 */
 	if (new_day == -1) {
-		if (e_day_view_get_extreme_long_event (day_view, TRUE,
-						       day_out, event_num_out))
-			return TRUE;
+		if (direction == GTK_DIR_TAB_FORWARD) {
+			if (e_day_view_get_extreme_long_event (day_view, TRUE,
+							       day_out,
+							       event_num_out))
+				return TRUE;
 
-		/* no long event, set to first normal event if there is one
-		 */
-		return e_day_view_get_extreme_event (day_view, 0,
-						     days_shown - 1, TRUE,
-						     day_out, event_num_out);
+			/* no long event, set to first event if there is
+			 */
+			e_day_view_get_extreme_event (day_view, 0,
+						      days_shown - 1, TRUE,
+						      day_out, event_num_out);
+			/* go to event if found, or day view widget
+			 */
+			return TRUE;
+		}
+		else {
+			if (e_day_view_get_extreme_event (day_view, 0,
+							  days_shown - 1, FALSE,
+							  day_out, event_num_out))
+				return TRUE;
+
+			/* no event, set to last long event if there is
+			 */
+			e_day_view_get_extreme_long_event (day_view, FALSE,
+							   day_out,
+							   event_num_out);
+
+			/* go to long event if found, or day view widget
+			 */
+			return TRUE;
+		}
 	}
 	/* go backward from the first long event */
 	else if ((new_day == E_DAY_VIEW_LONG_EVENT) && (new_event_num < 0)) {
-		if (e_day_view_get_extreme_event (day_view, 0,
-						  days_shown - 1, FALSE,
-						  day_out, event_num_out))
-			return TRUE;
-		return e_day_view_get_extreme_long_event (day_view, FALSE,
-							  day_out,
-							  event_num_out);
+		/* let focus go to day view widget in this case
+		 */
+		return TRUE;
 	}
 	/* go forward from the last long event */
 	else if ((new_day == E_DAY_VIEW_LONG_EVENT) &&
 		 (new_event_num >= day_view->long_events->len)) {
-		if (e_day_view_get_extreme_event (day_view, 0,
-						  days_shown - 1, TRUE,
-						  day_out, event_num_out))
-			return TRUE;
-		return e_day_view_get_extreme_long_event (day_view, TRUE,
-							  day_out,
-							  event_num_out);
+		e_day_view_get_extreme_event (day_view, 0,
+					      days_shown - 1, TRUE,
+					      day_out, event_num_out);
+		/* go to the next main item event if found or day view widget
+		 */
+		return TRUE;
 	}
 
 	/* go backward from the first event in current editting day */
@@ -5271,31 +5335,28 @@
 						  new_day - 1, FALSE,
 						  day_out, event_num_out))
 			return TRUE;
-		else if (e_day_view_get_extreme_long_event (day_view, FALSE,
-							    day_out,
-							    event_num_out))
-			return TRUE;
-		return e_day_view_get_extreme_event (day_view, new_day,
-						     days_shown - 1, FALSE,
-						     day_out, event_num_out);
+		/* try to find a long event
+		 */
+		e_day_view_get_extreme_long_event (day_view, FALSE,
+						   day_out, event_num_out);
+		/* go to a long event if found, or day view widget
+		 */
+		return TRUE;
 	}
 	/* go forward from the last event in current editting day */
 	else if ((new_day < E_DAY_VIEW_LONG_EVENT) &&
 		 (new_event_num >= day_view->events[new_day]->len)) {
 		/* try to find a event from the next day in days shown
 		 */
-		if (e_day_view_get_extreme_event (day_view, (new_day + 1),
-						  days_shown - 1, TRUE,
-						  day_out, event_num_out))
-			return TRUE;
-		else if (e_day_view_get_extreme_long_event (day_view, TRUE,
-							    day_out,
-							    event_num_out))
-			return TRUE;
-		return e_day_view_get_extreme_event (day_view, 0,
-						     new_day, TRUE,
-						     day_out, event_num_out);
+		e_day_view_get_extreme_event (day_view, (new_day + 1),
+					      days_shown - 1, TRUE,
+					      day_out, event_num_out);
+		/* go to a event found, or day view widget
+		 */
+		return TRUE;
 	}
+	/* in the normal case
+	 */
 	*day_out = new_day;
 	*event_num_out = new_event_num;
 	return TRUE;
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.175
diff -u -r1.175 e-week-view.c
--- gui/e-week-view.c	23 Jul 2003 15:52:08 -0000	1.175
+++ gui/e-week-view.c	28 Jul 2003 01:50:46 -0000
@@ -902,7 +902,15 @@
 	return FALSE;
 }
 
-
+/**
+ * e_week_view_get_next_tab_event
+ * @week_view: the week_view widget operate on
+ * @direction: GTK_DIR_TAB_BACKWARD or GTK_DIR_TAB_FORWARD.
+ * @current_event_num and @current_span_num: current status.
+ * @next_event_num: the event number focus should go next.
+ *                  -1 indicates focus should go to week_view widget.
+ * @next_span_num: always return 0.
+ **/
 static gboolean
 e_week_view_get_next_tab_event (EWeekView *week_view,
 				GtkDirectionType direction,
@@ -934,10 +942,18 @@
 		return FALSE;
 	}
 
-	if (event_num < 0)
+	if (event_num == -1)
+		/* backward, out of event range, go to week view widget
+		 */
+		*next_event_num = -1;
+	else if (event_num < -1)
+		/* backward from week_view, go to the last event
+		 */
 		*next_event_num = week_view->events->len - 1;
 	else if (event_num >= week_view->events->len)
-		*next_event_num = 0;
+		/* forward, out of event range, go to week view widget
+		 */
+		*next_event_num = -1;
 	else
 		*next_event_num = event_num;
 	return TRUE;
@@ -968,6 +984,13 @@
 						     &new_event_num,
 						     &new_span_num))
 			return FALSE;
+
+		if (new_event_num == -1) {
+			/* focus should go to week_view widget
+			 */
+			gtk_widget_grab_focus (widget);
+			return TRUE;
+		}
 
 		editable = e_week_view_start_editing_event (week_view,
 							    new_event_num,


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