Looks ok pending Rodrigo or JPR's approve.
Harry
Bolian Yin wrote:
-------- Original Message --------
Hi,
another calendar a11y patch.
Thanks,
Bolian
? a
? calendar/a
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ChangeLog,v
retrieving revision 1.14
diff -u -r1.14 ChangeLog
--- ChangeLog 9 Dec 2003 07:09:23 -0000 1.14
+++ ChangeLog 9 Dec 2003 09:56:03 -0000
@@ -1,3 +1,11 @@
+2003-12-05 Bolian Yin <bolian yin sun com>
+
+ * calendar/ea-cal-view-event.c (ea_cal_view_event_get_index_in_parent): corret index error in week view.
+ * calendar/ea-day-view-cell.c: impl. get_index_in_parent
+ * calendar/ea-day-view-main-item.c: emit signal "active-descendant-changed", fix error in selection_interface_ref_selection.
+ * widgets/ea-calendar-cell.c: impl. get_index_in_parent.
+ * widgets/ea-calendar-item.c: change signature of e_calendar_item_get_offset_for_date, emit signal "active-descendant-changed".
+
2003-12-09 Andrew Wu <Yang Wu sun com>
* calendar/Makefile.am: add entries for new source files
Index: calendar/ea-cal-view-event.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/calendar/ea-cal-view-event.c,v
retrieving revision 1.8
diff -u -r1.8 ea-cal-view-event.c
--- calendar/ea-cal-view-event.c 9 Dec 2003 01:28:57 -0000 1.8
+++ calendar/ea-cal-view-event.c 9 Dec 2003 09:56:03 -0000
@@ -346,15 +346,18 @@
}
}
else if (E_IS_WEEK_VIEW (cal_view)) {
- gint index;
- EWeekViewEvent *week_view_event;
- EWeekView *week_view = E_WEEK_VIEW (cal_view);
-
- for (index = week_view->events->len - 1; index >= 0; --index) {
- week_view_event = &g_array_index (week_view->events,
- EWeekViewEvent, index);
- if (cal_view_event == (ECalendarViewEvent*)week_view_event)
+ AtkObject *atk_parent, *atk_child;
+ gint index = 0;
+
+ atk_parent = atk_object_get_parent (accessible);
+ while ((atk_child = atk_object_ref_accessible_child (atk_parent,
+ index)) != NULL) {
+ if (atk_child == accessible) {
+ g_object_unref (atk_child);
return index;
+ }
+ g_object_unref (atk_child);
+ ++index;
}
}
else {
Index: calendar/ea-day-view-cell.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/calendar/ea-day-view-cell.c,v
retrieving revision 1.1
diff -u -r1.1 ea-day-view-cell.c
--- calendar/ea-day-view-cell.c 4 Nov 2003 08:15:56 -0000 1.1
+++ calendar/ea-day-view-cell.c 9 Dec 2003 09:56:04 -0000
@@ -95,6 +95,7 @@
static G_CONST_RETURN gchar* ea_day_view_cell_get_description (AtkObject *accessible);
static AtkStateSet* ea_day_view_cell_ref_state_set (AtkObject *obj);
static AtkObject * ea_day_view_cell_get_parent (AtkObject *accessible);
+static gint ea_day_view_cell_get_index_in_parent (AtkObject *accessible);
/* component interface */
static void atk_component_interface_init (AtkComponentIface *iface);
@@ -160,6 +161,7 @@
class->ref_state_set = ea_day_view_cell_ref_state_set;
class->get_parent = ea_day_view_cell_get_parent;
+ class->get_index_in_parent = ea_day_view_cell_get_index_in_parent;
}
AtkObject*
@@ -280,7 +282,28 @@
return NULL;
cell = E_DAY_VIEW_CELL (g_obj);
- return gtk_widget_get_accessible (GTK_WIDGET (cell->day_view->main_canvas));
+ return atk_gobject_accessible_for_object (G_OBJECT (cell->day_view->main_canvas_item));
+}
+
+static gint
+ea_day_view_cell_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewCell *cell;
+ AtkObject *parent;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ cell = E_DAY_VIEW_CELL (g_obj);
+ parent = atk_object_get_parent (accessible);
+ return atk_table_get_index_at (ATK_TABLE (parent),
+ cell->row, cell->column);
}
/* Atk Component Interface */
@@ -329,8 +352,6 @@
*x += day_view->day_offsets[cell->column] - scroll_x;
*y += day_view->row_height * cell->row
- scroll_y;
- printf ("ybl: cellrow=%d, cellcol=%d, scroll_x=%d, scroll_y=%d\n",
- cell->row, cell->column, scroll_x, scroll_y);
*width = day_view->day_widths[cell->column];
*height = day_view->row_height;
}
Index: calendar/ea-day-view-main-item.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/calendar/ea-day-view-main-item.c,v
retrieving revision 1.2
diff -u -r1.2 ea-day-view-main-item.c
--- calendar/ea-day-view-main-item.c 7 Nov 2003 07:12:34 -0000 1.2
+++ calendar/ea-day-view-main-item.c 9 Dec 2003 09:56:05 -0000
@@ -422,6 +422,7 @@
ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data)
{
EaDayViewMainItem *ea_main_item;
+ AtkObject *item_cell = NULL;
g_return_if_fail (E_IS_DAY_VIEW (day_view));
g_return_if_fail (data);
@@ -432,6 +433,18 @@
#ifdef ACC_DEBUG
printf ("EvoAcc: ea_day_view_main_item time changed cb\n");
#endif
+ /* only deal with the first selected child, for now */
+ item_cell = atk_selection_ref_selection (ATK_SELECTION (ea_main_item),
+ 0);
+ if (item_cell) {
+ AtkStateSet *state_set;
+ state_set = atk_object_ref_state_set (item_cell);
+ atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
+ g_object_unref (state_set);
+ }
+ g_signal_emit_by_name (ea_main_item,
+ "active-descendant-changed",
+ item_cell);
g_signal_emit_by_name (data, "selection_changed");
}
@@ -1187,9 +1200,23 @@
static AtkObject*
selection_interface_ref_selection (AtkSelection *selection, gint i)
{
- if (selection_interface_is_child_selected (selection, i))
- return ea_day_view_main_item_ref_child (ATK_OBJECT (selection), i);
- return NULL;
+ gint count;
+ GObject *g_obj;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection);
+ gint start_index;
+
+ count = selection_interface_get_selection_count (selection);
+ if (i < 0 || i >=count)
+ return NULL;
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_main_item));
+ day_view = E_DAY_VIEW_MAIN_ITEM (g_obj)->day_view;
+ start_index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ day_view->selection_start_row,
+ day_view->selection_start_day);
+
+ return ea_day_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i);
}
static gint
Index: widgets/ea-calendar-cell.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-cell.c,v
retrieving revision 1.1
diff -u -r1.1 ea-calendar-cell.c
--- widgets/ea-calendar-cell.c 11 Nov 2003 10:33:43 -0000 1.1
+++ widgets/ea-calendar-cell.c 9 Dec 2003 09:56:06 -0000
@@ -93,6 +93,7 @@
static G_CONST_RETURN gchar* ea_calendar_cell_get_name (AtkObject *accessible);
static G_CONST_RETURN gchar* ea_calendar_cell_get_description (AtkObject *accessible);
static AtkObject * ea_calendar_cell_get_parent (AtkObject *accessible);
+static gint ea_calendar_cell_get_index_in_parent (AtkObject *accessible);
/* component interface */
static void atk_component_interface_init (AtkComponentIface *iface);
@@ -158,6 +159,7 @@
class->get_description = ea_calendar_cell_get_description;
class->get_parent = ea_calendar_cell_get_parent;
+ class->get_index_in_parent = ea_calendar_cell_get_index_in_parent;
}
AtkObject*
@@ -248,6 +250,24 @@
return atk_gobject_accessible_for_object (G_OBJECT (calitem));
}
+static gint
+ea_calendar_cell_get_index_in_parent (AtkObject *accessible)
+{
+ GObject *g_obj;
+ ECalendarCell *cell;
+ AtkObject *parent;
+
+ g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), -1);
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible));
+ if (!g_obj)
+ return -1;
+ cell = E_CALENDAR_CELL (g_obj);
+ parent = atk_object_get_parent (accessible);
+ return atk_table_get_index_at (ATK_TABLE (parent),
+ cell->row, cell->column);
+}
+
/* Atk Component Interface */
static void
Index: widgets/ea-calendar-item.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-item.c,v
retrieving revision 1.3
diff -u -r1.3 ea-calendar-item.c
--- widgets/ea-calendar-item.c 9 Dec 2003 01:35:29 -0000 1.3
+++ widgets/ea-calendar-item.c 9 Dec 2003 09:56:08 -0000
@@ -122,6 +122,9 @@
gint row,
gchar *buffer,
gint buffer_size);
+static gboolean e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
+ gint year, gint month, gint day,
+ gint *offset);
#ifdef ACC_DEBUG
static gint n_ea_calendar_item_created = 0;
@@ -596,16 +599,16 @@
calitem = E_CALENDAR_ITEM (g_obj);
e_calendar_item_get_selection (calitem, &start_date, &end_date);
- sel_index_start =
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&start_date),
- g_date_get_month (&start_date),
- g_date_get_day (&start_date));
- sel_index_end =
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&end_date),
- g_date_get_month (&end_date),
- g_date_get_day (&end_date));
+ e_calendar_item_get_offset_for_date (calitem,
+ g_date_get_year (&start_date),
+ g_date_get_month (&start_date),
+ g_date_get_day (&start_date),
+ &sel_index_start);
+ e_calendar_item_get_offset_for_date (calitem,
+ g_date_get_year (&end_date),
+ g_date_get_month (&end_date),
+ g_date_get_day (&end_date),
+ &sel_index_end);
if ((sel_index_start < row_index_start &&
sel_index_end >= row_index_start) ||
@@ -648,16 +651,15 @@
calitem = E_CALENDAR_ITEM (g_obj);
e_calendar_item_get_selection (calitem, &start_date, &end_date);
- sel_index_start =
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&start_date),
- g_date_get_month (&start_date),
- g_date_get_day (&start_date));
- sel_index_end =
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&end_date),
- g_date_get_month (&end_date),
- g_date_get_day (&end_date));
+ e_calendar_item_get_offset_for_date (calitem,
+ g_date_get_year (&start_date),
+ g_date_get_month (&start_date),
+ g_date_get_day (&start_date),
+ &sel_index_start);
+ e_calendar_item_get_offset_for_date (calitem,
+ g_date_get_year (&end_date),
+ g_date_get_month (&end_date),
+ g_date_get_day (&end_date), &sel_index_end);
if (sel_index_start <= index && sel_index_end >= index)
return TRUE;
@@ -895,10 +897,12 @@
calitem = E_CALENDAR_ITEM (g_obj);
e_calendar_item_get_selection (calitem, &start_date, &end_date);
- sel_offset = e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&start_date),
- g_date_get_month (&start_date),
- g_date_get_day (&start_date));
+ if (!e_calendar_item_get_offset_for_date (calitem,
+ g_date_get_year (&start_date),
+ g_date_get_month (&start_date) - 1,
+ g_date_get_day (&start_date),
+ &sel_offset))
+ return NULL;
return ea_calendar_item_ref_child (ATK_OBJECT (selection), sel_offset + i);
}
@@ -954,10 +958,23 @@
selection_preview_change_cb (ECalendarItem *calitem)
{
AtkObject *atk_obj;
+ AtkObject *item_cell = NULL;
g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
+ /* only deal with the first selected child, for now */
+ item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_obj),
+ 0);
+ if (item_cell) {
+ AtkStateSet *state_set;
+ state_set = atk_object_ref_state_set (item_cell);
+ atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
+ g_object_unref (state_set);
+ }
+ g_signal_emit_by_name (atk_obj,
+ "active-descendant-changed",
+ item_cell);
g_signal_emit_by_name (atk_obj, "selection_changed");
}
@@ -1200,17 +1217,19 @@
return TRUE;
}
-/* month is from 0 to 11 */
-gint
+/* the arg month is from 0 to 11 */
+static gboolean
e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
- gint year, gint month, gint day)
+ gint year, gint month, gint day,
+ gint *offset)
{
gint start_year, start_month, start_day;
gint end_year, end_month, end_day;
GDate *start_date, *end_date;
gint n_days;
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), -1);
+ *offset = 0;
+ g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE);
if (!e_calendar_item_get_date_range (calitem, &start_year,
&start_month, &start_day,
@@ -1221,10 +1240,11 @@
start_date = g_date_new_dmy (start_day, start_month + 1, start_year);
end_date = g_date_new_dmy (day, month + 1, year);
- n_days = g_date_days_between (start_date, end_date);
+ *offset = g_date_days_between (start_date, end_date);
g_free (start_date);
g_free (end_date);
- return n_days;
+
+ return TRUE;
}
gint
Index: widgets/ea-calendar-item.h
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-item.h,v
retrieving revision 1.2
diff -u -r1.2 ea-calendar-item.h
--- widgets/ea-calendar-item.h 11 Nov 2003 10:33:43 -0000 1.2
+++ widgets/ea-calendar-item.h 9 Dec 2003 09:56:08 -0000
@@ -64,8 +64,6 @@
gint day_offset,
gint *year, gint *month,
gint *day);
-gint e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
- gint year, gint month, gint day);
gint e_calendar_item_get_n_days_from_week_start (ECalendarItem *calitem,
gint year, gint month);
|