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



The attached patch causes at-poke to be responsive when tables have large number 
of rows or columns andh -m and -t command line options are specified vor 
at-poke.

OK to commit?

Padraig
----

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-poke/ChangeLog,v
retrieving revision 1.47
diff -p -u -r1.47 ChangeLog
--- ChangeLog	16 Jan 2003 09:55:13 -0000	1.47
+++ ChangeLog	28 Jan 2003 15:44:26 -0000
@@ -1,3 +1,13 @@
+2003-01-28  Padraig O'Briain   <padraig obriain sun com>
+
+	* src/poke.c
+	(update_if_table): Set max number of rows and columns to max_children
+	if it has been set.
+	(update_if_selection): Check whether use_table_if and max_children
+	have been set and use to restrict the number of children retrieved.
+
+	This addresses bug #100213
+
 2003-01-16  Padraig O'Briain   <padraig obriain sun com>
 
 	* configure.in: Update to Version 0.2.0
Index: src/poke.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/poke.c,v
retrieving revision 1.30
diff -p -u -r1.30 poke.c
--- src/poke.c	15 Jan 2003 16:25:31 -0000	1.30
+++ src/poke.c	28 Jan 2003 15:44:27 -0000
@@ -35,6 +35,8 @@
 #include "accessible-tree-model.h"
 
 extern void poke (Accessible *accessible);
+extern int max_children;
+extern gboolean use_table_if;
 
 typedef struct {
 	GladeXML     *xml;
@@ -684,6 +686,12 @@ update_if_table (Poker *poker, Accessibl
 
 	rows = AccessibleTable_getNRows (table);
 	cols = AccessibleTable_getNColumns (table);
+	if (max_children) {
+		if (rows > max_children)
+			rows = max_children;
+		if (cols > max_children)
+			cols = max_children;
+	}
 
 	widget = glade_xml_get_widget (poker->xml, "table_if_rows");
 	txt = g_strdup_printf ("%ld", rows);
@@ -695,14 +703,14 @@ update_if_table (Poker *poker, Accessibl
 	gtk_label_set_text (GTK_LABEL (widget), txt);
 	g_free (txt);
 
-
 	gtk_list_store_clear (poker->table_rows_store);
 	for (i = 0; i < rows; i++) {
 		GtkTreeIter iter;
-		char *description =
-			AccessibleTable_getRowDescription (table, i);
-		int extent =
-			AccessibleTable_getRowExtentAt (table, i, 0);
+		char *description;
+		int extent;
+
+		description = AccessibleTable_getRowDescription (table, i);
+		extent =  AccessibleTable_getRowExtentAt (table, i, 0);
 		gtk_list_store_append (poker->table_rows_store, &iter);
 		gtk_list_store_set (poker->table_rows_store, &iter,
 				    0, description,
@@ -744,18 +752,58 @@ update_if_image (Poker *poker, Accessibl
 }
 
 static void
+process_accessible (Poker *poker, AccessibleSelection *selection, Accessible *child, GtkTreeSelection *view_sel, long i)
+{
+	char *name, *descr;
+	GtkTreeIter    iter;
+	AccessibleRole role;
+	GValue         idx;
+		
+	name = Accessible_getName (child);
+	role = Accessible_getRole (child);
+	descr = Accessible_getDescription (child);
+
+	if (!name || !name [0]) {
+		AccessibleText *text = Accessible_getText (child);
+		SPI_freeString (name);
+		name = AccessibleText_getText (text, 0, -1);
+		AccessibleText_unref (text);
+	}
+
+	memset (&idx, 0, sizeof (GValue));
+	g_value_set_int (g_value_init (&idx, G_TYPE_INT), i);
+	
+	gtk_list_store_append (poker->selection_store, &iter);
+	gtk_list_store_set (poker->selection_store, &iter,
+			    POKER_SELECTION_NAME, name,
+			    POKER_SELECTION_DESCR, descr,
+			    POKER_SELECTION_ICON,
+			    get_pixbuf_for_role (role),
+			    POKER_SELECTION_IDX, &idx, -1);
+
+	if (AccessibleSelection_isChildSelected (selection, i))
+		gtk_tree_selection_select_iter (view_sel, &iter);
+
+	SPI_freeString (descr);
+	SPI_freeString (name);
+	Accessible_unref (child);
+}
+
+
+static void
 update_if_selection (Poker *poker, AccessibleSelection *selection)
 {
-	long i;
-	long children;
+	long i, j, k;
 	Accessible *parent;
+	Accessible *child;
+	AccessibleTable *table;
 	GtkTreeSelection *view_sel;
+	gboolean use_table = FALSE;
 
 	parent = Accessible_queryInterface (
 		selection, "IDL:Accessibility/Accessible:1.0");
 	g_return_if_fail (parent != NULL);
 
-	children = Accessible_getChildCount (parent);
 
 	gtk_list_store_clear (poker->selection_store);
 	view_sel = gtk_tree_view_get_selection (poker->selection_view);
@@ -764,43 +812,32 @@ update_if_selection (Poker *poker, Acces
 
 	gtk_tree_selection_unselect_all (view_sel);
 
-	for (i = 0; i < children; i++) {
-		char *name, *descr;
-		Accessible    *child;
-		GtkTreeIter    iter;
-		AccessibleRole role;
-		GValue         idx;
-		
-		child = Accessible_getChildAtIndex (parent, i);
+	if (use_table_if) {
+		table = Accessible_getTable (parent);
 
-		name = Accessible_getName (child);
-		role = Accessible_getRole (child);
-		descr = Accessible_getDescription (child);
-
-		if (!name || !name [0]) {
-			AccessibleText *text = Accessible_getText (child);
-			SPI_freeString (name);
-			name = AccessibleText_getText (text, 0, -1);
-			AccessibleText_unref (text);
+		if (table)
+			use_table = TRUE;
+	}
+	if (use_table) {
+		for (j = 0; max_children ? j < max_children : TRUE; i++) {
+			for (k = 0; max_children ? k < max_children : TRUE; i++) {
+			
+				child = AccessibleTable_getAccessibleAt (table, j, k);
+				if (!child)
+					break;
+
+				i++;
+				process_accessible (poker, selection, child, view_sel, i);
+			}
+		}
+		Accessible_unref (table);
+	} else {
+		for (i = 0; max_children ? i < max_children : TRUE; i++) {
+			child = Accessible_getChildAtIndex (parent, i);
+			if (!child)
+				break;
+			process_accessible (poker, selection, child, view_sel, i);
 		}
-
-		memset (&idx, 0, sizeof (GValue));
-		g_value_set_int (g_value_init (&idx, G_TYPE_INT), i);
-		
-		gtk_list_store_append (poker->selection_store, &iter);
-		gtk_list_store_set (poker->selection_store, &iter,
-				    POKER_SELECTION_NAME, name,
-				    POKER_SELECTION_DESCR, descr,
-				    POKER_SELECTION_ICON,
-				    get_pixbuf_for_role (role),
-				    POKER_SELECTION_IDX, &idx, -1);
-
-		if (AccessibleSelection_isChildSelected (selection, i))
-			gtk_tree_selection_select_iter (view_sel, &iter);
-
-		SPI_freeString (descr);
-		SPI_freeString (name);
-		Accessible_unref (child);
 	}
 
 	g_signal_handler_unblock (view_sel, poker->selection_changed_id);


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