[evolution-patches] patch for #51145



Hi Mike,

gal a11y patch again.

see it here:  http://bugzilla.ximian.com/show_bug.cgi?id=51145
Summary: add column headers as children of e-table-item. (impl. get_column_header)

Thanks,
Bolian

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.824
diff -u -r1.824 ChangeLog
--- ChangeLog	17 Nov 2003 21:05:13 -0000	1.824
+++ ChangeLog	19 Nov 2003 07:41:20 -0000
@@ -1,3 +1,17 @@
+2003-11-19  Bolian Yin  <bolian yin sun com>
+                                                                                
+        Fixes #51145
+                                                                                
+        * gal/a11y/gal-a11y-e-table-item (eti_get_column_header): new impl.
+        (eti_ref_child): add column headers as children
+                                                                                
+2003-11-19  Bolian Yin  <bolian yin sun com>
+
+        Fixes #51139
+
+	* gal/a11y/gal-a11y-e-table-item: (gal_a11y_e_table_item_ref_selection)	
+	  (gal_a11y_e_table_item_unref_selection): new functions.
+
 2003-11-17  Mike Kestner  <mkestner ximian com>
 
 	* gal/widgets/gtk-combo* : renamespace and move to
Index: gal/a11y/e-table/gal-a11y-e-table-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-item.c,v
retrieving revision 1.3
diff -u -r1.3 gal-a11y-e-table-item.c
--- gal/a11y/e-table/gal-a11y-e-table-item.c	11 Nov 2003 03:42:58 -0000	1.3
+++ gal/a11y/e-table/gal-a11y-e-table-item.c	19 Nov 2003 07:41:21 -0000
@@ -34,8 +34,13 @@
 	gint index_in_parent;
 	int selection_change_id;
 	int cursor_change_id;
+	ESelectionModel *selection;
 };
 
+static gboolean gal_a11y_e_table_item_ref_selection (GalA11yETableItem *a11y,
+						     ESelectionModel *selection);
+static gboolean gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y);
+
 #if 0
 static void
 unref_accessible (gpointer user_data, GObject *obj_loc)
@@ -90,6 +95,8 @@
 
 	if (parent_class->dispose)
 		parent_class->dispose (object);
+	if (priv->selection)
+		gal_a11y_e_table_item_unref_selection (a11y);
 }
 
 /* Static functions */
@@ -122,7 +129,7 @@
 }
 
 static AtkObject*
-eti_ref_child (AtkObject *accessible, gint i)
+eti_ref_child (AtkObject *accessible, gint index)
 {
 	AtkGObjectAccessible *atk_gobj;
 	ETableItem *item;
@@ -133,8 +140,19 @@
 	if (!item)
 		return NULL;
 
-	col = i % item->cols;
-	row = i / item->cols;
+	if (index < item->cols) {
+		AtkObject *child;
+
+		/* A column header is required */
+		child = atk_table_get_column_header (ATK_TABLE (accessible), index);
+		if (child)
+			g_object_ref (child);
+		return child;
+	}
+
+	index -= item->cols;
+	col = index % item->cols;
+	row = index / item->cols;
 
 	return atk_table_ref_at (ATK_TABLE (accessible), row, col);
 }
@@ -384,11 +402,22 @@
 }
 
 static AtkObject *
-eti_get_column_header (AtkTable *table,
-		       gint column)
+eti_get_column_header (AtkTable *table, gint column)
 {
-	/* Unimplemented */
-	return NULL;
+	ETableItem *item;
+	ETableCol *ecol;
+	AtkObject *atk_obj = NULL;
+	ECell *ecell;
+
+	item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
+	if (!item)
+		return NULL;
+
+	ecol = e_table_header_get_column (item->header, column);
+	ecell = ecol->ecell;
+	if (ecell)
+		atk_obj = atk_gobject_accessible_for_object (G_OBJECT (ecell));
+	return atk_obj;
 }
 
 static G_CONST_RETURN gchar *
@@ -471,7 +500,8 @@
 
 	if (table_is_row_selected (table, row))
 		return TRUE;
-	e_selection_model_toggle_single_row (item->selection, view_to_model_row (item, row));
+	e_selection_model_toggle_single_row (item->selection,
+					     view_to_model_row (item, row));
 
 	return TRUE;
 }
@@ -554,6 +584,7 @@
 	priv->index_in_parent = -1;
 	priv->selection_change_id = 0;
 	priv->cursor_change_id = 0;
+	priv->selection = NULL;
 }
 
 /* atk selection */
@@ -575,9 +606,11 @@
 static void eti_a11y_selection_model_added_cb (ETableItem *eti,
 					       ESelectionModel *selection,
 					       gpointer data);
-static void eti_a11y_selection_changed_cb (ESelectionModel *selection, GalA11yETableItem *a11y);
+static void eti_a11y_selection_changed_cb (ESelectionModel *selection,
+					   GalA11yETableItem *a11y);
 static void eti_a11y_cursor_changed_cb (ESelectionModel *selection,
-					int row, int col,  GalA11yETableItem *a11y);
+					int row, int col,
+					GalA11yETableItem *a11y);
 
 /**
  * gal_a11y_e_table_item_get_type:
@@ -660,16 +693,9 @@
 				  G_CALLBACK (eti_a11y_selection_model_removed_cb), NULL);
 		g_signal_connect (G_OBJECT(item), "selection_model_added",
 				  G_CALLBACK (eti_a11y_selection_model_added_cb), NULL);
-		if (item->selection) {
-			GET_PRIVATE (a11y)->selection_change_id = g_signal_connect (
-				    G_OBJECT(item->selection), "selection_changed",
-				    G_CALLBACK (eti_a11y_selection_changed_cb), a11y);
-			GET_PRIVATE (a11y)->cursor_change_id = g_signal_connect (
- 				    G_OBJECT(item->selection), "cursor_changed",
-				    G_CALLBACK (eti_a11y_cursor_changed_cb), a11y);
-
-			g_object_ref (item->selection);
-		}
+		if (item->selection)
+			gal_a11y_e_table_item_ref_selection (a11y,
+							     item->selection);
 	}
 	if (parent)
 		g_object_ref (parent);
@@ -684,6 +710,53 @@
 	return ATK_OBJECT (a11y);
 }
 
+static gboolean
+gal_a11y_e_table_item_ref_selection (GalA11yETableItem *a11y,
+				     ESelectionModel *selection)
+{
+	GalA11yETableItemPrivate *priv;
+
+	g_return_val_if_fail (a11y && selection, FALSE);
+
+	priv = GET_PRIVATE (a11y);
+	priv->selection_change_id = g_signal_connect (
+	    G_OBJECT(selection), "selection_changed",
+	    G_CALLBACK (eti_a11y_selection_changed_cb), a11y);
+	priv->cursor_change_id = g_signal_connect (
+            G_OBJECT(selection), "cursor_changed",
+	    G_CALLBACK (eti_a11y_cursor_changed_cb), a11y);
+
+	priv->selection = selection;
+	g_object_ref (selection);
+
+	return TRUE;
+}
+
+static gboolean
+gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y)
+{
+	GalA11yETableItemPrivate *priv;
+
+	g_return_val_if_fail (a11y, FALSE);
+
+	priv = GET_PRIVATE (a11y);
+
+	g_return_val_if_fail (priv->selection_change_id != 0, FALSE);
+	g_return_val_if_fail (priv->cursor_change_id != 0, FALSE);
+
+
+	g_signal_handler_disconnect (priv->selection,
+				     priv->selection_change_id);
+	g_signal_handler_disconnect (priv->selection,
+				     priv->cursor_change_id);
+	priv->cursor_change_id = 0;
+	priv->selection_change_id = 0;
+
+	g_object_unref (priv->selection);
+	priv->selection = NULL;
+
+	return TRUE;
+}
 
 /* callbacks */
 
@@ -700,16 +773,8 @@
 	atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti));
 	a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj);
 
-	if (GET_PRIVATE (a11y)->selection_change_id != 0 &&
-	    GET_PRIVATE (a11y)->cursor_change_id != 0) {
-		g_signal_handler_disconnect (selection,
-					     GET_PRIVATE (a11y)->selection_change_id);
-		g_signal_handler_disconnect (selection,
-					     GET_PRIVATE (a11y)->cursor_change_id);
-		GET_PRIVATE (a11y)->cursor_change_id = 0;
-		GET_PRIVATE (a11y)->selection_change_id = 0;
-		g_object_unref (selection);
-	}
+	if (selection == GET_PRIVATE (a11y)->selection)
+		gal_a11y_e_table_item_unref_selection (a11y);
 }
 
 static void
@@ -725,14 +790,9 @@
 	atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti));
 	a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj);
 
-	GET_PRIVATE (a11y)->selection_change_id = g_signal_connect (
-		    G_OBJECT(selection), "selection_changed",
-		    G_CALLBACK (eti_a11y_selection_changed_cb), a11y);
-	GET_PRIVATE (a11y)->cursor_change_id = g_signal_connect (
-                    G_OBJECT(selection), "cursor_changed",
-		    G_CALLBACK (eti_a11y_cursor_changed_cb), a11y);
-
-	g_object_ref (selection);
+	if (GET_PRIVATE (a11y)->selection)
+		gal_a11y_e_table_item_unref_selection (a11y);
+	gal_a11y_e_table_item_ref_selection (a11y, selection);
 }
 
 static void


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