[gtk+/a11y] API: Add gtk_widget_class_set_accessible_type()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/a11y] API: Add gtk_widget_class_set_accessible_type()
- Date: Sun, 19 Jun 2011 04:32:08 +0000 (UTC)
commit 99af8e0e95e7b7eb33c5d125b18b1ef1910bca5b
Author: Benjamin Otte <otte redhat com>
Date: Sat Jun 18 09:51:18 2011 +0200
API: Add gtk_widget_class_set_accessible_type()
The function is supposed to bypass the ATK registry. For 2 reasons:
1) We get rid of a lot of boilerplate madness.
2) The registry allows creating multiple accessibles per widget and we
don't.
The old code for registries is still there.
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkwidget.c | 54 +++++++++++++++++++++++++++++----
gtk/gtkwidget.h | 2 +
4 files changed, 51 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index f0654c3..0ec7c15 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5050,6 +5050,7 @@ gtk_widget_style_get
gtk_widget_style_get_property
gtk_widget_style_get_valist
gtk_widget_style_attach
+gtk_widget_class_set_accessible_type
gtk_widget_get_accessible
gtk_widget_child_focus
gtk_widget_child_notify
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index cde5ce5..5bac657 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -3462,6 +3462,7 @@ gtk_widget_class_install_style_property
gtk_widget_class_install_style_property_parser
gtk_widget_class_list_style_properties
gtk_widget_class_path
+gtk_widget_class_set_accessible_type
gtk_widget_compute_expand
gtk_widget_create_pango_context
gtk_widget_create_pango_layout
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 535a5a9..5c3ca8b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -409,7 +409,7 @@ struct _GtkWidgetPrivate
struct _GtkWidgetClassPrivate
{
- int dummy;
+ GType accessible_type;
};
enum {
@@ -939,6 +939,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->show_help = gtk_widget_real_show_help;
/* Accessibility support */
+ klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE;
klass->get_accessible = gtk_widget_real_get_accessible;
klass->adjust_size_request = gtk_widget_real_adjust_size_request;
@@ -11918,6 +11919,33 @@ G_DEFINE_BOXED_TYPE (GtkRequisition, gtk_requisition,
gtk_requisition_free)
/**
+ * gtk_widget_class_set_accessible_type:
+ * @widget_class: class to set the accessible type for
+ * @type: The object type that implements the accessible for @widget_class
+ *
+ * Sets the type to be used for creating accessibles for widgets of
+ * @widget_class. The given @type must be a subtype of the type used for
+ * accessibles of the parent class.
+ *
+ * This function should only be called from class init functions of widgets.
+ *
+ * Since: 3.2
+ **/
+void
+gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class,
+ GType type)
+{
+ GtkWidgetClassPrivate *priv;
+
+ g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
+ g_return_if_fail (g_type_is_a (type, widget_class->priv->accessible_type));
+
+ priv = widget_class->priv;
+
+ priv->accessible_type = type;
+}
+
+/**
* gtk_widget_get_accessible:
* @widget: a #GtkWidget
*
@@ -11960,15 +11988,27 @@ gtk_widget_real_get_accessible (GtkWidget *widget)
quark_accessible_object);
if (!accessible)
{
+ GtkWidgetClass *widget_class;
AtkObjectFactory *factory;
AtkRegistry *default_registry;
- default_registry = atk_get_default_registry ();
- factory = atk_registry_get_factory (default_registry,
- G_TYPE_FROM_INSTANCE (widget));
- accessible =
- atk_object_factory_create_accessible (factory,
- G_OBJECT (widget));
+ widget_class = GTK_WIDGET_GET_CLASS (widget);
+
+ if (widget_class->priv->accessible_type == GTK_TYPE_ACCESSIBLE)
+ {
+ default_registry = atk_get_default_registry ();
+ factory = atk_registry_get_factory (default_registry,
+ G_TYPE_FROM_INSTANCE (widget));
+ accessible =
+ atk_object_factory_create_accessible (factory,
+ G_OBJECT (widget));
+ }
+ else
+ {
+ accessible = g_object_new (widget_class->priv->accessible_type, NULL);
+ atk_object_initialize (accessible, widget);
+ }
+
g_object_set_qdata (G_OBJECT (widget),
quark_accessible_object,
accessible);
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 09d8a8e..8aa1e1f 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -722,6 +722,8 @@ void gtk_widget_set_support_multidevice (GtkWidget *widget,
gboolean support_multidevice);
/* Accessibility support */
+void gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class,
+ GType type);
AtkObject* gtk_widget_get_accessible (GtkWidget *widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]