[evolution-patches] patch to fix 72897 and 72797



Hi, Rodrigo

Here is a patch to fix 72897 and 72797. Please help me to review it.
Thank you very much.

Regards,
Li
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ChangeLog,v
retrieving revision 1.33
diff -u -r1.33 ChangeLog
--- ChangeLog	22 Feb 2005 03:24:40 -0000	1.33
+++ ChangeLog	23 Feb 2005 09:55:03 -0000
@@ -1,3 +1,26 @@
+2005-02-23  Li Yuan  <li yuan sun com>
+
+	Fix for 72897 and 72797.
+	* ea-cell-table.c: 
+	(ea_cell_table_destroy): no need to output the information.
+	* widgets/ea-calendar-cell.c: 
+	(ea_calendar_cell_get_type): add instance init function.
+	(ea_calendar_cell_class_init): add ref_state_set function.
+	(ea_calendar_cell_init): instance init function.
+	(ea_calendar_cell_new): change the cell's role to ATK_ROLE_TABLE_CELL.
+	(ea_calendar_cell_ref_state_set): the ref_state_set function.
+	(atk_component_interface_init),
+	(component_interface_get_extents),
+	(component_interface_grab_focus): implement grab focus function.
+	* widgets/ea-calendar-cell.h:
+	add the state_set variable.
+	* widgets/ea-calendar-item.c: 
+	(ea_calendar_item_new): change the item's role to ATK_ROLE_CALENDAR.
+	no need to connect "selection_preview_changed" signal here.
+	(date_range_changed_cb): call ea_calendar_set_focus_object.
+	(ea_calendar_set_focus_object): make the "gail-focus-object" of the item
+	point to the focused cell.
+
 2005-02-21  Harry Lu <harry lu sun com>
 
 	Fix for 72781
Index: ea-cell-table.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ea-cell-table.c,v
retrieving revision 1.1
diff -u -r1.1 ea-cell-table.c
--- ea-cell-table.c	4 Nov 2003 08:15:56 -0000	1.1
+++ ea-cell-table.c	23 Feb 2005 09:55:03 -0000
@@ -59,8 +59,6 @@
 	gint index;
 	g_return_if_fail (cell_data);
 
-	g_print ("destroy cell table (%d, %d)\n", cell_data->rows,
-		  cell_data->columns);
 	for (index = 0; index < cell_data->columns; ++index)
 		if (cell_data->column_labels [index])
 			g_free (cell_data->column_labels [index]);
Index: widgets/ea-calendar-cell.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-cell.c,v
retrieving revision 1.3
diff -u -r1.3 ea-calendar-cell.c
--- widgets/ea-calendar-cell.c	30 Sep 2004 07:32:36 -0000	1.3
+++ widgets/ea-calendar-cell.c	23 Feb 2005 09:55:14 -0000
@@ -23,6 +23,8 @@
  *
  */
 
+#include <gtk/gtk.h>
+#include <gal/util/e-util.h>
 #include "ea-calendar-cell.h"
 #include "ea-calendar-item.h"
 #include "ea-factory.h"
@@ -89,11 +91,13 @@
 /* EaCalendarCell */
 
 static void ea_calendar_cell_class_init (EaCalendarCellClass *klass);
+static void ea_calendar_cell_init (EaCalendarCell *a11y);
 
 static G_CONST_RETURN gchar* ea_calendar_cell_get_name (AtkObject *accessible);
 static G_CONST_RETURN gchar* ea_calendar_cell_get_description (AtkObject *accessible);
 static AtkObject * ea_calendar_cell_get_parent (AtkObject *accessible);
 static gint ea_calendar_cell_get_index_in_parent (AtkObject *accessible);
+static AtkStateSet *ea_calendar_cell_ref_state_set (AtkObject *accessible);
 
 /* component interface */
 static void atk_component_interface_init (AtkComponentIface *iface);
@@ -101,6 +105,7 @@
 					     gint *x, gint *y,
 					     gint *width, gint *height,
 					     AtkCoordType coord_type);
+static gboolean component_interface_grab_focus (AtkComponent *component);
 
 static gpointer parent_class = NULL;
 
@@ -124,7 +129,7 @@
 			NULL, /* class data */
 			sizeof (EaCalendarCell), /* instance size */
 			0, /* nb preallocs */
-			(GInstanceInitFunc) NULL, /* instance init */
+			(GInstanceInitFunc) ea_calendar_cell_init, /* instance init */
 			NULL /* value table */
 		};
 
@@ -160,6 +165,19 @@
 
 	class->get_parent = ea_calendar_cell_get_parent;
 	class->get_index_in_parent = ea_calendar_cell_get_index_in_parent;
+	class->ref_state_set = ea_calendar_cell_ref_state_set;
+}
+
+static void
+ea_calendar_cell_init (EaCalendarCell *a11y)
+{
+	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);
 }
 
 AtkObject* 
@@ -172,7 +190,7 @@
 	object = g_object_new (EA_TYPE_CALENDAR_CELL, NULL);
 	atk_object = ATK_OBJECT (object);
 	atk_object_initialize (atk_object, obj);
-	atk_object->role = ATK_ROLE_UNKNOWN;
+	atk_object->role = ATK_ROLE_TABLE_CELL;
 
 #ifdef ACC_DEBUG
 	++n_ea_calendar_cell_created;
@@ -268,6 +286,19 @@
 				       cell->row, cell->column);
 }
 
+static AtkStateSet *
+ea_calendar_cell_ref_state_set (AtkObject *accessible)
+{
+	EaCalendarCell *atk_cell = EA_CALENDAR_CELL (accessible);
+
+	g_return_val_if_fail (atk_cell->state_set, NULL);
+
+	g_object_ref(atk_cell->state_set);
+
+	return atk_cell->state_set;
+	
+}
+
 /* Atk Component Interface */
 
 static void 
@@ -276,6 +307,7 @@
 	g_return_if_fail (iface != NULL);
 
 	iface->get_extents = component_interface_get_extents;
+	iface->grab_focus  = component_interface_grab_focus;
 }
 
 static void 
@@ -322,4 +354,34 @@
 					     coord_type);
 	*x += canvas_x;
 	*y += canvas_y;
+}
+
+static gboolean
+component_interface_grab_focus (AtkComponent *component)
+{
+	GObject *g_obj;
+	GtkWidget *toplevel;
+	AtkObject *ea_calitem;
+	ECalendarItem *calitem;
+	EaCalendarCell *a11y;
+	gint index;
+
+	a11y = EA_CALENDAR_CELL (component);
+	ea_calitem = ea_calendar_cell_get_parent (ATK_OBJECT (a11y));
+
+	g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(ea_calitem));
+	calitem = E_CALENDAR_ITEM (g_obj);
+
+	index = atk_object_get_index_in_parent (ATK_OBJECT (a11y));
+	
+	atk_selection_clear_selection (ATK_SELECTION (ea_calitem));
+	atk_selection_add_selection (ATK_SELECTION (ea_calitem), index);
+	
+	gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas));
+	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas));
+	if (toplevel && GTK_WIDGET_TOPLEVEL (toplevel))
+		gtk_window_present (GTK_WINDOW (toplevel));
+
+	return TRUE;
+
 }
Index: widgets/ea-calendar-cell.h
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-cell.h,v
retrieving revision 1.1
diff -u -r1.1 ea-calendar-cell.h
--- widgets/ea-calendar-cell.h	11 Nov 2003 10:33:43 -0000	1.1
+++ widgets/ea-calendar-cell.h	23 Feb 2005 09:55:31 -0000
@@ -74,6 +74,7 @@
 struct _EaCalendarCell
 {
 	AtkGObjectAccessible parent;
+	AtkStateSet *state_set;
 };
 
 GType ea_calendar_cell_get_type (void);
Index: widgets/ea-calendar-item.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-item.c,v
retrieving revision 1.6
diff -u -r1.6 ea-calendar-item.c
--- widgets/ea-calendar-item.c	2 Feb 2005 02:10:09 -0000	1.6
+++ widgets/ea-calendar-item.c	23 Feb 2005 09:55:32 -0000
@@ -30,6 +30,7 @@
 #include <glib/gdate.h>
 #include <gal/util/e-util.h>
 #include <libgnome/gnome-i18n.h>
+#include <gal/util/e-util.h>
 #include "ea-calendar-item.h"
 #include "ea-calendar-cell.h"
 #include "ea-cell-table.h"
@@ -112,7 +113,6 @@
 /* callbacks */
 static void selection_preview_change_cb (ECalendarItem *calitem);
 static void date_range_changed_cb (ECalendarItem *calitem);
-static void selection_changed_cb (ECalendarItem *calitem);
 
 /* helpers */
 static EaCellTable *ea_calendar_item_get_cell_data (EaCalendarItem *ea_calitem);
@@ -128,6 +128,8 @@
 static gboolean e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
 						     gint year, gint month, gint day,
 						     gint *offset);
+static void ea_calendar_set_focus_object (EaCalendarItem *ea_calitem, 
+					  AtkObject *item_cell);
 
 #ifdef ACC_DEBUG
 static gint n_ea_calendar_item_created = 0;
@@ -215,12 +217,19 @@
 {
 	gpointer object;
 	AtkObject *atk_object;
+	AtkObject *item_cell;
 
 	g_return_val_if_fail (E_IS_CALENDAR_ITEM (obj), NULL);
 	object = g_object_new (EA_TYPE_CALENDAR_ITEM, NULL);
 	atk_object = ATK_OBJECT (object);
 	atk_object_initialize (atk_object, obj);
-	atk_object->role = ATK_ROLE_TABLE;
+	atk_object->role = ATK_ROLE_CALENDAR;
+
+	item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_object),
+							0);
+	if (item_cell)
+		ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_object), item_cell);
+
 #ifdef ACC_DEBUG
 	++n_ea_calendar_item_created;
 	g_print ("ACC_DEBUG: n_ea_calendar_item_created = %d\n",
@@ -233,9 +242,6 @@
 	g_signal_connect (obj, "date_range_changed",
 			  G_CALLBACK (date_range_changed_cb),
 			  atk_object);
-	g_signal_connect (obj, "selection_preview_changed",
-			  G_CALLBACK (selection_changed_cb),
-			  atk_object);
 
 	return atk_object;
 }
@@ -992,20 +998,19 @@
 selection_preview_change_cb (ECalendarItem *calitem)
 {
 	AtkObject *atk_obj;
-	AtkObject *item_cell = NULL;
+	AtkObject *item_cell;
 
 	g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
 	atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
+	ea_calendar_item_destory_cell_data (EA_CALENDAR_ITEM (atk_obj));
 
 	/* only deal with the first selected child, for now */
 	item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_obj),
 						 0);
-	if (item_cell) {
-		AtkStateSet *state_set;
-		state_set = atk_object_ref_state_set (item_cell);
-		atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
-		g_object_unref (state_set);
-	}
+
+	if (item_cell)
+		ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_obj), item_cell);
+
 	g_signal_emit_by_name (atk_obj,
 			       "active-descendant-changed",
 			       item_cell);
@@ -1016,18 +1021,18 @@
 date_range_changed_cb (ECalendarItem *calitem)
 {
 	AtkObject *atk_obj;
+	AtkObject *item_cell;
 
 	g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
 	atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
 	ea_calendar_item_destory_cell_data (EA_CALENDAR_ITEM (atk_obj));
 
-	g_signal_emit_by_name (atk_obj, "model_changed");
-}
+	item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_obj),
+							0);
+	if (item_cell)
+		ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_obj), item_cell);
 
-static void
-selection_changed_cb (ECalendarItem *calitem)
-{
-	selection_preview_change_cb (calitem);
+	g_signal_emit_by_name (atk_obj, "model_changed");
 }
 
 /* helpers */
@@ -1297,4 +1302,25 @@
 	days_from_week_start = (start_weekday + 7 - calitem->week_start_day)
 		% 7;
 	return days_from_week_start;
+}
+
+static void
+ea_calendar_set_focus_object (EaCalendarItem *ea_calitem, AtkObject *item_cell)
+{
+	AtkStateSet *state_set, *old_state_set;
+	AtkObject *old_cell;
+
+	old_cell = (AtkObject *)g_object_get_data (G_OBJECT(ea_calitem), "gail-focus-object");
+	if (old_cell && EA_IS_CALENDAR_CELL (old_cell)) {
+		old_state_set = atk_object_ref_state_set (old_cell);
+		atk_state_set_remove_state (old_state_set, ATK_STATE_FOCUSED);
+		g_object_unref (old_state_set);
+	}
+	if (old_cell)
+		g_object_unref (old_cell);
+
+	state_set = atk_object_ref_state_set (item_cell);
+	atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
+	g_object_set_data (G_OBJECT(ea_calitem), "gail-focus-object", item_cell);
+	g_object_unref (state_set);
 }


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