aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--a11y/ChangeLog10
-rw-r--r--a11y/calendar/Makefile.am6
-rw-r--r--a11y/calendar/ea-calendar-helpers.c24
-rw-r--r--a11y/calendar/ea-calendar.c48
-rw-r--r--a11y/calendar/ea-calendar.h1
-rw-r--r--a11y/calendar/ea-jump-button.c225
-rw-r--r--a11y/calendar/ea-jump-button.h64
-rw-r--r--a11y/calendar/ea-week-view-cell.c356
-rw-r--r--a11y/calendar/ea-week-view-cell.h92
-rw-r--r--a11y/calendar/ea-week-view-main-item.c1270
-rw-r--r--a11y/calendar/ea-week-view-main-item.h65
-rw-r--r--a11y/calendar/ea-week-view.c14
12 files changed, 2163 insertions, 12 deletions
diff --git a/a11y/ChangeLog b/a11y/ChangeLog
index 6752384193..67266ee580 100644
--- a/a11y/ChangeLog
+++ b/a11y/ChangeLog
@@ -1,3 +1,13 @@
+2003-12-09 Andrew Wu <Yang.Wu@sun.com>
+
+ * calendar/Makefile.am: add entries for new source files
+ * calendar/ea-calendar-helpers.c: add cases for jump button.
+ * calendar/ea-calendar.c: add cases for week view and week view main item.
+ * calendar/ea-jump-button.c: new impl.
+ * calendar/ea-week-view-cell.c: new impl.
+ * calendar/ea-week-view-main-item.c: new impl.
+ * calendar/ea-week-view.c: add main item as first child.
+
2003-12-05 Bolian Yin <bolian.yin@sun.com>
* calendar/ea-cal-view-event.c (ea_cal_view_event_new): shortcut when cal_view is NULL.
diff --git a/a11y/calendar/Makefile.am b/a11y/calendar/Makefile.am
index 0c4aba11a0..478c303efd 100644
--- a/a11y/calendar/Makefile.am
+++ b/a11y/calendar/Makefile.am
@@ -70,6 +70,12 @@ libevolution_calendar_a11y_la_SOURCES = \
ea-day-view-cell.h \
ea-week-view.c \
ea-week-view.h \
+ ea-week-view-main-item.c \
+ ea-week-view-main-item.h \
+ ea-week-view-cell.c \
+ ea-week-view-cell.h \
+ ea-jump-button.c \
+ ea-jump-button.h \
ea-gnome-calendar.c \
ea-gnome-calendar.h
diff --git a/a11y/calendar/ea-calendar-helpers.c b/a11y/calendar/ea-calendar-helpers.c
index 535265ebeb..9b484d0040 100644
--- a/a11y/calendar/ea-calendar-helpers.c
+++ b/a11y/calendar/ea-calendar-helpers.c
@@ -25,14 +25,16 @@
#include "ea-calendar-helpers.h"
#include "ea-cal-view-event.h"
+#include "ea-jump-button.h"
#include "e-day-view.h"
#include "e-week-view.h"
#include <gal/e-text/e-text.h>
+#include <libgnomecanvas/gnome-canvas-pixbuf.h>
/**
* ea_calendar_helpers_get_accessible_for
- * @canvas_item: the canvas item (e_text) for a event
+ * @canvas_item: the canvas item for a event or a jump button
* @returns: the atk object for the canvas_item
*
**/
@@ -42,7 +44,7 @@ ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item)
AtkObject *atk_obj = NULL;
GObject *g_obj;
- g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL);
+ g_return_val_if_fail ((E_IS_TEXT (canvas_item)) || (GNOME_IS_CANVAS_ITEM (canvas_item)), NULL);;
g_obj = G_OBJECT (canvas_item);
/* we cannot use atk_gobject_accessible_for_object here,
@@ -50,14 +52,22 @@ ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item)
* registered facotry of E_TEXT
*/
atk_obj = g_object_get_data (g_obj, "accessible-object");
- if (!atk_obj)
+ if (!atk_obj) {
+ if (E_IS_TEXT (canvas_item)) {
atk_obj = ea_cal_view_event_new (g_obj);
+ }
+ else if (GNOME_IS_CANVAS_PIXBUF(canvas_item)) {
+ atk_obj = ea_jump_button_new (g_obj);
+ }
+ else
+ return NULL;
+ }
return atk_obj;
}
/**
* ea_calendar_helpers_get_view_widget_from:
- * @canvas_item: the canvas item (e_text) for a event
+ * @canvas_item: the canvas item for a event or a jump button
* @returns: the cal view widget if exists
*
* Get the cal view widget contains the canvas_item.
@@ -70,16 +80,16 @@ ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item)
GtkWidget *view_widget = NULL;
g_return_val_if_fail (canvas_item, NULL);
- g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL);
+ g_return_val_if_fail ((E_IS_TEXT (canvas_item)) || (GNOME_IS_CANVAS_ITEM (canvas_item)), NULL);
/* canvas_item is the e_text for the event */
/* canvas_item->canvas is the ECanvas for day view */
/* parent of canvas_item->canvas is the EDayView or EWeekView widget */
canvas = canvas_item->canvas;
view_widget = gtk_widget_get_parent (GTK_WIDGET(canvas));
- if (!view_widget || !E_IS_CALENDAR_VIEW (view_widget))
+ if (!view_widget || !E_IS_CAL_VIEW (view_widget))
return NULL;
- return E_CALENDAR_VIEW (view_widget);
+ return E_CAL_VIEW (view_widget);
}
/**
diff --git a/a11y/calendar/ea-calendar.c b/a11y/calendar/ea-calendar.c
index bb528cb919..f2510bbcf9 100644
--- a/a11y/calendar/ea-calendar.c
+++ b/a11y/calendar/ea-calendar.c
@@ -24,6 +24,7 @@
*/
#include <gal/e-text/e-text.h>
+#include <libgnomecanvas/gnome-canvas-pixbuf.h>
#include "ea-calendar-helpers.h"
#include "ea-factory.h"
#include "ea-calendar.h"
@@ -33,6 +34,7 @@
#include "calendar/ea-day-view.h"
#include "calendar/ea-day-view-main-item.h"
#include "calendar/ea-week-view.h"
+#include "calendar/ea-week-view-main-item.h"
#include "calendar/ea-gnome-calendar.h"
@@ -40,6 +42,7 @@ EA_FACTORY (EA_TYPE_CAL_VIEW, ea_cal_view, ea_cal_view_new)
EA_FACTORY (EA_TYPE_DAY_VIEW, ea_day_view, ea_day_view_new)
EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_MAIN_ITEM, ea_day_view_main_item, ea_day_view_main_item_new)
EA_FACTORY (EA_TYPE_WEEK_VIEW, ea_week_view, ea_week_view_new)
+EA_FACTORY_GOBJECT (EA_TYPE_WEEK_VIEW_MAIN_ITEM, ea_week_view_main_item, ea_week_view_main_item_new)
EA_FACTORY (EA_TYPE_GNOME_CALENDAR, ea_gnome_calendar, ea_gnome_calendar_new)
static gboolean ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
@@ -57,6 +60,9 @@ gnome_calendar_a11y_init (void)
g_signal_add_emission_hook (g_signal_lookup ("event", E_TYPE_TEXT),
0, ea_calendar_focus_watcher,
NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event", GNOME_TYPE_CANVAS_PIXBUF),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
g_signal_add_emission_hook (g_signal_lookup ("event-after",
e_day_view_get_type()),
0, ea_calendar_focus_watcher,
@@ -65,6 +71,14 @@ gnome_calendar_a11y_init (void)
e_day_view_main_item_get_type()),
0, ea_calendar_focus_watcher,
NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event-after",
+ e_week_view_get_type()),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event",
+ e_week_view_main_item_get_type()),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
}
}
@@ -81,7 +95,8 @@ e_day_view_a11y_init (void)
EA_SET_FACTORY (e_day_view_get_type(), ea_day_view);
}
-void e_day_view_main_item_a11y_init (void)
+void
+e_day_view_main_item_a11y_init (void)
{
EA_SET_FACTORY (e_day_view_main_item_get_type (), ea_day_view_main_item);
}
@@ -92,6 +107,12 @@ e_week_view_a11y_init (void)
EA_SET_FACTORY (e_week_view_get_type(), ea_week_view);
}
+void
+e_week_view_main_item_a11y_init (void)
+{
+ EA_SET_FACTORY (e_week_view_main_item_get_type (), ea_week_view_main_item);
+}
+
gboolean
ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
@@ -105,7 +126,7 @@ ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
object = g_value_get_object (param_values + 0);
event = g_value_get_boxed (param_values + 1);
- if (E_IS_TEXT (object)) {
+ if ((E_IS_TEXT (object)) || (GNOME_IS_CANVAS_PIXBUF (object))) {
/* "event" signal on canvas item
*/
GnomeCanvasItem *canvas_item;
@@ -146,6 +167,29 @@ ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
#endif
atk_focus_tracker_notify (ea_event);
}
+ } else if (E_IS_WEEK_VIEW (object)) {
+ EWeekView *week_view = E_WEEK_VIEW (object);
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ /* give main item chance to emit focus */
+ gnome_canvas_item_grab_focus (week_view->main_canvas_item);
+ }
+ }
+ }
+ else if (E_IS_WEEK_VIEW_MAIN_ITEM (object)) {
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ /* we should emit focus on main item */
+ ea_event = atk_gobject_accessible_for_object (object);
+ }
+ else
+ /* focus out */
+ ea_event = NULL;
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: focus notify on week main item %p\n", (void *)object);
+#endif
+ atk_focus_tracker_notify (ea_event);
+ }
}
return TRUE;
}
diff --git a/a11y/calendar/ea-calendar.h b/a11y/calendar/ea-calendar.h
index 4b1779c0b5..92bb80a962 100644
--- a/a11y/calendar/ea-calendar.h
+++ b/a11y/calendar/ea-calendar.h
@@ -34,5 +34,6 @@ void e_cal_view_a11y_init (void);
void e_day_view_a11y_init (void);
void e_day_view_main_item_a11y_init (void);
void e_week_view_a11y_init (void);
+void e_week_view_main_item_a11y_init (void);
#endif /* _EA_CALENDAR_H__ */
diff --git a/a11y/calendar/ea-jump-button.c b/a11y/calendar/ea-jump-button.c
new file mode 100644
index 0000000000..2209447ced
--- /dev/null
+++ b/a11y/calendar/ea-jump-button.c
@@ -0,0 +1,225 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-jump-button.c
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Yang Wu <yang.wu@sun.com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#include "ea-jump-button.h"
+#include "ea-calendar-helpers.h"
+#include "ea-week-view.h"
+#include "e-week-view.h"
+#include <libgnomecanvas/gnome-canvas.h>
+
+static void ea_jump_button_class_init (EaJumpButtonClass *klass);
+
+static G_CONST_RETURN gchar* ea_jump_button_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_jump_button_get_description (AtkObject *accessible);
+
+/* action interface */
+static void atk_action_interface_init (AtkActionIface *iface);
+static gboolean jump_button_do_action (AtkAction *action,
+ gint i);
+static gint jump_button_get_n_actions (AtkAction *action);
+static G_CONST_RETURN gchar* jump_button_get_keybinding (AtkAction *action,
+ gint i);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_jump_button_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaJumpButtonClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_jump_button_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaJumpButton), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_action_info =
+ {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (atk object for GNOME_TYPE_CANVAS_ITEM, in this case)
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ GNOME_TYPE_CANVAS_ITEM);
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ /* we inherit the component and other interfaces from GNOME_TYPE_CANVAS_ITEM */
+ type = g_type_register_static (derived_atk_type,
+ "EaJumpButton", &tinfo, 0);
+
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
+ }
+
+ return type;
+}
+
+static void
+ea_jump_button_class_init (EaJumpButtonClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_jump_button_get_name;
+ class->get_description = ea_jump_button_get_description;
+}
+
+AtkObject*
+ea_jump_button_new (GObject *obj)
+{
+ AtkObject *atk_obj = NULL;
+ GObject *target_obj;
+
+ g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (obj), NULL);
+
+ target_obj = obj;
+ atk_obj = g_object_get_data (target_obj, "accessible-object");
+
+ if (!atk_obj) {
+ static AtkRole event_role = ATK_ROLE_INVALID;
+ atk_obj = ATK_OBJECT (g_object_new (EA_TYPE_JUMP_BUTTON,
+ NULL));
+ atk_object_initialize (atk_obj, target_obj);
+ if (event_role == ATK_ROLE_INVALID)
+ event_role = atk_role_register ("Jump Button");
+ atk_obj->role = event_role;
+ }
+
+ /* the registered factory for GNOME_TYPE_CANVAS_ITEM is cannot create a EaJumpbutton,
+ * we should save the EaJumpbutton object in it.
+ */
+ g_object_set_data (obj, "accessible-object", atk_obj);
+
+ return atk_obj;
+}
+
+static G_CONST_RETURN gchar*
+ea_jump_button_get_name (AtkObject *accessible)
+{
+ g_return_val_if_fail (EA_IS_JUMP_BUTTON (accessible), NULL);
+
+ if (accessible->name)
+ return accessible->name;
+ return "Jump";
+}
+
+static G_CONST_RETURN gchar*
+ea_jump_button_get_description (AtkObject *accessible)
+{
+ if (accessible->description)
+ return accessible->description;
+
+ return "Click here, you can find more events.";
+}
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = jump_button_do_action;
+ iface->get_n_actions = jump_button_get_n_actions;
+ iface->get_keybinding = jump_button_get_keybinding;
+}
+
+static gboolean
+jump_button_do_action (AtkAction *action,
+ gint i)
+{
+ gboolean return_value = TRUE;
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ GnomeCanvasItem *item;
+ ECalendarView *cal_view;
+ EWeekView *week_view;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (action);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ item = GNOME_CANVAS_ITEM (g_obj);
+ cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (item));
+ week_view = E_WEEK_VIEW (cal_view);
+
+ switch (i)
+ {
+ case 0:
+ e_week_view_jump_to_button_item (week_view, GNOME_CANVAS_ITEM (item));
+ break;
+ default:
+ return_value = FALSE;
+ break;
+ }
+ return return_value;
+}
+
+static gint
+jump_button_get_n_actions (AtkAction *action)
+{
+ return 1;
+}
+
+static G_CONST_RETURN gchar*
+jump_button_get_keybinding (AtkAction *action,
+ gint i)
+{
+ gchar *return_value = NULL;
+
+ switch (i)
+ {
+ case 0:
+ {
+ return_value = "space or enter";
+ break;
+ }
+ default:
+ break;
+ }
+ return return_value;
+}
diff --git a/a11y/calendar/ea-jump-button.h b/a11y/calendar/ea-jump-button.h
new file mode 100644
index 0000000000..ef1f1efb35
--- /dev/null
+++ b/a11y/calendar/ea-jump-button.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-jump-button.h
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Yang Wu <yang.wu@sun.com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#ifndef __EA_JUMP_BUTTON_H__
+#define __EA_JUMP_BUTTON_H__
+
+#include <atk/atkgobjectaccessible.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define EA_TYPE_JUMP_BUTTON (ea_jump_button_get_type ())
+#define EA_JUMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_JUMP_BUTTON, EaJumpButton))
+#define EA_JUMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_JUMP_BUTTON, EaJumpButtonClass))
+#define EA_IS_JUMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_JUMP_BUTTON))
+#define EA_IS_JUMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_JUMP_BUTTON))
+#define EA_JUMP_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_JUMP_BUTTON, EaJumpButtonClass))
+
+typedef struct _EaJumpButton EaJumpButton;
+typedef struct _EaJumpButtonClass EaJumpButtonClass;
+
+struct _EaJumpButton
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_jump_button_get_type (void);
+
+struct _EaJumpButtonClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject *ea_jump_button_new (GObject *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __EA_JUMP_BUTTON_H__ */
diff --git a/a11y/calendar/ea-week-view-cell.c b/a11y/calendar/ea-week-view-cell.c
new file mode 100644
index 0000000000..5d97ed74b4
--- /dev/null
+++ b/a11y/calendar/ea-week-view-cell.c
@@ -0,0 +1,356 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-week-view-cell.c
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Bolian Yin <bolian.yin@sun.com> Sun Microsystem Inc., 2003
+ * Author: Yang Wu <Yang.Wu@sun.com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#include "ea-week-view-cell.h"
+#include "ea-week-view-main-item.h"
+#include "ea-factory.h"
+
+/* EWeekViewCell */
+
+static void e_week_view_cell_class_init (EWeekViewCellClass *class);
+
+EA_FACTORY_GOBJECT (EA_TYPE_WEEK_VIEW_CELL, ea_week_view_cell, ea_week_view_cell_new)
+
+GType
+e_week_view_cell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EWeekViewCellClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) e_week_view_cell_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EWeekViewCell), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "EWeekViewCell", &tinfo, 0);
+ }
+
+ return type;
+}
+
+static void
+e_week_view_cell_class_init (EWeekViewCellClass *class)
+{
+ EA_SET_FACTORY (e_week_view_cell_get_type (), ea_week_view_cell);
+}
+
+EWeekViewCell *
+e_week_view_cell_new (EWeekView *week_view, gint row, gint column)
+{
+ GObject *object;
+ EWeekViewCell *cell;
+
+ g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL);
+
+ object = g_object_new (E_TYPE_WEEK_VIEW_CELL, NULL);
+ cell = E_WEEK_VIEW_CELL (object);
+ cell->week_view = week_view;
+ cell->row = row;
+ cell->column = column;
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: e_week_view_cell created %p\n", (void *)cell);
+#endif
+
+ return cell;
+}
+
+/* EaWeekViewCell */
+
+static void ea_week_view_cell_class_init (EaWeekViewCellClass *klass);
+
+static G_CONST_RETURN gchar* ea_week_view_cell_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_week_view_cell_get_description (AtkObject *accessible);
+static AtkStateSet* ea_week_view_cell_ref_state_set (AtkObject *obj);
+static AtkObject * ea_week_view_cell_get_parent (AtkObject *accessible);
+static gint ea_week_view_cell_get_index_in_parent (AtkObject *accessible);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type);
+static gpointer parent_class = NULL;
+
+#ifdef ACC_DEBUG
+static gint n_ea_week_view_cell_created = 0, n_ea_week_view_cell_destroyed = 0;
+static void ea_week_view_cell_finalize (GObject *object);
+#endif
+
+GType
+ea_week_view_cell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaWeekViewCellClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_week_view_cell_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaWeekViewCell), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE,
+ "EaWeekViewCell", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+
+ }
+
+ return type;
+}
+
+static void
+ea_week_view_cell_class_init (EaWeekViewCellClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+#ifdef ACC_DEBUG
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ea_week_view_cell_finalize;
+#endif
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_week_view_cell_get_name;
+ class->get_description = ea_week_view_cell_get_description;
+ class->ref_state_set = ea_week_view_cell_ref_state_set;
+
+ class->get_parent = ea_week_view_cell_get_parent;
+ class->get_index_in_parent = ea_week_view_cell_get_index_in_parent;
+
+}
+
+AtkObject*
+ea_week_view_cell_new (GObject *obj)
+{
+ gpointer object;
+ AtkObject *atk_object;
+
+ g_return_val_if_fail (E_IS_WEEK_VIEW_CELL (obj), NULL);
+ object = g_object_new (EA_TYPE_WEEK_VIEW_CELL, NULL);
+ atk_object = ATK_OBJECT (object);
+ atk_object_initialize (atk_object, obj);
+ atk_object->role = ATK_ROLE_UNKNOWN;
+
+#ifdef ACC_DEBUG
+ ++n_ea_week_view_cell_created;
+ printf ("ACC_DEBUG: n_ea_week_view_cell_created = %d\n",
+ n_ea_week_view_cell_created);
+#endif
+ return atk_object;
+}
+
+#ifdef ACC_DEBUG
+static void ea_week_view_cell_finalize (GObject *object)
+{
+ ++n_ea_week_view_cell_destroyed;
+ printf ("ACC_DEBUG: n_ea_week_view_cell_destroyed = %d\n",
+ n_ea_week_view_cell_destroyed);
+}
+#endif
+
+static G_CONST_RETURN gchar*
+ea_week_view_cell_get_name (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewCell *cell;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), NULL);
+
+ if (!accessible->name) {
+ AtkObject *ea_main_item;
+ GnomeCanvasItem *main_item;
+ gchar *new_name = g_strdup ("");
+ const gchar *row_label, *column_label;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ main_item = cell->week_view->main_canvas_item;
+ ea_main_item = atk_gobject_accessible_for_object (G_OBJECT (main_item));
+ column_label = atk_table_get_column_description (ATK_TABLE (ea_main_item),
+ cell->column);
+ row_label = atk_table_get_row_description (ATK_TABLE (ea_main_item),
+ cell->row);
+ new_name = g_strconcat (column_label, " ", row_label, NULL);
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name);
+ g_free (new_name);
+ }
+ return accessible->name;
+}
+
+static G_CONST_RETURN gchar*
+ea_week_view_cell_get_description (AtkObject *accessible)
+{
+ return ea_week_view_cell_get_name (accessible);
+}
+
+static AtkStateSet*
+ea_week_view_cell_ref_state_set (AtkObject *obj)
+{
+ AtkStateSet *state_set;
+ GObject *g_obj;
+ AtkObject *parent;
+ gint x, y, width, height;
+ gint parent_x, parent_y, parent_width, parent_height;
+
+ state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj));
+ if (!g_obj)
+ return state_set;
+
+ atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
+
+ parent = atk_object_get_parent (obj);
+ atk_component_get_extents (ATK_COMPONENT (obj), &x, &y,
+ &width, &height, ATK_XY_WINDOW);
+ atk_component_get_extents (ATK_COMPONENT (parent), &parent_x, &parent_y,
+ &parent_width, &parent_height, ATK_XY_WINDOW);
+
+
+ if (x + width < parent_x || x > parent_x + parent_width ||
+ y + height < parent_y || y > parent_y + parent_height)
+ /* the cell is out of the main canvas */
+ ;
+ else
+ atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
+
+ return state_set;
+}
+
+static AtkObject *
+ea_week_view_cell_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewCell *cell;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ return atk_gobject_accessible_for_object (G_OBJECT (cell->week_view->main_canvas_item));
+}
+
+static gint
+ea_week_view_cell_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewCell *cell;
+ AtkObject *parent;
+
+ g_return_val_if_fail (EA_IS_WEEK_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_WEEK_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 */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = component_interface_get_extents;
+}
+
+static void
+component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ AtkObject *atk_obj;
+ EWeekViewCell *cell;
+ EWeekView *week_view;
+ GtkWidget *main_canvas;
+ gint week_view_width, week_view_height;
+ gint scroll_x, scroll_y;
+
+ *x = *y = *width = *height = 0;
+
+ g_return_if_fail (EA_IS_WEEK_VIEW_CELL (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ week_view = cell->week_view;
+ main_canvas = cell->week_view->main_canvas;
+
+ atk_obj = atk_gobject_accessible_for_object (G_OBJECT (main_canvas));
+ atk_component_get_extents (ATK_COMPONENT (atk_obj),
+ x, y,
+ &week_view_width, &week_view_height,
+ coord_type);
+ gnome_canvas_get_scroll_offsets (GNOME_CANVAS (week_view->main_canvas),
+ &scroll_x, &scroll_y);
+ *x += week_view->col_offsets[cell->column] - scroll_x;
+ *y += week_view->row_offsets[cell->row*2]- scroll_y;
+ *width = week_view->col_widths[cell->column];
+ *height = week_view->row_heights[ cell->row*2]*2;
+}
diff --git a/a11y/calendar/ea-week-view-cell.h b/a11y/calendar/ea-week-view-cell.h
new file mode 100644
index 0000000000..4fcb0d0890
--- /dev/null
+++ b/a11y/calendar/ea-week-view-cell.h
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-week-view-cell.h
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Bolian Yin <bolian.yin@sun.com> Sun Microsystem Inc., 2003
+ * Author: Yang Wu <yang.wu@sun.com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#ifndef __EA_WEEK_VIEW_CELL_H__
+#define __EA_WEEK_VIEW_CELL_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-week-view.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define E_TYPE_WEEK_VIEW_CELL (e_week_view_cell_get_type ())
+#define E_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_WEEK_VIEW_CELL, EWeekViewCell))
+#define E_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_WEEK_VIEW_CELL, EWeekViewCellClass))
+#define E_IS_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_WEEK_VIEW_CELL))
+#define E_IS_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_WEEK_VIEW_CELL))
+#define E_WEEK_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_WEEK_VIEW_CELL, EWeekViewCellClass))
+
+typedef struct _EWeekViewCell EWeekViewCell;
+typedef struct _EWeekViewCellClass EWeekViewCellClass;
+
+struct _EWeekViewCell
+{
+ GObject parent;
+ EWeekView *week_view;
+ gint row;
+ gint column;
+};
+
+GType e_week_view_cell_get_type (void);
+
+struct _EWeekViewCellClass
+{
+ GObjectClass parent_class;
+};
+
+EWeekViewCell * e_week_view_cell_new (EWeekView *week_view, gint row, gint column);
+
+#define EA_TYPE_WEEK_VIEW_CELL (ea_week_view_cell_get_type ())
+#define EA_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCell))
+#define EA_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCellClass))
+#define EA_IS_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW_CELL))
+#define EA_IS_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW_CELL))
+#define EA_WEEK_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCellClass))
+
+typedef struct _EaWeekViewCell EaWeekViewCell;
+typedef struct _EaWeekViewCellClass EaWeekViewCellClass;
+
+struct _EaWeekViewCell
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_week_view_cell_get_type (void);
+
+struct _EaWeekViewCellClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject* ea_week_view_cell_new (GObject *gobj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __EA_WEEK_VIEW_CELL_H__ */
diff --git a/a11y/calendar/ea-week-view-main-item.c b/a11y/calendar/ea-week-view-main-item.c
new file mode 100644
index 0000000000..073ec7e10c
--- /dev/null
+++ b/a11y/calendar/ea-week-view-main-item.c
@@ -0,0 +1,1270 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-week-view-main-item.c
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Bolian Yin <bolian.yin@sun.com> Sun Microsystem Inc., 2003
+ * Author: Yang Wu <Yang.Wu@sun.com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#include "ea-week-view-main-item.h"
+#include "ea-week-view.h"
+#include "ea-week-view-cell.h"
+#include "ea-cell-table.h"
+
+/* EaWeekViewMainItem */
+static void ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass);
+
+static void ea_week_view_main_item_finalize (GObject *object);
+static G_CONST_RETURN gchar* ea_week_view_main_item_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_week_view_main_item_get_description (AtkObject *accessible);
+
+static gint ea_week_view_main_item_get_n_children (AtkObject *obj);
+static AtkObject* ea_week_view_main_item_ref_child (AtkObject *obj,
+ gint i);
+static AtkObject * ea_week_view_main_item_get_parent (AtkObject *accessible);
+static gint ea_week_view_main_item_get_index_in_parent (AtkObject *accessible);
+
+/* callbacks */
+static void ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data);
+static void ea_week_view_main_item_time_change_cb (EWeekView *week_view, gpointer data);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type);
+
+/* atk table interface */
+static void atk_table_interface_init (AtkTableIface *iface);
+static gint table_interface_get_index_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_column_at_index (AtkTable *table,
+ gint index);
+static gint table_interface_get_row_at_index (AtkTable *table,
+ gint index);
+static AtkObject* table_interface_ref_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_n_rows (AtkTable *table);
+static gint table_interface_get_n_columns (AtkTable *table);
+static gint table_interface_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+
+static gboolean table_interface_is_row_selected (AtkTable *table,
+ gint row);
+static gboolean table_interface_is_column_selected (AtkTable *table,
+ gint row);
+static gboolean table_interface_is_selected (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_selected_rows (AtkTable *table,
+ gint **rows_selected);
+static gint table_interface_get_selected_columns (AtkTable *table,
+ gint **columns_selected);
+static gboolean table_interface_add_row_selection (AtkTable *table, gint row);
+static gboolean table_interface_remove_row_selection (AtkTable *table,
+ gint row);
+static gboolean table_interface_add_column_selection (AtkTable *table,
+ gint column);
+static gboolean table_interface_remove_column_selection (AtkTable *table,
+ gint column);
+static AtkObject* table_interface_get_row_header (AtkTable *table, gint row);
+static AtkObject* table_interface_get_column_header (AtkTable *table,
+ gint in_col);
+static AtkObject* table_interface_get_caption (AtkTable *table);
+
+static G_CONST_RETURN gchar*
+table_interface_get_column_description (AtkTable *table, gint in_col);
+
+static G_CONST_RETURN gchar*
+table_interface_get_row_description (AtkTable *table, gint row);
+
+static AtkObject* table_interface_get_summary (AtkTable *table);
+
+/* atk selection interface */
+static void atk_selection_interface_init (AtkSelectionIface *iface);
+static gboolean selection_interface_add_selection (AtkSelection *selection,
+ gint i);
+static gboolean selection_interface_clear_selection (AtkSelection *selection);
+static AtkObject* selection_interface_ref_selection (AtkSelection *selection,
+ gint i);
+static gint selection_interface_get_selection_count (AtkSelection *selection);
+static gboolean selection_interface_is_child_selected (AtkSelection *selection,
+ gint i);
+
+/* helpers */
+static EaCellTable *
+ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item);
+
+static void
+ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item);
+
+static gint
+ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
+ gint row, gint column);
+static gint
+ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index);
+static gint
+ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index);
+static gint
+ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item,
+ gint row, gchar *buffer,
+ gint buffer_size);
+
+#ifdef ACC_DEBUG
+static gint n_ea_week_view_main_item_created = 0;
+static gint n_ea_week_view_main_item_destroyed = 0;
+#endif
+
+static gpointer parent_class = NULL;
+
+GType
+ea_week_view_main_item_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaWeekViewMainItemClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_week_view_main_item_class_init,
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaWeekViewMainItem), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo atk_table_info = {
+ (GInterfaceInitFunc) atk_table_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ static const GInterfaceInfo atk_selection_info = {
+ (GInterfaceInitFunc) atk_selection_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (GailCanvasItem, in this case)
+ *
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ e_week_view_main_item_get_type());
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaWeekViewMainItem", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+ g_type_add_interface_static (type, ATK_TYPE_TABLE,
+ &atk_table_info);
+ g_type_add_interface_static (type, ATK_TYPE_SELECTION,
+ &atk_selection_info);
+ }
+
+ return type;
+}
+
+static void
+ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = ea_week_view_main_item_finalize;
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_week_view_main_item_get_name;
+ class->get_description = ea_week_view_main_item_get_description;
+
+ class->get_n_children = ea_week_view_main_item_get_n_children;
+ class->ref_child = ea_week_view_main_item_ref_child;
+ class->get_parent = ea_week_view_main_item_get_parent;
+ class->get_index_in_parent = ea_week_view_main_item_get_index_in_parent;
+}
+
+AtkObject*
+ea_week_view_main_item_new (GObject *obj)
+{
+ AtkObject *accessible;
+ GnomeCalendar *gcal;
+ EWeekViewMainItem *main_item;
+
+ g_return_val_if_fail (E_IS_WEEK_VIEW_MAIN_ITEM (obj), NULL);
+
+ accessible = ATK_OBJECT (g_object_new (EA_TYPE_WEEK_VIEW_MAIN_ITEM,
+ NULL));
+
+ atk_object_initialize (accessible, obj);
+
+#ifdef ACC_DEBUG
+ ++n_ea_week_view_main_item_created;
+ printf ("ACC_DEBUG: n_ea_week_view_main_item_created = %d\n",
+ n_ea_week_view_main_item_created);
+#endif
+ main_item = E_WEEK_VIEW_MAIN_ITEM (obj);
+ g_signal_connect (main_item->week_view, "selected_time_changed",
+ G_CALLBACK (ea_week_view_main_item_time_change_cb),
+ accessible);
+
+ /* listen for date changes of calendar */
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (main_item->week_view));
+ if (gcal)
+ g_signal_connect (gcal, "dates_shown_changed",
+ G_CALLBACK (ea_week_view_main_item_dates_change_cb),
+ accessible);
+
+ return accessible;
+}
+
+static void
+ea_week_view_main_item_finalize (GObject *object)
+{
+ EaWeekViewMainItem *ea_main_item;
+
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (object));
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (object);
+
+ /* Free the allocated cell data */
+ ea_week_view_main_item_destory_cell_data (ea_main_item);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+#ifdef ACC_DEBUG
+ ++n_ea_week_view_main_item_destroyed;
+ printf ("ACC_DEBUG: n_ea_week_view_main_item_destroyed = %d\n",
+ n_ea_week_view_main_item_destroyed);
+#endif
+}
+
+static G_CONST_RETURN gchar*
+ea_week_view_main_item_get_name (AtkObject *accessible)
+{
+ AtkObject *parent;
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
+ parent = atk_object_get_parent (accessible);
+ return atk_object_get_name (parent);
+
+}
+
+static G_CONST_RETURN gchar*
+ea_week_view_main_item_get_description (AtkObject *accessible)
+{
+ return "a table to view and select the current time range";
+}
+
+static gint
+ea_week_view_main_item_get_n_children (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->multi_week_view)
+ return 7 * week_view->weeks_shown;
+ else
+ return 7;
+}
+
+static AtkObject *
+ea_week_view_main_item_ref_child (AtkObject *accessible, gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ gint n_children;
+ EWeekViewCell *cell;
+ EaCellTable *cell_data;
+ EaWeekViewMainItem *ea_main_item;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ n_children = ea_week_view_main_item_get_n_children (accessible);
+ if (index < 0 || index >= n_children)
+ return NULL;
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (accessible);
+ cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+ cell = ea_cell_table_get_cell_at_index (cell_data, index);
+ if (!cell) {
+ gint row, column;
+
+ row = ea_week_view_main_item_get_row_at_index (ea_main_item, index);
+ column = ea_week_view_main_item_get_column_at_index (ea_main_item, index);
+ cell = e_week_view_cell_new (week_view, row, column);
+ ea_cell_table_set_cell_at_index (cell_data, index, cell);
+ g_object_unref (cell);
+ }
+
+ return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell)));
+}
+
+static AtkObject *
+ea_week_view_main_item_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ return gtk_widget_get_accessible (GTK_WIDGET (main_item->week_view));
+}
+
+static gint
+ea_week_view_main_item_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ /* always the first child of ea-week-view */
+ return 0;
+}
+
+/* callbacks */
+
+static void
+ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data)
+{
+ EaWeekViewMainItem *ea_main_item;
+
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data));
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_week_view_main_item update cb\n");
+#endif
+
+ ea_week_view_main_item_destory_cell_data (ea_main_item);
+}
+
+static void
+ea_week_view_main_item_time_change_cb (EWeekView *week_view, gpointer data)
+{
+ EaWeekViewMainItem *ea_main_item;
+ AtkObject *item_cell = NULL;
+
+ g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data));
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_week_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");
+}
+
+/* helpers */
+
+static gint
+ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
+ gint row, gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (row >= 0 && row < week_view->weeks_shown &&
+ column >= 0 && column < 7)
+ return row * 7 + column;
+
+ return -1;
+}
+
+static gint
+ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ gint n_children;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
+ if (index >= 0 && index < n_children)
+ return index / 7;
+ return -1;
+}
+
+static gint
+ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ gint n_children;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
+ if (index >= 0 && index < n_children)
+ return index % 7;
+ return -1;
+}
+
+static gint
+ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item,
+ gint row, gchar *buffer, gint buffer_size)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ g_return_val_if_fail (ea_main_item, 0);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return 0 ;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ return g_snprintf (buffer, buffer_size, "the %i week",
+ row + 1);
+
+}
+
+static EaCellTable *
+ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaCellTable *cell_data;
+
+ g_return_val_if_fail (ea_main_item, NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ cell_data = g_object_get_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table");
+ if (!cell_data) {
+ cell_data = ea_cell_table_create (week_view->weeks_shown, 7, TRUE);
+ g_object_set_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table", cell_data);
+ }
+ return cell_data;
+}
+
+static void
+ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item)
+{
+ EaCellTable *cell_data;
+
+ g_return_if_fail (ea_main_item);
+
+ cell_data = g_object_get_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table");
+ if (cell_data) {
+ ea_cell_table_destroy (cell_data);
+ g_object_set_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table", NULL);
+ }
+}
+
+/* Atk Component Interface */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = component_interface_get_extents;
+}
+
+static void
+component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ AtkObject *ea_canvas;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ *x = *y = *width = *height = 0;
+
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ ea_canvas = gtk_widget_get_accessible (week_view->main_canvas);
+ atk_component_get_extents (ATK_COMPONENT (ea_canvas), x, y,
+ width, height, coord_type);
+}
+
+/* atk table interface */
+
+static void
+atk_table_interface_init (AtkTableIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->ref_at = table_interface_ref_at;
+
+ iface->get_n_rows = table_interface_get_n_rows;
+ iface->get_n_columns = table_interface_get_n_columns;
+ iface->get_index_at = table_interface_get_index_at;
+ iface->get_column_at_index = table_interface_get_column_at_index;
+ iface->get_row_at_index = table_interface_get_row_at_index;
+ iface->get_column_extent_at = table_interface_get_column_extent_at;
+ iface->get_row_extent_at = table_interface_get_row_extent_at;
+
+ iface->is_selected = table_interface_is_selected;
+ iface->get_selected_rows = table_interface_get_selected_rows;
+ iface->get_selected_columns = table_interface_get_selected_columns;
+ iface->is_row_selected = table_interface_is_row_selected;
+ iface->is_column_selected = table_interface_is_column_selected;
+ iface->add_row_selection = table_interface_add_row_selection;
+ iface->remove_row_selection = table_interface_remove_row_selection;
+ iface->add_column_selection = table_interface_add_column_selection;
+ iface->remove_column_selection = table_interface_remove_column_selection;
+
+ iface->get_row_header = table_interface_get_row_header;
+ iface->get_column_header = table_interface_get_column_header;
+ iface->get_caption = table_interface_get_caption;
+ iface->get_summary = table_interface_get_summary;
+ iface->get_row_description = table_interface_get_row_description;
+ iface->get_column_description = table_interface_get_column_description;
+}
+
+static AtkObject*
+table_interface_ref_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ return ea_week_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index);
+}
+
+static gint
+table_interface_get_n_rows (AtkTable *table)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ return week_view->weeks_shown;
+}
+
+static gint
+table_interface_get_n_columns (AtkTable *table)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ return 7;
+}
+
+static gint
+table_interface_get_index_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ return ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+}
+
+static gint
+table_interface_get_column_at_index (AtkTable *table,
+ gint index)
+{
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ return ea_week_view_main_item_get_column_at_index (ea_main_item, index);
+}
+
+static gint
+table_interface_get_row_at_index (AtkTable *table,
+ gint index)
+{
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ return ea_week_view_main_item_get_row_at_index (ea_main_item, index);
+}
+
+static gint
+table_interface_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+ gint width = 0, height = 0;
+ AtkObject *child;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item),
+ index);
+ if (child)
+ atk_component_get_size (ATK_COMPONENT (child),
+ &width, &height);
+
+ return width;
+}
+
+static gint
+table_interface_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+ gint width = 0, height = 0;
+ AtkObject *child;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item),
+ index);
+ if (child)
+ atk_component_get_size (ATK_COMPONENT (child),
+ &width, &height);
+
+ return height;
+}
+
+static gboolean
+table_interface_is_row_selected (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1)
+ /* no selection */
+ return FALSE;
+ if ((row < 0)&&(row + 1 > week_view->weeks_shown ))
+ return FALSE;
+ if (((week_view->selection_start_day < row*7)&&(week_view->selection_end_day<row*7))
+ ||((week_view->selection_start_day > row*7+6)&&(week_view->selection_end_day > row*7+6)))
+ return FALSE;
+ else
+ return TRUE;
+}
+
+static gboolean
+table_interface_is_selected (AtkTable *table,
+ gint row,
+ gint column)
+{
+ return table_interface_is_row_selected (table, row) && table_interface_is_column_selected(table, column);
+}
+
+static gboolean
+table_interface_is_column_selected (AtkTable *table,
+ gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if ((column <0)||(column >6))
+ return FALSE;
+ else {
+ gint i;
+ for (i=0;i<week_view->weeks_shown;i++)
+ if ((column + i*7>= week_view->selection_start_day ) &&
+ (column + i*7<= week_view->selection_end_day))
+ return TRUE;
+ return FALSE;
+ }
+}
+
+static gint
+table_interface_get_selected_rows (AtkTable *table,
+ gint **rows_selected)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint start_row = -1, n_rows = 0;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1)
+ return 0;
+
+ start_row = week_view->selection_start_day;
+ n_rows = week_view->selection_end_day - start_row + 1;
+
+ if (n_rows > 0 && start_row != -1 && rows_selected) {
+ gint index;
+
+ *rows_selected = (gint *) g_malloc (n_rows * sizeof (gint));
+ for (index = 0; index < n_rows; ++index)
+ (*rows_selected)[index] = start_row + index;
+ }
+ return n_rows;
+}
+
+static gint
+table_interface_get_selected_columns (AtkTable *table,
+ gint **columns_selected)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint start_column = -1, n_columns = 0;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1)
+ return 0;
+ if (week_view->selection_end_day - week_view->selection_start_day >= 6 ) {
+ start_column = 0;
+ n_columns =7;
+ } else {
+ start_column = week_view->selection_start_day % 7;
+ n_columns = (week_view->selection_end_day % 7) - start_column + 1;
+ }
+ if (n_columns > 0 && start_column != -1 && columns_selected) {
+ gint index;
+
+ *columns_selected = (gint *) g_malloc (n_columns * sizeof (gint));
+ for (index = 0; index < n_columns; ++index)
+ (*columns_selected)[index] = start_column + index;
+ }
+ return n_columns;
+}
+
+static gboolean
+table_interface_add_row_selection (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ /* FIXME: we need multi-selection */
+
+ week_view->selection_start_day = row * 7;
+ week_view->selection_end_day = row *7 + 6;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+table_interface_remove_row_selection (AtkTable *table,
+ gint row)
+{
+ return FALSE;
+}
+
+static gboolean
+table_interface_add_column_selection (AtkTable *table,
+ gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ /* FIXME: we need multi-selection */
+
+ week_view->selection_start_day = column;
+ week_view->selection_end_day = (week_view->weeks_shown - 1)*7+column;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+table_interface_remove_column_selection (AtkTable *table,
+ gint column)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return FALSE;
+}
+
+static AtkObject*
+table_interface_get_row_header (AtkTable *table,
+ gint row)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static AtkObject*
+table_interface_get_column_header (AtkTable *table,
+ gint in_col)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static AtkObject*
+table_interface_get_caption (AtkTable *table)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static G_CONST_RETURN gchar*
+table_interface_get_column_description (AtkTable *table,
+ gint in_col)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ const gchar *description;
+ EaCellTable *cell_data;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (in_col < 0 || in_col > 6)
+ return NULL;
+ cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ description = ea_cell_table_get_column_label (cell_data, in_col);
+ if (!description) {
+ gchar buffer[128];
+
+ switch (in_col) {
+ case 0:
+ g_snprintf(buffer,128,"Monday");
+ break;
+ case 1:
+ g_snprintf(buffer,128,"Tuesday");
+ break;
+ case 2:
+ g_snprintf(buffer,128,"Wednesday");
+ break;
+ case 3:
+ g_snprintf(buffer,128,"Thursday");
+ break;
+ case 4:
+ g_snprintf(buffer,128,"Friday");
+ break;
+ case 5:
+ g_snprintf(buffer,128,"Saturday");
+ break;
+ case 6:
+ g_snprintf(buffer,128,"Sunday");
+ break;
+ default:
+ break;
+ }
+
+ ea_cell_table_set_column_label (cell_data, in_col, buffer);
+ description = ea_cell_table_get_column_label (cell_data, in_col);
+ }
+ return description;
+}
+
+static G_CONST_RETURN gchar*
+table_interface_get_row_description (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ const gchar *description;
+ EaCellTable *cell_data;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (row < 0 || row >= week_view->weeks_shown)
+ return NULL;
+ cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ description = ea_cell_table_get_row_label (cell_data, row);
+ if (!description) {
+ gchar buffer[128];
+ ea_week_view_main_item_get_row_label (ea_main_item, row, buffer, sizeof (buffer));
+ ea_cell_table_set_row_label (cell_data, row, buffer);
+ description = ea_cell_table_get_row_label (cell_data,
+ row);
+ }
+ return description;
+}
+
+static AtkObject*
+table_interface_get_summary (AtkTable *table)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+/* atkselection interface */
+
+static void
+atk_selection_interface_init (AtkSelectionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->add_selection = selection_interface_add_selection;
+ iface->clear_selection = selection_interface_clear_selection;
+ iface->ref_selection = selection_interface_ref_selection;
+ iface->get_selection_count = selection_interface_get_selection_count;
+ iface->is_child_selected = selection_interface_is_child_selected;
+}
+
+static gboolean
+selection_interface_add_selection (AtkSelection *selection, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (i < 0 || i > week_view->weeks_shown * 7 -1)
+ return FALSE;
+
+ /*FIXME: multi-selection is needed */
+ week_view->selection_start_day = i;
+ week_view->selection_end_day = i;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+selection_interface_clear_selection (AtkSelection *selection)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ week_view->selection_start_day = -1;
+ week_view->selection_end_day = -1;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+
+ return TRUE;
+}
+
+static AtkObject*
+selection_interface_ref_selection (AtkSelection *selection, gint i)
+{
+ gint count;
+ GObject *g_obj;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_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));
+ week_view = E_WEEK_VIEW_MAIN_ITEM (g_obj)->week_view;
+ start_index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ week_view->selection_start_day / 7,
+ week_view->selection_start_day % 7);
+
+ return ea_week_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i);
+}
+
+static gint
+selection_interface_get_selection_count (AtkSelection *selection)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return 0;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1 ||
+ week_view->selection_end_day == -1)
+ return 0;
+
+ return week_view->selection_end_day - week_view->selection_start_day + 1;
+}
+
+static gboolean
+selection_interface_is_child_selected (AtkSelection *selection, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if ((week_view->selection_start_day <= i)&&(week_view->selection_end_day >= i))
+ return TRUE;
+ else
+ return FALSE;
+}
+
diff --git a/a11y/calendar/ea-week-view-main-item.h b/a11y/calendar/ea-week-view-main-item.h
new file mode 100644
index 0000000000..fcf8b45fc8
--- /dev/null
+++ b/a11y/calendar/ea-week-view-main-item.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-week-view-main-item.h
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Bolian Yin <bolian.yin@sun.com> Sun Microsystem Inc., 2003
+ * Author: Yang Wu <Yang.Wu@sun.com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#ifndef __EA_WEEK_VIEW_MAIN_ITEM_H__
+#define __EA_WEEK_VIEW_MAIN_ITEM_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-week-view-main-item.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define EA_TYPE_WEEK_VIEW_MAIN_ITEM (ea_week_view_main_item_get_type ())
+#define EA_WEEK_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItem))
+#define EA_WEEK_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItemClass))
+#define EA_IS_WEEK_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM))
+#define EA_IS_WEEK_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW_MAIN_ITEM))
+#define EA_WEEK_VIEW_MAIN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItemClass))
+
+typedef struct _EaWeekViewMainItem EaWeekViewMainItem;
+typedef struct _EaWeekViewMainItemClass EaWeekViewMainItemClass;
+
+struct _EaWeekViewMainItem
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_week_view_main_item_get_type (void);
+
+struct _EaWeekViewMainItemClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject* ea_week_view_main_item_new (GObject *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __EA_WEEK_VIEW_MAIN_ITEM_H__ */
diff --git a/a11y/calendar/ea-week-view.c b/a11y/calendar/ea-week-view.c
index 3c3e13a268..966ec49b28 100644
--- a/a11y/calendar/ea-week-view.c
+++ b/a11y/calendar/ea-week-view.c
@@ -71,7 +71,7 @@ ea_week_view_get_type (void)
*/
factory = atk_registry_get_factory (atk_get_default_registry (),
- e_cal_view_get_type());
+ e_calendar_view_get_type());
derived_atk_type = atk_object_factory_get_accessible_type (factory);
g_type_query (derived_atk_type, &query);
@@ -227,6 +227,9 @@ ea_week_view_get_n_children (AtkObject *accessible)
++count;
}
+ /* "+1" for the main item */
+ count++;
+
#ifdef ACC_DEBUG
printf("AccDebug: week view %p has %d children\n", (void *)week_view, count);
#endif
@@ -255,6 +258,11 @@ ea_week_view_ref_child (AtkObject *accessible, gint index)
week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget);
max_count = week_view->events->len;
+ if (index == 0) {
+ /* index == 0 is the main item */
+ atk_object = atk_gobject_accessible_for_object (G_OBJECT (week_view->main_canvas_item));
+ g_object_ref (atk_object);
+ } else
for (event_index = 0; event_index < max_count; ++event_index) {
EWeekViewEvent *event;
EWeekViewEventSpan *span;
@@ -282,7 +290,7 @@ ea_week_view_ref_child (AtkObject *accessible, gint index)
else
continue;
- if (count == (index + 1)) {
+ if (count == index) {
if (span->text_item) {
/* Not use atk_gobject_accessible_for_object for event
* text_item we need to do special thing here
@@ -290,7 +298,7 @@ ea_week_view_ref_child (AtkObject *accessible, gint index)
atk_object = ea_calendar_helpers_get_accessible_for (span->text_item);
}
else {
- atk_object = atk_gobject_accessible_for_object (G_OBJECT(week_view->jump_buttons[current_day == -1 ? 0 : current_day]));
+ atk_object = ea_calendar_helpers_get_accessible_for (week_view->jump_buttons[current_day == -1 ? 0 : current_day]);
}
g_object_ref (atk_object);
break;