From 6150d7e5ee69838450f520561701d990f9ba0dfb Mon Sep 17 00:00:00 2001 From: billh Date: Sat, 16 Mar 2002 17:51:29 +0000 Subject: [PATCH] Added a diagnostic test to simple-at which (when compiled with PRINT_TREE defined, via a oneline source change) allows the hierarchy of each app to be printed out at startup, as a diagnostic tool. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@259 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 6 ++++++ test/simple-at.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 90eec5f..f7eb4a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-03-16 Bill Haneman + + * test/simple-at.c: + Added a #define-guarded tree-traversal step + when enumerating the apps (diagnostic tool). + 2002-03-15 Bill Haneman * idl/Accessibility_Role.idl: diff --git a/test/simple-at.c b/test/simple-at.c index 0c732cb..0bc34bb 100644 --- a/test/simple-at.c +++ b/test/simple-at.c @@ -29,6 +29,8 @@ #include "../util/mag_client.h" #include "../cspi/spi-private.h" /* A hack for now */ +#undef PRINT_TREE + static void report_focus_event (const AccessibleEvent *event, void *user_data); static void report_generic_event (const AccessibleEvent *event, void *user_data); static void report_text_event (const AccessibleEvent *event, void *user_data); @@ -42,6 +44,10 @@ static int _festival_init (); static void _festival_say (const char *text, const char *voice, SPIBoolean shutup); static void _festival_write (const char *buff, int fd); +#ifdef PRINT_TREE +static void print_accessible_tree (Accessible *accessible, char *prefix); +#endif + static SPIBoolean use_magnifier = FALSE; static SPIBoolean use_festival = FALSE; static SPIBoolean festival_chatty = FALSE; @@ -76,7 +82,7 @@ main (int argc, char **argv) modules = g_getenv ("GTK_MODULES"); if (!modules || modules [0] == '\0') { - putenv ("GTK_MODULES=gail:atk-bridge"); + putenv ("GTK_MODULES="); } modules = NULL; @@ -110,6 +116,9 @@ main (int argc, char **argv) application = Accessible_getChildAtIndex (desktop, j); s = Accessible_getName (application); fprintf (stderr, "app %d name: %s\n", j, s); +#ifdef PRINT_TREE + print_accessible_tree (application, "*"); +#endif SPI_freeString (s); Accessible_unref (application); } @@ -173,6 +182,46 @@ get_environment_vars (void) } } +#ifdef PRINT_TREE +static void +print_accessible_tree (Accessible *accessible, char *prefix) +{ + int n_children; + int i; + char *name; + char *role_name; + char *parent_name; + char *parent_role; + char child_prefix[100]; + Accessible *child; + Accessible *parent; + + strncpy (child_prefix, prefix, 98); + strcat (child_prefix, "*"); + parent = Accessible_getParent (accessible); + if (parent) + { + parent_name = Accessible_getName (parent); + parent_role = Accessible_getRoleName (parent); + } + Accessible_unref (parent); + name = Accessible_getName (accessible); + role_name = Accessible_getRoleName (accessible); + fprintf (stdout, "%sAccessible [%s] \"%s\"; parent [%s] %s\n", + prefix, role_name, name, parent_role, parent_name); + SPI_freeString (name); + SPI_freeString (role_name); + SPI_freeString (parent_name); + n_children = Accessible_getChildCount (accessible); + for (i = 0; i < n_children; ++i) + { + child = Accessible_getChildAtIndex (accessible, i); + print_accessible_tree (child, child_prefix); + Accessible_unref (child); + } +} +#endif + void report_focussed_accessible (Accessible *obj, SPIBoolean shutup_previous_speech) { -- 2.7.4