diff options
author | Li Yuan <li.yuan@sun.com> | 2005-02-25 14:48:18 +0800 |
---|---|---|
committer | Harry Lu <haip@src.gnome.org> | 2005-02-25 14:48:18 +0800 |
commit | 658dcc0fc89eb79a23bf3894975b9f758f4a1e33 (patch) | |
tree | 10e2856710aa28caa6faa73cea01fae214bc1702 /a11y | |
parent | 0ffd23b06370fc3c539cec4905f2c0c439779003 (diff) | |
download | gsoc2013-evolution-658dcc0fc89eb79a23bf3894975b9f758f4a1e33.tar.gz gsoc2013-evolution-658dcc0fc89eb79a23bf3894975b9f758f4a1e33.tar.zst gsoc2013-evolution-658dcc0fc89eb79a23bf3894975b9f758f4a1e33.zip |
Fix for 72897 and 72797. no need to output the information. add instance
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.
svn path=/trunk/; revision=28886
Diffstat (limited to 'a11y')
-rw-r--r-- | a11y/ChangeLog | 23 | ||||
-rw-r--r-- | a11y/ea-cell-table.c | 2 | ||||
-rw-r--r-- | a11y/widgets/ea-calendar-cell.c | 66 | ||||
-rw-r--r-- | a11y/widgets/ea-calendar-cell.h | 1 | ||||
-rw-r--r-- | a11y/widgets/ea-calendar-item.c | 62 |
5 files changed, 132 insertions, 22 deletions
diff --git a/a11y/ChangeLog b/a11y/ChangeLog index 929d778e9c..e9c173661d 100644 --- a/a11y/ChangeLog +++ b/a11y/ChangeLog @@ -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 diff --git a/a11y/ea-cell-table.c b/a11y/ea-cell-table.c index 80f5ecbaaa..c87a63023e 100644 --- a/a11y/ea-cell-table.c +++ b/a11y/ea-cell-table.c @@ -59,8 +59,6 @@ ea_cell_table_destroy (EaCellTable * cell_data) 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]); diff --git a/a11y/widgets/ea-calendar-cell.c b/a11y/widgets/ea-calendar-cell.c index 682485605f..9601d0b259 100644 --- a/a11y/widgets/ea-calendar-cell.c +++ b/a11y/widgets/ea-calendar-cell.c @@ -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 @@ e_calendar_cell_new (ECalendarItem *calitem, gint row, gint column) /* 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 @@ static void component_interface_get_extents (AtkComponent *component, 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 @@ ea_calendar_cell_get_type (void) 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 @@ ea_calendar_cell_class_init (EaCalendarCellClass *klass) 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 @@ ea_calendar_cell_new (GObject *obj) 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 @@ ea_calendar_cell_get_index_in_parent (AtkObject *accessible) 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 @@ atk_component_interface_init (AtkComponentIface *iface) g_return_if_fail (iface != NULL); iface->get_extents = component_interface_get_extents; + iface->grab_focus = component_interface_grab_focus; } static void @@ -323,3 +355,33 @@ component_interface_get_extents (AtkComponent *component, *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; + +} diff --git a/a11y/widgets/ea-calendar-cell.h b/a11y/widgets/ea-calendar-cell.h index f87ede90a7..9cd1ea31f1 100644 --- a/a11y/widgets/ea-calendar-cell.h +++ b/a11y/widgets/ea-calendar-cell.h @@ -74,6 +74,7 @@ typedef struct _EaCalendarCellClass EaCalendarCellClass; struct _EaCalendarCell { AtkGObjectAccessible parent; + AtkStateSet *state_set; }; GType ea_calendar_cell_get_type (void); diff --git a/a11y/widgets/ea-calendar-item.c b/a11y/widgets/ea-calendar-item.c index b80bbdcb77..82af38ecbc 100644 --- a/a11y/widgets/ea-calendar-item.c +++ b/a11y/widgets/ea-calendar-item.c @@ -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 @@ static gboolean selection_interface_is_child_selected (AtkSelection *selection, /* 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 ea_calendar_item_get_row_label (EaCalendarItem *ea_calitem, 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 @@ ea_calendar_item_new (GObject *obj) { 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 @@ ea_calendar_item_new (GObject *obj) 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 @@ static void 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 @@ static void 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 */ @@ -1298,3 +1303,24 @@ e_calendar_item_get_n_days_from_week_start (ECalendarItem *calitem, % 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); +} |