Started fixing IDL docs.
[platform/core/uifw/at-spi2-atk.git] / libspi / application.c
index 2a1fcde..e7d1a66 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-/*
- * application.c: implements SpiApplication.idl
- *
- */
+/* application.c: implements SpiApplication.idl */
+
 #include <string.h>
 #include <config.h>
-#include <bonobo/Bonobo.h>
 #include <atk/atkutil.h>
-
-/*
- * This pulls the CORBA definitions for the "Accessibility::Accessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition for the BonoboObject (GObject Type)
- */
-#include "application.h"
+#include <libspi/application.h>
 
 /*
  * Our parent Gtk object type
@@ -57,9 +45,23 @@ static void notify_listeners (GList *listeners,
                              Accessibility_Event *e,
                              CORBA_Environment *ev);
 
-static char* lookup_toolkit_event_for_name (char *generic_name);
+static char *reverse_lookup_name_for_toolkit_event (char *toolkit_name);
 
-static char* reverse_lookup_name_for_toolkit_event (char *toolkit_name);
+static const char *
+lookup_toolkit_event_for_name (const char *generic_name)
+{
+    char *toolkit_specific_name;
+    SpiApplicationClass *klass = g_type_class_peek (SPI_APPLICATION_TYPE);
+#ifdef SPI_DEBUG
+    fprintf (stderr, "looking for %s in hash table.\n", generic_name);
+#endif
+    toolkit_specific_name =
+           (char *) g_hash_table_lookup (klass->toolkit_event_names, generic_name);
+#ifdef SPI_DEBUG
+    fprintf (stderr, "generic event %s converted to %s\n", generic_name, toolkit_specific_name);
+#endif
+    return toolkit_specific_name;
+}
 
 /*
  * Implemented GObject::finalize
@@ -75,30 +77,23 @@ static CORBA_string
 impl_accessibility_application_get_toolkit_name (PortableServer_Servant servant,
                                                  CORBA_Environment *ev)
 {
-  CORBA_char *retval;
-  SpiApplication *application = SPI_APPLICATION (bonobo_object_from_servant (servant));
-  retval = CORBA_string_dup (atk_get_toolkit_name ());
-  return retval;
+       return CORBA_string_dup (atk_get_toolkit_name ());
 }
 
 static CORBA_string
 impl_accessibility_application_get_version (PortableServer_Servant servant,
                                             CORBA_Environment *ev)
 {
-  CORBA_char *retval;
-  SpiApplication *application = SPI_APPLICATION (bonobo_object_from_servant (servant));
-  retval = CORBA_string_dup (atk_get_toolkit_version ());
-  return retval;
+       return CORBA_string_dup (atk_get_toolkit_version ());
 }
 
 static CORBA_long
 impl_accessibility_application_get_id (PortableServer_Servant servant,
                                        CORBA_Environment *ev)
 {
-  CORBA_long retval;
-  SpiApplication *application = SPI_APPLICATION (bonobo_object_from_servant (servant));
-  retval = (CORBA_long) application->id;
-  return retval;
+       SpiApplication *application = SPI_APPLICATION (
+               bonobo_object_from_servant (servant));
+       return application->id;
 }
 
 static void
@@ -106,8 +101,9 @@ impl_accessibility_application_set_id (PortableServer_Servant servant,
                                        const CORBA_long id,
                                        CORBA_Environment *ev)
 {
-  SpiApplication *application = SPI_APPLICATION (bonobo_object_from_servant (servant));
-  application->id = id;
+       SpiApplication *application = SPI_APPLICATION (
+               bonobo_object_from_servant (servant));
+       application->id = id;
 }
 
 #define APP_STATIC_BUFF_SZ 64
@@ -124,7 +120,7 @@ spi_application_object_event_listener (GSignalInvocationHint *signal_hint,
   SpiAccessible *source;
   CORBA_Environment ev;
   GSignalQuery signal_query;
-  gchar *name;
+  const gchar *name;
   char sbuf[APP_STATIC_BUFF_SZ];
   char *generic_name;
   
@@ -151,6 +147,7 @@ spi_application_object_event_listener (GSignalInvocationHint *signal_hint,
   }
   else
   {
+    aobject = NULL;
     g_error("received event from non-AtkImplementor");
   }
 
@@ -190,7 +187,7 @@ spi_application_toolkit_event_listener (GSignalInvocationHint *signal_hint,
   SpiAccessible *source;
   CORBA_Environment ev;
   GSignalQuery signal_query;
-  gchar *name;
+  const char *name;
   char sbuf[APP_STATIC_BUFF_SZ];
 
   g_signal_query (signal_hint->signal_id, &signal_query);
@@ -211,7 +208,7 @@ spi_application_toolkit_event_listener (GSignalInvocationHint *signal_hint,
       e->detail1 = 0;
       e->detail2 = 0;
       if (the_app) notify_listeners (the_app->toolkit_listeners, e, &ev);
-      bonobo_object_unref (source);
+      bonobo_object_unref (BONOBO_OBJECT (source));
       g_object_unref (G_OBJECT (aobject));
     }
   return TRUE;
@@ -225,7 +222,7 @@ impl_accessibility_application_register_toolkit_event_listener (PortableServer_S
 {
   guint spi_listener_id;
   spi_listener_id =
-     atk_add_global_event_listener (spi_application_toolkit_event_listener, event_name);
+     atk_add_global_event_listener (spi_application_toolkit_event_listener, (char *) event_name);
   the_app->toolkit_listeners = g_list_append (the_app->toolkit_listeners,
                                              CORBA_Object_duplicate (listener, ev));
 #ifdef SPI_DEBUG
@@ -241,8 +238,9 @@ impl_accessibility_application_register_object_event_listener (PortableServer_Se
                                                               const CORBA_char *event_name,
                                                               CORBA_Environment *ev)
 {
-  guint spi_listener_id;
-  char *toolkit_specific_event_name = lookup_toolkit_event_for_name (event_name);
+  guint spi_listener_id = 0;
+  const char *toolkit_specific_event_name =
+         lookup_toolkit_event_for_name (event_name);
   if (toolkit_specific_event_name)
   {
     spi_listener_id =
@@ -278,22 +276,6 @@ notify_listeners (GList *listeners, Accessibility_Event *e, CORBA_Environment *e
 }
 
 static char *
-lookup_toolkit_event_for_name (char *generic_name)
-{
-    char *toolkit_specific_name;
-    SpiApplicationClass *klass = g_type_class_peek (SPI_APPLICATION_TYPE);
-#ifdef SPI_DEBUG
-    fprintf (stderr, "looking for %s in hash table.\n", generic_name);
-#endif
-    toolkit_specific_name =
-           (char *) g_hash_table_lookup (klass->toolkit_event_names, generic_name);
-#ifdef SPI_DEBUG
-    fprintf (stderr, "generic event %s converted to %s\n", generic_name, toolkit_specific_name);
-#endif
-    return toolkit_specific_name;
-}
-
-static char *
 reverse_lookup_name_for_toolkit_event (char *toolkit_specific_name)
 {
     char *generic_name;
@@ -346,52 +328,20 @@ spi_application_class_init (SpiApplicationClass *klass)
 static void
 spi_application_init (SpiApplication  *application)
 {
-  SPI_ACCESSIBLE (application)->atko = g_object_new (atk_object_get_type(), NULL);
-  application->toolkit_listeners = (GList *) NULL;
+  application->parent.atko = g_object_new (ATK_TYPE_OBJECT, NULL);
+  application->toolkit_listeners = NULL;
   the_app = application;
 }
 
-GType
-spi_application_get_type (void)
-{
-        static GType type = 0;
-
-        if (!type) {
-                static const GTypeInfo tinfo = {
-                        sizeof (SpiApplicationClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) spi_application_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL, /* class data */
-                        sizeof (SpiApplication),
-                        0, /* n preallocs */
-                        (GInstanceInitFunc) spi_application_init,
-                        NULL /* value table */
-                };
-                /*
-                 * Bonobo_type_unique auto-generates a load of
-                 * CORBA structures for us. All derived types must
-                 * use bonobo_type_unique.
-                 */
-                type = bonobo_type_unique (
-                        PARENT_TYPE,
-                        POA_Accessibility_Application__init,
-                        NULL,
-                        G_STRUCT_OFFSET (SpiApplicationClass, epv),
-                        &tinfo,
-                        "SpiApplication");
-        }
-
-        return type;
-}
+BONOBO_TYPE_FUNC_FULL (SpiApplication,
+                      Accessibility_Application,
+                      PARENT_TYPE, spi_application);
 
 SpiApplication *
 spi_application_new (AtkObject *app_root)
 {
-    SpiApplication *retval =
-               SPI_APPLICATION (g_object_new (spi_application_get_type (), NULL));
-    SPI_ACCESSIBLE (retval)->atko = app_root;
+    SpiApplication *retval = g_object_new (SPI_APPLICATION_TYPE, NULL);
+    retval->parent.atko = app_root;
     g_object_ref (G_OBJECT (app_root));
     return retval;
 }