2002-03-27 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / libspi / base.c
index a7f4097..7c602d6 100644 (file)
@@ -1,50 +1,86 @@
-#include <libspi/base.h>
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Ximian 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.
+ */
+
+/* base.c: the base object managing an AtkObject proxy */
+
+#include <config.h>
+#include <stdio.h>
+#include <libspi/libspi.h>
+
+/* Our parent Gtk object type  */
+#define PARENT_TYPE BONOBO_TYPE_OBJECT
 
 /* A pointer to our parent object class */
 static GObjectClass *spi_base_parent_class;
 
+/*
+ * Implemented GObject::dispose
+ */
 static void
-spi_base_dispose (GObject *object)
+spi_base_object_dispose (GObject *gobject)
 {
-       SpiBase *base = SPI_BASE (object);
+  SpiBase *object = SPI_BASE (gobject);
 
-       if (base->atko) {
-               g_object_unref (base->atko);
-               base->atko = NULL;
-       }
+  if (object->gobj)
+    {
+      g_assert (G_IS_OBJECT (object->gobj));
+      g_object_unref (object->gobj);
+      object->gobj = NULL;
+    }
 
-       spi_base_parent_class->dispose (object);
+  spi_base_parent_class->dispose (gobject);
 }
 
 static void
-spi_base_class_init (GObjectClass *klass)
+spi_base_class_init (SpiBaseClass *klass)
 {
-       spi_base_parent_class = g_type_klass_peek_parent (klass);
+        GObjectClass * object_class = (GObjectClass *) klass;
+
+        spi_base_parent_class = g_type_class_peek_parent (klass);
 
-       klass->dispose = spi_base_dispose;
+        object_class->dispose = spi_base_object_dispose;
 }
 
 static void
-spi_base_init (SpiBase *base)
+spi_base_init (SpiBase *object)
 {
 }
 
-BONOBO_TYPE_FUNC (SpiBase, BONOBO_TYPE_OBJECT, spi_base);
+BONOBO_TYPE_FUNC (SpiBase, PARENT_TYPE, spi_base);
 
-gpointer
-spi_base_construct (SpiBase   *base,
-                   AtkObject *o)
+void
+spi_base_construct (SpiBase *object, GObject *gobject)
 {
-       g_return_val_if_fail (ATK_IS_OBJECT (o), NULL);
-       g_return_val_if_fail (SPI_IS_BASE (base), NULL);
-
-       base->atko = g_object_ref (o);
+  object->gobj = g_object_ref (gobject);
 }
 
-AtkObject *
-spi_base_get_atk_object (SpiBase *base)
+void
+spi_base_construct_default (SpiBase *object)
 {
-       g_return_val_if_fail (SPI_IS_BASE (base), NULL);
+  object->gobj = g_object_new (G_TYPE_OBJECT, NULL);
+}
 
-       return base->atko;
+GObject *
+spi_base_get_gobject (SpiBase *object)
+{
+  return object->gobj;
 }