[g-a-devel]Patch for at-poke
- From: "Padraig O'Briain" <Padraig Obriain Sun COM>
- To: gnome-accessibility-devel gnome org
- Subject: [g-a-devel]Patch for at-poke
- Date: Tue, 10 Dec 2002 09:57:24 +0000 (GMT)
Attached is a patch for at-poke which
- Allows children of a table to be obtained using AccessibleTable interface
- Places optional limit on numnber of rows and columns whose cells are reported.
- Allows no children of an Accessible with state MANAGES_DESCENDANTS to be
reported
- Reports when active-descendant-changed event is emitted.
Padraig
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-poke/ChangeLog,v
retrieving revision 1.43
diff -u -p -r1.43 ChangeLog
--- ChangeLog 6 Dec 2002 11:05:54 -0000 1.43
+++ ChangeLog 10 Dec 2002 09:50:34 -0000
@@ -1,3 +1,29 @@
+2002-12-10 Padraig O'Briain <padraig obriain sun com>
+
+ * src/accessible-tree-model.c:
+ Add boolean variables dontdisplaychildren and use_table_if.
+ Add display_children variable to ModelNode data structure.
+ (model_node_new): Set display_children for ModelNode to FALSE if
+ dontdisplaychildren is set and state set of Accessible includes
+ SPI_STATE_MANAGES_DESCENDANTS.
+ (model_node_has_children): Check ModelNodes's display_children
+ variable.
+ (model_node_sync_children): Use AccessibleTable_getAccessibleAt() to
+ get children of AccessibleTable if use_table_if is specified.
+ (model_node_children_changed): Ignore if ModelNode's display_children
+ is FALSE.
+ (report_global_event): Add check for receipt of
+ active-descendant-changed event.
+ (accessible_tree_model_init): register for receipt of
+ active-descendant-changed event.
+
+ * src/main.c:
+ Add -d (dont display children) and -t (use table if) command line
+ options.
+
+ * src/poke.c (update_if_accessible): Ensure that MANAGES_DESCENDANTS
+ state is displayed in alphabetic order.
+
2002-12-06 Padraig O'Briain <padraig obriain sun com>
* src/poke.c:
Index: src/accessible-tree-model.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/accessible-tree-model.c,v
retrieving revision 1.24
diff -u -p -r1.24 accessible-tree-model.c
--- src/accessible-tree-model.c 7 Nov 2002 10:26:46 -0000 1.24
+++ src/accessible-tree-model.c 10 Dec 2002 09:50:34 -0000
@@ -35,9 +35,12 @@ typedef struct {
char *description;
AccessibleRole role;
char *role_name; /* sad but true */
+ gboolean display_children;
} ModelNode;
int max_children = 0;
+gboolean dontdisplaychildren = FALSE;
+gboolean use_table_if = FALSE;
static GNode *
model_node_new (AccessibleTreeModel *model, Accessible *accessible)
@@ -49,6 +52,17 @@ model_node_new (AccessibleTreeModel *mod
mnode->accessible = accessible;
Accessible_ref (accessible);
+ mnode->display_children = TRUE;
+ if (dontdisplaychildren) {
+ AccessibleStateSet *state_set;
+
+ state_set = Accessible_getStateSet (accessible);
+ if (AccessibleStateSet_contains (state_set,
+ SPI_STATE_MANAGES_DESCENDANTS)) {
+ mnode->display_children = FALSE;
+ }
+ AccessibleStateSet_unref (state_set);
+ }
node = g_node_new (mnode);
g_hash_table_insert (model->accessible_to_node, accessible, node);
@@ -167,6 +181,9 @@ model_node_has_children (GtkTreeModel *t
mnode = node->data;
+ if (!mnode->display_children)
+ return FALSE;
+
if (mnode->state & NODE_GOT_CHILDREN)
return node->children != NULL;
@@ -181,11 +198,13 @@ model_node_has_children (GtkTreeModel *t
static void
model_node_sync_children (GtkTreeModel *tree_model, GNode *node)
{
- int i;
+ int i, j;
GNode *lnode;
GSList *children, *l;
ModelNode *mnode;
AccessibleTreeModel *model = ACCESSIBLE_TREE_MODEL (tree_model);
+ AccessibleTable *accessible_table;
+ gboolean use_table = FALSE;
g_return_if_fail (node != NULL);
@@ -194,28 +213,60 @@ model_node_sync_children (GtkTreeModel *
if (mnode->state & NODE_GOT_CHILDREN)
return;
+ if (use_table_if) {
+ accessible_table = Accessible_getTable (mnode->accessible);
+
+ if (accessible_table)
+ use_table = TRUE;
+ }
+
retry_on_reenter:
mnode->state |= NODE_GOT_CHILDREN | NODE_FETCHING_CHILDREN;
model->stamp++;
children = NULL;
- for (i = 0; max_children ? i < max_children : TRUE; i++) {
- Accessible *accessible;
- accessible = Accessible_getChildAtIndex (mnode->accessible, i);
+ if (use_table) {
+ for (i = 0; max_children ? i < max_children : TRUE; i++) {
+ for (j = 0; max_children ? j < max_children : TRUE; j++) {
+ Accessible *accessible;
+
+ accessible = AccessibleTable_getAccessibleAt (accessible_table, i, j);
+ if (mnode->state & NODE_CHILDREN_CHANGED) {
+ mnode->state &= ~NODE_CHILDREN_CHANGED;
+ for (l = children; l; l = l->next)
+ Accessible_unref (l->data);
+ g_slist_free (children);
+ goto retry_on_reenter;
+ }
+
+ if (!accessible)
+ break;
- if (mnode->state & NODE_CHILDREN_CHANGED) {
- mnode->state &= ~NODE_CHILDREN_CHANGED;
- for (l = children; l; l = l->next)
- Accessible_unref (l->data);
- g_slist_free (children);
- goto retry_on_reenter;
+ children = g_slist_prepend (children, accessible);
+ }
}
+ Accessible_unref (accessible_table);
+ } else {
+
+ for (i = 0; max_children ? i < max_children : TRUE; i++) {
+ Accessible *accessible;
+
+ accessible = Accessible_getChildAtIndex (mnode->accessible, i);
- if (!accessible)
- break;
+ if (mnode->state & NODE_CHILDREN_CHANGED) {
+ mnode->state &= ~NODE_CHILDREN_CHANGED;
+ for (l = children; l; l = l->next)
+ Accessible_unref (l->data);
+ g_slist_free (children);
+ goto retry_on_reenter;
+ }
- children = g_slist_prepend (children, accessible);
+ if (!accessible)
+ break;
+
+ children = g_slist_prepend (children, accessible);
+ }
}
mnode->state &= ~NODE_FETCHING_CHILDREN;
@@ -287,6 +338,9 @@ model_node_children_changed (AccessibleT
return;
}
+ if (!mnode->display_children)
+ return;
+
if (mnode->state & NODE_FETCHING_CHILDREN) {
mnode->state |= NODE_CHILDREN_CHANGED;
g_warning ("Heavy duty re-entrancy on node '%p'", node);
@@ -626,7 +680,19 @@ report_global_event (const AccessibleEve
if (!model || !model->accessible_to_node)
return;
- model_node_children_changed (model, event->source);
+ if (!strcmp (event->type, "object:children-changed")) {
+ model_node_children_changed (model, event->source);
+ } else if (!strcmp (event->type, "object:active-descendant-changed")) {
+ Accessible *active_descendant;
+ char *role_txt;
+
+ active_descendant = AccessibleActiveDescendantChangedEvent_getActiveDescendant (event);
+
+ role_txt = Accessible_getRoleName (active_descendant);
+
+ g_print ("New active descendant: %p Role: %s Index: %d\n", active_descendant, role_txt, event->detail1);
+ SPI_freeString (role_txt);
+ }
}
static void
@@ -638,6 +704,8 @@ accessible_tree_model_init (AccessibleTr
report_global_event, model);
SPI_registerGlobalEventListener (
model->event_listener, "object:children-changed");
+ SPI_registerGlobalEventListener (
+ model->event_listener, "object:active-descendant-changed");
}
static void
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/main.c,v
retrieving revision 1.17
diff -u -p -r1.17 main.c
--- src/main.c 7 Nov 2002 10:26:46 -0000 1.17
+++ src/main.c 10 Dec 2002 09:50:35 -0000
@@ -29,10 +29,16 @@
#include "accessible-listener.h"
extern int max_children;
+extern gboolean dontdisplaychildren;
+extern gboolean use_table_if;
static const struct poptOption options[] = {
{ "maxchildren", 'm', POPT_ARG_INT, &max_children, 1,
- "Specify the maximum number of children of an Accessible to be returned\n", "INT"},
+ "Specify the maximum number of children of an Accessible to be returned; or maximum ch ildren in a row or column if table is specified.\n", "INT"},
+ { "dontdisplaychildren", 'd', POPT_ARG_NONE, &dontdisplaychildren, 1,
+ "Do not display children for object which has state MANAGES_DESCENDANTS\n", NULL},
+ { "table", 't', POPT_ARG_NONE, &use_table_if, 1,
+ "Use AccessibleTable_getAccessibleAt to get children of Accessible which implements AccessibleTable\n", NULL},
{NULL, '\0', 0, NULL, 0, NULL, NULL}
};
Index: src/poke.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/poke.c,v
retrieving revision 1.28
diff -u -p -r1.28 poke.c
--- src/poke.c 6 Dec 2002 11:05:55 -0000 1.28
+++ src/poke.c 10 Dec 2002 09:50:35 -0000
@@ -239,6 +239,7 @@ update_if_accessible (Poker *poker, Acce
{ SPI_STATE_FOCUSED, "FOCUSED" },
{ SPI_STATE_HORIZONTAL, "HORIZONTAL" },
{ SPI_STATE_ICONIFIED, "ICONIFIED" },
+ { SPI_STATE_MANAGES_DESCENDANTS, "MANAGES_DESCENDANTS" },
{ SPI_STATE_MODAL, "MODAL" },
{ SPI_STATE_MULTI_LINE, "MULTI_LINE" },
{ SPI_STATE_MULTISELECTABLE, "MULTISELECTABLE" },
@@ -254,7 +255,6 @@ update_if_accessible (Poker *poker, Acce
{ SPI_STATE_TRANSIENT, "TRANSIENT" },
{ SPI_STATE_VERTICAL, "VERTICAL" },
{ SPI_STATE_VISIBLE, "VISIBLE" },
- { SPI_STATE_MANAGES_DESCENDANTS, "MANAGES_DESCENDANTS" },
{ 0, NULL }
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]