From 7bb25afd430ffab77397d9fc4e6b756251ba31d8 Mon Sep 17 00:00:00 2001 From: Bolian Yin Date: Wed, 20 Aug 2003 07:46:05 +0000 Subject: setup the a11y directory for evolution accessibility work New files are: 2003-08-20 Bolian Yin 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 --- a11y/calendar/ea-calendar-helpers.c | 148 ++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 a11y/calendar/ea-calendar-helpers.c (limited to 'a11y/calendar/ea-calendar-helpers.c') 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 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 + +/** + * 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; +} -- cgit v1.2.3