[g-a-devel]Patch for at-poke



The attached is a patch for at-poke to address bug 97624.


OK to commit?

Padraig
cvs server: Diffing .
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-poke/ChangeLog,v
retrieving revision 1.41
diff -u -p -r1.41 ChangeLog
--- ChangeLog	16 Oct 2002 15:14:52 -0000	1.41
+++ ChangeLog	5 Nov 2002 13:55:46 -0000
@@ -1,3 +1,18 @@
+2002-11-05  Padraig O'Briain   <padraig obriain sun com>
+
+	* src/accessible-tree-model.c: Add global variable max_children
+	which specifies the number of children to be reported
+	(model_node_has_children): New function which determines whether
+	node has children.
+	(model_node_sync_children): Report only max_children children of node
+	if max_children is specified; otherwise report all children
+	(accessible_tree_model_iter_has_child): Use model_node_has_children()
+	to determine whether a node has children; this avoids getting all the
+	children of a node when determining whether a node has children.
+
+	* src/main.c: Define command line options and use to initialize
+	max_children.
+
 2002-10-16  Padraig O'Briain   <padraig obriain sun com>
 
 	* glade/at-poke.glade2: Add poker_hypertext_frame.
cvs server: Diffing glade
cvs server: Diffing icons
cvs server: Diffing src
Index: src/accessible-tree-model.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/accessible-tree-model.c,v
retrieving revision 1.23
diff -u -p -r1.23 accessible-tree-model.c
--- src/accessible-tree-model.c	8 Oct 2002 07:40:52 -0000	1.23
+++ src/accessible-tree-model.c	5 Nov 2002 13:55:46 -0000
@@ -37,6 +37,8 @@ typedef struct {
 	char           *role_name; /* sad but true */
 } ModelNode;
 
+int max_children = 0;
+
 static GNode *
 model_node_new (AccessibleTreeModel *model, Accessible *accessible)
 {
@@ -153,6 +155,29 @@ model_node_destroy (GtkTreeModel *model,
 	gtk_tree_path_free (path);
 }
 
+static gboolean
+model_node_has_children (GtkTreeModel *tree_model, GNode *node)
+{
+	ModelNode *mnode;
+	AccessibleTreeModel *model = ACCESSIBLE_TREE_MODEL (tree_model);
+	Accessible *accessible;
+	gboolean retval;
+
+	g_return_val_if_fail (node != NULL, FALSE);
+
+	mnode = node->data;
+
+	if (mnode->state & NODE_GOT_CHILDREN)
+		return node->children != NULL;
+
+	accessible = Accessible_getChildAtIndex (mnode->accessible, 0);
+	retval = accessible != NULL;
+	if (accessible)
+		Accessible_unref (accessible);
+
+	return retval;
+}
+
 static void
 model_node_sync_children (GtkTreeModel *tree_model, GNode *node)
 {
@@ -174,7 +199,7 @@ model_node_sync_children (GtkTreeModel *
 
 	model->stamp++;
 	children = NULL;
-	for (i = 0; ; i++) {
+	for (i = 0; max_children ? i < max_children : TRUE; i++) {
 		Accessible *accessible;
 
 		accessible = Accessible_getChildAtIndex (mnode->accessible, i);
@@ -463,8 +488,7 @@ accessible_tree_model_iter_has_child (Gt
 	GNode *node = ITER_NODE (iter);
 
 	if (node) {
-		model_node_sync_children (model, node);
-		return node->children != NULL;
+		return model_node_has_children (model, node);
 	} else
 		return FALSE;
 }
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/main.c,v
retrieving revision 1.16
diff -u -p -r1.16 main.c
--- src/main.c	3 Oct 2002 16:27:45 -0000	1.16
+++ src/main.c	5 Nov 2002 13:55:46 -0000
@@ -22,11 +22,20 @@
 #include <gtk/gtk.h>
 #include <cspi/spi.h>
 #include <libgnomeui/gnome-ui-init.h>
+#include <popt.h>
 
 #include "graphics.h"
 #include "child-listener.h"
 #include "accessible-listener.h"
 
+extern int max_children;
+
+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"},
+	{NULL, '\0', 0, NULL, 0, NULL, NULL}
+};
+
 extern void poke (Accessible *accessible);
 extern Accessible *get_accessible_at_index (GtkListStore *list_store, int i);
 
@@ -401,7 +410,10 @@ main (int argc, char **argv)
 
 	gnome_program_init ("at-poke", VERSION,
 			    LIBGNOMEUI_MODULE,
-			    argc, argv, NULL);
+			    argc, argv, 
+			    GNOME_PARAM_POPT_TABLE, options, NULL);
+	if (max_children < 0)
+		max_children = 0;
 
 	application_window ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]