[gtk+/drop-gail: 2/24] Add a factory for GtkWidgetAccessible



commit adf7869afcece787d9376e0f7c355c800ddf51a5
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 21 01:26:48 2011 -0500

    Add a factory for GtkWidgetAccessible

 gtk/gtkwidget.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b38f072..01e60db 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15155,3 +15155,71 @@ atk_component_interface_init (AtkComponentIface *iface)
   iface->get_layer = gtk_widget_accessible_get_layer;
   iface->grab_focus = gtk_widget_accessible_grab_focus;
 }
+
+static AtkObject *
+gtk_widget_accessible_new (GtkWidget *widget)
+{
+  AtkObject *accessible;
+
+  accessible = g_object_new (GTK_TYPE_WIDGET_ACCESSIBLE, NULL);
+  atk_object_initialize (accessible, 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)



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