summaryrefslogtreecommitdiff
path: root/atk/atkgobjectaccessible.c
diff options
context:
space:
mode:
authorPadraig O'Briain <padraigo@src.gnome.org>2001-12-19 12:34:25 +0000
committerPadraig O'Briain <padraigo@src.gnome.org>2001-12-19 12:34:25 +0000
commit273d1a64b904bc019c3c8c5cd4e7ad44210f795d (patch)
tree3fd8c9dc0d9a8e797ef90307079e392407725c65 /atk/atkgobjectaccessible.c
parentfc73f6f4ccdd5cbf4c304cb105c711664d918f70 (diff)
downloadatk-273d1a64b904bc019c3c8c5cd4e7ad44210f795d.tar.gz
Add new files atk/atkgobjectaccessible.c atk/atkgobjectaccessible.h
docs/tmpl/atkgobjectaccessible.sgml * atk/Makefile.am atk/atk.h: Add references to new files * atk/atkobject.c atk/atkobject.h docs/tmpl/atkobject.sgml: Add new function atk_object_initialize * atk/atkobjectfactory.c atk/atkobjectfactory.h docs/tmpl/atkobjectfactory.sgml: Add new function atk_object_factory_get_accessible_type * docs/atk-sections.txt: Add new functions. Add functions in atk-unused.txt
Diffstat (limited to 'atk/atkgobjectaccessible.c')
-rw-r--r--atk/atkgobjectaccessible.c149
1 files changed, 149 insertions, 0 deletions
diff --git a/atk/atkgobjectaccessible.c b/atk/atkgobjectaccessible.c
new file mode 100644
index 0000000..377d436
--- /dev/null
+++ b/atk/atkgobjectaccessible.c
@@ -0,0 +1,149 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems 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.
+ */
+
+#include <atk/atkgobjectaccessible.h>
+
+static void atk_gobject_accessible_class_init (AtkGObjectAccessibleClass *klass);
+static void atk_real_gobject_accessible_initialize (AtkObject *atk_obj,
+ gpointer data);
+static void atk_gobject_accessible_dispose (gpointer data);
+
+static GQuark quark_accessible_object = 0;
+static GQuark quark_object = 0;
+static AtkObjectClass *parent_class = NULL;
+
+GType
+atk_gobject_accessible_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ {
+ static const GTypeInfo tinfo =
+ {
+ sizeof (AtkGObjectAccessibleClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) atk_gobject_accessible_class_init,
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (AtkGObjectAccessible),
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ type = g_type_register_static (ATK_TYPE_OBJECT,
+ "AtkGObjectAccessible", &tinfo, 0);
+ }
+
+ return type;
+}
+
+/**
+ * atk_gobject_accessible_for_object:
+ * @obj: a #GObject
+ *
+ * Gets the accessible object for the specified @obj.
+ *
+ * Returns: a #AtkObject which is the accessible object for the @obj
+ **/
+AtkObject*
+atk_gobject_accessible_for_object (GObject *obj)
+{
+ AtkObject* accessible;
+
+ g_return_val_if_fail (G_IS_OBJECT (obj), NULL);
+ /* See if we have a cached accessible for this object */
+
+ accessible = g_object_get_qdata (obj,
+ quark_accessible_object);
+
+ if (!accessible)
+ {
+ AtkObjectFactory *factory;
+ AtkRegistry *default_registry;
+
+ default_registry = atk_get_default_registry ();
+ factory = atk_registry_get_factory (default_registry,
+ G_OBJECT_TYPE (obj));
+ accessible = atk_object_factory_create_accessible (factory,
+ obj);
+ g_object_set_qdata (obj, quark_accessible_object, accessible);
+ }
+ return accessible;
+}
+
+/**
+ * atk_gobject_accessible_get_object:
+ * @obj: a #AtkObject
+ *
+ * Gets the GObject for which @obj is the accessible object.
+ *
+ * Returns: a #GObject which is the object for which @obj is the accessible objedct
+ **/
+GObject *
+atk_gobject_accessible_get_object (AtkGObjectAccessible *obj)
+{
+ g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (obj), NULL);
+
+ return g_object_get_qdata (G_OBJECT (obj), quark_object);
+}
+
+static void
+atk_real_gobject_accessible_initialize (AtkObject *atk_obj,
+ gpointer data)
+{
+ AtkGObjectAccessible *atk_gobj;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (atk_obj);
+
+ g_object_set_qdata (G_OBJECT (atk_gobj), quark_object, data);
+ atk_obj->layer = ATK_LAYER_WIDGET;
+
+ g_object_weak_ref (data,
+ (GWeakNotify) atk_gobject_accessible_dispose,
+ atk_gobj);
+}
+
+static void
+atk_gobject_accessible_dispose (gpointer data)
+{
+ g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (data));
+
+ g_object_set_qdata (G_OBJECT (data), quark_accessible_object, NULL);
+ atk_object_notify_state_change (ATK_OBJECT (data), ATK_STATE_DEFUNCT,
+ TRUE);
+ g_object_unref (data);
+}
+
+static void
+atk_gobject_accessible_class_init (AtkGObjectAccessibleClass *klass)
+{
+ AtkObjectClass *class;
+
+ class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_ref (ATK_TYPE_OBJECT);
+
+ class->initialize = atk_real_gobject_accessible_initialize;
+
+ quark_accessible_object = g_quark_from_static_string ("accessible-object");
+ quark_object = g_quark_from_static_string ("object-for-accessible");
+}