[evolution-patches] bug 51151, gal: AT application can't recognize whether a tree cell is expanded or not



Hi Mike,
   Would you please take a look at this patch.
   This is part of a11y implementation for ETable and ETree.
   After applying this patch gnopernicus can recognize whether a tree
cell is expanded or not.

   In this patch 3 files in gal/a11y/e-table dir are modified.
1) gal-a11y-e-cell-tree.c: connect to the "model_row_change" signal, so
that when the tree cell is expanded or collapsed, its corresponding a11y
object will be notified and set/remove the flag of ATK_STATE_EXPANDED.

2) gal-a11y-e-cell-tree.h: add one member to save the connected signal
id.

3) gal-a11y-e-cell-toggle.c: use table item to get the model. Sometimes
the model in the cell_view is NULL, so to use item to get the model is
more safe.


Tim
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.826
diff -u -r1.826 ChangeLog
--- ChangeLog	21 Nov 2003 04:28:02 -0000	1.826
+++ ChangeLog	22 Nov 2003 10:01:34 -0000
@@ -1,3 +1,20 @@
+2003-11-22  Tim Wo  <tim wo sun com>
+
+	* gal/a11y/e-table/gal-a11y-e-cell-toggle.c:
+	(gal_a11y_e_cell_toggle_dispose): use table item to get the model.
+	(gal_a11y_e_cell_toggle_new): use table item to get the model.
+	* gal/a11y/e-table/gal-a11y-e-cell-tree.c:
+	(ectr_model_row_changed_cb): new function to deal with tree cell
+	expansion and collapse
+	(ectr_subcell_weak_ref): destroy the cell_tree a11y instance along
+	with it's subcell's a11y instance.
+	(gal_a11y_e_cell_tree_new): init the atk state of the tree cell,
+	and connect to the model_row_change signal of table model, so that
+	when the tree cell expands or collapses, the corresponding AtkState
+	could be set.
+	* gal/a11y/e-table/gal-a11y-e-cell-tree.h: add one member to save
+	the connected signal id.
+
 2003-11-21  Tim Wo  <tim wo sun com>
 
 	* gal/a11y/e-table/gal-a11y-e-cell-text.c: (ect_get_name): override
Index: gal/a11y/e-table/gal-a11y-e-cell-toggle.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-cell-toggle.c,v
retrieving revision 1.2
diff -u -r1.2 gal-a11y-e-cell-toggle.c
--- gal/a11y/e-table/gal-a11y-e-cell-toggle.c	21 Nov 2003 04:28:04 -0000	1.2
+++ gal/a11y/e-table/gal-a11y-e-cell-toggle.c	22 Nov 2003 10:01:34 -0000
@@ -13,7 +13,7 @@
 {
 	GalA11yECellToggle *a11y = GAL_A11Y_E_CELL_TOGGLE (object);
 
-	ETableModel *e_table_model = GAL_A11Y_E_CELL (a11y)->cell_view->e_table_model;
+	ETableModel *e_table_model = GAL_A11Y_E_CELL (a11y)->item->table_model;
 
 	if (e_table_model)
 		g_signal_handler_disconnect (e_table_model, a11y->model_id);
@@ -146,7 +146,7 @@
 				    NULL,              /* action keybinding */
 				    toggle_cell_action);
 
-	toggle_cell->model_id = g_signal_connect (cell_view->e_table_model,
+	toggle_cell->model_id = g_signal_connect (item->table_model,
 						  "model_cell_changed",
 						  (GCallback) model_change_cb,
 						  a11y);
Index: gal/a11y/e-table/gal-a11y-e-cell-tree.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-cell-tree.c,v
retrieving revision 1.1
diff -u -r1.1 gal-a11y-e-cell-tree.c
--- gal/a11y/e-table/gal-a11y-e-cell-tree.c	12 Nov 2003 05:12:04 -0000	1.1
+++ gal/a11y/e-table/gal-a11y-e-cell-tree.c	22 Nov 2003 10:01:34 -0000
@@ -7,7 +7,7 @@
  */
 
 #include <config.h>
-#include <atk/atkaction.h>
+#include <atk/atk.h>
 #include "gal-a11y-e-cell-tree.h"
 #include "gal-a11y-util.h"
 #include "gal/e-table/e-cell-tree.h"
@@ -19,6 +19,41 @@
 #define A11Y_PARENT_TYPE (gal_a11y_e_cell_get_type ())
 
 static void
+ectr_model_row_changed_cb (ETableModel *etm,
+			   gint row,
+			   GalA11yECell *a11y)
+{
+	ETreePath node;
+	ETreeModel *tree_model;
+	ETreeTableAdapter *tree_table_adapter;
+
+	g_return_if_fail (a11y);
+	if (a11y->row != row)
+		return;
+
+	node = e_table_model_value_at (etm, -1, a11y->row);
+	tree_model = e_table_model_value_at (etm, -2, a11y->row);
+	tree_table_adapter = e_table_model_value_at (etm, -3, a11y->row);
+
+	if (e_tree_model_node_is_expandable (tree_model, node)) {
+		gboolean is_exp = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
+		if (is_exp)
+			gal_a11y_e_cell_add_state (a11y, ATK_STATE_EXPANDED, TRUE);
+		else
+			gal_a11y_e_cell_remove_state (a11y, ATK_STATE_EXPANDED, TRUE);
+	}
+}
+
+static void
+ectr_subcell_weak_ref (GalA11yECellTree *a11y,
+		       GalA11yECell     *subcell_a11y)
+{
+	g_signal_handler_disconnect (GAL_A11Y_E_CELL (a11y)->item->table_model,
+				     a11y->model_row_changed_id);
+	g_object_unref (a11y);
+}
+
+static void
 ectr_do_action_expand (AtkAction *action)
 {
 	GalA11yECell *a11y;
@@ -109,46 +144,66 @@
 			  int         view_col,
 			  int         row)
 {
-	GalA11yECell *a11y;
+	AtkObject *subcell_a11y;
+	GalA11yECellTree *a11y;
         GtkWidget *e_table;
-        gint model_row;
 
+        ETreePath node;
+        ETreeModel *tree_model;
+        ETreeTableAdapter *tree_table_adapter;
+ 
 	ECellView *subcell_view;
 	subcell_view = e_cell_tree_view_get_subcell_view (cell_view);
 
 	if (subcell_view->ecell) {
-		a11y = gal_a11y_e_cell_registry_get_object (NULL,
-							    item,
-							    subcell_view,
-							    parent,
-							    model_col,
-							    view_col,
-							    row);
-	} else {
-		a11y = g_object_new (gal_a11y_e_cell_tree_get_type (), NULL);
-
-		gal_a11y_e_cell_construct (a11y,
-					   item,
-					   cell_view,
-					   parent,
-					   model_col,
-					   view_col,
-					   row);
+		subcell_a11y = gal_a11y_e_cell_registry_get_object (NULL,
+								    item,
+								    subcell_view,
+								    parent,
+								    model_col,
+								    view_col,
+								    row);
+		gal_a11y_e_cell_add_action (subcell_a11y,
+					    "expand",
+					    "expands the row in the ETree containing this cell",
+					    NULL,
+					    (ACTION_FUNC)ectr_do_action_expand);
+
+		gal_a11y_e_cell_add_action (subcell_a11y,
+					    "collapse",
+					    "collapses the row in the ETree containing this cell",
+					    NULL,
+					    (ACTION_FUNC)ectr_do_action_collapse);
+
+		/* init AtkStates for the cell's a11y object */
+		node = e_table_model_value_at (item->table_model, -1, row);
+		tree_model = e_table_model_value_at (item->table_model, -2, row);
+		tree_table_adapter = e_table_model_value_at (item->table_model, -3, row);
+		if (e_tree_model_node_is_expandable (tree_model, node)) {
+			gal_a11y_e_cell_add_state (subcell_a11y, ATK_STATE_EXPANDABLE, FALSE);
+			if (e_tree_table_adapter_node_is_expanded (tree_table_adapter, node))
+				gal_a11y_e_cell_add_state (subcell_a11y, ATK_STATE_EXPANDED, FALSE);
+		}
 	}
+	else
+		subcell_a11y = NULL;
 
-	gal_a11y_e_cell_add_action (a11y,
-				    "expand",
-				    "expands the row in the ETree containing this cell",
-				    NULL,
-				    (ACTION_FUNC)ectr_do_action_expand);
-
-	gal_a11y_e_cell_add_action (a11y,
-				    "collapse",
-				    "collapses the row in the ETree containing this cell",
-				    NULL,
-				    (ACTION_FUNC)ectr_do_action_collapse);
-
-	gal_a11y_e_cell_add_state (a11y, ATK_STATE_EXPANDABLE, FALSE);
+	/* create a companion a11y object, this object has type GalA11yECellTree
+	   and it connects to some signals to determine whether a tree cell is
+	   expanded or collapsed */
+	a11y = g_object_new (gal_a11y_e_cell_tree_get_type (), NULL);
+	gal_a11y_e_cell_construct (a11y,
+				   item,
+				   cell_view,
+				   parent,
+				   model_col,
+				   view_col,
+				   row);
+	a11y->model_row_changed_id =
+		g_signal_connect (item->table_model, "model_row_changed",
+				  G_CALLBACK (ectr_model_row_changed_cb),
+				  subcell_a11y);
+	g_object_weak_ref (subcell_a11y, ectr_subcell_weak_ref, a11y);
 
-	return a11y;
+	return subcell_a11y;
 }
Index: gal/a11y/e-table/gal-a11y-e-cell-tree.h
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-cell-tree.h,v
retrieving revision 1.1
diff -u -r1.1 gal-a11y-e-cell-tree.h
--- gal/a11y/e-table/gal-a11y-e-cell-tree.h	12 Nov 2003 05:12:04 -0000	1.1
+++ gal/a11y/e-table/gal-a11y-e-cell-tree.h	22 Nov 2003 10:01:34 -0000
@@ -29,6 +29,8 @@
  **/
 struct _GalA11yECellTree {
 	GalA11yECell object;
+
+	int model_row_changed_id;
 };
 
 struct _GalA11yECellTreeClass {


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