[g-a-devel]at-spi patch
- From: "Padraig O'Briain" <Padraig Obriain Sun COM>
- To: gnome-accessibility-devel gnome org
- Subject: [g-a-devel]at-spi patch
- Date: Fri, 7 Mar 2003 16:37:49 +0000 (GMT)
The attached patch fixes AccessibleTextSelectionChangedEvent_getSelectionString
and AccessibleNameChangedEvent_getNameString.
OK to commit?
Padraig
Index: atk-bridge/bridge.c
===================================================================
RCS file: /cvs/gnome/at-spi/atk-bridge/bridge.c,v
retrieving revision 1.59
diff -u -p -r1.59 bridge.c
--- atk-bridge/bridge.c 7 Mar 2003 15:34:37 -0000 1.59
+++ atk-bridge/bridge.c 7 Mar 2003 16:38:46 -0000
@@ -21,6 +21,7 @@
* Boston, MA 02111-1307, USA.
*/
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -48,9 +49,9 @@ static SpiApplication *this_app = NULL;
static gboolean registry_died = FALSE;
static gboolean atk_listeners_registered = FALSE;
static guint toplevel_handler;
+static gint max_selection_string = 255;
/* NOT YET USED
- static GQuark atk_quark_property_changed_name;
static GQuark atk_quark_property_changed_description;
static GQuark atk_quark_property_changed_parent;
static GQuark atk_quark_property_changed_role;
@@ -59,12 +60,13 @@ static guint toplevel_handler;
static GQuark atk_quark_property_changed_table_row_description;
*/
+
static guint atk_signal_text_changed;
static guint atk_signal_children_changed;
static guint atk_signal_active_descendant_changed;
+static guint atk_signal_text_selection_changed;
/* NOT YET USED
- static guint atk_signal_text_selection_changed;
static guint atk_signal_row_reordered;
static guint atk_signal_row_inserted;
static guint atk_signal_row_deleted;
@@ -134,6 +136,8 @@ spi_atk_bridge_init_event_type_consts ()
ATK_TYPE_OBJECT);
atk_signal_link_selected = g_signal_lookup ("link_selected",
ATK_TYPE_HYPERTEXT);
+ atk_signal_text_selection_changed = g_signal_lookup ("text_selection_changed",
+ ATK_TYPE_TEXT);
}
static int
@@ -565,6 +569,9 @@ spi_atk_bridge_property_event_listener (
{
AtkPropertyValues *values;
GObject *gobject;
+ const gchar *prop_name;
+ CORBA_any any;
+ const gchar *sp;
#ifdef SPI_BRIDGE_DEBUG
GSignalQuery signal_query;
@@ -585,8 +592,19 @@ spi_atk_bridge_property_event_listener (
gobject = g_value_get_object (param_values + 0);
values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
- spi_atk_emit_eventv (gobject, 0, 0, NULL,
- "object:property-change:%s", values->property_name);
+ prop_name = values->property_name;
+ if (strcmp (prop_name, "accessible-name") == 0)
+ {
+ sp = atk_object_get_name (ATK_OBJECT (gobject));
+ spi_init_any_string (&any, (gchar *)&sp);
+ }
+ else
+ {
+ spi_init_any_nil (&any);
+ }
+
+ spi_atk_emit_eventv (gobject, 0, 0, &any,
+ "object:property-change:%s", prop_name);
return TRUE;
}
@@ -708,6 +726,7 @@ spi_atk_bridge_signal_listener (GSignalI
CORBA_Object c_obj;
char *sp = NULL;
AtkObject *ao;
+ AtkText *text;
gint detail1 = 0, detail2 = 0;
SpiAccessible *s_ao = NULL;
#ifdef SPI_BRIDGE_DEBUG
@@ -780,6 +799,27 @@ spi_atk_bridge_signal_listener (GSignalI
detail1,
detail1+detail2);
spi_init_any_string (&any, &sp);
+ }
+ else if (signal_query.signal_id == atk_signal_text_selection_changed)
+ {
+ text = ATK_TEXT (gobject);
+
+ if (atk_text_get_n_selections (text) == 1)
+ {
+ sp = atk_text_get_selection (text, 0, &detail1, &detail2);
+ if (abs (detail2 - detail1) < max_selection_string)
+ {
+ spi_init_any_string (&any, &sp);
+ }
+ else
+ {
+ spi_init_any_nil (&any);
+ }
+ }
+ else
+ {
+ spi_init_any_nil (&any);
+ }
}
else
{
Index: cspi/spi_event.c
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi_event.c,v
retrieving revision 1.31
diff -u -p -r1.31 spi_event.c
--- cspi/spi_event.c 5 Mar 2003 17:24:58 -0000 1.31
+++ cspi/spi_event.c 7 Mar 2003 16:38:46 -0000
@@ -548,10 +548,21 @@ cspi_internal_event_remove (const Intern
_cspi_event_queue = g_slist_remove_link (_cspi_event_queue, link);
}
+/**
+ * AccessiblenameChangedEvent_getNametring:
+ * @event: a pointer to the #AccessibleEvent being queried.
+ *
+ * Queries an #AccessibleEvent of type "object:property-change:accessible_name:",
+ * returning the name.
+ *
+ * Returns: a UTF-8 text string representing the name of the
+ * object which recently changed.
+ **/
char *
AccessibleNameChangedEvent_getNameString (const AccessibleEvent *e)
{
- return NULL;
+ const InternalEvent *foo = (InternalEvent *) e;
+ return cspi_internal_event_get_text (foo);
}
SPIBoolean
Index: test/event-listener-test.c
===================================================================
RCS file: /cvs/gnome/at-spi/test/event-listener-test.c,v
retrieving revision 1.17
diff -u -p -r1.17 event-listener-test.c
--- test/event-listener-test.c 7 Mar 2003 15:34:38 -0000 1.17
+++ test/event-listener-test.c 7 Mar 2003 16:38:46 -0000
@@ -32,6 +32,7 @@ static void report_detail_event (const
static void report_detail1_event (const AccessibleEvent *event, void *user_data);
static void report_text_event (const AccessibleEvent *event, void *user_data);
static void report_children_changed_event (const AccessibleEvent *event, void *user_data);
+static void report_name_changed_event (const AccessibleEvent *event, void *user_data);
static void timing_test_event (const AccessibleEvent *event, void *user_data);
static SPIBoolean report_mouse_event (const AccessibleDeviceEvent *event, void *user_data);
@@ -41,6 +42,7 @@ static AccessibleEventListener *detail1_
static AccessibleEventListener *test_listener;
static AccessibleEventListener *text_listener;
static AccessibleEventListener *children_changed_listener;
+static AccessibleEventListener *name_changed_listener;
static AccessibleDeviceListener *mouse_device_listener;
static gint n_elements_traversed = 0;
static GTimer *timer;
@@ -98,6 +100,8 @@ main (int argc, char **argv)
report_text_event, NULL);
children_changed_listener = SPI_createAccessibleEventListener (
report_children_changed_event, NULL);
+ name_changed_listener = SPI_createAccessibleEventListener (
+ report_name_changed_event, NULL);
test_listener = SPI_createAccessibleEventListener (
timing_test_event, NULL);
mouse_device_listener = SPI_createAccessibleDeviceListener (
@@ -122,8 +126,8 @@ main (int argc, char **argv)
"keyboard:modifiers");
SPI_registerGlobalEventListener (generic_listener,
"object:property-change");
-/* SPI_registerGlobalEventListener (specific_listener,
- "object:property-change:accessible-name");*/
+ SPI_registerGlobalEventListener (name_changed_listener,
+ "object:property-change:accessible-name");
SPI_registerGlobalEventListener (generic_listener,
"object:state-changed");
/* SPI_registerGlobalEventListener (specific_listener,
@@ -136,7 +140,7 @@ main (int argc, char **argv)
"object:active-descendant");
SPI_registerGlobalEventListener (generic_listener,
"object:visible-data-changed");
- SPI_registerGlobalEventListener (generic_listener,
+ SPI_registerGlobalEventListener (text_listener,
"object:text-selection-changed");
SPI_registerGlobalEventListener (generic_listener,
@@ -312,6 +316,18 @@ report_children_changed_event (const Acc
SPI_freeString (s);
SPI_freeString (s1);
Accessible_unref (ao);
+}
+
+void
+report_name_changed_event (const AccessibleEvent *event, void *user_data)
+{
+ char *s = Accessible_getName (event->source);
+ fprintf (stderr, "(detail) %s %s %d %d\n", event->type, s,
+ event->detail1, event->detail2);
+ SPI_freeString (s);
+ s = AccessibleNameChangedEvent_getNameString (event);
+ fprintf (stderr, "context string %s\n", (s) ? s : "<nil>");
+ SPI_freeString (s);
}
SPIBoolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]