diff options
-rw-r--r-- | a11y/ChangeLog | 21 | ||||
-rw-r--r-- | a11y/Makefile.am | 34 | ||||
-rw-r--r-- | a11y/calendar/Makefile.am | 38 | ||||
-rw-r--r-- | a11y/calendar/ea-cal-view-event.c | 333 | ||||
-rw-r--r-- | a11y/calendar/ea-cal-view-event.h | 64 | ||||
-rw-r--r-- | a11y/calendar/ea-cal-view.c | 271 | ||||
-rw-r--r-- | a11y/calendar/ea-cal-view.h | 64 | ||||
-rw-r--r-- | a11y/calendar/ea-calendar-helpers.c | 148 | ||||
-rw-r--r-- | a11y/calendar/ea-calendar-helpers.h | 43 | ||||
-rw-r--r-- | a11y/calendar/ea-calendar.c | 135 | ||||
-rw-r--r-- | a11y/calendar/ea-calendar.h | 37 | ||||
-rw-r--r-- | a11y/calendar/ea-day-view.c | 245 | ||||
-rw-r--r-- | a11y/calendar/ea-day-view.h | 64 | ||||
-rw-r--r-- | a11y/calendar/ea-gnome-calendar.c | 234 | ||||
-rw-r--r-- | a11y/calendar/ea-gnome-calendar.h | 65 | ||||
-rw-r--r-- | a11y/calendar/ea-week-view.c | 235 | ||||
-rw-r--r-- | a11y/calendar/ea-week-view.h | 65 | ||||
-rw-r--r-- | a11y/ea-factory.h | 94 |
18 files changed, 2190 insertions, 0 deletions
diff --git a/a11y/ChangeLog b/a11y/ChangeLog new file mode 100644 index 0000000000..dc933096e9 --- /dev/null +++ b/a11y/ChangeLog @@ -0,0 +1,21 @@ +2003-08-20 Bolian Yin <bolian.yin@sun.com> + setup the a11y directory for evolution accessibility work + New files are: + ChangeLog + ea-factory.h + Makefile.am + calendar/ea-calendar.c + calendar/ea-calendar.h + calendar/ea-calendar-helpers.c + calendar/ea-calendar-helpers.h + calendar/ea-cal-view.c + calendar/ea-cal-view.h + calendar/ea-cal-view-event.c + calendar/ea-cal-view-event.h + calendar/ea-day-view.c + calendar/ea-day-view.h + calendar/ea-week-view.c + calendar/ea-week-view.h + calendar/ea-gnome-calendar.c + calendar/ea-gnome-calendar.h + calendar/Makefile.am diff --git a/a11y/Makefile.am b/a11y/Makefile.am new file mode 100644 index 0000000000..4ff451e404 --- /dev/null +++ b/a11y/Makefile.am @@ -0,0 +1,34 @@ +# Calendar IDL files + +CALENDAR_IDLS = $(top_srcdir)/calendar/idl/evolution-calendar.idl + +CALENDAR_IDL_GENERATED_H = evolution-calendar.h + +$(CALENDAR_IDL_GENERATED_H): $(CALENDAR_IDLS) + $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) \ + $(top_srcdir)/calendar/idl/evolution-calendar.idl + +SUBDIRS = calendar + +INCLUDES = \ + -DPREFIX=\"$(prefix)\" \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DDATADIR=\"$(datadir)\" \ + -DLIBDIR=\"$(libdir)\" \ + -DG_LOG_DOMAIN=\"evolution-a11y\" \ + -I$(top_srcdir) \ + -DG_DISABLE_DEPRECATED \ + -DLIBGNOME_DISABLE_DEPRECATED \ + $(EVOLUTION_CALENDAR_CFLAGS) \ + $(A11Y_CFLAGS) + +privlib_LTLIBRARIES = libevolution-a11y.la + +libevolution_a11y_la_SOURCES = \ + $(CALENDAR_IDL_GENERATED_H) + +BUILT_SOURCES = $(CALENDAR_IDL_GENERATED_H) + +libevolution_a11y_la_LIBADD = \ + $(A11Y_LIBS) \ + $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la diff --git a/a11y/calendar/Makefile.am b/a11y/calendar/Makefile.am new file mode 100644 index 0000000000..849e152135 --- /dev/null +++ b/a11y/calendar/Makefile.am @@ -0,0 +1,38 @@ + +noinst_LTLIBRARIES = libevolution-calendar-a11y.la + +INCLUDES = \ + -DG_LOG_DOMAIN=\"evolution-a11y\" \ + -I$(top_srcdir)/shell \ + -I$(top_srcdir)/calendar \ + -I$(top_srcdir)/calendar/cal-client \ + -I$(top_srcdir)/libical/src/libical \ + -I$(top_srcdir)/calendar/gui \ + -I$(top_srcdir)/widgets \ + -I$(top_srcdir)/a11y \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ + -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ + -DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \ + -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ + -DG_DISABLE_DEPRECATED \ + -DPREFIX=\""$(prefix)"\" \ + $(A11Y_CFLAGS) \ + $(EVOLUTION_CALENDAR_CFLAGS) + +libevolution_calendar_a11y_la_SOURCES = \ + ea-calendar.c \ + ea-calendar.h \ + ea-calendar-helpers.c \ + ea-calendar-helpers.h \ + ea-cal-view.c \ + ea-cal-view.h \ + ea-cal-view-event.c \ + ea-cal-view-event.h \ + ea-day-view.c \ + ea-day-view.h \ + ea-week-view.c \ + ea-week-view.h \ + ea-gnome-calendar.c \ + ea-gnome-calendar.h diff --git a/a11y/calendar/ea-cal-view-event.c b/a11y/calendar/ea-cal-view-event.c new file mode 100644 index 0000000000..b7405acafc --- /dev/null +++ b/a11y/calendar/ea-cal-view-event.c @@ -0,0 +1,333 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-cal-view-event.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 + * + */ + +#include "ea-cal-view-event.h" +#include "ea-calendar-helpers.h" +#include "ea-day-view.h" +#include "ea-week-view.h" +#include <gal/e-text/e-text.h> + +static void ea_cal_view_event_class_init (EaCalViewEventClass *klass); + +static G_CONST_RETURN gchar* ea_cal_view_event_get_name (AtkObject *accessible); +static G_CONST_RETURN gchar* ea_cal_view_event_get_description (AtkObject *accessible); +static AtkObject* ea_cal_view_event_get_parent (AtkObject *accessible); +static gint ea_cal_view_event_get_index_in_parent (AtkObject *accessible); + +static gpointer parent_class = NULL; + +GType +ea_cal_view_event_get_type (void) +{ + static GType type = 0; + AtkObjectFactory *factory; + GTypeQuery query; + GType derived_atk_type; + + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaCalViewEventClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_cal_view_event_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaCalViewEvent), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + /* + * Figure out the size of the class and instance + * we are run-time deriving from (atk object for E_TEXT, in this case) + */ + + factory = atk_registry_get_factory (atk_get_default_registry (), + E_TYPE_TEXT); + 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, text and other interfaces from E_TEXT */ + type = g_type_register_static (derived_atk_type, + "EaCalViewEvent", &tinfo, 0); + } + + return type; +} + +static void +ea_cal_view_event_class_init (EaCalViewEventClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + + class->get_name = ea_cal_view_event_get_name; + class->get_description = ea_cal_view_event_get_description; + class->get_parent = ea_cal_view_event_get_parent; + class->get_index_in_parent = ea_cal_view_event_get_index_in_parent; + +} + +AtkObject* +ea_cal_view_event_new (GObject *obj) +{ + AtkObject *atk_obj = NULL; + GObject *target_obj; + ECalView *cal_view; + + + g_return_val_if_fail (E_IS_TEXT (obj), NULL); + cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (obj)); + if (E_IS_WEEK_VIEW (cal_view)) { + gint event_num, span_num; + EWeekViewEvent *week_view_event; + EWeekViewEventSpan *event_span; + EWeekView *week_view = E_WEEK_VIEW (cal_view); + + /* for week view, we need to check if a atkobject exists for + * the first span of the same event + */ + if (!e_week_view_find_event_from_item (week_view, + GNOME_CANVAS_ITEM (obj), + &event_num, + &span_num)) + return NULL; + week_view_event = &g_array_index (week_view->events, + EWeekViewEvent, + event_num); + /* get the first span */ + event_span = &g_array_index (week_view->spans, + EWeekViewEventSpan, + week_view_event->spans_index); + target_obj = G_OBJECT (event_span->text_item); + atk_obj = g_object_get_data (target_obj, "accessible-object"); + + } + else + target_obj = obj; + + if (!atk_obj) { + atk_obj = ATK_OBJECT (g_object_new (EA_TYPE_CAL_VIEW_EVENT, + NULL)); + atk_object_initialize (atk_obj, target_obj); + atk_obj->role = ATK_ROLE_TEXT; +#ifdef ACC_DEBUG + printf ("EvoAcc: ea_cal_view_event created %p for item=%p\n", + atk_obj, target_obj); +#endif + } + + /* the registered factory for E_TEXT is cannot create a EaCalViewEvent, + * we should save the EaCalViewEvent object in it. + */ + g_object_set_data (obj, "accessible-object", atk_obj); + + return atk_obj; +} + +static G_CONST_RETURN gchar* +ea_cal_view_event_get_name (AtkObject *accessible) +{ + g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL); + + if (accessible->name) + return accessible->name; + else { + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + ECalViewEvent *event; + gchar *tmp_name; + gchar *new_name = g_strdup (""); + CalComponentText comp_text; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj || !E_IS_TEXT (g_obj)) + return NULL; + event = ea_calendar_helpers_get_cal_view_event_from (GNOME_CANVAS_ITEM(g_obj)); + + if (event && event->comp) { + CalComponent *comp = event->comp; + + if (cal_component_has_alarms (comp)) { + tmp_name = new_name; + new_name = g_strconcat (new_name, "alarm ", NULL); + g_free (tmp_name); + } + + if (cal_component_has_recurrences (comp)) { + tmp_name = new_name; + new_name = g_strconcat (new_name, "recurrence ", NULL); + g_free (tmp_name); + } + + if (event->different_timezone) { + tmp_name = new_name; + new_name = g_strconcat (new_name, "time-zone ", NULL); + g_free (tmp_name); + } + + if (cal_component_has_organizer (comp)) { + tmp_name = new_name; + new_name = g_strconcat (new_name, "meeting ", NULL); + g_free (tmp_name); + } + } + tmp_name = new_name; + new_name = g_strconcat (new_name, "event. Summary is ", NULL); + g_free (tmp_name); + + cal_component_get_summary (event->comp, &comp_text); + if (comp_text.value) { + char *text = (char*) comp_text.value; + tmp_name = new_name; + new_name = g_strconcat (new_name, text, NULL); + g_free (tmp_name); + } + else { + tmp_name = new_name; + new_name = g_strconcat (new_name, "empty", NULL); + g_free (tmp_name); + } + + ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name); +#ifdef ACC_DEBUG + printf("EvoAcc: name for event accobj=%p, is %s\n", + accessible, new_name); +#endif + g_free (new_name); + return accessible->name; + } +} + +static G_CONST_RETURN gchar* +ea_cal_view_event_get_description (AtkObject *accessible) +{ + if (accessible->description) + return accessible->description; + + return "calendar view event"; +} + +static AtkObject * +ea_cal_view_event_get_parent (AtkObject *accessible) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + GnomeCanvasItem *canvas_item; + ECalView *cal_view; + + g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL); + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (g_obj == NULL) + /* Object is defunct */ + return NULL; + canvas_item = GNOME_CANVAS_ITEM (g_obj); + + cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); + + if (!cal_view) + return NULL; + + return gtk_widget_get_accessible (GTK_WIDGET (cal_view)); +} + +static gint +ea_cal_view_event_get_index_in_parent (AtkObject *accessible) +{ + GObject *g_obj; + GnomeCanvasItem *canvas_item; + ECalView *cal_view; + ECalViewEvent *cal_view_event; + + g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), -1); + g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)); + if (!g_obj) + /* defunct object*/ + return -1; + + canvas_item = GNOME_CANVAS_ITEM (g_obj); + cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); + if (!cal_view) + return -1; + + cal_view_event = ea_calendar_helpers_get_cal_view_event_from (canvas_item); + if (!cal_view_event) + return -1; + + if (E_IS_DAY_VIEW (cal_view)) { + gint day, event_num, num_before; + EDayViewEvent *day_view_event; + EDayView *day_view = E_DAY_VIEW (cal_view); + + /* the long event comes first in the order */ + for (event_num = day_view->long_events->len - 1; event_num >= 0; + --event_num) { + day_view_event = &g_array_index (day_view->long_events, + EDayViewEvent, event_num); + if (cal_view_event == (ECalViewEvent*)day_view_event) + return event_num; + + } + num_before = day_view->long_events->len; + + for (day = 0; day < day_view->days_shown; ++day) { + for (event_num = day_view->events[day]->len - 1; event_num >= 0; + --event_num) { + day_view_event = &g_array_index (day_view->events[day], + EDayViewEvent, event_num); + if (cal_view_event == (ECalViewEvent*)day_view_event) + return num_before + event_num; + } + num_before += day_view->events[day]->len; + } + } + 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 == (ECalViewEvent*)week_view_event) + return index; + } + } + else { + g_assert_not_reached (); + return -1; + } + return -1; +} diff --git a/a11y/calendar/ea-cal-view-event.h b/a11y/calendar/ea-cal-view-event.h new file mode 100644 index 0000000000..f139dde9fb --- /dev/null +++ b/a11y/calendar/ea-cal-view-event.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-cal-view-event.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 + * + */ + +#ifndef __EA_CAL_VIEW_EVENT_H__ +#define __EA_CAL_VIEW_EVENT_H__ + +#include <atk/atkgobjectaccessible.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EA_TYPE_CAL_VIEW_EVENT (ea_cal_view_event_get_type ()) +#define EA_CAL_VIEW_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEvent)) +#define EA_CAL_VIEW_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEventClass)) +#define EA_IS_CAL_VIEW_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CAL_VIEW_EVENT)) +#define EA_IS_CAL_VIEW_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CAL_VIEW_EVENT)) +#define EA_CAL_VIEW_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEventClass)) + +typedef struct _EaCalViewEvent EaCalViewEvent; +typedef struct _EaCalViewEventClass EaCalViewEventClass; + +struct _EaCalViewEvent +{ + AtkGObjectAccessible parent; +}; + +GType ea_cal_view_event_get_type (void); + +struct _EaCalViewEventClass +{ + AtkGObjectAccessibleClass parent_class; +}; + +AtkObject *ea_cal_view_event_new (GObject *obj); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __EA_CAL_VIEW_EVENT_H__ */ diff --git a/a11y/calendar/ea-cal-view.c b/a11y/calendar/ea-cal-view.c new file mode 100644 index 0000000000..f31d24cc55 --- /dev/null +++ b/a11y/calendar/ea-cal-view.c @@ -0,0 +1,271 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-cal-view.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 + * + */ + +#include "ea-cal-view.h" +#include "ea-calendar-helpers.h" +#include "e-day-view.h" +#include "e-week-view.h" +#include "calendar-commands.h" +#include <glib/gstrfuncs.h> + +static void ea_cal_view_class_init (EaCalViewClass *klass); + +static AtkObject* ea_cal_view_get_parent (AtkObject *accessible); +static gint ea_cal_view_get_index_in_parent (AtkObject *accessible); +static void ea_cal_view_real_initialize (AtkObject *accessible, gpointer data); + +static void ea_cal_view_event_changed_cb (ECalView *cal_view, + ECalViewEvent *event, gpointer data); +static void ea_cal_view_event_added_cb (ECalView *cal_view, + ECalViewEvent *event, gpointer data); + +static void ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data); + +static gpointer parent_class = NULL; + +GType +ea_cal_view_get_type (void) +{ + static GType type = 0; + AtkObjectFactory *factory; + GTypeQuery query; + GType derived_atk_type; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaCalViewClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_cal_view_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaCalView), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + /* + * Figure out the size of the class and instance + * we are run-time deriving from (GailWidget, in this case) + */ + + factory = atk_registry_get_factory (atk_get_default_registry (), + GTK_TYPE_WIDGET); + 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, + "EaCalView", &tinfo, 0); + } + + return type; +} + +static void +ea_cal_view_class_init (EaCalViewClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + class->get_parent = ea_cal_view_get_parent; + class->get_index_in_parent = ea_cal_view_get_index_in_parent; + class->initialize = ea_cal_view_real_initialize; +} + +AtkObject* +ea_cal_view_new (GtkWidget *widget) +{ + GObject *object; + AtkObject *accessible; + + g_return_val_if_fail (E_IS_CAL_VIEW (widget), NULL); + + object = g_object_new (EA_TYPE_CAL_VIEW, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + + return accessible; +} + +static void +ea_cal_view_real_initialize (AtkObject *accessible, gpointer data) +{ + ECalView *cal_view; + GnomeCalendar *gcal; + + g_return_if_fail (EA_IS_CAL_VIEW (accessible)); + g_return_if_fail (E_IS_CAL_VIEW (data)); + + ATK_OBJECT_CLASS (parent_class)->initialize (accessible, data); + accessible->role = ATK_ROLE_CANVAS; + cal_view = E_CAL_VIEW (data); + + /* add listener for event_changed, event_added + * we don't need to listen on event_removed. When the e_text + * of the event is removed, the cal_view_event will go to the state + * of "defunct" (changed by weak ref callback of atkgobjectaccessible + */ + g_signal_connect (G_OBJECT(cal_view), "event_changed", + G_CALLBACK (ea_cal_view_event_changed_cb), NULL); + g_signal_connect (G_OBJECT(cal_view), "event_added", + G_CALLBACK (ea_cal_view_event_added_cb), NULL); + + /* listen for date changes of calendar */ + gcal = e_cal_view_get_calendar (cal_view); + + if (gcal) + g_signal_connect (gcal, "dates_shown_changed", + G_CALLBACK (ea_cal_view_dates_change_cb), + accessible); +} + +static AtkObject* +ea_cal_view_get_parent (AtkObject *accessible) +{ + ECalView *cal_view; + GnomeCalendar *gnomeCalendar; + + g_return_val_if_fail (EA_IS_CAL_VIEW (accessible), NULL); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + cal_view = E_CAL_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + gnomeCalendar = e_cal_view_get_calendar (cal_view); + + return gtk_widget_get_accessible (GTK_WIDGET(gnomeCalendar)); +} + +static gint +ea_cal_view_get_index_in_parent (AtkObject *accessible) +{ + return 1; +} + +static void +ea_cal_view_event_changed_cb (ECalView *cal_view, ECalViewEvent *event, + gpointer data) +{ + AtkObject *atk_obj; + EaCalView *ea_cal_view; + AtkObject *event_atk_obj = NULL; + + g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + + atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view)); + if (!EA_IS_CAL_VIEW (atk_obj)) + return; + ea_cal_view = EA_CAL_VIEW (atk_obj); + + if ((E_IS_DAY_VIEW (cal_view)) && event && event->canvas_item) { + event_atk_obj = + ea_calendar_helpers_get_accessible_for (event->canvas_item); + } + else if ((E_IS_WEEK_VIEW (cal_view)) && event) { + EWeekViewEventSpan *span; + EWeekViewEvent *week_view_event = (EWeekViewEvent *)event; + EWeekView *week_view = E_WEEK_VIEW (cal_view); + /* get the first span of the event */ + span = &g_array_index (week_view->spans, EWeekViewEventSpan, + week_view_event->spans_index); + if (span && span->text_item) + event_atk_obj = ea_calendar_helpers_get_accessible_for (span->text_item); + } + if (event_atk_obj) { +#ifdef ACC_DEBUG + printf ("AccDebug: event=%p changed\n", event); +#endif + g_object_notify (G_OBJECT(event_atk_obj), "accessible-name"); + g_signal_emit_by_name (event_atk_obj, "visible_data_changed"); + } + +} + +static void +ea_cal_view_event_added_cb (ECalView *cal_view, ECalViewEvent *event, + gpointer data) +{ + AtkObject *atk_obj; + EaCalView *ea_cal_view; + AtkObject *event_atk_obj = NULL; + gint index; + + g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + + atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view)); + if (!EA_IS_CAL_VIEW (atk_obj)) + return; + ea_cal_view = EA_CAL_VIEW (atk_obj); + + if ((E_IS_DAY_VIEW (cal_view)) && event && event->canvas_item) { + event_atk_obj = + ea_calendar_helpers_get_accessible_for (event->canvas_item); + } + else if ((E_IS_WEEK_VIEW (cal_view)) && event) { + EWeekViewEventSpan *span; + EWeekViewEvent *week_view_event = (EWeekViewEvent *)event; + EWeekView *week_view = E_WEEK_VIEW (cal_view); + /* get the first span of the event */ + span = &g_array_index (week_view->spans, EWeekViewEventSpan, + week_view_event->spans_index); + if (span && span->text_item) + event_atk_obj = ea_calendar_helpers_get_accessible_for (span->text_item); + + } + if (event_atk_obj) { + index = atk_object_get_index_in_parent (event_atk_obj); + if (index < 0) + return; +#ifdef ACC_DEBUG + printf ("AccDebug: event=%p added\n", event); +#endif + g_signal_emit_by_name (atk_obj, "children_changed::add", + index, event_atk_obj, NULL); + } +} + +static void +ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data) +{ + AtkObject *atk_obj; + + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_if_fail (data); + g_return_if_fail (EA_IS_CAL_VIEW (data)); + + atk_obj = ATK_OBJECT(data); + if (atk_obj->name) { + g_free (atk_obj->name); + atk_obj->name = NULL; + } + g_object_notify (G_OBJECT (data), "accessible-name"); + g_signal_emit_by_name (data, "visible_data_changed"); +} diff --git a/a11y/calendar/ea-cal-view.h b/a11y/calendar/ea-cal-view.h new file mode 100644 index 0000000000..858aa497d4 --- /dev/null +++ b/a11y/calendar/ea-cal-view.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-cal-view.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 + * + */ + +#ifndef __EA_CAL_VIEW_H__ +#define __EA_CAL_VIEW_H__ + +#include <gtk/gtkaccessible.h> +#include "e-cal-view.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EA_TYPE_CAL_VIEW (ea_cal_view_get_type ()) +#define EA_CAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CAL_VIEW, EaCalView)) +#define EA_CAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CAL_VIEW, EaCalViewClass)) +#define EA_IS_CAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CAL_VIEW)) +#define EA_IS_CAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CAL_VIEW)) +#define EA_CAL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CAL_VIEW, EaCalViewClass)) + +typedef struct _EaCalView EaCalView; +typedef struct _EaCalViewClass EaCalViewClass; + +struct _EaCalView +{ + GtkAccessible parent; +}; + +GType ea_cal_view_get_type (void); + +struct _EaCalViewClass +{ + GtkAccessibleClass parent_class; +}; + +AtkObject* ea_cal_view_new (GtkWidget *widget); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EA_CAL_VIEW_H__ */ diff --git a/a11y/calendar/ea-calendar-helpers.c b/a11y/calendar/ea-calendar-helpers.c new file mode 100644 index 0000000000..e8b0d3aa9c --- /dev/null +++ b/a11y/calendar/ea-calendar-helpers.c @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-calendar-helpers.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 + * + */ + +#include "ea-calendar-helpers.h" +#include "ea-cal-view-event.h" +#include "e-day-view.h" +#include "e-week-view.h" + +#include <gal/e-text/e-text.h> + +/** + * ea_calendar_helpers_get_accessible_for + * @canvas_item: the canvas item (e_text) for a event + * @returns: the atk object for the canvas_item + * + **/ +AtkObject * +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_obj = G_OBJECT (canvas_item); + /* we cannot use atk_gobject_accessible_for_object here, + * EaDayViewEvent/EaWeekViewEvent cannot be created by the + * registered facotry of E_TEXT + */ + atk_obj = g_object_get_data (g_obj, "accessible-object"); + if (!atk_obj) + atk_obj = ea_cal_view_event_new (g_obj); + return atk_obj; +} + +/** + * ea_calendar_helpers_get_view_widget_from: + * @canvas_item: the canvas item (e_text) for a event + * @returns: the cal view widget if exists + * + * Get the cal view widget contains the canvas_item. + * + **/ +ECalView * +ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item) +{ + GnomeCanvas *canvas; + GtkWidget *view_widget = NULL; + + g_return_val_if_fail (canvas_item, NULL); + g_return_val_if_fail (E_IS_TEXT (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_CAL_VIEW (view_widget)) + return NULL; + return E_CAL_VIEW (view_widget); +} + +/** + * ea_calendar_helpers_get_cal_view_event_from + * @canvas_item: the cavas_item (e_text) for the event + * @returns: the ECalViewEvent + * + * Get the ECalViewEvent for the canvas_item. + * + **/ +ECalViewEvent * +ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item) +{ + ECalView *cal_view; + gboolean event_found; + ECalViewEvent *cal_view_event; + + g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL); + + cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); + + if (!cal_view) + return NULL; + + if (E_IS_DAY_VIEW (cal_view)) { + gint event_day, event_num; + EDayViewEvent *day_view_event; + EDayView *day_view = E_DAY_VIEW (cal_view); + event_found = e_day_view_find_event_from_item (day_view, canvas_item, + &event_day, &event_num); + if (!event_found) + return NULL; + if (event_day == E_DAY_VIEW_LONG_EVENT) { + /* a long event */ + day_view_event = &g_array_index (day_view->long_events, + EDayViewEvent, event_num); + } + else { + /* a main canvas event */ + day_view_event = &g_array_index (day_view->events[event_day], + EDayViewEvent, event_num); + } + cal_view_event = (ECalViewEvent *) day_view_event; + } + else if (E_IS_WEEK_VIEW (cal_view)) { + gint event_num, span_num; + EWeekViewEvent *week_view_event; + EWeekView *week_view = E_WEEK_VIEW (cal_view); + event_found = e_week_view_find_event_from_item (week_view, + canvas_item, + &event_num, + &span_num); + if (!event_found) + return NULL; + + week_view_event = &g_array_index (week_view->events, EWeekViewEvent, + event_num); + + cal_view_event = (ECalViewEvent *)week_view_event; + } + else { + g_assert_not_reached (); + return NULL; + } + return cal_view_event; +} diff --git a/a11y/calendar/ea-calendar-helpers.h b/a11y/calendar/ea-calendar-helpers.h new file mode 100644 index 0000000000..3b7417a4c0 --- /dev/null +++ b/a11y/calendar/ea-calendar-helpers.h @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-calendar-helpers.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 + * + */ + +/* Evolution Accessibility + */ + +#ifndef _EA_CALENDAR_HELPERS_H__ +#define _EA_CALENDAR_HELPERS_H__ + +#include "ea-cal-view.h" + +AtkObject * +ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item); + +ECalView * +ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item); + +ECalViewEvent * +ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item); + +#endif /* _EA_CALENDAR_HELPERS_H__ */ diff --git a/a11y/calendar/ea-calendar.c b/a11y/calendar/ea-calendar.c new file mode 100644 index 0000000000..b5296c2618 --- /dev/null +++ b/a11y/calendar/ea-calendar.c @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-calendar.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 + * + */ + +#include <gal/e-text/e-text.h> +#include "ea-calendar-helpers.h" +#include "ea-factory.h" +#include "ea-calendar.h" + +#include "calendar/ea-cal-view.h" +#include "calendar/ea-cal-view-event.h" +#include "calendar/ea-day-view.h" +#include "calendar/ea-week-view.h" +#include "calendar/ea-gnome-calendar.h" + + +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 (EA_TYPE_WEEK_VIEW, ea_week_view, ea_week_view_new); +EA_FACTORY (EA_TYPE_GNOME_CALENDAR, ea_gnome_calendar, ea_gnome_calendar_new); + +static gboolean ea_calendar_focus_watcher (GSignalInvocationHint *ihint, + guint n_param_values, + const GValue *param_values, + gpointer data); + +void +gnome_calendar_a11y_init (void) +{ + EA_SET_FACTORY (gnome_calendar_get_type(), ea_gnome_calendar); + /* we only add focus watcher when accessibility is enabled + */ + if (atk_get_root ()) + g_signal_add_emission_hook (g_signal_lookup ("event", E_TYPE_TEXT), + 0, ea_calendar_focus_watcher, + NULL, (GDestroyNotify) NULL); +} + +void +e_cal_view_a11y_init (void) +{ + EA_SET_FACTORY (e_cal_view_get_type(), ea_cal_view); + /* we only add focus watcher when accessibility is enabled + */ +#if 0 + if (atk_get_root ()) + g_signal_add_emission_hook (g_signal_lookup ("selection_time_changed", + e_cal_view_get_type ()), + 0, ea_calendar_focus_watcher, + NULL, (GDestroyNotify) NULL); +#endif +} + +void +e_day_view_a11y_init (void) +{ + EA_SET_FACTORY (e_day_view_get_type(), ea_day_view); +} + +void +e_week_view_a11y_init (void) +{ + EA_SET_FACTORY (e_week_view_get_type(), ea_week_view); +} + +gboolean +ea_calendar_focus_watcher (GSignalInvocationHint *ihint, + guint n_param_values, + const GValue *param_values, + gpointer data) +{ + GObject *object; + GdkEvent *event; + + object = g_value_get_object (param_values + 0); + event = g_value_get_boxed (param_values + 1); + + if (E_IS_TEXT (object)) { + /* "event" signal on canvas item + */ + GnomeCanvasItem *canvas_item; + AtkObject *ea_event; + + canvas_item = GNOME_CANVAS_ITEM (object); + if (event->type == GDK_FOCUS_CHANGE) { + if (event->focus_change.in) + ea_event = + ea_calendar_helpers_get_accessible_for (canvas_item); + else + /* focus out */ + ea_event = NULL; + atk_focus_tracker_notify (ea_event); + + } + } +#if 0 + else if (E_IS_DAY_VIEW (object)) { + /* "selection_time_changed" signal on day_view + */ + if (ATK_IS_SELECTION (object)) { + AtkSelection *atk_selection; + AtkObject *atk_obj; + atk_selection = ATK_SELECTION (object); + atk_obj = atk_selection_ref_selection (atk_selection, 0); + +#ifdef ACC_DEBUG + printf ("EvoAcc: ref a selection %p\n", atk_selection); +#endif + atk_focus_tracker_notify (atk_obj); + } + } +#endif + return TRUE; +} diff --git a/a11y/calendar/ea-calendar.h b/a11y/calendar/ea-calendar.h new file mode 100644 index 0000000000..61cdab1a89 --- /dev/null +++ b/a11y/calendar/ea-calendar.h @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-calendar.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 + * + */ + +/* Evolution Accessibility +*/ + +#ifndef _EA_CALENDAR_H__ +#define _EA_CALENDAR_H__ + +void gnome_calendar_a11y_init (void); +void e_cal_view_a11y_init (void); +void e_day_view_a11y_init (void); +void e_week_view_a11y_init (void); + +#endif /* _EA_CALENDAR_H__ */ diff --git a/a11y/calendar/ea-day-view.c b/a11y/calendar/ea-day-view.c new file mode 100644 index 0000000000..65cfb31752 --- /dev/null +++ b/a11y/calendar/ea-day-view.c @@ -0,0 +1,245 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-day-view.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 + * + */ + +#include "ea-day-view.h" +#include "ea-cal-view-event.h" + +#include "ea-calendar-helpers.h" +#include "calendar-commands.h" +#include <glib/gstrfuncs.h> + +static void ea_day_view_class_init (EaDayViewClass *klass); + +static G_CONST_RETURN gchar* ea_day_view_get_name (AtkObject *accessible); +static G_CONST_RETURN gchar* ea_day_view_get_description (AtkObject *accessible); +static gint ea_day_view_get_n_children (AtkObject *obj); +static AtkObject* ea_day_view_ref_child (AtkObject *obj, + gint i); +static gpointer parent_class = NULL; + +GType +ea_day_view_get_type (void) +{ + static GType type = 0; + AtkObjectFactory *factory; + GTypeQuery query; + GType derived_atk_type; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaDayViewClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_day_view_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaDayView), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + /* + * Figure out the size of the class and instance + * we are run-time deriving from (EaCalView, in this case) + * + * Note: we must still use run-time deriving here, because + * our parent class EaCalView is run-time deriving. + */ + + factory = atk_registry_get_factory (atk_get_default_registry (), + e_cal_view_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, + "EaDayView", &tinfo, 0); + } + + return type; +} + +static void +ea_day_view_class_init (EaDayViewClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + class->get_name = ea_day_view_get_name; + class->get_description = ea_day_view_get_description; + + class->get_n_children = ea_day_view_get_n_children; + class->ref_child = ea_day_view_ref_child; +} + +AtkObject* +ea_day_view_new (GtkWidget *widget) +{ + GObject *object; + AtkObject *accessible; + + g_return_val_if_fail (E_IS_DAY_VIEW (widget), NULL); + + object = g_object_new (EA_TYPE_DAY_VIEW, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + +#ifdef ACC_DEBUG + printf ("EvoAcc: ea_day_view created %p\n", accessible); +#endif + + return accessible; +} + +static G_CONST_RETURN gchar* +ea_day_view_get_name (AtkObject *accessible) +{ + EDayView *day_view; + + g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + if (!accessible->name) { + GnomeCalendar *gcal; + const gchar *label_text; + GnomeCalendarViewType view_type; + + gcal = e_cal_view_get_calendar (E_CAL_VIEW (day_view)); + label_text = calendar_get_text_for_folder_bar_label (gcal); + + view_type = gnome_calendar_get_view (gcal); + if (view_type == GNOME_CAL_WORK_WEEK_VIEW) + accessible->name = g_strconcat ("work week view :", + label_text, + NULL); + else + accessible->name = g_strconcat ("day view :", + label_text, NULL); + } + return accessible->name; +} + +static G_CONST_RETURN gchar* +ea_day_view_get_description (AtkObject *accessible) +{ + EDayView *day_view; + + g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + if (accessible->description) + return accessible->description; + else { + GnomeCalendar *gcal; + GnomeCalendarViewType view_type; + + gcal = e_cal_view_get_calendar (E_CAL_VIEW (day_view)); + view_type = gnome_calendar_get_view (gcal); + + if (view_type == GNOME_CAL_WORK_WEEK_VIEW) + return "calendar view for a work week"; + else + return "calendar view for one or more days"; + } +} + +static gint +ea_day_view_get_n_children (AtkObject *accessible) +{ + EDayView *day_view; + gint day; + gint child_num = 0; + + g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), -1); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return -1; + + day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + child_num += day_view->long_events->len; + + for (day = 0; day < day_view->days_shown; day++) { + child_num += day_view->events[day]->len; + } + + return child_num; +} + +static AtkObject * +ea_day_view_ref_child (AtkObject *accessible, gint index) +{ + EDayView *day_view; + gint child_num; + gint day; + AtkObject *atk_object = NULL; + EDayViewEvent *event = NULL; + + g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL); + + child_num = atk_object_get_n_accessible_children (accessible); + if (child_num <= 0 || index < 0 || index >= child_num) + return NULL; + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + /* a long event */ + if (index < day_view->long_events->len) { + event = &g_array_index (day_view->long_events, + EDayViewEvent, index); + } + else { + index -= day_view->long_events->len; + day = 0; + while (index >= day_view->events[day]->len) { + index -= day_view->events[day]->len; + ++day; + } + + event = &g_array_index (day_view->events[day], + EDayViewEvent, index); + } + if (event && event->canvas_item) { + /* Not use atk_gobject_accessible_for_object here, + * we need to do special thing here + */ + atk_object = ea_calendar_helpers_get_accessible_for (event->canvas_item); + g_object_ref (atk_object); + } + return atk_object; +} diff --git a/a11y/calendar/ea-day-view.h b/a11y/calendar/ea-day-view.h new file mode 100644 index 0000000000..5ca4614f03 --- /dev/null +++ b/a11y/calendar/ea-day-view.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-day-view.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 + * + */ + +#ifndef __EA_DAY_VIEW_H__ +#define __EA_DAY_VIEW_H__ + +#include "ea-cal-view.h" +#include "e-day-view.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EA_TYPE_DAY_VIEW (ea_day_view_get_type ()) +#define EA_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW, EaDayView)) +#define EA_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW, EaDayViewClass)) +#define EA_IS_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW)) +#define EA_IS_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW)) +#define EA_DAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW, EaDayViewClass)) + +typedef struct _EaDayView EaDayView; +typedef struct _EaDayViewClass EaDayViewClass; + +struct _EaDayView +{ + EaCalView parent; +}; + +GType ea_day_view_get_type (void); + +struct _EaDayViewClass +{ + EaCalViewClass parent_class; +}; + +AtkObject* ea_day_view_new (GtkWidget *widget); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EA_DAY_VIEW_H__ */ diff --git a/a11y/calendar/ea-gnome-calendar.c b/a11y/calendar/ea-gnome-calendar.c new file mode 100644 index 0000000000..20361f1451 --- /dev/null +++ b/a11y/calendar/ea-gnome-calendar.c @@ -0,0 +1,234 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-gnome-calendar.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 + * + */ + +#include "ea-gnome-calendar.h" +#include "calendar-commands.h" +#include <gtk/gtknotebook.h> + +static void ea_gnome_calendar_class_init (EaGnomeCalendarClass *klass); + +static G_CONST_RETURN gchar* ea_gnome_calendar_get_name (AtkObject *accessible); +static G_CONST_RETURN gchar* ea_gnome_calendar_get_description (AtkObject *accessible); +static gint ea_gnome_calendar_get_n_children (AtkObject* obj); +static AtkObject * ea_gnome_calendar_ref_child (AtkObject *obj, gint i); + +static void ea_gcal_switch_view_cb (GtkNotebook *widget, GtkNotebookPage *page, + guint index, gpointer data); +static void ea_gcal_dates_change_cb (GnomeCalendar *gcal, gpointer data); + +static gpointer parent_class = NULL; + +GType +ea_gnome_calendar_get_type (void) +{ + static GType type = 0; + AtkObjectFactory *factory; + GTypeQuery query; + GType derived_atk_type; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaGnomeCalendarClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_gnome_calendar_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaGnomeCalendar), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + /* + * Figure out the size of the class and instance + * we are run-time deriving from (GailWidget, in this case) + */ + + factory = atk_registry_get_factory (atk_get_default_registry (), + GTK_TYPE_WIDGET); + 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, + "EaGnomeCalendar", &tinfo, 0); + + } + + return type; +} + +static void +ea_gnome_calendar_class_init (EaGnomeCalendarClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + class->get_name = ea_gnome_calendar_get_name; + class->get_description = ea_gnome_calendar_get_description; + + class->get_n_children = ea_gnome_calendar_get_n_children; + class->ref_child = ea_gnome_calendar_ref_child; +} + +AtkObject* +ea_gnome_calendar_new (GtkWidget *widget) +{ + GObject *object; + AtkObject *accessible; + GnomeCalendar *gcal; + GtkWidget *notebook; + + g_return_val_if_fail (GNOME_IS_CALENDAR (widget), NULL); + + object = g_object_new (EA_TYPE_GNOME_CALENDAR, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + + accessible->role = ATK_ROLE_FILLER; + + gcal = GNOME_CALENDAR (widget); + + /* listen on view type change + */ + notebook = gnome_calendar_get_view_notebook_widget (gcal); + if (notebook) { + g_signal_connect (notebook, "switch_page", + G_CALLBACK (ea_gcal_switch_view_cb), + accessible); + g_signal_connect (widget, "dates_shown_changed", + G_CALLBACK (ea_gcal_dates_change_cb), + accessible); + } + +#ifdef ACC_DEBUG + printf ("EvoAcc: ea-gnome-calendar created: %p\n", accessible); +#endif + + return accessible; +} + +static G_CONST_RETURN gchar* +ea_gnome_calendar_get_name (AtkObject *accessible) +{ + if (accessible->name) + return accessible->name; + return "Gnome Calendar"; +} + +static G_CONST_RETURN gchar* +ea_gnome_calendar_get_description (AtkObject *accessible) +{ + if (accessible->description) + return accessible->description; + return "Gnome Calendar"; +} + +static gint +ea_gnome_calendar_get_n_children (AtkObject* obj) +{ + g_return_val_if_fail (EA_IS_GNOME_CALENDAR (obj), 0); + + if (!GTK_ACCESSIBLE (obj)->widget) + return -1; + return 4; +} + +static AtkObject * +ea_gnome_calendar_ref_child (AtkObject *obj, gint i) +{ + AtkObject * child = NULL; + GnomeCalendar * calendarWidget; + GtkWidget *childWidget; + + g_return_val_if_fail (EA_IS_GNOME_CALENDAR (obj), NULL); + /* valid child index range is [0-3] */ + if (i < 0 || i >3 ) + return NULL; + + if (!GTK_ACCESSIBLE (obj)->widget) + return NULL; + calendarWidget = GNOME_CALENDAR (GTK_ACCESSIBLE (obj)->widget); + + switch (i) { + case 0: + /* for the search bar */ + childWidget = gnome_calendar_get_search_bar_widget (calendarWidget); + child = gtk_widget_get_accessible (childWidget); + atk_object_set_parent (child, obj); + atk_object_set_name (child, "search bar"); + atk_object_set_description (child, "evolution calendar search bar"); + break; + case 1: + /* for the day/week view */ + childWidget = gnome_calendar_get_current_view_widget (calendarWidget); + child = gtk_widget_get_accessible (childWidget); + atk_object_set_parent (child, obj); + break; + case 2: + /* for calendar */ + childWidget = gnome_calendar_get_e_calendar_widget (calendarWidget); + child = gtk_widget_get_accessible (childWidget); + break; + case 3: + /* for todo list */ + childWidget = GTK_WIDGET (gnome_calendar_get_task_pad (calendarWidget)); + child = gtk_widget_get_accessible (childWidget); + break; + default: + break; + } + if (child) + g_object_ref(child); + return child; +} + +static void +ea_gcal_switch_view_cb (GtkNotebook *widget, GtkNotebookPage *page, + guint index, gpointer data) +{ + g_signal_emit_by_name (G_OBJECT(data), "children_changed", + 0, NULL, NULL); +#ifdef ACC_DEBUG + printf ("AccDebug: switch view: children_changed notified\n"); +#endif +} + +static void +ea_gcal_dates_change_cb (GnomeCalendar *gcal, gpointer data) +{ + const gchar *new_name; + + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_if_fail (data); + g_return_if_fail (EA_IS_GNOME_CALENDAR (data)); + + new_name = calendar_get_text_for_folder_bar_label (gcal); + atk_object_set_name (ATK_OBJECT(data), new_name); +} diff --git a/a11y/calendar/ea-gnome-calendar.h b/a11y/calendar/ea-gnome-calendar.h new file mode 100644 index 0000000000..2cb39219c4 --- /dev/null +++ b/a11y/calendar/ea-gnome-calendar.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-gnome-calendar.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 + * + */ + +#ifndef __EA_GNOME_CALENDAR_H__ +#define __EA_GNOME_CALENDAR_H__ + +#include <gtk/gtkaccessible.h> +#include "gnome-cal.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EA_TYPE_GNOME_CALENDAR (ea_gnome_calendar_get_type ()) +#define EA_GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendar)) +#define EA_GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendarClass)) +#define EA_IS_GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_GNOME_CALENDAR)) +#define EA_IS_GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_GNOME_CALENDAR)) +#define EA_GNOME_CALENDAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendarClass)) + +typedef struct _EaGnomeCalendar EaGnomeCalendar; +typedef struct _EaGnomeCalendarClass EaGnomeCalendarClass; + +struct _EaGnomeCalendar +{ + GtkAccessible parent; +}; + +GType ea_gnome_calendar_get_type (void); + +struct _EaGnomeCalendarClass +{ + GtkAccessibleClass parent_class; +}; + +AtkObject* ea_gnome_calendar_new (GtkWidget *widget); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __EA_GNOME_CALENDAR_H__ */ diff --git a/a11y/calendar/ea-week-view.c b/a11y/calendar/ea-week-view.c new file mode 100644 index 0000000000..9917d147d2 --- /dev/null +++ b/a11y/calendar/ea-week-view.c @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-week-view.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 + * + */ + +#include "ea-week-view.h" +#include "ea-cal-view.h" +#include "ea-cal-view-event.h" +#include "ea-calendar-helpers.h" +#include "calendar-commands.h" + +static void ea_week_view_class_init (EaWeekViewClass *klass); + +static G_CONST_RETURN gchar* ea_week_view_get_name (AtkObject *accessible); +static G_CONST_RETURN gchar* ea_week_view_get_description (AtkObject *accessible); +static gint ea_week_view_get_n_children (AtkObject *obj); +static AtkObject* ea_week_view_ref_child (AtkObject *obj, + gint i); + +static gpointer parent_class = NULL; + +GType +ea_week_view_get_type (void) +{ + static GType type = 0; + AtkObjectFactory *factory; + GTypeQuery query; + GType derived_atk_type; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaWeekViewClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_week_view_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaWeekView), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + /* + * Figure out the size of the class and instance + * we are run-time deriving from (EaCalView, in this case) + * + * Note: we must still use run-time deriving here, because + * our parent class EaCalView is run-time deriving. + */ + + factory = atk_registry_get_factory (atk_get_default_registry (), + e_cal_view_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, + "EaWeekView", &tinfo, 0); + + } + + return type; +} + +static void +ea_week_view_class_init (EaWeekViewClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + class->get_name = ea_week_view_get_name; + class->get_description = ea_week_view_get_description; + + class->get_n_children = ea_week_view_get_n_children; + class->ref_child = ea_week_view_ref_child; +} + +AtkObject* +ea_week_view_new (GtkWidget *widget) +{ + GObject *object; + AtkObject *accessible; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + object = g_object_new (EA_TYPE_WEEK_VIEW, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + +#ifdef ACC_DEBUG + printf ("EvoAcc: ea_week_view created %p\n", accessible); +#endif + + return accessible; +} + +static G_CONST_RETURN gchar* +ea_week_view_get_name (AtkObject *accessible) +{ + EWeekView *week_view; + + g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + if (!accessible->name) { + GnomeCalendar *gcal; + const gchar *label_text; + GnomeCalendarViewType view_type; + + gcal = e_cal_view_get_calendar (E_CAL_VIEW (week_view)); + label_text = calendar_get_text_for_folder_bar_label (gcal); + view_type = gnome_calendar_get_view (gcal); + + view_type = gnome_calendar_get_view (gcal); + + if (view_type == GNOME_CAL_MONTH_VIEW) + accessible->name = g_strconcat ("month view :", + label_text, + NULL); + + + else + accessible->name = g_strconcat ("week view :", + label_text, NULL); + } + return accessible->name; +} + +static G_CONST_RETURN gchar* +ea_week_view_get_description (AtkObject *accessible) +{ + EWeekView *week_view; + + g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + if (accessible->description) + return accessible->description; + else { + GnomeCalendar *gcal; + GnomeCalendarViewType view_type; + + gcal = e_cal_view_get_calendar (E_CAL_VIEW (week_view)); + view_type = gnome_calendar_get_view (gcal); + + if (view_type == GNOME_CAL_MONTH_VIEW) + return "calendar view for a month"; + else + return "calendar view for one or more weeks"; + } +} + +static gint +ea_week_view_get_n_children (AtkObject *accessible) +{ + EWeekView *week_view; + + g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), -1); + + if (!GTK_ACCESSIBLE (accessible)->widget) + return -1; + week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + return week_view->events->len; +} + +static AtkObject * +ea_week_view_ref_child (AtkObject *accessible, gint index) +{ + EWeekView *week_view; + gint child_num; + AtkObject *atk_object = NULL; + EWeekViewEvent *event; + EWeekViewEventSpan *span; + gint span_num = 0; + + g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); + + child_num = atk_object_get_n_accessible_children (accessible); + if (child_num <= 0 || index < 0 || index >= child_num) + return NULL; + + if (!GTK_ACCESSIBLE (accessible)->widget) + return NULL; + week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); + + event = &g_array_index (week_view->events, + EWeekViewEvent, index); + span = &g_array_index (week_view->spans, EWeekViewEventSpan, + event->spans_index + span_num); + + if (event) { + /* Not use atk_gobject_accessible_for_object here, + * we need to do special thing here + */ + atk_object = ea_calendar_helpers_get_accessible_for (span->text_item); + g_object_ref (atk_object); + } +#ifdef ACC_DEBUG + printf ("EvoAcc: ea_week_view_ref_child [%d]=%p\n", + index, atk_object); +#endif + return atk_object; +} diff --git a/a11y/calendar/ea-week-view.h b/a11y/calendar/ea-week-view.h new file mode 100644 index 0000000000..f0ed117375 --- /dev/null +++ b/a11y/calendar/ea-week-view.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.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 + * + */ + +#ifndef __EA_WEEK_VIEW_H__ +#define __EA_WEEK_VIEW_H__ + +#include <gtk/gtkaccessible.h> +#include "e-week-view.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EA_TYPE_WEEK_VIEW (ea_week_view_get_type ()) +#define EA_WEEK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW, EaWeekView)) +#define EA_WEEK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW, EaWeekViewClass)) +#define EA_IS_WEEK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW)) +#define EA_IS_WEEK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW)) +#define EA_WEEK_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW, EaWeekViewClass)) + +typedef struct _EaWeekView EaWeekView; +typedef struct _EaWeekViewClass EaWeekViewClass; + +struct _EaWeekView +{ + GtkAccessible parent; +}; + +GType ea_week_view_get_type (void); + +struct _EaWeekViewClass +{ + GtkAccessibleClass parent_class; +}; + +AtkObject* ea_week_view_new (GtkWidget *widget); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __EA_WEEK_VIEW_H__ */ diff --git a/a11y/ea-factory.h b/a11y/ea-factory.h new file mode 100644 index 0000000000..07d91271be --- /dev/null +++ b/a11y/ea-factory.h @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-factory.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 + * + */ + +/* Evolution Accessibility +*/ + +#ifndef _EA_FACTORY_H__ +#define _EA_FACTORY_H__ + +#include <glib-object.h> +#include <atk/atkobject.h> + +#define EA_FACTORY(type, type_as_function, opt_create_accessible) \ + \ +static GType \ +type_as_function ## _factory_get_accessible_type (void) \ +{ \ + return type; \ +} \ + \ +static AtkObject* \ +type_as_function ## _factory_create_accessible (GObject *obj) \ +{ \ + GtkWidget *widget; \ + AtkObject *accessible; \ + \ + g_return_val_if_fail (GTK_IS_WIDGET (obj), NULL); \ + \ + widget = GTK_WIDGET (obj); \ + \ + accessible = opt_create_accessible (widget); \ + \ + return accessible; \ +} \ + \ +static void \ +type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass) \ +{ \ + klass->create_accessible = type_as_function ## _factory_create_accessible; \ + klass->get_accessible_type = type_as_function ## _factory_get_accessible_type;\ +} \ + \ +static GType \ +type_as_function ## _factory_get_type (void) \ +{ \ + static GType t = 0; \ + \ + if (!t) \ + { \ + char *name; \ + static const GTypeInfo tinfo = \ + { \ + sizeof (AtkObjectFactoryClass), \ + NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init, \ + NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL \ + }; \ + \ + name = g_strconcat (g_type_name (type), "Factory", NULL); \ + t = g_type_register_static ( \ + ATK_TYPE_OBJECT_FACTORY, name, &tinfo, 0); \ + g_free (name); \ + } \ + \ + return t; \ +} + +#define EA_SET_FACTORY(widget_type, type_as_function) \ + atk_registry_set_factory_type (atk_get_default_registry (), \ + widget_type, \ + type_as_function ## _factory_get_type ()) + +#endif /* _EA_FACTORY_H__ */ |