[gtk+/drop-gail: 3/24] Register GtkWidgetAccessibleFactory instead of GailWidgetFactory



commit cd73b3b7f2d45498a008f00a089704ded711e6df
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 21 01:27:14 2011 -0500

    Register GtkWidgetAccessibleFactory instead of GailWidgetFactory

 gtk/gtkaccessibility.h    |   97 +++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.c           |   57 +--------------------------
 modules/other/gail/gail.c |    9 ++++-
 3 files changed, 106 insertions(+), 57 deletions(-)
---
diff --git a/gtk/gtkaccessibility.h b/gtk/gtkaccessibility.h
new file mode 100644
index 0000000..ff95914
--- /dev/null
+++ b/gtk/gtkaccessibility.h
@@ -0,0 +1,97 @@
+/* GTK - The GIMP Toolkit
+ * Copyright 2011 Sun Microsystems 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.
+ */
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_ACCESSIBILITY_H__
+#define __GTK_ACCESSIBILITY_H__
+
+G_BEGIN_DECLS
+
+/**
+ * GTK_ACCESSIBLE_FACTORY:
+ * @type: GType of the accessible which is created by the factory
+ * @prefix: prefix of the accessible object methods
+ * @create_accessible_func: function to instantiate the accessible for a
+ *     given object
+ *
+ * Implements a new #AtkObjectFactory to create accessible objects of a
+ * specific type. It defines the GType of the factory and implements
+ * the relevant #AtkObjectFactory methods.
+ */
+#define GTK_ACCESSIBLE_FACTORY(type, prefix, create_accessible_func)    \
+static GType                                                            \
+prefix ## _factory_get_accessible_type (void)                           \
+{                                                                       \
+  return type;                                                          \
+}                                                                       \
+                                                                        \
+static AtkObject *                                                      \
+prefix ## _factory_create_accessible (GObject *obj)                     \
+{                                                                       \
+  GtkWidget *widget = GTK_WIDGET (obj);                                 \
+  AtkObject *accessible;                                                \
+                                                                        \
+  accessible = create_accessible_func (widget);                         \
+                                                                        \
+  return accessible;                                                    \
+}                                                                       \
+                                                                        \
+static void                                                             \
+type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass)  \
+{                                                                       \
+  klass->create_accessible   = prefix ## _factory_create_accessible;    \
+  klass->get_accessible_type = prefix ## _factory_get_accessible_type;  \
+}                                                                       \
+                                                                        \
+GType                                                                   \
+prefix ## _factory_get_type (void)                                      \
+{                                                                       \
+  static GType t = 0;                                                   \
+                                                                        \
+  if (!t)                                                               \
+  {                                                                     \
+    gchar *name;                                                        \
+    static const GTypeInfo info =                                      \
+    {                                                                   \
+      sizeof (AtkObjectFactoryClass),                                   \
+      NULL,                                                             \
+      NULL,                                                             \
+      (GClassInitFunc) prefix ## _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, &info, 0); \
+    g_free (name);                                                      \
+  }                                                                     \
+                                                                        \
+  return t;                                                             \
+}
+
+G_END_DECLS
+
+#endif /* __GTK_ACCESSIBILITY_H__ */
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 01e60db..48768b0 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15167,59 +15167,4 @@ gtk_widget_accessible_new (GtkWidget *widget)
   return accessible;
 }
 
-#define GTK_WIDGET_ACCESSIBLE_FACTORY(type, type_as_function, create_accessible_func)  \
-static GType                                                                    \
-type_as_function ## _factory_get_accessible_type (void)                         \
-{                                                                               \
-  return type;                                                                  \
-}                                                                               \
-                                                                                \
-static AtkObject *                                                              \
-type_as_function ## _factory_create_accessible (GObject *obj)                   \
-{                                                                               \
-  GtkWidget *widget = GTK_WIDGET (obj);                                         \
-  AtkObject *accessible;                                                        \
-                                                                                \
-  accessible = create_accessible_func (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;\
-}                                                                               \
-                                                                                \
-GType                                                                    \
-type_as_function ## _factory_get_type (void)                                    \
-{                                                                               \
-  static GType t = 0;                                                           \
-                                                                                \
-  if (!t)                                                                       \
-  {                                                                             \
-    gchar *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;                                                                     \
-}
-
-GTK_WIDGET_ACCESSIBLE_FACTORY(GTK_TYPE_WIDGET, gtk_widget_accessible, gtk_widget_accessible_new)
+GTK_ACCESSIBLE_FACTORY(GTK_TYPE_WIDGET, gtk_widget_accessible, gtk_widget_accessible_new)
diff --git a/modules/other/gail/gail.c b/modules/other/gail/gail.c
index 28a9996..8248152 100644
--- a/modules/other/gail/gail.c
+++ b/modules/other/gail/gail.c
@@ -856,6 +856,11 @@ gail_set_focus_object (AtkObject *focus_obj,
 extern void gnome_accessibility_module_init     (void);
 extern void gnome_accessibility_module_shutdown (void);
 
+/* This is only temporary until factory registration moves
+ * to GTK+ proper
+ */
+extern GType gtk_widget_accessible_factory_get_type (void);
+
 static int gail_initialized = FALSE;
 
 static void
@@ -878,7 +883,9 @@ gail_accessibility_module_init (void)
   if (a_t_support)
     fprintf (stderr, "GTK Accessibility Module initialized\n");
 
-  GAIL_WIDGET_SET_FACTORY (GTK_TYPE_WIDGET, gail_widget);
+  atk_registry_set_factory_type (atk_get_default_registry (),
+                                 GTK_TYPE_WIDGET,
+                                 gtk_widget_accessible_factory_get_type ());
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CONTAINER, gail_container);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BUTTON, gail_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_LINK_BUTTON, gail_link_button);



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