Added some implementation for toolkit events.
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 16 Aug 2001 22:11:14 +0000 (22:11 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 16 Aug 2001 22:11:14 +0000 (22:11 +0000)
Changed at.c to listen to Gtk:GtkWidget:button_press_event
events as well as focus events.

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

libspi/registry.c
registryd/registry.c
test/at.c

index 34542cd..0cca46a 100644 (file)
@@ -59,6 +59,7 @@ typedef enum {
 } EventTypeMajor;
 
 typedef struct {
 } EventTypeMajor;
 
 typedef struct {
+  char *event_name;
   EventTypeMajor major;
   char * minor;
   char * detail;
   EventTypeMajor major;
   char * minor;
   char * detail;
@@ -108,7 +109,6 @@ impl_accessibility_registry_register_application (PortableServer_Servant servant
 #ifdef SPI_DEBUG
   fprintf (stderr, "registering app %p\n", application);
 #endif
 #ifdef SPI_DEBUG
   fprintf (stderr, "registering app %p\n", application);
 #endif
-  ORBit_register_objref (application);
   registry->desktop->applications = g_list_append (registry->desktop->applications,
                                                    CORBA_Object_duplicate (application, ev));
 
   registry->desktop->applications = g_list_append (registry->desktop->applications,
                                                    CORBA_Object_duplicate (application, ev));
 
@@ -131,18 +131,31 @@ compare_object_hash (gconstpointer p1, gconstpointer p2)
 }
 
 static gboolean
 }
 
 static gboolean
-toolkit_listener (GSignalInvocationHint *signal_hint, guint n_param_value,
-                  const GValue *param_values, gpointer data)
+toolkit_listener (GSignalInvocationHint *signal_hint,
+                  guint n_param_values,
+                  const GValue *param_values,
+                  gpointer data)
 {
 {
-  ;
-  return FALSE;
+  gchar *name =
+    g_signal_name (signal_hint->signal_id);
+  fprintf (stderr, "Received signal %s\n", name);
+
+  /* TODO: notify the actual listeners! */
+
+  return TRUE;
 }
 
 static void
 register_with_toolkit (EventTypeStruct *etype)
 {
 }
 
 static void
 register_with_toolkit (EventTypeStruct *etype)
 {
-  guint listener_id =
-  atk_add_global_event_listener (toolkit_listener, g_strconcat (etype->minor, etype->detail, NULL));
+  guint listener_id;
+  listener_id =
+     atk_add_global_event_listener (toolkit_listener, etype->event_name);
+#ifdef SPI_DEBUG
+  fprintf (stderr, "registered %d for toolkit events named: %s\n",
+           listener_id,
+           etype->event_name);
+#endif
 }
 
 static gint
 }
 
 static gint
@@ -159,6 +172,8 @@ parse_event_type (EventTypeStruct *etype, char *event_name)
   char * minor_delim_char;
   guint nbytes = 0;
 
   char * minor_delim_char;
   guint nbytes = 0;
 
+  etype->event_name = g_strndup(event_name, 255);
+
   if (!delimiter)
     {
       delimiter = g_utf8_get_char (":");
   if (!delimiter)
     {
       delimiter = g_utf8_get_char (":");
@@ -184,26 +199,27 @@ parse_event_type (EventTypeStruct *etype, char *event_name)
       etype->major = ETYPE_TOOLKIT;
     }
 
       etype->major = ETYPE_TOOLKIT;
     }
 
-  if (major_delim_char)
-    {
-      etype->minor = g_strndup (major_delim_char, nbytes);
-      etype->hash = g_str_hash (major_delim_char);
-    }
-  else
-    {
-      etype->minor = g_strdup ("");
-      etype->hash = g_str_hash ("");
-    }
   if (major_delim_char != minor_delim_char)
     {
   if (major_delim_char != minor_delim_char)
     {
+      etype->minor = g_strndup (major_delim_char, nbytes);
       etype->detail = g_strdup (minor_delim_char);
       etype->detail = g_strdup (minor_delim_char);
+      etype->hash = g_str_hash (major_delim_char);
     }
   else
     {
     }
   else
     {
+      if (* (major_delim_char+1))
+        {
+          etype->minor = g_strdup (major_delim_char+1);
+          etype->hash = g_str_hash (major_delim_char+1);
+        }
+      else
+        {
+          etype->minor = g_strdup ("");
+          etype->hash = g_str_hash ("");
+        }
       etype->detail = g_strdup ("");
     }
 
       etype->detail = g_strdup ("");
     }
 
-
   /* TODO: don't forget to free the strings from caller when done ! */
 }
 
   /* TODO: don't forget to free the strings from caller when done ! */
 }
 
index 34542cd..0cca46a 100644 (file)
@@ -59,6 +59,7 @@ typedef enum {
 } EventTypeMajor;
 
 typedef struct {
 } EventTypeMajor;
 
 typedef struct {
+  char *event_name;
   EventTypeMajor major;
   char * minor;
   char * detail;
   EventTypeMajor major;
   char * minor;
   char * detail;
@@ -108,7 +109,6 @@ impl_accessibility_registry_register_application (PortableServer_Servant servant
 #ifdef SPI_DEBUG
   fprintf (stderr, "registering app %p\n", application);
 #endif
 #ifdef SPI_DEBUG
   fprintf (stderr, "registering app %p\n", application);
 #endif
-  ORBit_register_objref (application);
   registry->desktop->applications = g_list_append (registry->desktop->applications,
                                                    CORBA_Object_duplicate (application, ev));
 
   registry->desktop->applications = g_list_append (registry->desktop->applications,
                                                    CORBA_Object_duplicate (application, ev));
 
@@ -131,18 +131,31 @@ compare_object_hash (gconstpointer p1, gconstpointer p2)
 }
 
 static gboolean
 }
 
 static gboolean
-toolkit_listener (GSignalInvocationHint *signal_hint, guint n_param_value,
-                  const GValue *param_values, gpointer data)
+toolkit_listener (GSignalInvocationHint *signal_hint,
+                  guint n_param_values,
+                  const GValue *param_values,
+                  gpointer data)
 {
 {
-  ;
-  return FALSE;
+  gchar *name =
+    g_signal_name (signal_hint->signal_id);
+  fprintf (stderr, "Received signal %s\n", name);
+
+  /* TODO: notify the actual listeners! */
+
+  return TRUE;
 }
 
 static void
 register_with_toolkit (EventTypeStruct *etype)
 {
 }
 
 static void
 register_with_toolkit (EventTypeStruct *etype)
 {
-  guint listener_id =
-  atk_add_global_event_listener (toolkit_listener, g_strconcat (etype->minor, etype->detail, NULL));
+  guint listener_id;
+  listener_id =
+     atk_add_global_event_listener (toolkit_listener, etype->event_name);
+#ifdef SPI_DEBUG
+  fprintf (stderr, "registered %d for toolkit events named: %s\n",
+           listener_id,
+           etype->event_name);
+#endif
 }
 
 static gint
 }
 
 static gint
@@ -159,6 +172,8 @@ parse_event_type (EventTypeStruct *etype, char *event_name)
   char * minor_delim_char;
   guint nbytes = 0;
 
   char * minor_delim_char;
   guint nbytes = 0;
 
+  etype->event_name = g_strndup(event_name, 255);
+
   if (!delimiter)
     {
       delimiter = g_utf8_get_char (":");
   if (!delimiter)
     {
       delimiter = g_utf8_get_char (":");
@@ -184,26 +199,27 @@ parse_event_type (EventTypeStruct *etype, char *event_name)
       etype->major = ETYPE_TOOLKIT;
     }
 
       etype->major = ETYPE_TOOLKIT;
     }
 
-  if (major_delim_char)
-    {
-      etype->minor = g_strndup (major_delim_char, nbytes);
-      etype->hash = g_str_hash (major_delim_char);
-    }
-  else
-    {
-      etype->minor = g_strdup ("");
-      etype->hash = g_str_hash ("");
-    }
   if (major_delim_char != minor_delim_char)
     {
   if (major_delim_char != minor_delim_char)
     {
+      etype->minor = g_strndup (major_delim_char, nbytes);
       etype->detail = g_strdup (minor_delim_char);
       etype->detail = g_strdup (minor_delim_char);
+      etype->hash = g_str_hash (major_delim_char);
     }
   else
     {
     }
   else
     {
+      if (* (major_delim_char+1))
+        {
+          etype->minor = g_strdup (major_delim_char+1);
+          etype->hash = g_str_hash (major_delim_char+1);
+        }
+      else
+        {
+          etype->minor = g_strdup ("");
+          etype->hash = g_str_hash ("");
+        }
       etype->detail = g_strdup ("");
     }
 
       etype->detail = g_strdup ("");
     }
 
-
   /* TODO: don't forget to free the strings from caller when done ! */
 }
 
   /* TODO: don't forget to free the strings from caller when done ! */
 }
 
index 8964c18..b0aa7ab 100644 (file)
--- a/test/at.c
+++ b/test/at.c
 #include "listener.h"
 #include "desktop.h"
 
 #include "listener.h"
 #include "desktop.h"
 
+void
+check_ev (CORBA_Environment *ev, char *desc)
+{
+        if (ev->_major != CORBA_NO_EXCEPTION) {
+                fprintf(stderr,
+                ("Accessibility app error: exception during CORBA call %s (%s)\n"),
+                        CORBA_exception_id(ev), desc);
+                CORBA_exception_free(ev);
+                exit(-1);
+        }
+}
+
 int
 main(int argc, char **argv)
 {
 int
 main(int argc, char **argv)
 {
@@ -79,7 +91,14 @@ main(int argc, char **argv)
                                          bonobo_object_corba_objref (bonobo_object (listener)),
                                     "focus:",
                                     &ev);
                                          bonobo_object_corba_objref (bonobo_object (listener)),
                                     "focus:",
                                     &ev);
-
+        check_ev (&ev, "register:focus");
+        Accessibility_Registry_registerGlobalEventListener
+                                   (registry,
+                                    (Accessibility_EventListener)
+                                         bonobo_object_corba_objref (bonobo_object (listener)),
+                                    "Gtk:GtkWidget:button_press_event",
+                                    &ev);
+        check_ev (&ev, "register:button_press");
         fprintf (stderr, "AT callback registered.\n");
 
 
         fprintf (stderr, "AT callback registered.\n");
 
 
@@ -90,13 +109,17 @@ main(int argc, char **argv)
                 desktop = Accessibility_Registry_getDesktop (registry, i, &ev);
                 fprintf (stderr, "desktop %d name: %s\n", i,
                          Accessibility_Desktop__get_name (desktop, &ev));
                 desktop = Accessibility_Registry_getDesktop (registry, i, &ev);
                 fprintf (stderr, "desktop %d name: %s\n", i,
                          Accessibility_Desktop__get_name (desktop, &ev));
+                check_ev (&ev, "desktop:name");
                 n_apps = Accessibility_Desktop__get_childCount (desktop, &ev);
                 n_apps = Accessibility_Desktop__get_childCount (desktop, &ev);
+                check_ev (&ev, "desktop:childCount");
                 fprintf (stderr, "desktop has %d apps:\n", n_apps);
                 for (j=0; j<n_apps; ++j)
                   {
                     app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev);
                 fprintf (stderr, "desktop has %d apps:\n", n_apps);
                 for (j=0; j<n_apps; ++j)
                   {
                     app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev);
+                    check_ev (&ev, "desktop:getChildAtIndex");
                     fprintf (stderr, "app %d name: %s\n", j,
                              Accessibility_Application__get_name (app, &ev));
                     fprintf (stderr, "app %d name: %s\n", j,
                              Accessibility_Application__get_name (app, &ev));
+                    check_ev (&ev, "app:getName");
                   }
               }
 
                   }
               }