[evolution-patches] [Fwd: seek review for bug #47814, Atk suport for evolution-calendar-item]



Hi JP and Rodrigo,

go time to review the patch?

-------- Original Message --------
Subject: seek review for bug #47814, Atk suport for evolution-calendar-item
Date: Fri, 22 Aug 2003 13:20:23 +0800
From: Bolian Yin <bolian yin sun com>
To: Evolution Patches <evolution-patches ximian com>, EvolutionAcc <sceri-evolution-acc sun com>
CC: JP Rosevear <jpr ximian com>, Rodrigo Moya <rodrigo ximian com>


Hi,

This is another a11y patch.

This patch does the following work:
  1. simple atk support for evolution-calendar-item
  2. atkcomponent interface for ea-cal-view-event
  3. Makefile changes to make a11y libs combined with widget libs.

Thanks,
Bolian

Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.601
diff -u -r1.601 configure.in
--- configure.in	20 Aug 2003 08:05:21 -0000	1.601
+++ configure.in	22 Aug 2003 03:55:58 -0000
@@ -1319,6 +1319,7 @@
 Makefile
 a11y/Makefile
 a11y/calendar/Makefile
+a11y/widgets/Makefile
 addressbook/Makefile
 addressbook/gui/Makefile
 addressbook/gui/component/Makefile
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/Makefile.am,v
retrieving revision 1.84
diff -u -r1.84 Makefile.am
--- Makefile.am	20 Aug 2003 08:05:21 -0000	1.84
+++ Makefile.am	22 Aug 2003 03:55:58 -0000
@@ -29,12 +29,12 @@
         e-util                  \
 	libical			\
 	libversit		\
+	a11y			\
         widgets                 \
         shell                   \
 	camel			\
 	filter			\
 	addressbook		\
-	a11y			\
 	calendar		\
 	my-evolution		\
         art                     \
Index: calendar/gui/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/Makefile.am,v
retrieving revision 1.272
diff -u -r1.272 Makefile.am
--- calendar/gui/Makefile.am	20 Aug 2003 08:04:59 -0000	1.272
+++ calendar/gui/Makefile.am	22 Aug 2003 03:55:58 -0000
@@ -73,7 +73,7 @@
 	-I$(top_srcdir)/addressbook/backend		\
 	-I$(top_builddir)/addressbook/backend		\
 	-I$(top_srcdir)/widgets				\
-	-I$(top_srcdir)/a11y/calendar				\
+	-I$(top_srcdir)/a11y/calendar			\
 	-DEVOLUTION_DATADIR=\""$(datadir)"\"		\
 	-DEVOLUTION_GLADEDIR=\""$(gladedir)"\"		\
 	-DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\"	\
@@ -195,7 +195,7 @@
 	$(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la		\
 	$(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la	\
 	$(top_builddir)/widgets/misc/libemiscwidgets.la			\
-	$(top_builddir)/a11y/libevolution-a11y.la                       \
+	$(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la                       \
 	$(EVOLUTION_CALENDAR_LIBS)
 
 libevolution_calendar_la_LDFLAGS = -avoid-version -module
Index: a11y/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/a11y/Makefile.am,v
retrieving revision 1.3
diff -u -r1.3 Makefile.am
--- a11y/Makefile.am	20 Aug 2003 09:08:27 -0000	1.3
+++ a11y/Makefile.am	22 Aug 2003 03:56:16 -0000
@@ -1,36 +1,5 @@
-# Calendar IDL files
-                                                                                
-CALENDAR_IDLS = $(top_srcdir)/calendar/idl/evolution-calendar.idl
 
-CALENDAR_IDL_GENERATED_H = evolution-calendar.h
+SUBDIRS = calendar widgets
 
-$(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)			\
-        ea-factory.h
-
-
-BUILT_SOURCES = $(CALENDAR_IDL_GENERATED_H)
-
-libevolution_a11y_la_LIBADD =				\
-	$(A11Y_LIBS)					\
-	$(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la 
+EXTRA_DIST = ea-factory.h
Index: a11y/ea-factory.h
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ea-factory.h,v
retrieving revision 1.2
diff -u -r1.2 ea-factory.h
--- a11y/ea-factory.h	20 Aug 2003 07:46:01 -0000	1.2
+++ a11y/ea-factory.h	22 Aug 2003 03:56:16 -0000
@@ -32,29 +32,40 @@
 #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;									\
-}										\
-										\
+#define EA_FACTORY_PARTA_GOBJECT(type, type_as_function, opt_create_accessible)	\
 static AtkObject*								\
 type_as_function ## _factory_create_accessible (GObject *obj)			\
-{										\
+{                                                                               \
+  AtkObject *accessible;							\
+  g_return_val_if_fail (G_IS_OBJECT (obj), NULL);				\
+  accessible = opt_create_accessible (G_OBJECT (obj));	                 	\
+  return accessible;	                                                        \
+}
+
+#define EA_FACTORY_PARTA(type, type_as_function, opt_create_accessible)	        \
+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;	                                                        \
+}
+
+#define EA_FACTORY_PARTB(type, type_as_function, opt_create_accessible)	        \
 										\
-  return accessible;								\
+static GType									\
+type_as_function ## _factory_get_accessible_type (void)				\
+{										\
+  return type;									\
 }										\
 										\
+										\
 static void									\
 type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass)		\
 {										\
@@ -72,8 +83,8 @@
     char *name;									\
     static const GTypeInfo tinfo =						\
     {										\
-      sizeof (AtkObjectFactoryClass),					\
-      NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init,			\
+      sizeof (AtkObjectFactoryClass),				         	\
+      NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init,	\
       NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL			\
     };										\
 										\
@@ -86,9 +97,17 @@
   return t;									\
 }
 
-#define EA_SET_FACTORY(widget_type, type_as_function)			\
+#define EA_FACTORY(type, type_as_function, opt_create_accessible)	        \
+        EA_FACTORY_PARTA(type, type_as_function, opt_create_accessible)	        \
+        EA_FACTORY_PARTB(type, type_as_function, opt_create_accessible)
+
+#define EA_FACTORY_GOBJECT(type, type_as_function, opt_create_accessible)	\
+        EA_FACTORY_PARTA_GOBJECT(type, type_as_function, opt_create_accessible)	\
+        EA_FACTORY_PARTB(type, type_as_function, opt_create_accessible)
+
+#define EA_SET_FACTORY(obj_type, type_as_function)		         	\
 	atk_registry_set_factory_type (atk_get_default_registry (),		\
-				       widget_type,				\
+				       obj_type,				\
 				       type_as_function ## _factory_get_type ())
 
 #endif /* _EA_FACTORY_H__ */
Index: a11y/calendar/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/a11y/calendar/Makefile.am,v
retrieving revision 1.2
diff -u -r1.2 Makefile.am
--- a11y/calendar/Makefile.am	20 Aug 2003 07:46:04 -0000	1.2
+++ a11y/calendar/Makefile.am	22 Aug 2003 03:56:16 -0000
@@ -1,4 +1,46 @@
+# Calendar IDL files
+                                                                                                                       
+CALENDAR_IDLS = $(top_srcdir)/calendar/idl/evolution-calendar.idl
+SHELL_IDLS = \
+        $(top_srcdir)/shell/Evolution-Activity.idl                  \
+        $(top_srcdir)/shell/Evolution-ConfigControl.idl             \
+        $(top_srcdir)/shell/Evolution-Offline.idl                   \
+        $(top_srcdir)/shell/Evolution-Session.idl                   \
+        $(top_srcdir)/shell/Evolution-Shell.idl                     \
+        $(top_srcdir)/shell/Evolution-ShellComponent.idl            \
+        $(top_srcdir)/shell/Evolution-ShellComponentDnd.idl         \
+        $(top_srcdir)/shell/Evolution-ShellView.idl                 \
+        $(top_srcdir)/shell/Evolution-Shortcuts.idl                 \
+        $(top_srcdir)/shell/Evolution-Storage.idl                   \
+        $(top_srcdir)/shell/Evolution-StorageSetView.idl            \
+        $(top_srcdir)/shell/Evolution-Wizard.idl                    \
+        $(top_srcdir)/shell/Evolution-common.idl                    \
+        $(top_srcdir)/shell/Evolution.idl
+                                                                                                                       
+CALENDAR_IDL_GENERATED_H = evolution-calendar.h
+CALENDAR_IDL_GENERATED_C =                              \
+        evolution-calendar-common.c                     \
+        evolution-calendar-skels.c                      \
+        evolution-calendar-stubs.c
 
+SHELL_IDL_GENERATED_H = Evolution.h
+SHELL_IDL_GENERATED_C =			\
+	Evolution-common.c  		\
+	Evolution-skels.c 		\
+	Evolution-stubs.c
+                                                                                                                       
+$(CALENDAR_IDL_GENERATED_H): $(CALENDAR_IDLS)
+	$(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES)   \
+                $(top_srcdir)/calendar/idl/evolution-calendar.idl
+                                                                                                                       
+$(SHELL_IDL_GENERATED_H): $(SHELL_IDLS)
+	$(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES)  \
+        $(top_srcdir)/shell/Evolution.idl
+
+IDL_GENERATED = $(SHELL_IDL_GENERATED_H) $(CALENDAR_IDL_GENERATED_H)
+BUILT_SOURCES = $(IDL_GENERATED)
+CLEANFILES = $(BUILT_SOURCES) $(CALENDAR_IDL_GENERATED_C) $(SHELL_IDL_GENERATED_C)
+                                                                                                                       
 noinst_LTLIBRARIES = libevolution-calendar-a11y.la
 
 INCLUDES =						\
@@ -22,6 +64,8 @@
 	$(EVOLUTION_CALENDAR_CFLAGS)
 
 libevolution_calendar_a11y_la_SOURCES =		\
+	$(CALENDAR_IDL_GENERATED_H)		\
+	$(SHELL_IDL_GENERATED_H)		\
 	ea-calendar.c				\
 	ea-calendar.h				\
 	ea-calendar-helpers.c			\
Index: a11y/calendar/ea-cal-view-event.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/calendar/ea-cal-view-event.c,v
retrieving revision 1.3
diff -u -r1.3 ea-cal-view-event.c
--- a11y/calendar/ea-cal-view-event.c	20 Aug 2003 10:17:47 -0000	1.3
+++ a11y/calendar/ea-cal-view-event.c	22 Aug 2003 03:56:17 -0000
@@ -36,6 +36,12 @@
 static AtkObject* ea_cal_view_event_get_parent (AtkObject *accessible);
 static gint ea_cal_view_event_get_index_in_parent (AtkObject *accessible);
 
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void ea_cal_view_get_extents (AtkComponent *component,
+				     gint *x, gint *y, gint *width, gint *height,
+				     AtkCoordType coord_type);
+
 static gpointer parent_class = NULL;
 
 GType
@@ -61,6 +67,12 @@
 			NULL /* value table */
 		};
 
+		static const GInterfaceInfo atk_component_info = {
+			(GInterfaceInitFunc) atk_component_interface_init,
+			(GInterfaceFinalizeFunc) NULL,
+			NULL
+		};
+
 		/*
 		 * Figure out the size of the class and instance
 		 * we are run-time deriving from (atk object for E_TEXT, in this case)
@@ -77,6 +89,8 @@
 		/* we inherit the component, text and other interfaces from E_TEXT */
 		type = g_type_register_static (derived_atk_type,
 					       "EaCalViewEvent", &tinfo, 0);
+		g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+					     &atk_component_info);
 	}
 
 	return type;
@@ -104,7 +118,6 @@
 	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)) {
@@ -136,10 +149,13 @@
 		target_obj = obj;
 
 	if (!atk_obj) {
+		static AtkRole event_role = ATK_ROLE_INVALID;
 		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;
+		if (event_role == ATK_ROLE_INVALID)
+			event_role = atk_role_register ("Calendar Event");
+		atk_obj->role = event_role;
 #ifdef ACC_DEBUG
 		printf ("EvoAcc: ea_cal_view_event created %p for item=%p\n",
 			atk_obj, target_obj);
@@ -327,4 +343,118 @@
 		return -1;
 	}
 	return -1;
+}
+
+/* Atk Component Interface */
+
+static void 
+atk_component_interface_init (AtkComponentIface *iface)
+{
+  g_return_if_fail (iface != NULL);
+
+  iface->get_extents = ea_cal_view_get_extents;
+}
+
+static void 
+ea_cal_view_get_extents (AtkComponent   *component,
+                         gint           *x,
+                         gint           *y,
+                         gint           *width,
+                         gint           *height,
+                         AtkCoordType   coord_type)
+{
+	GObject *g_obj;
+	GnomeCanvasItem *canvas_item;
+	gint x_window, y_window;
+	gint scroll_x, scroll_y;
+	ECalView *cal_view;
+	gint item_x, item_y, item_w, item_h;
+	GtkWidget *canvas = NULL;
+
+	g_return_if_fail (EA_IS_CAL_VIEW_EVENT (component));
+
+	g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+	if (!g_obj)
+		/* defunct object*/
+		return;
+	g_return_if_fail (E_IS_TEXT (g_obj));
+
+	canvas_item = GNOME_CANVAS_ITEM (g_obj);
+	cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item);
+	if (!cal_view)
+		return;
+
+	if (E_IS_DAY_VIEW (cal_view)) {
+		gint day, event_num;
+
+		if (!e_day_view_find_event_from_item (E_DAY_VIEW (cal_view),
+						      canvas_item,
+						      &day, &event_num))
+			return;
+		if (day == E_DAY_VIEW_LONG_EVENT) {
+			gint start_day, end_day;
+			if (!e_day_view_get_long_event_position (E_DAY_VIEW (cal_view),
+								 event_num,
+								 &start_day,
+								 &end_day,
+								 &item_x,
+								 &item_y,
+								 &item_w,
+								 &item_h))
+				return;
+			canvas = E_DAY_VIEW (cal_view)->top_canvas;
+		}
+		else {
+			if (!e_day_view_get_event_position (E_DAY_VIEW (cal_view), day,
+							    event_num,
+							    &item_x, &item_y,
+							    &item_w, &item_h))
+
+				return;
+			canvas = E_DAY_VIEW (cal_view)->main_canvas;
+		}
+	}
+	else if (E_IS_WEEK_VIEW (cal_view)) {
+		gint event_num, span_num;
+		if (!e_week_view_find_event_from_item (E_WEEK_VIEW (cal_view),
+						       canvas_item, &event_num,
+						       &span_num))
+			return;
+
+		if (!e_week_view_get_span_position (E_WEEK_VIEW (cal_view),
+						    event_num, span_num,
+						    &item_x, &item_y, &item_w))
+			return;
+		item_h = E_WEEK_VIEW_ICON_HEIGHT;
+		canvas = E_WEEK_VIEW (cal_view)->main_canvas;
+	}
+	else
+		return;
+
+	if (!canvas)
+		return;
+
+	gdk_window_get_origin (canvas->window,
+			       &x_window, &y_window);
+	gnome_canvas_get_scroll_offsets (GNOME_CANVAS (canvas), &scroll_x, &scroll_y);
+
+	*x = item_x + x_window - scroll_x;
+	*y = item_y + y_window - scroll_y;
+	*width = item_w;
+	*height = item_h;
+
+	if (coord_type == ATK_XY_WINDOW) {
+		GdkWindow *window;
+		gint x_toplevel, y_toplevel;
+
+		window = gdk_window_get_toplevel (GTK_WIDGET (cal_view)->window);
+		gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
+
+		*x -= x_toplevel;
+		*y -= y_toplevel;
+	}
+
+#ifdef ACC_DEBUG
+	printf ("Event Bounds (%d, %d, %d, %d)\n", *x, *y, *width, *height);
+#endif
 }
Index: a11y/calendar/ea-gnome-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/calendar/ea-gnome-calendar.c,v
retrieving revision 1.2
diff -u -r1.2 ea-gnome-calendar.c
--- a11y/calendar/ea-gnome-calendar.c	20 Aug 2003 07:46:05 -0000	1.2
+++ a11y/calendar/ea-gnome-calendar.c	22 Aug 2003 03:56:18 -0000
@@ -117,14 +117,14 @@
 
 	/* listen on view type change
 	 */
+	g_signal_connect (widget, "dates_shown_changed",
+			  G_CALLBACK (ea_gcal_dates_change_cb),
+			  accessible);
 	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
@@ -213,10 +213,19 @@
 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);
+	GtkWidget *new_widget;
+
+	new_widget = gtk_notebook_get_nth_page (widget, index);
+
+	/* views are always the second child in gnome calendar
+	 */
+	if (new_widget)
+		g_signal_emit_by_name (G_OBJECT(data), "children_changed::add",
+				       1, gtk_widget_get_accessible (new_widget), NULL);
+
 #ifdef ACC_DEBUG
-	printf ("AccDebug: switch view: children_changed notified\n");
+	printf ("AccDebug: view switch to widget %p (index=%d) \n",
+		new_widget, index);
 #endif
 }
 
@@ -231,4 +240,9 @@
 
 	new_name = calendar_get_text_for_folder_bar_label (gcal);
 	atk_object_set_name (ATK_OBJECT(data), new_name);
+	g_signal_emit_by_name (data, "visible_data_changed");
+
+#ifdef ACC_DEBUG
+	printf ("AccDebug: calendar dates changed, label=%s\n", new_name);
+#endif
 }
Index: a11y/widgets/Makefile.am
===================================================================
RCS file: a11y/widgets/Makefile.am
diff -N a11y/widgets/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/Makefile.am	22 Aug 2003 03:56:19 -0000
@@ -0,0 +1,23 @@
+
+noinst_LTLIBRARIES = libevolution-widgets-a11y.la
+
+INCLUDES =						\
+	-DG_LOG_DOMAIN=\"evolution-a11y\"		\
+	-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_widgets_a11y_la_SOURCES =		\
+	ea-calendar-item.c			\
+	ea-calendar-item.h			\
+	ea-widgets.c				\
+	ea-widgets.h
Index: a11y/widgets/ea-calendar-item.c
===================================================================
RCS file: a11y/widgets/ea-calendar-item.c
diff -N a11y/widgets/ea-calendar-item.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-calendar-item.c	22 Aug 2003 03:56:19 -0000
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-calendar-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
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <libgnomecanvas/gnome-canvas.h>
+#include <glib/gdate.h>
+#include "ea-calendar-item.h"
+
+static void ea_calendar_item_class_init (EaCalendarItemClass *klass);
+
+static G_CONST_RETURN gchar* ea_calendar_item_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_calendar_item_get_description (AtkObject *accessible);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_calendar_item_get_type (void)
+{
+	static GType type = 0;
+	AtkObjectFactory *factory;
+	GTypeQuery query;
+	GType derived_atk_type;
+
+
+	if (!type) {
+		static GTypeInfo tinfo = {
+			sizeof (EaCalendarItemClass),
+			(GBaseInitFunc) NULL, /* base init */
+			(GBaseFinalizeFunc) NULL, /* base finalize */
+			(GClassInitFunc) ea_calendar_item_class_init, /* class init */
+			(GClassFinalizeFunc) NULL, /* class finalize */
+			NULL, /* class data */
+			sizeof (EaCalendarItem), /* 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 (GailCanvasItem, 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;
+
+		type = g_type_register_static (derived_atk_type,
+					       "EaCalendarItem", &tinfo, 0);
+	}
+
+	return type;
+}
+
+static void
+ea_calendar_item_class_init (EaCalendarItemClass *klass)
+{
+	AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+	parent_class = g_type_class_peek_parent (klass);
+
+	class->get_name = ea_calendar_item_get_name;
+	class->get_description = ea_calendar_item_get_description;
+}
+
+AtkObject* 
+ea_calendar_item_new (GObject *obj)
+{
+	gpointer object;
+	AtkObject *atk_object;
+
+	g_return_val_if_fail (E_IS_CALENDAR_ITEM (obj), NULL);
+	object = g_object_new (EA_TYPE_CALENDAR_ITEM, NULL);
+	atk_object = ATK_OBJECT (object);
+	atk_object_initialize (atk_object, obj);
+	atk_object->role = ATK_ROLE_CALENDAR;
+#ifdef ACC_DEBUG
+	g_print ("ea_calendar_item created %p\n", atk_object);
+#endif
+	return atk_object;
+}
+
+static G_CONST_RETURN gchar*
+ea_calendar_item_get_name (AtkObject *accessible)
+{
+	GObject *g_obj;
+	ECalendarItem *calitem;
+	gint start_year, start_month, start_day;
+	gint end_year, end_month, end_day;
+	GDate select_start, select_end;
+	static gchar new_name[256] = "";
+
+	g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), NULL);
+
+	if (accessible->name)
+		return accessible->name;
+
+	g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible));
+	g_return_val_if_fail (E_IS_CALENDAR_ITEM (g_obj), NULL);
+
+	calitem = E_CALENDAR_ITEM (g_obj);
+	if (e_calendar_item_get_date_range (calitem,
+					    &start_year, &start_month, &start_day,
+					    &end_year, &end_month, &end_day)) {
+		++start_month;
+		++end_month;
+		sprintf (new_name, "calendar date range: from %d-%d-%d to %d-%d-%d.",
+			 start_year, start_month, start_day,
+			 end_year, end_month, end_day);
+	}
+	if (e_calendar_item_get_selection (calitem, &select_start, &select_end)) {
+		gint year1, year2, month1, month2, day1, day2;
+
+		year1 = g_date_get_year (&select_start);
+		month1  = g_date_get_month (&select_start);
+		day1 = g_date_get_day (&select_start);
+
+		year2 = g_date_get_year (&select_end);
+		month2  = g_date_get_month (&select_end);
+		day2 = g_date_get_day (&select_end);
+
+		sprintf (new_name + strlen (new_name),
+			 "current selection: from %d-%d-%d to %d-%d-%d.",
+			 year1, month1, day1,
+			 year2, month2, day2);
+	}
+
+	return new_name;
+}
+
+static G_CONST_RETURN gchar*
+ea_calendar_item_get_description (AtkObject *accessible)
+{
+	if (accessible->description)
+		return accessible->description;
+
+	return "evolution calendar widget";
+}
Index: a11y/widgets/ea-calendar-item.h
===================================================================
RCS file: a11y/widgets/ea-calendar-item.h
diff -N a11y/widgets/ea-calendar-item.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-calendar-item.h	22 Aug 2003 03:56:19 -0000
@@ -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-calendar-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
+ *
+ */
+
+#ifndef __EA_CALENDAR_ITEM_H__
+#define __EA_CALENDAR_ITEM_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include <misc/e-calendar-item.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define EA_TYPE_CALENDAR_ITEM                   (ea_calendar_item_get_type ())
+#define EA_CALENDAR_ITEM(obj)                   (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CALENDAR_ITEM, EaCalendarItem))
+#define EA_CALENDAR_ITEM_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CALENDAR_ITEM, EaCalendarItemClass))
+#define EA_IS_CALENDAR_ITEM(obj)                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CALENDAR_ITEM))
+#define EA_IS_CALENDAR_ITEM_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CALENDAR_ITEM))
+#define EA_CALENDAR_ITEM_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CALENDAR_ITEM, EaCalendarItemClass))
+
+typedef struct _EaCalendarItem                   EaCalendarItem;
+typedef struct _EaCalendarItemClass              EaCalendarItemClass;
+
+struct _EaCalendarItem
+{
+	AtkGObjectAccessible parent;
+};
+
+GType ea_calendar_item_get_type (void);
+
+struct _EaCalendarItemClass
+{
+	AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject *ea_calendar_item_new (GObject *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __EA_CALENDAR_ITEM_H__ */
Index: a11y/widgets/ea-widgets.c
===================================================================
RCS file: a11y/widgets/ea-widgets.c
diff -N a11y/widgets/ea-widgets.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-widgets.c	22 Aug 2003 03:56:19 -0000
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-widgets.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-factory.h"
+#include "widgets/ea-calendar-item.h"
+#include "ea-widgets.h"
+
+EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new);
+
+void e_calendar_item_a11y_init (void)
+{
+    EA_SET_FACTORY (e_calendar_item_get_type (), ea_calendar_item);
+}
Index: a11y/widgets/ea-widgets.h
===================================================================
RCS file: a11y/widgets/ea-widgets.h
diff -N a11y/widgets/ea-widgets.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-widgets.h	22 Aug 2003 03:56:20 -0000
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-widgets.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_WIDGETS_H__
+#define _EA_WIDGETS_H__
+
+void e_calendar_item_a11y_init (void);
+
+#endif /* _EA_WIDGETS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]