[evolution-patches] patch to imlement a11y support for minicard of AB



hi, Chris

To make a11y work in Addressbook, two parts of work should be done: a11y implement and keyboard.

I have finished implementing the first part: a11y support for minicard of addressbook.
(I will discuss with you more details about keyboard naviagtion isssues in future days because diffirence in UI
between 1.4 and HEAD)


Current patch include two parts:
1) main a11y implement:
   Create new codes in a11y directory, just like current calendar's implement.
   thse codes can create atkobject for minicard, addressbook view and minicard view when they have focus.
   btw, those codes are based on HEAD.
   (We have test those codes based on 1.4 fr a month, and now codes are being pored to HEAD)

2) initilze a11y support in addressbook codes:
   change codes in addressbook/gui.
   initialize factory for minicard, addressbook view and minicard view.
   To make ATKobject can read info of minicard label when focus is in minicard, add a function which can return labels.

3) also related makefile.am files are changed too.

pls, review it.

thx



leon
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/ChangeLog,v
retrieving revision 1.1273
diff -u -r1.1273 ChangeLog
--- ChangeLog	8 Dec 2003 01:46:03 -0000	1.1273
+++ ChangeLog	10 Dec 2003 06:39:00 -0000
@@ -1,3 +1,7 @@
+2003-12-09 Leon Zhang <leon zhang sun com>
+
+	* configure.in: add a11y/addressbook/Makefile
+
 2003-12-07  JP Rosevear  <jpr ximian com>
 
 	* configure.in: update version reliance
Index: a11y/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/a11y/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- a11y/Makefile.am	4 Nov 2003 08:15:56 -0000	1.5
+++ a11y/Makefile.am	10 Dec 2003 06:39:00 -0000
@@ -1,4 +1,4 @@
-SUBDIRS = . calendar widgets
+SUBDIRS = . addressbook calendar widgets
 
 # for debug
 #A11Y_CFLAGS += -pedantic -ansi -DACC_DEBUG -Werror
Index: a11y/addressbook/Makefile.am
===================================================================
RCS file: a11y/addressbook/Makefile.am
diff -N a11y/addressbook/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/Makefile.am	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,33 @@
+privlib_LTLIBRARIES = libevolution-addressbook-a11y.la
+
+INCLUDES =						\
+	-DG_LOG_DOMAIN=\"evolution-a11y\"		\
+	-I$(top_srcdir)/a11y				\
+	-I$(top_srcdir)/a11y/addressbook		\
+	-I$(top_srcdir)/shell				\
+	-I$(top_srcdir)/addressbook			\
+	-I$(top_srcdir)/addressbook/gui			\
+	-I$(top_srcdir)/addressbook/gui/widgets		\
+	-I$(top_srcdir)/addressbook/gui/contact-editor	\
+	-I$(top_srcdir)/addressbook/backend             \
+	-I$(top_srcdir)/addressbook/backend/ebook       \
+	-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_ADDRESSBOOK_CFLAGS)
+
+libevolution_addressbook_a11y_la_SOURCES =		\
+			ea-minicard.c  			\
+			ea-minicard.h			\
+			ea-minicard-view.c		\
+			ea-minicard-view.h		\
+			ea-addressbook-view.c		\
+			ea-addressbook-view.h		\
+			ea-addressbook.c		\
+			ea-addressbook.h
Index: a11y/addressbook/ea-addressbook-view.c
===================================================================
RCS file: a11y/addressbook/ea-addressbook-view.c
diff -N a11y/addressbook/ea-addressbook-view.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-addressbook-view.c	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,123 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * ea-addressbook-view.c
+ * Copyright (C) 2000  Ximian, Inc.
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:  Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ */
+
+#include <config.h>
+
+#include "ea-addressbook-view.h"
+
+static G_CONST_RETURN gchar* ea_ab_view_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_ab_view_get_description (AtkObject *accessible);
+
+static void ea_ab_view_class_init (EABViewClass *klass);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_ab_view_get_type (void)
+{
+	static GType type = 0;
+	AtkObjectFactory *factory;
+	GTypeQuery query;
+	GType derived_atk_type;
+
+	if (!type) {
+		static  GTypeInfo tinfo =  {
+			sizeof (EABViewClass),
+			(GBaseInitFunc) NULL,  /* base_init */
+			(GBaseFinalizeFunc) NULL,  /* base_finalize */
+			(GClassInitFunc) ea_ab_view_class_init,
+			(GClassFinalizeFunc) NULL, /* class_finalize */
+			NULL,	/* class_data */
+			sizeof (EaABView),
+			0,	/* n_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_EVENT_BOX);
+		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,
+						"EaABView", &tinfo, 0);
+	}
+
+	return type;
+}
+
+static void
+ea_ab_view_class_init (EABViewClass *klass)
+{
+	AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+	parent_class = g_type_class_peek_parent (klass);
+
+	class->get_name = ea_ab_view_get_name;
+	class->get_description = ea_ab_view_get_description;
+}
+
+static G_CONST_RETURN gchar*
+ea_ab_view_get_name (AtkObject *accessible)
+{
+	static gchar new_name[50]="evolution addressbook";
+
+	g_return_val_if_fail (EA_IS_AB_VIEW(accessible), NULL);
+	if (accessible->name)
+		return accessible->name;
+
+	return new_name;
+}
+
+static G_CONST_RETURN gchar*
+ea_ab_view_get_description (AtkObject *accessible)
+{
+	if (accessible->description)
+		return accessible->description;
+
+	return "evolution addressbook";
+}
+
+AtkObject* 
+ea_ab_view_new (GtkWidget *obj)
+{
+	GObject *object;
+	AtkObject *accessible;
+
+	g_return_val_if_fail(obj != NULL, NULL);
+	g_return_val_if_fail (E_IS_ADDRESSBOOK_VIEW(obj), NULL);
+
+	object = g_object_new (EA_TYPE_AB_VIEW, NULL);
+
+	accessible = ATK_OBJECT (object);
+	atk_object_initialize (accessible, obj);
+	accessible->role = ATK_ROLE_CANVAS;
+
+	return accessible;
+}
Index: a11y/addressbook/ea-addressbook-view.h
===================================================================
RCS file: a11y/addressbook/ea-addressbook-view.h
diff -N a11y/addressbook/ea-addressbook-view.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-addressbook-view.h	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * ea-addressbook_view.h
+ * Copyright (C) 2000  Ximian, Inc.
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ */
+#ifndef __EA_ADDRESSBOOK_VIEW_H__
+#define __EA_ADDRESSBOOK_VIEW_H__
+
+#include <gtk/gtkaccessible.h>
+#include "e-addressbook-view.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EA_TYPE_AB_VIEW			(ea_ab_view_get_type ())
+#define EA_AB_VIEW(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_AB_VIEW, EaABView))
+#define EA_AB_VIEW_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_AB_VIEW, EaABViewClass))
+#define EA_IS_AB_VIEW(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_AB_VIEW))
+#define EA_IS_AB_VIEW_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((obj), EA_TYPE_AB_VIEW))
+
+typedef struct _EaABView       EaABView;
+typedef struct _EaABViewClass  EaABViewClass;
+
+struct _EaABView
+{
+	GtkAccessible parent;
+};
+
+
+struct _EaABViewClass
+{
+	GtkAccessibleClass parent_class;
+};
+
+GType ea_ab_view_get_type (void);
+AtkObject* ea_ab_view_new(GtkWidget *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __EA_ADDRESSBOOK_VIEW_H__ */
Index: a11y/addressbook/ea-addressbook.c
===================================================================
RCS file: a11y/addressbook/ea-addressbook.c
diff -N a11y/addressbook/ea-addressbook.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-addressbook.c	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+/* Evolution Accessibility: ea-addressbook.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: Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ *
+ */
+
+#include <gal/e-text/e-text.h>
+#include "ea-factory.h"
+#include "ea-addressbook.h"
+#include "addressbook/ea-minicard.h"
+#include "addressbook/ea-minicard-view.h"
+#include "addressbook/ea-addressbook-view.h"
+
+EA_FACTORY_GOBJECT (EA_TYPE_MINICARD, ea_minicard, ea_minicard_new);
+EA_FACTORY_GOBJECT (EA_TYPE_MINICARD_VIEW, ea_minicard_view, ea_minicard_view_new);
+EA_FACTORY_GOBJECT (EA_TYPE_AB_VIEW, ea_ab_view, ea_ab_view_new);
+
+static gboolean ea_addressbook_focus_watcher (GSignalInvocationHint *ihint,
+					      guint n_param_values,
+					      const GValue *param_values,
+					      gpointer data);
+
+void e_minicard_a11y_init (void)
+{
+	EA_SET_FACTORY (e_minicard_get_type (), ea_minicard);
+}
+
+void e_minicard_view_a11y_init (void)
+{
+	EA_SET_FACTORY (e_minicard_view_get_type (), ea_minicard_view);
+
+	if (atk_get_root ()) {
+		g_signal_add_emission_hook (g_signal_lookup ("event",
+					    e_minicard_get_type()),
+					    0, ea_addressbook_focus_watcher,
+					    NULL, (GDestroyNotify) NULL);
+	}
+}
+
+void eab_view_a11y_init (void)
+{
+	EA_SET_FACTORY (eab_view_get_type (), ea_ab_view);
+}
+
+gboolean
+ea_addressbook_focus_watcher (GSignalInvocationHint *ihint,
+			   guint n_param_values,
+			   const GValue *param_values,
+			   gpointer data)
+{
+	GObject *object;
+	GdkEvent *event;
+	AtkObject *ea_event = NULL;
+
+	object = g_value_get_object (param_values + 0);
+	event = g_value_get_boxed (param_values + 1);
+
+	if (E_IS_MINICARD(object)) {
+		EMinicard *minicard = E_MINICARD (object);
+                GnomeCanvasItem *item = GNOME_CANVAS_ITEM(object);
+		ea_event = atk_gobject_accessible_for_object(minicard);
+		if (event->type == GDK_FOCUS_CHANGE) {
+			if ((event->focus_change.in) && (E_IS_MINICARD(item->canvas->focused_item)))
+				atk_focus_tracker_notify(ea_event);
+		}
+	}
+
+	return TRUE;
+}
Index: a11y/addressbook/ea-addressbook.h
===================================================================
RCS file: a11y/addressbook/ea-addressbook.h
diff -N a11y/addressbook/ea-addressbook.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-addressbook.h	10 Dec 2003 06:39:00 -0000
@@ -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-addressbook.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: Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ *
+ */
+
+/* Evolution Accessibility
+*/
+
+#ifndef _EA_ADDRESSBOOK_H__
+#define _EA_ADDRESSBOOK_H__
+
+void eab_view_a11y_init (void);
+void e_minicard_view_a11y_init (void);
+void e_minicard_a11y_init (void);
+void e_minicard_label_a11y_init (void);
+
+#endif /* _EA_ADDRESSBOOK_H__ */
Index: a11y/addressbook/ea-minicard-view.c
===================================================================
RCS file: a11y/addressbook/ea-minicard-view.c
diff -N a11y/addressbook/ea-minicard-view.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-minicard-view.c	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,129 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * ea-minicard-view.c
+ * Copyright (C) 2000  Ximian, Inc.
+ * Author:  Leon Zhang < leon zhang sun com>
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include "ea-minicard.h"
+#include "ea-minicard-view.h"
+
+static G_CONST_RETURN gchar* ea_minicard_view_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_minicard_view_get_description (AtkObject *accessible);
+
+static void ea_minicard_view_class_init (EaMinicardViewClass *klass);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_minicard_view_get_type (void)
+{
+	static GType type = 0;
+	AtkObjectFactory *factory;
+	GTypeQuery query;
+	GType derived_atk_type;
+
+	if (!type) {
+		static  GTypeInfo tinfo =  {
+			sizeof (EaMinicardViewClass),
+			(GBaseInitFunc) NULL,  /* base_init */
+			(GBaseFinalizeFunc) NULL,  /* base_finalize */
+			(GClassInitFunc) ea_minicard_view_class_init,
+			(GClassFinalizeFunc) NULL, /* class_finalize */
+			NULL,	   /* class_data */
+			sizeof (EaMinicardView),
+			0,	     /* n_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 (),
+							GNOME_TYPE_CANVAS_GROUP);
+		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,
+						"EaMinicardView", &tinfo, 0);
+	}
+
+	return type;
+}
+
+static void
+ea_minicard_view_class_init (EaMinicardViewClass *klass)
+{
+	AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+	parent_class = g_type_class_peek_parent (klass);
+
+	class->get_name = ea_minicard_view_get_name;
+	class->get_description = ea_minicard_view_get_description;
+}
+
+static G_CONST_RETURN gchar*
+ea_minicard_view_get_name (AtkObject *accessible)
+{
+	static char name[100];
+	char *p = name;
+	gchar str[10];
+	EReflow *reflow;
+
+	g_return_val_if_fail (EA_IS_MINICARD_VIEW(accessible), NULL);
+	memset(name, '\0', 100);
+	memset(str, '\0', 10);
+
+	reflow = E_REFLOW(atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)));
+	sprintf(str, "%d", reflow->count);
+
+	strcat(p,"current addressbook folder ");
+	strcat(p, (reflow->count) > 1 ? "have ":"has ");
+	strcat(p, str);
+	strcat(p, (reflow->count) > 1 ? " cards":" card");
+
+	return name;
+}
+
+static G_CONST_RETURN gchar*
+ea_minicard_view_get_description (AtkObject *accessible)
+{
+	if (accessible->description)
+		return accessible->description;
+
+	return "evolution addressbook";
+}
+
+AtkObject* 
+ea_minicard_view_new (GObject *obj)
+{
+	GObject *object;
+	AtkObject *accessible;
+
+	g_return_val_if_fail (E_IS_MINICARD_VIEW(obj), NULL);
+	object = g_object_new (EA_TYPE_MINICARD_VIEW, NULL);
+	accessible = ATK_OBJECT (object);
+	atk_object_initialize (accessible, obj);
+	accessible->role = ATK_ROLE_PANEL;
+	return accessible;
+}
Index: a11y/addressbook/ea-minicard-view.h
===================================================================
RCS file: a11y/addressbook/ea-minicard-view.h
diff -N a11y/addressbook/ea-minicard-view.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-minicard-view.h	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * ea-minicard-view.h
+ * Copyright (C) 2000  Ximian, Inc.
+ * Author: Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __EA_MINICARD_VIEW_H__
+#define __EA_MINICARD_VIEW_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-minicard-view.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EA_TYPE_MINICARD_VIEW			(ea_minicard_view_get_type ())
+#define EA_MINICARD_VIEW(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_MINICARD_VIEW, EaMinicardView))
+#define EA_MINICARD_VIEW_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_MINICARD_VIEW, EaMiniCardViewClass))
+#define EA_IS_MINICARD_VIEW(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_MINICARD_VIEW))
+#define EA_IS_MINICARD_VIEW_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((obj), EA_TYPE_MINICARD_VIEW))
+
+
+typedef struct _EaMinicardView       EaMinicardView;
+typedef struct _EaMinicardViewClass  EaMinicardViewClass;
+
+struct _EaMinicardView
+{
+	AtkGObjectAccessible parent;
+};
+
+
+struct _EaMinicardViewClass
+{
+	AtkGObjectAccessibleClass parent_class;
+};
+
+GType ea_minicard_view_get_type (void);
+
+AtkObject* ea_minicard_view_new(GObject *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __EA_MINICARD_VIEW_H__ */
Index: a11y/addressbook/ea-minicard.c
===================================================================
RCS file: a11y/addressbook/ea-minicard.c
diff -N a11y/addressbook/ea-minicard.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-minicard.c	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,203 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * ea-minicard.c
+ * Copyright (C) 2000  Ximian, Inc.
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:  Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ */
+
+#include <config.h>
+#include <string.h>
+#include "ea-minicard.h"
+
+static G_CONST_RETURN gchar* ea_minicard_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar* ea_minicard_get_description (AtkObject *accessible);
+
+static void ea_minicard_class_init (EaMinicardClass *klass);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_minicard_get_type (void)
+{
+	static GType type = 0;
+	AtkObjectFactory *factory;
+	GTypeQuery query;
+	GType derived_atk_type;
+
+	if (!type) {
+		static  GTypeInfo tinfo =  {
+			sizeof (EaMinicardClass),
+			(GBaseInitFunc) NULL,  /* base_init */
+			(GBaseFinalizeFunc) NULL,  /* base_finalize */
+			(GClassInitFunc) ea_minicard_class_init,
+			(GClassFinalizeFunc) NULL, /* class_finalize */
+			NULL,	/* class_data */
+			sizeof (EaMinicard),
+			0,	/* n_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 (),
+						    GNOME_TYPE_CANVAS_GROUP);
+		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,
+						"EaMinicard", &tinfo, 0);
+	}
+
+	return type;
+}
+
+static void
+ea_minicard_class_init (EaMinicardClass *klass)
+{
+	AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+	parent_class = g_type_class_peek_parent (klass);
+
+	class->get_name = ea_minicard_get_name;
+	class->get_description = ea_minicard_get_description;
+}
+
+/*
+ *  we access the main content of current minicard, including 
+ *  header text, label(field, field name)
+ */
+static G_CONST_RETURN gchar*
+ea_minicard_get_name (AtkObject *accessible)
+{
+#define BUFFSIZE 500
+	static gchar name[BUFFSIZE];
+	char *string;
+	char *p = name;
+	int len, count, r;
+	EMinicard *card;
+	GList *list;
+
+	g_return_val_if_fail (EA_IS_MINICARD(accessible), NULL);
+	memset(name, '\0', BUFFSIZE);
+
+	strcat(p, "contact's header: ");
+
+	card = E_MINICARD(atk_gobject_accessible_get_object 
+			 (ATK_GOBJECT_ACCESSIBLE(accessible)));
+	g_object_get (card->header_text, "text", &string, NULL);
+
+	count = strlen(p);
+	p += count;
+	r = BUFFSIZE - count;
+
+	/* we copy header to current buffer */
+	len = strlen(string);
+	count = len < r ? len : r;
+	strncpy(p, string, count);
+	g_free(string);
+
+	p += count;
+	r -= count;
+	/* if there exist no enough space for remain info, return */
+	if (r <= 1 ) {
+		return name;
+	}
+
+	*p = ' ';
+	p++;
+	r--;
+
+	for ( list = card->fields; list; list = g_list_next( list ) ) {
+		char *f, *fn;
+        	int f_len, fn_len;
+		EMinicardLabel *label;
+
+		label = E_MINICARD_LABEL(get_label_from_list(list));
+
+		g_object_get (label->fieldname, "text", &fn, NULL);
+		fn_len = strlen(fn);
+
+		/* copy field name to current buffer */
+		count = fn_len < r? fn_len : r;
+		strncpy(p, fn, count);
+		g_free(fn);
+
+		p += count;
+		r -= count;
+		if (r <= 1 ) {
+			break;
+		}
+
+		*p = ' ';
+		p++;
+		r--;
+
+		g_object_get (label->field, "text", &f, NULL);
+		f_len = strlen(f);
+
+		/* copy field to current buffer */
+		count = f_len < r ? f_len : r;
+		strncpy(p, f, count);
+		g_free(f);
+
+		p += count;
+		r -= count;
+		if (r <= 1 ) {
+			break;
+		}
+
+		*p = ' ';
+		p++;
+		r--;
+	}
+
+	return name;
+}
+
+static G_CONST_RETURN gchar*
+ea_minicard_get_description (AtkObject *accessible)
+{
+	if (accessible->description)
+		return accessible->description;
+																
+	return "evolution minicard";
+}
+
+AtkObject* 
+ea_minicard_new (GObject *obj)
+{
+	GObject *object;
+	AtkObject *accessible;
+
+	g_return_val_if_fail(obj != NULL, NULL);
+	g_return_val_if_fail (E_IS_MINICARD(obj), NULL);
+
+	object = g_object_new (EA_TYPE_MINICARD, NULL);
+	accessible = ATK_OBJECT (object);
+	atk_object_initialize (accessible, obj);
+
+	accessible->role = ATK_ROLE_PANEL;
+	return accessible;
+}
Index: a11y/addressbook/ea-minicard.h
===================================================================
RCS file: a11y/addressbook/ea-minicard.h
diff -N a11y/addressbook/ea-minicard.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/addressbook/ea-minicard.h	10 Dec 2003 06:39:00 -0000
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * ea-minicard.h
+ * Copyright (C) 2000  Ximian, Inc.
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ * 
+ * Author: Leon Zhang <leon zhang sun com> Sun Microsystem Inc., 2003
+ */
+#ifndef __EA_MINICARD_H__
+#define __EA_MINICARD_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-minicard.h"
+#include "e-minicard-label.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EA_TYPE_MINICARD			(ea_minicard_get_type ())
+#define EA_MINICARD(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_MINICARD, EaMinicard))
+#define EA_MINICARD_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_MINICARD, EaMiniCardClass))
+#define EA_IS_MINICARD(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_MINICARD))
+#define EA_IS_MINICARD_CLASS(klass)		(G_TYPE_CHECK_CLASS_TYPE ((obj), EA_TYPE_MINICARD))
+
+typedef struct _EaMinicard       EaMinicard;
+typedef struct _EaMinicardClass  EaMinicardClass;
+
+struct _EaMinicard
+{
+	AtkGObjectAccessible parent;
+};
+
+
+struct _EaMinicardClass
+{
+	AtkGObjectAccessibleClass parent_class;
+};
+
+GType ea_minicard_get_type (void);
+AtkObject* ea_minicard_new(GObject *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __EA_MINICARD_H__ */
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1497
diff -u -r1.1497 ChangeLog
--- addressbook/ChangeLog	6 Dec 2003 23:18:58 -0000	1.1497
+++ addressbook/ChangeLog	10 Dec 2003 06:39:03 -0000
@@ -1,3 +1,17 @@
+2003-12-09 Leon Zhang <leon zhang sun com>
+
+	* gui/component/Makefile.am: add dependence to a11y module.
+
+	* gui/widgets/e-addressbook-view.c: e_addressbook_view_class_init():
+	initialization for a11y.
+
+	* gui/widgets/e-minicard-view.c:e_minicard_view_class_init(): same.
+
+	* gui/widgets/e-minicard.c:e_minicard_class_init(): same.
+	get_label_from_list(): return minicard label pointered by current list node. 
+
+	* gui/widgets/e-minicard.h: add declaration of function get_label_from_list().
+
 2003-12-06  Chris Toshok  <toshok ximian com>
 
 	* gui/component/select-names/e-select-names-manager.c
Index: addressbook/gui/component/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/Makefile.am,v
retrieving revision 1.100
diff -u -r1.100 Makefile.am
--- addressbook/gui/component/Makefile.am	6 Dec 2003 23:19:00 -0000	1.100
+++ addressbook/gui/component/Makefile.am	10 Dec 2003 06:39:04 -0000
@@ -12,6 +12,7 @@
 	-I$(top_srcdir)/addressbook/gui/widgets			\
 	-I$(top_srcdir)/addressbook/backend			\
 	-I$(top_builddir)/addressbook/backend			\
+	-I$(top_builddir)/a11y/addressbook			\
 	-DEVOLUTION_DATADIR=\""$(datadir)"\"			\
 	-DEVOLUTION_GLADEDIR=\""$(gladedir)"\"			\
 	-DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\"		\
@@ -54,6 +55,7 @@
 	$(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la	\
 	$(top_builddir)/widgets/misc/libemiscwidgets.la					\
 	$(top_builddir)/widgets/menus/libmenus.la					\
+	$(top_builddir)/a11y/addressbook/libevolution-addressbook-a11y.la		\
 	$(EVOLUTION_ADDRESSBOOK_LIBS) $(LDAP_LIBS)
 
 
Index: addressbook/gui/widgets/e-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.c,v
retrieving revision 1.120
diff -u -r1.120 e-addressbook-view.c
--- addressbook/gui/widgets/e-addressbook-view.c	7 Nov 2003 05:54:09 -0000	1.120
+++ addressbook/gui/widgets/e-addressbook-view.c	10 Dec 2003 06:39:06 -0000
@@ -233,6 +233,9 @@
 
 	if (!clipboard_atom)
 		clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+
+	/* init the accessibility support for e_addressbook_view */
+	eab_view_a11y_init();
 }
 
 static void
Index: addressbook/gui/widgets/e-minicard-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-minicard-view.c,v
retrieving revision 1.62
diff -u -r1.62 e-minicard-view.c
--- addressbook/gui/widgets/e-minicard-view.c	21 Oct 2003 18:48:56 -0000	1.62
+++ addressbook/gui/widgets/e-minicard-view.c	10 Dec 2003 06:39:06 -0000
@@ -489,6 +489,9 @@
 
 	reflow_class->selection_event = e_minicard_view_selection_event;
 	/* GnomeCanvasItem method overrides */
+
+	/* init the accessibility support for e_minicard_view */
+        e_minicard_view_a11y_init();
 }
 
 static void
Index: addressbook/gui/widgets/e-minicard.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-minicard.c,v
retrieving revision 1.110
diff -u -r1.110 e-minicard.c
--- addressbook/gui/widgets/e-minicard.c	14 Nov 2003 00:38:47 -0000	1.110
+++ addressbook/gui/widgets/e-minicard.c	10 Dec 2003 06:39:07 -0000
@@ -225,6 +225,9 @@
 	item_class->event      = e_minicard_event;
 
 	klass->selected        = NULL;
+
+	/* init the accessibility support for e_minicard */
+	e_minicard_a11y_init();
 }
 
 static void
@@ -966,3 +969,11 @@
 	}
 	return ret_val;
 }
+
+GnomeCanvasItem *
+get_label_from_list(GList *list)
+{
+	g_return_val_if_fail (list != NULL, 0);
+
+	return GNOME_CANVAS_ITEM(E_MINICARD_FIELD(list->data)->label);
+}
Index: addressbook/gui/widgets/e-minicard.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-minicard.h,v
retrieving revision 1.32
diff -u -r1.32 e-minicard.h
--- addressbook/gui/widgets/e-minicard.h	7 Nov 2003 05:51:41 -0000	1.32
+++ addressbook/gui/widgets/e-minicard.h	10 Dec 2003 06:39:07 -0000
@@ -115,6 +115,8 @@
 int         e_minicard_selected     (EMinicard *minicard,
 				     GdkEvent  *event);
 
+GnomeCanvasItem *get_label_from_list(GList *list);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */


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