Could we discuss the patch again on gal atk implementation? was:Re: [evolution-patches] Re: GAL status



Hi, Mike

Then could we discuss the patch I submitted for epaned atk support?

In fact, the patch is including two parts:

1) Remove the original libgal-a11y-2.0.so (which is rpm packaged as
libgal-modules).  Instead of that,  we create a new library
libgal-a11y.so for atk support. libgal-a11y.so is not a gtk modules at
all, and it should be installed with libgal before gal is dead totally.

2) atk object implementation for epaned. The source code for this part
are all under gal/a11y/e-paned.

At least, part 2 is not harmful. So could I check the whole patch to gal
HEAD,or I have to split the patch and make the part 1 into HEAD?

I attach the patch which has a very little changes  against  the
original one I had sent out several days before.

Best Regards
Gilbert 


On Thu, 2003-07-24 at 22:33, Mike Kestner wrote: 
> On Thu, 2003-07-24 at 03:19, Gilbert Fang wrote:
> >   
> >   Thank you for information. I scaned the gal code and found there may
> > be some stuff you do not talk:( please search "??" in my attachment)
> >   
> >  ECanvas* and EFileSelection
> 
> ECanvas is an etable dependency, and probably calendar too.  It is most
> likely going to stay around.  EFileSelection may be killable if they get
> the new file selection into gtk+-2.4.
Index: gal-2.0.pc.in
===================================================================
RCS file: /cvs/gnome/gal/gal-2.0.pc.in,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- gal-2.0.pc.in	21 Jan 2003 16:48:00 -0000	1.4
+++ gal-2.0.pc.in	15 Jul 2003 06:34:18 -0000	1.4.2.1
@@ -8,5 +8,5 @@
 Version: @VERSION@
 Requires: gtk+-2.0 libxml-2.0 libglade-2.0 libgnomeprint-2.2
 
-Libs: -L${libdir} -lgal-2.0
+Libs: -L${libdir} -lgal-2.0 -lgal-a11y
 Cflags: -I${includedir}/gal-2.0
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gal/configure.in,v
retrieving revision 1.270
retrieving revision 1.268.2.1
diff -u -r1.270 -r1.268.2.1
--- configure.in	25 Jun 2003 17:26:35 -0000	1.270
+++ configure.in	15 Jul 2003 06:34:18 -0000	1.268.2.1
@@ -286,6 +286,7 @@
 gal/a11y/Makefile
 gal/a11y/e-text/Makefile
 gal/a11y/e-table/Makefile
+gal/a11y/e-paned/Makefile
 gal/util/Makefile
 gal/widgets/Makefile
 gal/e-text/Makefile
Index: gal/Makefile.am
===================================================================
RCS file: /cvs/gnome/gal/gal/Makefile.am,v
retrieving revision 1.65
retrieving revision 1.65.2.1
diff -u -r1.65 -r1.65.2.1
--- gal/Makefile.am	3 May 2003 17:05:27 -0000	1.65
+++ gal/Makefile.am	15 Jul 2003 06:34:18 -0000	1.65.2.1
@@ -1,5 +1,5 @@
 nonui_subdirs = util
-ui_subdirs    = widgets e-paned e-table e-text menus shortcut-bar . a11y
+ui_subdirs    = widgets e-paned e-table e-text menus shortcut-bar a11y .
 
 SUBDIRS = $(nonui_subdirs) $(ui_subdirs) 
 
@@ -17,4 +17,5 @@
 		   e-text/libetext.la \
 		   menus/libgalmenus.la \
 		   shortcut-bar/libshortcut-bar.la \
+		   a11y/libgal-a11y.la		\
 		   $(EXTRA_GNOME_LIBS)
Index: gal/a11y/Makefile.am
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.3.2.3
diff -u -r1.3 -r1.3.2.3
--- gal/a11y/Makefile.am	3 May 2003 17:05:28 -0000	1.3
+++ gal/a11y/Makefile.am	25 Jul 2003 04:08:26 -0000	1.3.2.3
@@ -1,4 +1,4 @@
-SUBDIRS = e-table e-text
+SUBDIRS = e-table e-text e-paned
 
 INCLUDES =					\
 	-I$(top_srcdir)                         \
@@ -7,28 +7,30 @@
 	$(GNOME_BONOBO_CFLAGS)			\
 	$(GNOME_INCLUDEDIR)			\
 	$(ICONV_CFLAGS)				\
-        -DG_LOG_DOMAIN=\"gal-a11y\"
+	-DGTK_DISABLE_DEPRECATED=1		\
+	-DGDK_DISABLE_DEPRECATED=1 		\
+	-DG_DISABLE_DEPRECATED=1		\
+	-DGNOME_DISABLE_DEPRECATED=1       	\
+	-DG_LOG_DOMAIN=\"gal-a11y\"
 
-module_LTLIBRARIES = libgal-a11y-2.0.la
 
-moduledir = $(libdir)/gtk-2.0/modules
+lib_LTLIBRARIES = libgal-a11y.la
 
-libgal_a11y_2_0_la_LDFLAGS =    \
-	-rpath $(moduledir) -module -avoid-version -no-undefined \
+libgal_a11y_la_LDFLAGS =    \
+	-avoid-version -no-undefined \
         @LDFLAGS@
 
-libgal_a11y_2_0_la_SOURCES =	\
-	gal-a11y-util.c		\
-	init.c
+libgal_a11y_la_SOURCES =	\
+	gal-a11y-util.c
 
-libgal_a11y_2_0includedir = $(includedir)/gal-$(GAL_API_VERSION)/gal/a11y
+libgal_a11yincludedir = $(includedir)/gal-$(GAL_API_VERSION)/gal/a11y
 
-libgal_a11y_2_0include_HEADERS =		\
-	gal-a11y-util.h
+libgal_a11yinclude_HEADERS =		\
+	gal-a11y-util.h			\
+	gal-a11y-factory.h
 
 
-libgal_a11y_2_0_la_LIBADD =		\
-	e-table/libgal-a11y-etable.la	\
-	e-text/libgal-a11y-etext.la	\
-	$(top_builddir)/gal/libgal-2.0.la	\
+libgal_a11y_la_LIBADD =		\
+	e-paned/libgal-a11y-epaned.la	\
+	$(top_builddir)/gal/e-paned/libepaned.la	\
 	$(EXTRA_GNOME_LIBS)
Index: gal/e-paned/e-paned.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-paned/e-paned.c,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- gal/e-paned/e-paned.c	16 Nov 2002 23:31:47 -0000	1.10
+++ gal/e-paned/e-paned.c	15 Jul 2003 06:34:20 -0000	1.10.2.1
@@ -51,9 +51,15 @@
  */
 
 #include <gtk/gtkstyle.h>
+#include <gtk/gtk.h>
 #include <gal/util/e-i18n.h>
 #include <gal/util/e-util.h>
 #include "e-paned.h"
+#include "gal/a11y/gal-a11y-factory.h"
+#include "gal/a11y/e-paned/gal-a11y-e-paned.h"
+
+GAL_A11Y_FACTORY(GAL_A11Y_TYPE_E_PANED, gal_a11y_e_paned, gal_a11y_e_paned_new)
+
 
 enum {
 	PROP_0,
@@ -149,6 +155,8 @@
 						      /*_( */"XXX blurb" /*)*/,
 						      0, G_MAXUINT, 0,
 						      G_PARAM_READWRITE));
+
+  GAL_A11Y_WIDGET_SET_FACTORY(E_TYPE_PANED, gal_a11y_e_paned);
 }
 
 static GtkType
Index: gal/a11y/e-paned/Makefile.am
===================================================================
RCS file: gal/a11y/e-paned/Makefile.am
diff -N gal/a11y/e-paned/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gal/a11y/e-paned/Makefile.am	15 Jul 2003 06:34:20 -0000	1.1.2.1
@@ -0,0 +1,19 @@
+INCLUDES =					\
+	-I$(top_srcdir)                         \
+	-I$(top_srcdir)/gal                     \
+	-I$(top_srcdir)/gal/a11y		\
+	$(EXTRA_GNOME_CFLAGS)			\
+	$(GNOME_BONOBO_CFLAGS)			\
+	$(GNOME_INCLUDEDIR)			\
+	$(ICONV_CFLAGS)				\
+        -DG_LOG_DOMAIN=\"e-paned\"
+
+noinst_LTLIBRARIES = libgal-a11y-epaned.la
+
+libgal_a11y_epaned_la_SOURCES =			\
+	gal-a11y-e-paned.c
+
+libgal_a11y_epanedincludedir = $(includedir)/gal-$(GAL_API_VERSION)/gal/a11y/e-paned
+
+libgal_a11y_epanedinclude_HEADERS =		\
+	gal-a11y-e-paned.h
Index: gal/a11y/e-paned/gal-a11y-e-paned.c
===================================================================
RCS file: gal/a11y/e-paned/gal-a11y-e-paned.c
diff -N gal/a11y/e-paned/gal-a11y-e-paned.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gal/a11y/e-paned/gal-a11y-e-paned.c	25 Jul 2003 09:42:53 -0000	1.1.2.3
@@ -0,0 +1,308 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* GAL A11Y
+ * gal-a11y-e-paned.c
+ *
+ * Copyright 2003 Ximain Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ *
+ * Authors:
+ *  Gilbert Fang <gilbert fang sun com>, Sun Microsystem Inc. 2003.
+ *
+ * Since EPaned is based on GtkPaned from Gtk+, GalA11yEPaned is corresponding 
+ * based on GailPaned from Gail.
+ *
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkaccessible.h>
+
+#include <atk/atkobject.h>
+#include <atk/atktable.h>
+#include <atk/atkcomponent.h>
+#include <atk/atkobjectfactory.h>
+#include <atk/atkregistry.h>
+#include <atk/atkgobjectaccessible.h>
+#include <atk/atkaction.h>
+
+#include "gal/e-paned/e-paned.h"
+#include "gal/e-paned/e-hpaned.h"
+#include "gal/e-paned/e-vpaned.h"
+#include "gal-a11y-e-paned.h"
+#include "gal/a11y/gal-a11y-util.h"
+
+
+static GObjectClass  *parent_class;
+static GType         parent_type;
+static gint          priv_offset;
+static GQuark	     quark_accessible_object = 0;
+
+#define GET_PRIVATE(object) ((GalA11yEPanedPrivate *) (((char *) object) + priv_offset))
+
+#define PARENT_TYPE (parent_type)
+
+struct _GalA11yEPanedPrivate {
+	int dummy;
+};
+
+static void gal_a11y_e_paned_class_init (GalA11yEPanedClass *klass);
+static void gal_a11y_e_paned_real_initialize    (AtkObject     *obj,
+						 gpointer      data);  
+
+static AtkStateSet* gal_a11y_e_paned_ref_state_set (AtkObject *accessible);
+
+static void         gal_a11y_e_paned_size_allocate_gtk   (GtkWidget      *widget,
+                                                    GtkAllocation  *allocation);
+
+static void         atk_value_interface_init       (AtkValueIface  *iface);
+static void         gal_a11y_e_paned_get_current_value   (AtkValue       *obj,
+                                                    GValue         *value);
+static void         gal_a11y_e_paned_get_maximum_value   (AtkValue       *obj,
+                                                    GValue         *value);
+static void         gal_a11y_e_paned_get_minimum_value   (AtkValue       *obj,
+                                                    GValue         *value);
+static gboolean     gal_a11y_e_paned_set_current_value   (AtkValue       *obj,
+                                                    const GValue   *value);
+
+GType
+gal_a11y_e_paned_get_type (void)
+{
+  static GType type = 0;
+
+  if (!type)
+    {
+      static const GTypeInfo tinfo =
+      {
+        sizeof (GalA11yEPanedClass),
+        (GBaseInitFunc) NULL, /* base init */
+        (GBaseFinalizeFunc) NULL, /* base finalize */
+        (GClassInitFunc) gal_a11y_e_paned_class_init, /* class init */
+        (GClassFinalizeFunc) NULL, /* class finalize */
+        NULL, /* class data */
+        sizeof (GalA11yEPaned), /* instance size */
+        0, /* nb preallocs */
+        (GInstanceInitFunc)NULL, /* instance init */
+        NULL /* value table */
+      };
+
+      static const GInterfaceInfo atk_value_info =
+      {
+        (GInterfaceInitFunc) atk_value_interface_init,
+        (GInterfaceFinalizeFunc) NULL,
+        NULL
+      };
+      
+      AtkObjectFactory *factory;
+
+      factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_CONTAINER);
+      parent_type = atk_object_factory_get_accessible_type (factory);
+
+      type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yEPaned", &tinfo, 0,
+								   sizeof (GalA11yEPanedPrivate), &priv_offset);
+
+      g_type_add_interface_static (type, ATK_TYPE_VALUE,
+                                   &atk_value_info);
+    }
+
+  return type;
+}
+
+
+static void
+gal_a11y_e_paned_class_init (GalA11yEPanedClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+  parent_class = g_type_class_ref (PARENT_TYPE);
+
+  class->ref_state_set = gal_a11y_e_paned_ref_state_set;
+  class->initialize = gal_a11y_e_paned_real_initialize;
+}
+
+static void
+gal_a11y_e_paned_real_initialize (AtkObject *obj,
+                             gpointer  data)
+{
+
+  g_return_if_fail (GTK_IS_WIDGET (data));
+
+  ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
+
+  g_signal_connect (data,
+                    "size_allocate",
+                    G_CALLBACK (gal_a11y_e_paned_size_allocate_gtk),
+                    NULL);
+
+  obj->role = ATK_ROLE_SPLIT_PANE;
+}
+
+AtkObject* 
+gal_a11y_e_paned_new (GtkWidget *widget)
+{
+  GObject *object;
+  AtkObject *accessible;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+  object = g_object_new (GAL_A11Y_TYPE_E_PANED, NULL);
+
+  accessible = ATK_OBJECT (object);
+  atk_object_initialize (accessible, widget);
+
+  return accessible;
+}
+
+static AtkStateSet*
+gal_a11y_e_paned_ref_state_set (AtkObject *accessible)
+{
+  AtkStateSet *state_set;
+  GtkWidget *widget;
+
+  g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), NULL);
+
+  state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
+  widget = GTK_ACCESSIBLE (accessible)->widget;
+
+  if (widget == NULL)
+    return state_set;
+
+  if (E_IS_VPANED (widget))
+    atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
+  else if (E_IS_HPANED (widget))
+    atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
+
+  return state_set;
+}
+
+static void
+gal_a11y_e_paned_size_allocate_gtk (GtkWidget      *widget,
+                              GtkAllocation  *allocation)
+{
+  AtkObject *obj = gtk_widget_get_accessible (widget);
+
+  g_object_notify (G_OBJECT (obj), "accessible-value");
+}
+
+static void
+atk_value_interface_init (AtkValueIface *iface)
+{
+  g_return_if_fail (iface != NULL);
+
+  iface->get_current_value = gal_a11y_e_paned_get_current_value;
+  iface->get_maximum_value = gal_a11y_e_paned_get_maximum_value;
+  iface->get_minimum_value = gal_a11y_e_paned_get_minimum_value;
+  iface->set_current_value = gal_a11y_e_paned_set_current_value;
+
+}
+
+static void
+gal_a11y_e_paned_get_current_value (AtkValue             *obj,
+                              GValue               *value)
+{
+  GtkWidget* widget;
+  gint current_value;
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_INT);
+
+  g_return_if_fail (GTK_IS_ACCESSIBLE (obj));
+
+  widget = GTK_ACCESSIBLE (obj)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return;
+
+  current_value = e_paned_get_position (E_PANED (widget));
+
+  g_value_set_int (value,current_value);
+}
+
+static void
+gal_a11y_e_paned_get_maximum_value (AtkValue             *obj,
+                              GValue               *value)
+{
+  GtkWidget* widget;
+  gint maximum_value;
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_INT);
+  g_return_if_fail (GTK_IS_ACCESSIBLE (obj));
+
+  widget = GTK_ACCESSIBLE (obj)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return;
+
+  maximum_value = E_PANED (widget)->max_position;
+  g_value_set_int (value, maximum_value);
+}
+
+static void
+gal_a11y_e_paned_get_minimum_value (AtkValue             *obj,
+                              GValue               *value)
+{
+  GtkWidget* widget;
+  gint minimum_value;
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_INT);
+  g_return_if_fail (GTK_IS_ACCESSIBLE (obj));
+
+  widget = GTK_ACCESSIBLE (obj)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return;
+
+  minimum_value = E_PANED (widget)->min_position;
+  g_value_set_int (value, minimum_value);
+}
+
+/*
+ * Calling atk_value_set_current_value() is no guarantee that the value is
+ * acceptable; it is necessary to listen for accessible-value signals
+ * and check whether the current value has been changed or check what the 
+ * maximum and minimum values are.
+ */
+
+static gboolean
+gal_a11y_e_paned_set_current_value (AtkValue             *obj,
+                              const GValue         *value)
+{
+  GtkWidget* widget;
+  gint new_value;
+
+  g_return_val_if_fail (GTK_IS_ACCESSIBLE (obj), FALSEN);
+
+  widget = GTK_ACCESSIBLE (obj)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return FALSE;
+
+  if (G_VALUE_HOLDS_INT (value))
+    {
+      new_value = g_value_get_int (value);
+      e_paned_set_position (E_PANED (widget), new_value);
+
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
+
Index: gal/a11y/e-paned/gal-a11y-e-paned.h
===================================================================
RCS file: gal/a11y/e-paned/gal-a11y-e-paned.h
diff -N gal/a11y/e-paned/gal-a11y-e-paned.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gal/a11y/e-paned/gal-a11y-e-paned.h	15 Jul 2003 06:34:20 -0000	1.1.2.1
@@ -0,0 +1,75 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* GAL A11Y
+ * gal-a11y-e-paned.h
+ *
+ * Copyright 2003 Ximian Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ *
+ * Authors:
+ *  Gilbert Fang <gilbert fang sun com>, Sun Microsystem Inc. 2003.
+ * 
+ * Since EPaned is based on GtkPaned from Gtk+, GalA11yEPaned is corresponding 
+ * based on GailPaned from Gail.
+ *
+ */
+
+#ifndef __GAL_A11Y_E_PANED_H__
+#define __GAL_A11Y_E_PANED_H__
+
+#include <glib-object.h>
+#include <atk/atkobject.h>
+#include <atk/atkobjectfactory.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define GAL_A11Y_TYPE_E_PANED                     (gal_a11y_e_paned_get_type ())
+#define GAL_A11Y_E_PANED(obj)                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_PANED, GalA11yEPaned))
+#define GAL_A11Y_E_PANED_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST ((klass),  GAL_A11Y_TYPE_E_PANED, GalA11yEPanedClass))
+#define GAL_A11Y_IS_E_PANED(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_PANED))
+#define GAL_A11Y_IS_E_PANED_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE ((klass),  GAL_A11Y_TYPE_E_PANED))
+#define GAL_A11Y_E_PANED_GET_CLASS(obj)           (G_TYPE_INSTANCE_GET_CLASS ((obj),  GAL_A11Y_TYPE_E_PANED, GalA11yEPanedClass))
+
+typedef struct _GalA11yEPaned                   GalA11yEPaned;
+typedef struct _GalA11yEPanedClass              GalA11yEPanedClass;
+typedef struct _GalA11yEPanedPrivate            GalA11yEPanedPrivate;
+
+/* This struct should actually be larger as this isn't what we derive from.
+ * The GalA11yEPanedPrivate comes right after the parent class structure.
+ **/
+struct _GalA11yEPaned {
+	AtkObject object;
+};
+
+struct _GalA11yEPanedClass {
+	AtkObject parent_class;
+};
+
+
+/* Standard Glib function */
+GType      gal_a11y_e_text_get_type  (void);
+
+AtkObject*     gal_a11y_e_paned_new  (GtkWidget       *widget);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __GAL_A11Y_E_PANED_H__ */
Index: gal/a11y/gal-a11y-factory.h
===================================================================
RCS file: gal/a11y/gal-a11y-factory.h
diff -N gal/a11y/gal-a11y-factory.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gal/a11y/gal-a11y-factory.h	15 Jul 2003 06:34:19 -0000	1.1.2.1
@@ -0,0 +1,94 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* GAL A11Y
+ * gal-a11y-factory.h
+ *
+ * Copyright 2003 Ximian Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ *
+ * Authors:
+ *  Gilbert Fang <gilbert fang sun com>, Sun Microsystem Inc. 2003.
+ *
+ * This file is mainly from the gailfactory.h of GAIL. 
+ */
+
+#ifndef _GAL_A11Y_FACTORY_H__
+#define _GAL_A11Y_FACTORY_H__
+
+#include <glib-object.h>
+#include <atk/atkobject.h>
+#include <atk/atkobjectfactory.h>
+
+#define GAL_A11Y_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 GAL_A11Y_WIDGET_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 /* _GAL_A11Y_FACTORY_H__ */


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