[evolution-patches] gal a11y e-cell and e-table-click-to-add patch



Hi, JP

I just finished the patch for gal/a11y/e-table/gal-a11y-e-cell.c
and gal/a11y/e-table/gal-a11y-e-table-click-to-add.c. It fixes
some a11y bugs. The patch should be used with the gal/e-table
patch I sent to you on Dec 8.

And  for the function etcta_selection_cursor_changed I add in this patch,
it must work with the patch for gal-a11y-e-teble-item.c which I will send
to you latter.

Please help me to review it.

Thank you very much.

Regards,
Li

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.902
diff -u -r1.902 ChangeLog
--- ChangeLog	28 Nov 2004 20:32:01 -0000	1.902
+++ ChangeLog	15 Dec 2004 08:16:54 -0000
@@ -1,3 +1,36 @@
+2004-12-15  Li Yuan  <li yuan sun com>
+
+	* gal/a11y/e-table/gal-a11y-e-cell.c:
+	function name are changed form eti_* to gal_a11y_e_cell_*
+	(is_valid): check if the cell is valid.
+	(gal_a11y_e_cell_dispose): make sure state_set is null.
+	(gal_a11y_e_cell_get_name): implement the get_name function.
+	(gal_a11y_e_cell_ref_state_set): add VISIBLE state.
+	(gal_a11y_e_cell_get_parent): 
+	(gal_a11y_e_cell_get_index_in_parent): 
+	(gal_a11y_e_cell_get_extents): use e_tree_get_cell_geometry and
+	e_table_get_cell_geometry instead of e_table_item_get_cell_geometry.
+	(gal_a11y_e_cell_grab_focus): make grab_focus work with e-tree also.
+	(gal_a11y_e_cell_atk_component_iface_init): 
+	(gal_a11y_e_cell_class_init):add get_name function.
+	(gal_a11y_e_cell_init): add some state to cell.
+	(idle_do_action): check if cell is valid.
+	(gal_a11y_e_cell_action_do_action): check if cell is valid.
+	(gal_a11y_e_cell_get_type): 
+	(gal_a11y_e_cell_construct): ref e-table-item.
+	* gal/a11y/e-table/gal-a11y-e-table-click-to-add.c:
+	(etcta_get_description), (etcta_action_get_name):
+	add i18n support to strings.
+	(etcta_get_name): if etcta has message, return it.
+	(etcta_ref_state_set): implement the ref_state_set function,
+	add SENSITIVE and SHOWING state.
+	(etcta_class_init): add ref_state_set function.
+	(etcta_selection_cursor_changed): call atk_focus_tracker_notify 
+	to a11y-e-cell
+	(gal_a11y_e_table_click_to_add_new): connect 
+	etcta_selection_cursor_changed to cursor_changed signal.
+
+	
 2004-11-28  JP Rosevear  <jpr novell com>
 
 	* configure.in: bump version
Index: gal/a11y/e-table/gal-a11y-e-cell.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-cell.c,v
retrieving revision 1.8
diff -u -r1.8 gal-a11y-e-cell.c
--- gal/a11y/e-table/gal-a11y-e-cell.c	10 Jun 2004 17:00:45 -0000	1.8
+++ gal/a11y/e-table/gal-a11y-e-cell.c	15 Dec 2004 08:17:02 -0000
@@ -8,6 +8,8 @@
 
 #include <config.h>
 #include "gal/e-table/e-table.h"
+#include "gal/e-table/e-tree.h"
+#include "gal-a11y-e-table-item.h"
 #include "gal-a11y-e-cell.h"
 #include "gal-a11y-util.h"
 #include <atk/atkobject.h>
@@ -15,6 +17,7 @@
 #include <atk/atkaction.h>
 #include <atk/atkstateset.h>
 #include <gtk/gtkwindow.h>
+#include <glib/gi18n.h>
 
 #define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yECellClass))
 static GObjectClass *parent_class;
@@ -39,8 +42,28 @@
 }
 #endif 
 
+static gboolean 
+is_valid (AtkObject *cell)
+{
+	GalA11yECell *a11y = GAL_A11Y_E_CELL (cell);
+	GalA11yETableItem *a11yItem = GAL_A11Y_E_TABLE_ITEM (a11y->parent);
+	AtkStateSet *item_ss;
+	gboolean ret = TRUE;
+
+	item_ss = atk_object_ref_state_set (ATK_OBJECT (a11yItem));
+	if (atk_state_set_contains_state (item_ss, ATK_STATE_DEFUNCT))
+		ret = FALSE;
+
+	g_object_unref (item_ss);
+
+	if (ret && atk_state_set_contains_state (a11y->state_set, ATK_STATE_DEFUNCT))
+		ret = FALSE;
+
+	return ret;
+}
+
 static void
-eti_dispose (GObject *object)
+gal_a11y_e_cell_dispose (GObject *object)
 {
 	GalA11yECell *a11y = GAL_A11Y_E_CELL (object);
 
@@ -53,33 +76,60 @@
 		g_object_unref (a11y->parent);
 #endif
 
-	if (a11y->state_set)
+	if (a11y->state_set) {
 		g_object_unref (a11y->state_set);
+		a11y->state_set = NULL;
+	}
 
 	if (parent_class->dispose)
 		parent_class->dispose (object);
 }
 
 /* Static functions */
+static G_CONST_RETURN gchar*
+gal_a11y_e_cell_get_name (AtkObject * a11y)
+{
+	GalA11yECell *cell = GAL_A11Y_E_CELL (a11y);
+        ETableCol *ecol;
+
+	if (a11y->name != NULL && strcmp (a11y->name, ""))
+		return a11y->name;
+
+	if (cell->item != NULL) {
+ 		ecol = e_table_header_get_column (cell->item->header, cell->view_col);
+		if (ecol != NULL)
+			return ecol->text;
+	}
+
+	return _("Table Cell");
+}
+
 static AtkStateSet *
-eti_ref_state_set (AtkObject *accessible)
+gal_a11y_e_cell_ref_state_set (AtkObject *accessible)
 {
 	GalA11yECell *cell = GAL_A11Y_E_CELL (accessible);
+	AtkObject *parent;
+	gint x, y, width, height;
+	gint parent_x, parent_y, parent_width, parent_height;
+
 	g_return_val_if_fail (cell->state_set, NULL);
 
+	gal_a11y_e_cell_add_state (cell, ATK_STATE_VISIBLE, TRUE);
+                                                                              
 	g_object_ref(cell->state_set);
+
 	return cell->state_set;
 }
 
 static AtkObject*
-eti_get_parent (AtkObject *accessible)
+gal_a11y_e_cell_get_parent (AtkObject *accessible)
 {
 	GalA11yECell *a11y = GAL_A11Y_E_CELL (accessible);
 	return a11y->parent;
 }
 
 static gint
-eti_get_index_in_parent (AtkObject *accessible)
+gal_a11y_e_cell_get_index_in_parent (AtkObject *accessible)
 {
 	GalA11yECell *a11y = GAL_A11Y_E_CELL (accessible);
 
@@ -89,7 +139,7 @@
 
 /* Component IFace */
 static void
-eti_get_extents (AtkComponent *component,
+gal_a11y_e_cell_get_extents (AtkComponent *component,
 		gint *x,
 		gint *y,
 		gint *width,
@@ -97,6 +147,7 @@
 		AtkCoordType coord_type)
 {
 	GalA11yECell *a11y = GAL_A11Y_E_CELL (component);
+	GtkWidget *tableOrTree;
 	int row;
 	int col;
 	int xval;
@@ -105,14 +156,16 @@
 	row = a11y->row;
 	col = a11y->view_col;
 
-
-	e_table_item_get_cell_geometry (a11y->item,
-					&row, 
-					&col,
-					&xval,
-					&yval,
-					width,
-					height);
+	tableOrTree = gtk_widget_get_parent (GTK_WIDGET (a11y->item->parent.canvas));
+	if (E_IS_TREE (tableOrTree)) {
+		e_tree_get_cell_geometry (E_TREE (tableOrTree),
+					row, col, &xval, &yval,
+					width, height);
+	} else {
+		e_table_get_cell_geometry (E_TABLE (tableOrTree),
+					row, col, &xval, &yval,
+					width, height);
+	}
 
 	atk_component_get_position (ATK_COMPONENT (a11y->parent),
 				    x, y, coord_type);
@@ -123,22 +176,23 @@
 }
 
 static gboolean
-eti_grab_focus (AtkComponent *component)
+gal_a11y_e_cell_grab_focus (AtkComponent *component)
 {
 	GalA11yECell *a11y;
-	gint view_row;
-	GtkWidget *e_table, *toplevel;
+	gint index;
+	GtkWidget *toplevel;
+	GalA11yETableItem *a11yTableItem;
 
 	a11y = GAL_A11Y_E_CELL (component);
-	e_table = gtk_widget_get_parent (GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas));
-	view_row = e_table_view_to_model_row (E_TABLE (e_table), a11y->row);
-
-	e_selection_model_select_single_row (a11y->item->selection, view_row);
-	e_selection_model_change_cursor (a11y->item->selection, view_row, a11y->view_col);
-
-	gtk_widget_grab_focus (e_table);
-	toplevel = gtk_widget_get_toplevel (e_table);
-	if (GTK_WIDGET_TOPLEVEL (toplevel))
+	a11yTableItem = GAL_A11Y_E_TABLE_ITEM (a11y->parent);
+	index = atk_object_get_index_in_parent (ATK_OBJECT (a11y));
+	
+	atk_selection_clear_selection (ATK_SELECTION (a11yTableItem));
+	atk_selection_add_selection (ATK_SELECTION (a11yTableItem), index);
+	
+	gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas));
+	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas));
+	if (toplevel && GTK_WIDGET_TOPLEVEL (toplevel))
 		gtk_window_present (GTK_WINDOW (toplevel));
 
 	return TRUE;
@@ -147,29 +201,30 @@
 /* Table IFace */
 
 static void
-eti_atk_component_iface_init (AtkComponentIface *iface)
+gal_a11y_e_cell_atk_component_iface_init (AtkComponentIface *iface)
 {
-	iface->get_extents = eti_get_extents;
-	iface->grab_focus  = eti_grab_focus;
+	iface->get_extents = gal_a11y_e_cell_get_extents;
+	iface->grab_focus  = gal_a11y_e_cell_grab_focus;
 }
 
 static void
-eti_class_init (GalA11yECellClass *klass)
+gal_a11y_e_cell_class_init (GalA11yECellClass *klass)
 {
 	AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
 	parent_class                          = g_type_class_ref (PARENT_TYPE);
 
-	object_class->dispose                 = eti_dispose;
+	object_class->dispose                 = gal_a11y_e_cell_dispose;
 
-	atk_object_class->get_parent          = eti_get_parent;
-	atk_object_class->get_index_in_parent = eti_get_index_in_parent;
-	atk_object_class->ref_state_set       = eti_ref_state_set;
+	atk_object_class->get_parent          = gal_a11y_e_cell_get_parent;
+	atk_object_class->get_index_in_parent = gal_a11y_e_cell_get_index_in_parent;
+	atk_object_class->ref_state_set       = gal_a11y_e_cell_ref_state_set;
+	atk_object_class->get_name            = gal_a11y_e_cell_get_name;
 }
 
 static void
-eti_init (GalA11yECell *a11y)
+gal_a11y_e_cell_init (GalA11yECell *a11y)
 {
 	a11y->item = NULL;
 	a11y->cell_view = NULL;
@@ -181,6 +236,10 @@
 	a11y->state_set = atk_state_set_new ();
 	atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT);
 	atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED);
+	atk_state_set_add_state (a11y->state_set, ATK_STATE_SENSITIVE);
+	atk_state_set_add_state (a11y->state_set, ATK_STATE_SELECTABLE);
+	atk_state_set_add_state (a11y->state_set, ATK_STATE_SHOWING);
+	atk_state_set_add_state (a11y->state_set, ATK_STATE_FOCUSABLE);
 }
 
 
@@ -350,6 +409,10 @@
 	GalA11yECell *cell;
 
 	cell = GAL_A11Y_E_CELL (data);
+
+	if (!is_valid (ATK_OBJECT (cell)))
+		return FALSE;
+
 	cell->action_idle_handler = 0;
 	cell->action_func (cell);
                                                                                 
@@ -363,6 +426,9 @@
 	GalA11yECell *cell = GAL_A11Y_E_CELL(action);
 	ActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index);
 
+	if (!is_valid (ATK_OBJECT (action)))
+		return FALSE;
+
 	if (info == NULL)
 		return FALSE;
 	g_return_val_if_fail (info->do_action_func, FALSE);
@@ -477,17 +543,17 @@
 			sizeof (GalA11yECellClass),
 			(GBaseInitFunc) NULL,
 			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) eti_class_init,
+			(GClassInitFunc) gal_a11y_e_cell_class_init,
 			(GClassFinalizeFunc) NULL,
 			NULL, /* class_data */
 			sizeof (GalA11yECell),
 			0,
-			(GInstanceInitFunc) eti_init,
+			(GInstanceInitFunc) gal_a11y_e_cell_init,
 			NULL /* value_cell */
 		};
 
 		static const GInterfaceInfo atk_component_info = {
-			(GInterfaceInitFunc) eti_atk_component_iface_init,
+			(GInterfaceInitFunc) gal_a11y_e_cell_atk_component_iface_init,
 			(GInterfaceFinalizeFunc) NULL,
 			NULL
 		};
@@ -539,17 +605,16 @@
 	a11y->row       = row;
 	ATK_OBJECT (a11y) ->role	= ATK_ROLE_TABLE_CELL;
 
+	if (item)
+		g_object_ref (G_OBJECT (item)); 
+
 #if 0
 	if (parent)
 		g_object_ref (parent);
 
-	if (item)
-		g_object_ref (G_OBJECT (item)); /*,
-						  unref_item,
-						  a11y);*/
 	if (cell_view)
-		g_object_ref (G_OBJECT (cell_view)); /*,
-						  unref_cell,
-						  a11y);*/
+		g_object_ref (G_OBJECT (cell_view)); 
+
+
 #endif
 }
Index: gal/a11y/e-table/gal-a11y-e-table-click-to-add.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-click-to-add.c,v
retrieving revision 1.2
diff -u -r1.2 gal-a11y-e-table-click-to-add.c
--- gal/a11y/e-table/gal-a11y-e-table-click-to-add.c	10 Jun 2004 17:00:45 -0000	1.2
+++ gal/a11y/e-table/gal-a11y-e-table-click-to-add.c	15 Dec 2004 08:17:05 -0000
@@ -13,6 +13,7 @@
 #include <gal/e-table/e-table-click-to-add.h>
 #include <atk/atkcomponent.h>
 #include <atk/atkaction.h>
+#include <glib/gi18n.h>
 
 static AtkObjectClass *parent_class;
 static GType parent_type;
@@ -37,7 +38,7 @@
                              gint      i)
 {
 	if (i == 0)
-		return "click to add";
+		return _("click to add");
 
 	return NULL;
 }
@@ -46,7 +47,7 @@
 etcta_action_get_name (AtkAction *action, gint      i)
 {
 	if (i == 0)
-		return "click";
+		return _("click");
 
 	return NULL;
 }
@@ -104,9 +105,15 @@
 static G_CONST_RETURN gchar *
 etcta_get_name (AtkObject *obj)
 {
+	ETableClickToAdd * etcta;
+
 	g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD (obj), NULL);
 
-	return "click to add";
+	etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj)));
+	if (etcta && etcta->message != NULL)
+		return etcta->message;
+
+	return _("click to add");
 }
 
 static gint
@@ -140,6 +147,20 @@
 	return atk_obj;
 }
 
+static AtkStateSet *
+etcta_ref_state_set (AtkObject *accessible)
+{
+	AtkStateSet * state_set = NULL;
+
+	state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
+	if (state_set != NULL) {
+		atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
+		atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
+	}
+
+	return state_set;
+}
+
 static void
 etcta_class_init (GalA11yETableClickToAddClass *klass)
 {
@@ -150,6 +171,7 @@
 	atk_object_class->get_name = etcta_get_name;
         atk_object_class->get_n_children = etcta_get_n_children;
         atk_object_class->ref_child = etcta_ref_child;
+        atk_object_class->ref_state_set = etcta_ref_state_set;
 }
 
 static void
@@ -241,6 +263,27 @@
 	return TRUE;
 }
 
+static void
+etcta_selection_cursor_changed (ESelectionModel *esm, gint row, gint col,
+			GalA11yETableClickToAdd *a11y)
+{
+	ETableClickToAdd *etcta;
+	AtkObject *row_a11y;
+
+	etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(a11y)));
+
+	if (etcta == NULL || etcta->row == NULL)
+		return;
+
+	row_a11y = atk_gobject_accessible_for_object (G_OBJECT(etcta->row));
+	if (row_a11y) {
+		AtkObject *cell_a11y = g_object_get_data (G_OBJECT(row_a11y), "gail-focus-object");
+		if (cell_a11y) {
+			atk_focus_tracker_notify (cell_a11y);
+		}
+	}
+}
+
 AtkObject *
 gal_a11y_e_table_click_to_add_new (GObject *widget)
 {
@@ -265,5 +308,8 @@
 	g_signal_connect_after (G_OBJECT(widget), "event",
 	    			G_CALLBACK (etcta_event), a11y);
 
+	g_signal_connect (etcta->selection, "cursor_changed",
+			G_CALLBACK (etcta_selection_cursor_changed), a11y);
+
 	return ATK_OBJECT (a11y);
 }



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