Updated Basque language
[platform/upstream/atk.git] / atk / atkgobjectaccessible.c
index 377d436..4f3a07c 100644 (file)
@@ -1,5 +1,5 @@
 /* ATK - Accessibility Toolkit
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002, 2003 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
  */
 
 #include <atk/atkgobjectaccessible.h>
+#include <atk/atkregistry.h>
+#include <atk/atkutil.h>
 
+/**
+ * SECTION:atkgobjectaccessible
+ * @Short_description: This object class is derived from AtkObject and
+ *  can be used as a basis implementing accessible objects.
+ * @Title:AtkGObjectAccessible
+ *
+ * This object class is derived from AtkObject. It can be used as a
+ * basis for implementing accessible objects for GObjects which are
+ * not derived from GtkWidget. One example of its use is in providing
+ * an accessible object for GnomeCanvasItem in the GAIL library.
+ */
 static void       atk_gobject_accessible_class_init       (AtkGObjectAccessibleClass   *klass);
 static void       atk_real_gobject_accessible_initialize  (AtkObject         *atk_obj,
                                                            gpointer          data);
@@ -26,7 +39,7 @@ static void       atk_gobject_accessible_dispose          (gpointer          dat
 
 static GQuark quark_accessible_object = 0;
 static GQuark quark_object = 0;
-static AtkObjectClass *parent_class = NULL;
+static gpointer parent_class = NULL;
 
 GType
 atk_gobject_accessible_get_type (void)
@@ -62,7 +75,8 @@ atk_gobject_accessible_get_type (void)
  *
  * Gets the accessible object for the specified @obj.
  *
- * Returns: a #AtkObject which is the accessible object for the @obj
+ * Returns: (transfer none): a #AtkObject which is the accessible object for
+ * the @obj
  **/
 AtkObject*
 atk_gobject_accessible_for_object (GObject *obj)
@@ -85,6 +99,17 @@ atk_gobject_accessible_for_object (GObject *obj)
                                           G_OBJECT_TYPE (obj));
       accessible = atk_object_factory_create_accessible (factory,
                                                          obj);
+      if (!ATK_IS_GOBJECT_ACCESSIBLE (accessible))
+        {
+          /*
+           * The AtkObject which was created was not a AtkGObjectAccessible
+           */
+          g_object_weak_ref (obj,
+                             (GWeakNotify) g_object_unref,
+                             accessible); 
+          if (!quark_accessible_object)
+            quark_accessible_object = g_quark_from_static_string ("accessible-object");
+        }
       g_object_set_qdata (obj, quark_accessible_object, accessible);
     }
   return accessible;
@@ -92,11 +117,12 @@ atk_gobject_accessible_for_object (GObject *obj)
 
 /**
  * atk_gobject_accessible_get_object:
- * @obj: a #AtkObject
+ * @obj: a #AtkGObjectAccessible
  *
  * Gets the GObject for which @obj is the accessible object.
  *
- * Returns: a #GObject which is the object for which @obj is the accessible objedct
+ * Returns: (transfer none): a #GObject which is the object for which @obj is
+ * the accessible object
  **/
 GObject *
 atk_gobject_accessible_get_object (AtkGObjectAccessible *obj)
@@ -125,9 +151,15 @@ atk_real_gobject_accessible_initialize (AtkObject  *atk_obj,
 static void
 atk_gobject_accessible_dispose (gpointer  data)
 {
+  GObject *object;
+
   g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (data));
 
-  g_object_set_qdata (G_OBJECT (data), quark_accessible_object, NULL);
+  object = atk_gobject_accessible_get_object (data);
+  if (object)
+      g_object_set_qdata (object, quark_accessible_object, NULL);
+
+  g_object_set_qdata (G_OBJECT (data), quark_object, NULL);
   atk_object_notify_state_change (ATK_OBJECT (data), ATK_STATE_DEFUNCT,
                                   TRUE); 
   g_object_unref (data);
@@ -140,10 +172,11 @@ atk_gobject_accessible_class_init (AtkGObjectAccessibleClass *klass)
 
   class = ATK_OBJECT_CLASS (klass);
 
-  parent_class = g_type_class_ref (ATK_TYPE_OBJECT);
+  parent_class = g_type_class_peek_parent (klass);
 
   class->initialize = atk_real_gobject_accessible_initialize;
 
-  quark_accessible_object = g_quark_from_static_string ("accessible-object");
+  if (!quark_accessible_object)
+    quark_accessible_object = g_quark_from_static_string ("accessible-object");
   quark_object = g_quark_from_static_string ("object-for-accessible");
 }