2001-11-13 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / libspi / registry.c
index ce196c5..957be22 100644 (file)
 /*
  * Our parent GObject type
  */
-#define PARENT_TYPE LISTENER_TYPE
+#define PARENT_TYPE SPI_LISTENER_TYPE
 
 /*
  * A pointer to our parent object class
  */
-static ListenerClass *registry_parent_class;
+static SpiListenerClass *spi_registry_parent_class;
 
 typedef enum {
   ETYPE_FOCUS,
@@ -80,7 +80,7 @@ typedef struct {
   Accessibility_EventListener listener;
   guint event_type_hash;
   EventTypeCategory event_type_cat;
-} ListenerStruct;
+} SpiListenerStruct;
 
 /* static function prototypes */
 static void _registry_notify_listeners ( GList *listeners,
@@ -95,12 +95,12 @@ static gboolean _device_event_controller_hook (gpointer source);
  * Implemented GObject::finalize
  */
 static void
-registry_object_finalize (GObject *object)
+spi_registry_object_finalize (GObject *object)
 {
-/*        Registry *registry = REGISTRY (object); */
+/*        SpiRegistry *registry = SPI_REGISTRY (object); */
         GObjectClass *object_class = G_OBJECT_GET_CLASS( object);
 
-        printf("registry_object_finalize called\n");
+        printf("spi_registry_object_finalize called\n");
 
         object_class->finalize (object);
 }
@@ -118,7 +118,7 @@ impl_accessibility_registry_register_application (PortableServer_Servant servant
                                                   const Accessibility_Application application,
                                                   CORBA_Environment * ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
 
 #ifdef SPI_DEBUG
   fprintf (stderr, "registering app %p\n", application);
@@ -131,7 +131,7 @@ impl_accessibility_registry_register_application (PortableServer_Servant servant
 
   /*
    * TODO: change the implementation below to a WM-aware one;
-   * e.g. don't add all apps to the Desktop
+   * e.g. don't add all apps to the SpiDesktop
    */
 }
 
@@ -151,7 +151,7 @@ compare_corba_objects (gconstpointer p1, gconstpointer p2)
 }
 
 static void
-register_with_toolkits (Registry *registry_bonobo_object, EventTypeStruct *etype, CORBA_Environment *ev)
+register_with_toolkits (SpiRegistry *spi_registry_bonobo_object, EventTypeStruct *etype, CORBA_Environment *ev)
 {
   gint n_desktops;
   gint n_apps;
@@ -159,7 +159,7 @@ register_with_toolkits (Registry *registry_bonobo_object, EventTypeStruct *etype
   Accessibility_Desktop desktop;
   Accessibility_Application app;
   Accessibility_Registry registry;
-  registry  = BONOBO_OBJREF (registry_bonobo_object);
+  registry  = BONOBO_OBJREF (spi_registry_bonobo_object);
 
   /* for each app in each desktop, call ...Application_registerToolkitEventListener */
 
@@ -186,14 +186,14 @@ register_with_toolkits (Registry *registry_bonobo_object, EventTypeStruct *etype
 static gint
 compare_listener_hash (gconstpointer p1, gconstpointer p2)
 {
-  return (((ListenerStruct *)p2)->event_type_hash - ((ListenerStruct *)p1)->event_type_hash);
+  return (((SpiListenerStruct *)p2)->event_type_hash - ((SpiListenerStruct *)p1)->event_type_hash);
 }
 
 static gint
 compare_listener_corbaref (gconstpointer p1, gconstpointer p2)
 {
-  return compare_corba_objects (((ListenerStruct *)p2)->listener,
-                                ((ListenerStruct *)p1)->listener);
+  return compare_corba_objects (((SpiListenerStruct *)p2)->listener,
+                                ((SpiListenerStruct *)p1)->listener);
 }
 
 static void
@@ -270,7 +270,7 @@ impl_accessibility_registry_deregister_application (PortableServer_Servant serva
                                                     const Accessibility_Application application,
                                                     CORBA_Environment * ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
   GList *list = g_list_find_custom (registry->desktop->applications, &application, compare_corba_objects);
 
 #ifdef SPI_DEBUG
@@ -306,8 +306,8 @@ impl_accessibility_registry_register_global_event_listener (
                                              const CORBA_char *event_name,
                                              CORBA_Environment      *ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
-  ListenerStruct *ls = g_malloc (sizeof (ListenerStruct));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
+  SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
   EventTypeStruct etype;
   gboolean is_toolkit_specific = TRUE;
 
@@ -350,8 +350,8 @@ impl_accessibility_registry_deregister_global_event_listener_all (
                                                     Accessibility_EventListener listener,
                                                     CORBA_Environment      *ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
-  ListenerStruct *ls = g_malloc (sizeof (ListenerStruct));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
+  SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
   GList *list;
   ls->listener = listener;  
   list = g_list_find_custom (registry->object_listeners, ls,
@@ -387,8 +387,8 @@ impl_accessibility_registry_deregister_global_event_listener (
                                                     const CORBA_char * event_name,
                                                     CORBA_Environment      *ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
-  ListenerStruct ls;
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
+  SpiListenerStruct ls;
   EventTypeStruct etype;
   GList *list;
   GList **listeners;
@@ -454,7 +454,7 @@ impl_accessibility_registry_get_desktop (PortableServer_Servant servant,
                                          const CORBA_short n,
                                          CORBA_Environment * ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
 
   /* TODO: implement support for multiple virtual desktops */
   if (n == 0)
@@ -488,9 +488,9 @@ static Accessibility_DeviceEventController
 impl_accessibility_registry_get_device_event_controller (PortableServer_Servant servant,
                                                          CORBA_Environment * ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
   if (!registry->device_event_controller)
-    registry->device_event_controller = g_object_new (DEVICE_EVENT_CONTROLLER_TYPE, NULL);
+    registry->device_event_controller = g_object_new (SPI_DEVICE_EVENT_CONTROLLER_TYPE, NULL);
   return CORBA_Object_duplicate (BONOBO_OBJREF (registry->device_event_controller), ev);
 }
 
@@ -499,7 +499,7 @@ impl_registry_notify_event (PortableServer_Servant servant,
                             const Accessibility_Event *e,
                             CORBA_Environment *ev)
 {
-  Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
+  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
   EventTypeStruct etype;
 
   parse_event_type (&etype, e->type);
@@ -537,7 +537,7 @@ _registry_notify_listeners ( GList *listeners,
 {
   int n;
   int len;
-  ListenerStruct *ls;
+  SpiListenerStruct *ls;
   EventTypeStruct etype;
   guint minor_hash;
   parse_event_type (&etype, e->type);
@@ -546,8 +546,8 @@ _registry_notify_listeners ( GList *listeners,
 
   for (n=0; n<len; ++n)
     {
-      ls =  (ListenerStruct *) g_list_nth_data (listeners, n);
-#ifdef SPI_LISTENER_DEBUG
+      ls =  (SpiListenerStruct *) g_list_nth_data (listeners, n);
+#ifdef SPI_SPI_LISTENER_DEBUG
       fprintf(stderr, "event hashes: %lx %lx %lx\n", ls->event_type_hash, etype.hash, minor_hash);
       fprintf(stderr, "event name: %s\n", etype.event_name);
 #endif
@@ -574,22 +574,22 @@ _registry_notify_listeners ( GList *listeners,
 
 static gboolean _device_event_controller_hook (gpointer p)
 {
-    Registry *registry = (Registry *)p;
-    DeviceEventController *controller = registry->device_event_controller;
+    SpiRegistry *registry = (SpiRegistry *)p;
+    SpiDeviceEventController *controller = registry->device_event_controller;
     if (controller)
-       device_event_controller_check_key_event (controller);
+       spi_device_event_controller_check_key_event (controller);
     return TRUE;
 }
 
 static void
-registry_class_init (RegistryClass *klass)
+spi_registry_class_init (SpiRegistryClass *klass)
 {
         GObjectClass * object_class = (GObjectClass *) klass;
         POA_Accessibility_Registry__epv *epv = &klass->epv;
 
-        registry_parent_class = g_type_class_ref (LISTENER_TYPE);
+        spi_registry_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
 
-        object_class->finalize = registry_object_finalize;
+        object_class->finalize = spi_registry_object_finalize;
 
         epv->registerApplication = impl_accessibility_registry_register_application;
         epv->deregisterApplication = impl_accessibility_registry_deregister_application;
@@ -601,37 +601,37 @@ registry_class_init (RegistryClass *klass)
         epv->getDesktop = impl_accessibility_registry_get_desktop;
         epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
 
-        ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
+        ((SpiListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
 }
 
 static void
-registry_init (Registry *registry)
+spi_registry_init (SpiRegistry *registry)
 {
   registry->object_listeners = NULL;
   registry->window_listeners = NULL;
   registry->toolkit_listeners = NULL;
   registry->applications = NULL;
-  registry->desktop = desktop_new();
+  registry->desktop = spi_desktop_new();
   registry->device_event_controller = NULL;
   registry->kbd_event_hook = _device_event_controller_hook;
 }
 
 GType
-registry_get_type (void)
+spi_registry_get_type (void)
 {
         static GType type = 0;
 
         if (!type) {
                 static const GTypeInfo tinfo = {
-                        sizeof (RegistryClass),
+                        sizeof (SpiRegistryClass),
                         (GBaseInitFunc) NULL,
                         (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) registry_class_init,
+                        (GClassInitFunc) spi_registry_class_init,
                         (GClassFinalizeFunc) NULL,
                         NULL, /* class data */
-                        sizeof (Registry),
+                        sizeof (SpiRegistry),
                         0, /* n preallocs */
-                        (GInstanceInitFunc) registry_init,
+                        (GInstanceInitFunc) spi_registry_init,
                         NULL /* value table */
                 };
                 /*
@@ -644,18 +644,18 @@ registry_get_type (void)
                         PARENT_TYPE,
                         POA_Accessibility_Registry__init,
                         NULL,
-                        G_STRUCT_OFFSET (RegistryClass, epv),
+                        G_STRUCT_OFFSET (SpiRegistryClass, epv),
                         &tinfo,
-                        "Registry");
+                        "SpiRegistry");
         }
 
         return type;
 }
 
-Registry *
-registry_new (void)
+SpiRegistry *
+spi_registry_new (void)
 {
-    Registry *retval =
-               REGISTRY (g_object_new (registry_get_type (), NULL));
+    SpiRegistry *retval =
+               SPI_REGISTRY (g_object_new (spi_registry_get_type (), NULL));
     return retval;
 }