Improvements/fixes to app deregistration (but some still are pending).
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sun, 30 Sep 2001 13:53:57 +0000 (13:53 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sun, 30 Sep 2001 13:53:57 +0000 (13:53 +0000)
Started adding support for StateSet and RelationSet on Accessibles.
Added deregistration on app exit to the atk bridge.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@66 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
at-bridge/bridge.c
atk-bridge/bridge.c
libspi/accessible.c
libspi/desktop.c
libspi/registry.c
registryd/desktop.c
registryd/registry.c
test/simple-at.c
util/magnifier.c

index b1580f9..683da86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+<2001-09-30  Bill Haneman <bill.haneman@sun.com>
+
+       * libspi/accessible.c:
+               Stubbed-in the implementations for
+                       Accessibility_Accessible_getState and
+                       Accessibility_Accessible_getRelationSet.
+       * libspi/registry.c:
+               Improved de-registration process and fixed some bugs, 
+                       deregistration should work correctly
+                       once the compare_object_func()'s CORBA_Object_hash
+                       usage is fixed (currently still broken).
+               (Probably the event listener registration still needs
+                       fixing.)
+       * libspi/desktop.c:
+               Added initialization of applications list (to NULL).
+       * util/magnifier.c:
+               Reduced speech compression from 0.5 to 0.7, for demo.
+               Changed call to gdk_window_set_decorations()
+                       to gtk_window_set_decorated().
+       * at-bridge/bridge.c:
+               Bridge now deregisters when app exits, via
+                       registration of a cleanup function
+                       with the g_atexit() call.
+                       Required making 'app' static, renamed 'this_app'.
+               Fixed broken use of bonobo_init, passing argv wrongly.
+
 <2001-09-27  Bill Haneman <bill.haneman@sun.com>
 
        * util:
 <2001-09-27  Bill Haneman <bill.haneman@sun.com>
 
        * util:
index 58fc363..d4e1345 100644 (file)
@@ -39,9 +39,11 @@ struct _ArgStruct {
 
 static CORBA_Environment ev;
 static Accessibility_Registry registry;
 
 static CORBA_Environment ev;
 static Accessibility_Registry registry;
+static Application *this_app;
 
 static gboolean bridge_register_app (gpointer p);
 static void bridge_focus_tracker (AtkObject *object);
 
 static gboolean bridge_register_app (gpointer p);
 static void bridge_focus_tracker (AtkObject *object);
+static void bridge_exit_func(void);
 
 int
 gtk_module_init(gint *argc, gchar **argv[])
 
 int
 gtk_module_init(gint *argc, gchar **argv[])
@@ -50,6 +52,7 @@ gtk_module_init(gint *argc, gchar **argv[])
   args->c = *argc;
   args->v = *argv;
   g_idle_add (bridge_register_app, args);
   args->c = *argc;
   args->v = *argv;
   g_idle_add (bridge_register_app, args);
+  g_atexit (bridge_exit_func);
 }
 
 static gboolean
 }
 
 static gboolean
@@ -60,17 +63,15 @@ bridge_register_app (gpointer gp)
   char *obj_id;
   ArgStruct *args = (ArgStruct *)gp;
 
   char *obj_id;
   ArgStruct *args = (ArgStruct *)gp;
 
-  Application *app;
-
   CORBA_exception_init(&ev);
 
   CORBA_exception_init(&ev);
 
-  if (!bonobo_init (&(args->c), &args->v))
+  if (!bonobo_init (&(args->c), args->v))
     {
       g_error ("Could not initialize Bonobo");
     }
 
   /* Create the accesssible application server object */
     {
       g_error ("Could not initialize Bonobo");
     }
 
   /* Create the accesssible application server object */
-  app = application_new(atk_get_root ());
+  this_app = application_new(atk_get_root ());
 
   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
 
 
   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
 
@@ -98,11 +99,21 @@ bridge_register_app (gpointer gp)
   atk_add_focus_tracker (bridge_focus_tracker);
 
   Accessibility_Registry_registerApplication (registry,
   atk_add_focus_tracker (bridge_focus_tracker);
 
   Accessibility_Registry_registerApplication (registry,
-                                              bonobo_object_corba_objref (bonobo_object (app)),
+                                              bonobo_object_corba_objref (bonobo_object (this_app)),
                                               &ev);
   return FALSE;
 }
 
                                               &ev);
   return FALSE;
 }
 
+static void bridge_exit_func()
+{
+  fprintf (stderr, "exiting bridge\n");
+  Accessibility_Registry_deregisterApplication (registry,
+                                               bonobo_object_corba_objref (
+                                                       bonobo_object (this_app)),
+                                               &ev);
+  fprintf (stderr, "bridge exit func complete.\n");
+}
+
 static void bridge_focus_tracker (AtkObject *object)
 {
   Accessibility_Event *e = Accessibility_Event__alloc();
 static void bridge_focus_tracker (AtkObject *object)
 {
   Accessibility_Event *e = Accessibility_Event__alloc();
index 58fc363..d4e1345 100644 (file)
@@ -39,9 +39,11 @@ struct _ArgStruct {
 
 static CORBA_Environment ev;
 static Accessibility_Registry registry;
 
 static CORBA_Environment ev;
 static Accessibility_Registry registry;
+static Application *this_app;
 
 static gboolean bridge_register_app (gpointer p);
 static void bridge_focus_tracker (AtkObject *object);
 
 static gboolean bridge_register_app (gpointer p);
 static void bridge_focus_tracker (AtkObject *object);
+static void bridge_exit_func(void);
 
 int
 gtk_module_init(gint *argc, gchar **argv[])
 
 int
 gtk_module_init(gint *argc, gchar **argv[])
@@ -50,6 +52,7 @@ gtk_module_init(gint *argc, gchar **argv[])
   args->c = *argc;
   args->v = *argv;
   g_idle_add (bridge_register_app, args);
   args->c = *argc;
   args->v = *argv;
   g_idle_add (bridge_register_app, args);
+  g_atexit (bridge_exit_func);
 }
 
 static gboolean
 }
 
 static gboolean
@@ -60,17 +63,15 @@ bridge_register_app (gpointer gp)
   char *obj_id;
   ArgStruct *args = (ArgStruct *)gp;
 
   char *obj_id;
   ArgStruct *args = (ArgStruct *)gp;
 
-  Application *app;
-
   CORBA_exception_init(&ev);
 
   CORBA_exception_init(&ev);
 
-  if (!bonobo_init (&(args->c), &args->v))
+  if (!bonobo_init (&(args->c), args->v))
     {
       g_error ("Could not initialize Bonobo");
     }
 
   /* Create the accesssible application server object */
     {
       g_error ("Could not initialize Bonobo");
     }
 
   /* Create the accesssible application server object */
-  app = application_new(atk_get_root ());
+  this_app = application_new(atk_get_root ());
 
   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
 
 
   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
 
@@ -98,11 +99,21 @@ bridge_register_app (gpointer gp)
   atk_add_focus_tracker (bridge_focus_tracker);
 
   Accessibility_Registry_registerApplication (registry,
   atk_add_focus_tracker (bridge_focus_tracker);
 
   Accessibility_Registry_registerApplication (registry,
-                                              bonobo_object_corba_objref (bonobo_object (app)),
+                                              bonobo_object_corba_objref (bonobo_object (this_app)),
                                               &ev);
   return FALSE;
 }
 
                                               &ev);
   return FALSE;
 }
 
+static void bridge_exit_func()
+{
+  fprintf (stderr, "exiting bridge\n");
+  Accessibility_Registry_deregisterApplication (registry,
+                                               bonobo_object_corba_objref (
+                                                       bonobo_object (this_app)),
+                                               &ev);
+  fprintf (stderr, "bridge exit func complete.\n");
+}
+
 static void bridge_focus_tracker (AtkObject *object)
 {
   Accessibility_Event *e = Accessibility_Event__alloc();
 static void bridge_focus_tracker (AtkObject *object)
 {
   Accessibility_Event *e = Accessibility_Event__alloc();
index da25664..3777145 100644 (file)
@@ -193,6 +193,42 @@ impl_accessibility_accessible_get_child_at_index (PortableServer_Servant servant
 }
 
 /*
 }
 
 /*
+ * CORBA Accessibility::Accessible::getState method implementation
+ */
+static Accessibility_StateSet
+impl_accessibility_accessible_get_state (PortableServer_Servant servant,
+                                        CORBA_Environment     *ev)
+{
+  Accessibility_StateSet retval;
+  Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
+  AtkStateSet *state = atk_object_ref_state_set (accessible->atko);
+  retval = CORBA_OBJECT_NIL;
+  printf ("Accessible get_state.\n");
+  /* TODO: implement the bonobo stateset class */
+  return (Accessibility_StateSet) retval;
+}
+
+/*
+ * CORBA Accessibility::Accessible::getRelationSet method implementation
+ */
+static Accessibility_RelationSet *
+impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
+                                               const CORBA_long      index,
+                                               CORBA_Environment     *ev)
+{
+  Accessibility_RelationSet *retval;
+  Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
+  AtkRelationSet *relation_set = atk_object_ref_relation_set (accessible->atko);
+  retval = CORBA_sequence_Accessibility_Relation__alloc ();
+  /*
+   *  TODO: fill the sequence with relation set objects, themselves
+   *  initialized from the AtkRelation object in the AtkRelationSet.
+   */
+  printf ("Accessible get_relation_set.\n");
+  return retval;
+}
+
+/*
  * CORBA Accessibility::Accessible::getRole method implementation
  */
 static Accessibility_Role
  * CORBA Accessibility::Accessible::getRole method implementation
  */
 static Accessibility_Role
@@ -227,8 +263,8 @@ accessible_class_init (AccessibleClass *klass)
         epv->getChildAtIndex = impl_accessibility_accessible_get_child_at_index;
         epv->getIndexInParent = impl_accessibility_accessible_get_index_in_parent;
 
         epv->getChildAtIndex = impl_accessibility_accessible_get_child_at_index;
         epv->getIndexInParent = impl_accessibility_accessible_get_index_in_parent;
 
-        /* epv->getRelationSet = impl_accessibility_accessible_get_relation_set;      */
-        /* epv->getState = impl_accessibility_accessible_get_state;                   */
+        epv->getRelationSet = impl_accessibility_accessible_get_relation_set;
+        epv->getState = impl_accessibility_accessible_get_state;
         epv->getRole = impl_accessibility_accessible_get_role;
 }
 
         epv->getRole = impl_accessibility_accessible_get_role;
 }
 
index 55b9b63..040e698 100644 (file)
@@ -54,6 +54,7 @@ static void
 desktop_init (Desktop  *desktop)
 {
   ACCESSIBLE (desktop)->atko = g_object_new (atk_object_get_type(), NULL);
 desktop_init (Desktop  *desktop)
 {
   ACCESSIBLE (desktop)->atko = g_object_new (atk_object_get_type(), NULL);
+  desktop->applications = NULL;
   atk_object_set_name (ATK_OBJECT (ACCESSIBLE (desktop)->atko), "main");
 }
 
   atk_object_set_name (ATK_OBJECT (ACCESSIBLE (desktop)->atko), "main");
 }
 
index 4a3d8e0..9a61ae1 100644 (file)
@@ -21,8 +21,7 @@
  */
 
 /*
  */
 
 /*
- * registry.c: test for accessibility implementation
- *
+ * registry.c: the main accessibility service registry implementation
  */
 
 #ifdef SPI_DEBUG
  */
 
 #ifdef SPI_DEBUG
@@ -130,6 +129,15 @@ compare_object_hash (gconstpointer p1, gconstpointer p2)
   CORBA_Environment ev;
   long long diff = ((CORBA_Object_hash ((CORBA_Object) p2, (CORBA_unsigned_long) 0, &ev)) -
                     (CORBA_Object_hash ((CORBA_Object) p1, (CORBA_unsigned_long) 0, &ev)));
   CORBA_Environment ev;
   long long diff = ((CORBA_Object_hash ((CORBA_Object) p2, (CORBA_unsigned_long) 0, &ev)) -
                     (CORBA_Object_hash ((CORBA_Object) p1, (CORBA_unsigned_long) 0, &ev)));
+
+#ifdef SPI_DEBUG
+  fprintf (stderr, "comparing %p to %p, via hashes %ld and %ld; diff %ld\n",
+          p1, p2,
+          CORBA_Object_hash ((CORBA_Object) p1, (CORBA_unsigned_long) 0, &ev),
+          CORBA_Object_hash ((CORBA_Object) p2, (CORBA_unsigned_long) 0, &ev),
+          (long) diff);
+#endif
+  
   return ((diff < 0) ? -1 : ((diff > 0) ? 1 : 0));
 }
 
   return ((diff < 0) ? -1 : ((diff > 0) ? 1 : 0));
 }
 
@@ -243,12 +251,29 @@ impl_accessibility_registry_deregister_application (PortableServer_Servant serva
                                                     CORBA_Environment * ev)
 {
   Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
                                                     CORBA_Environment * ev)
 {
   Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
-  GList *list = g_list_find_custom (registry->applications, application, compare_object_hash);
+  GList *list = g_list_find_custom (registry->desktop->applications, application, compare_object_hash);
+
+#ifdef SPI_DEBUG
+  gint i;
+#endif
+
   if (list)
     {
   if (list)
     {
-      fprintf (stderr, "deregistering application\n");
-      registry->applications = g_list_delete_link (registry->applications, list);
+#ifdef SPI_DEBUG
+      fprintf (stderr, "deregistering application %p\n", application);
+#endif
+      registry->desktop->applications = g_list_delete_link (registry->desktop->applications, list);
+#ifdef SPI_DEBUG
+      fprintf (stderr, "there are now %d apps registered.\n", g_list_length (registry->desktop->applications));
+      for (i = 0; i < g_list_length (registry->desktop->applications); ++i) {
+          fprintf (stderr, "getting application %d\n", i);
+          fprintf (stderr, "object address %p\n",
+               g_list_nth_data (registry->desktop->applications, i));
+      }
+#endif      
     }
     }
+  else
+    fprintf (stderr, "could not deregister application\n");
 }
 
 /*
 }
 
 /*
@@ -529,10 +554,11 @@ registry_class_init (RegistryClass *klass)
         epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
         epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
         epv->deregisterGlobalEventListenerAll = impl_accessibility_registry_deregister_global_event_listener_all;
         epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
         epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
         epv->deregisterGlobalEventListenerAll = impl_accessibility_registry_deregister_global_event_listener_all;
+        epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
         epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
         epv->getDesktop = impl_accessibility_registry_get_desktop;
         epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
         epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
         epv->getDesktop = impl_accessibility_registry_get_desktop;
         epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
-        epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
+
         ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
 }
 
         ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
 }
 
index 55b9b63..040e698 100644 (file)
@@ -54,6 +54,7 @@ static void
 desktop_init (Desktop  *desktop)
 {
   ACCESSIBLE (desktop)->atko = g_object_new (atk_object_get_type(), NULL);
 desktop_init (Desktop  *desktop)
 {
   ACCESSIBLE (desktop)->atko = g_object_new (atk_object_get_type(), NULL);
+  desktop->applications = NULL;
   atk_object_set_name (ATK_OBJECT (ACCESSIBLE (desktop)->atko), "main");
 }
 
   atk_object_set_name (ATK_OBJECT (ACCESSIBLE (desktop)->atko), "main");
 }
 
index 4a3d8e0..9a61ae1 100644 (file)
@@ -21,8 +21,7 @@
  */
 
 /*
  */
 
 /*
- * registry.c: test for accessibility implementation
- *
+ * registry.c: the main accessibility service registry implementation
  */
 
 #ifdef SPI_DEBUG
  */
 
 #ifdef SPI_DEBUG
@@ -130,6 +129,15 @@ compare_object_hash (gconstpointer p1, gconstpointer p2)
   CORBA_Environment ev;
   long long diff = ((CORBA_Object_hash ((CORBA_Object) p2, (CORBA_unsigned_long) 0, &ev)) -
                     (CORBA_Object_hash ((CORBA_Object) p1, (CORBA_unsigned_long) 0, &ev)));
   CORBA_Environment ev;
   long long diff = ((CORBA_Object_hash ((CORBA_Object) p2, (CORBA_unsigned_long) 0, &ev)) -
                     (CORBA_Object_hash ((CORBA_Object) p1, (CORBA_unsigned_long) 0, &ev)));
+
+#ifdef SPI_DEBUG
+  fprintf (stderr, "comparing %p to %p, via hashes %ld and %ld; diff %ld\n",
+          p1, p2,
+          CORBA_Object_hash ((CORBA_Object) p1, (CORBA_unsigned_long) 0, &ev),
+          CORBA_Object_hash ((CORBA_Object) p2, (CORBA_unsigned_long) 0, &ev),
+          (long) diff);
+#endif
+  
   return ((diff < 0) ? -1 : ((diff > 0) ? 1 : 0));
 }
 
   return ((diff < 0) ? -1 : ((diff > 0) ? 1 : 0));
 }
 
@@ -243,12 +251,29 @@ impl_accessibility_registry_deregister_application (PortableServer_Servant serva
                                                     CORBA_Environment * ev)
 {
   Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
                                                     CORBA_Environment * ev)
 {
   Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
-  GList *list = g_list_find_custom (registry->applications, application, compare_object_hash);
+  GList *list = g_list_find_custom (registry->desktop->applications, application, compare_object_hash);
+
+#ifdef SPI_DEBUG
+  gint i;
+#endif
+
   if (list)
     {
   if (list)
     {
-      fprintf (stderr, "deregistering application\n");
-      registry->applications = g_list_delete_link (registry->applications, list);
+#ifdef SPI_DEBUG
+      fprintf (stderr, "deregistering application %p\n", application);
+#endif
+      registry->desktop->applications = g_list_delete_link (registry->desktop->applications, list);
+#ifdef SPI_DEBUG
+      fprintf (stderr, "there are now %d apps registered.\n", g_list_length (registry->desktop->applications));
+      for (i = 0; i < g_list_length (registry->desktop->applications); ++i) {
+          fprintf (stderr, "getting application %d\n", i);
+          fprintf (stderr, "object address %p\n",
+               g_list_nth_data (registry->desktop->applications, i));
+      }
+#endif      
     }
     }
+  else
+    fprintf (stderr, "could not deregister application\n");
 }
 
 /*
 }
 
 /*
@@ -529,10 +554,11 @@ registry_class_init (RegistryClass *klass)
         epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
         epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
         epv->deregisterGlobalEventListenerAll = impl_accessibility_registry_deregister_global_event_listener_all;
         epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
         epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
         epv->deregisterGlobalEventListenerAll = impl_accessibility_registry_deregister_global_event_listener_all;
+        epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
         epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
         epv->getDesktop = impl_accessibility_registry_get_desktop;
         epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
         epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
         epv->getDesktop = impl_accessibility_registry_get_desktop;
         epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
-        epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
+
         ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
 }
 
         ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
 }
 
index 904218a..b423408 100644 (file)
@@ -157,7 +157,7 @@ static int _festival_init ()
 
   _festival_write ("(audio_mode'async)\n", fd);
   _festival_write ("(Parameter.set 'Duration_Model 'Tree_ZScore)\n", fd);
 
   _festival_write ("(audio_mode'async)\n", fd);
   _festival_write ("(Parameter.set 'Duration_Model 'Tree_ZScore)\n", fd);
-  _festival_write ("(Parameter.set 'Duration_Stretch 0.5)\n", fd);
+  _festival_write ("(Parameter.set 'Duration_Stretch 0.7)\n", fd);
   return fd;
 }
 
   return fd;
 }
 
index c8e75c6..4a6ebe4 100644 (file)
@@ -190,7 +190,7 @@ int main (int argc, char** argv){
   gdk_window_resize (window->window, magnifier->mag_data->mag_width, magnifier->mag_data->mag_height);
   magnifier->mag_data->output_window = window;
   if (global_options.fullscreen) gdk_window_stick (window->window);
   gdk_window_resize (window->window, magnifier->mag_data->mag_width, magnifier->mag_data->mag_height);
   magnifier->mag_data->output_window = window;
   if (global_options.fullscreen) gdk_window_stick (window->window);
-  gdk_window_set_decorations(window->window, 0);
+  gtk_window_set_decorated(window, FALSE);
   gdk_window_set_functions(window->window, 0);
   gdk_window_raise(window->window);
   
   gdk_window_set_functions(window->window, 0);
   gdk_window_raise(window->window);