diff options
author | Bolian Yin <bolian.yin@sun.com> | 2003-08-20 15:46:05 +0800 |
---|---|---|
committer | Bolian Yin <byin@src.gnome.org> | 2003-08-20 15:46:05 +0800 |
commit | 7bb25afd430ffab77397d9fc4e6b756251ba31d8 (patch) | |
tree | e5aed36d5b6b60807223983ed3f03bf77c75fccf /a11y/calendar/ea-cal-view-event.c | |
parent | 432977b820abd0093e6f68f81bd7c01fafc3536f (diff) | |
download | gsoc2013-evolution-7bb25afd430ffab77397d9fc4e6b756251ba31d8.tar.gz gsoc2013-evolution-7bb25afd430ffab77397d9fc4e6b756251ba31d8.tar.zst gsoc2013-evolution-7bb25afd430ffab77397d9fc4e6b756251ba31d8.zip |
setup the a11y directory for evolution accessibility work New files are:
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
svn path=/trunk/; revision=22302
Diffstat (limited to 'a11y/calendar/ea-cal-view-event.c')
-rw-r--r-- | a11y/calendar/ea-cal-view-event.c | 333 |
1 files changed, 333 insertions, 0 deletions
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; +} |