diff options
author | Li Yuan <li.yuan@sun.com> | 2005-01-27 13:28:27 +0800 |
---|---|---|
committer | Harry Lu <haip@src.gnome.org> | 2005-01-27 13:28:27 +0800 |
commit | 0dcae6d9d8e91ff3e9592cea78f5d43da3477beb (patch) | |
tree | fab192fb0b14d0cf3bf6c1f29dc639ed36b9b013 /a11y/e-table/gal-a11y-e-cell.c | |
parent | d8d481373ff47bc77432b2f8d8de91afd1bd02a0 (diff) | |
download | gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.tar gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.tar.gz gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.tar.bz2 gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.tar.lz gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.tar.xz gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.tar.zst gsoc2013-evolution-0dcae6d9d8e91ff3e9592cea78f5d43da3477beb.zip |
add gal-a11y-e-cell-vbox.h and gal-a11y-e-cell-vbox.c
2005-01-27 Li Yuan <li.yuan@sun.com>
* gal/a11y/e-table/Makefile.am:
add gal-a11y-e-cell-vbox.h and gal-a11y-e-cell-vbox.c
* gal/a11y/e-table/gal-a11y-e-cell-popup.c:
(gal_a11y_e_cell_popup_new):
add i18n support to strings.
Fixes #70261
* gal/a11y/e-table/gal-a11y-e-cell-text.c:
(ect_dispose): disconnect the insert and the delete signal.
(ect_check):do some check works.
(ect_get_name), (ect_get_text),
(ect_get_character_at_offset), (ect_get_caret_offset),
(ect_get_character_count), (ect_get_n_selections),
(ect_get_selection), (ect_add_selection), (ect_set_caret_offset),
(ect_insert_text): use e_cell_text_get_text_by_view instead of
e_cell_text_get_text. make get_name work well when e-cell-text
is being edited.
(ect_do_action_edit): call e_table_item_enter_edit only when
the cell is editable.
(ect_text_inserted_cb), (ect_text_deleted_cb):
emit the text_changed::insert(delete) signal. make gnopernicus
know the text_changed.
(ect_class_init): add dispose function.
(ect_action_init): add the edit action.
(gal_a11y_e_cell_text_get_type): no ect_init function now.
(cell_text_destroyed): unref the atkobject.
(gal_a11y_e_cell_text_new): connect text_inserted and text_deleted
singals and make sure the state of editable is right.
* gal/a11y/e-table/gal-a11y-e-cell-text.h:
add two signal handler id.
* gal/a11y/e-table/gal-a11y-e-cell-toggle.c:
(gal_a11y_e_cell_toggle_dispose): fix #70261.
(model_change_cb): make gnopernicus to report state change signal.
(gal_a11y_e_cell_toggle_new):add i18n support to strings.
* gal/a11y/e-table/gal-a11y-e-cell-tree.c:
(gal_a11y_e_cell_tree_new):
add i18n support to strings.
Fixes #61688
* gal/a11y/e-table/gal-a11y-e-cell-vbox.c: (ecv_get_n_children),
(subcell_destroyed), (ecv_ref_child), (ecv_dispose),
(ecv_ref_accessible_at_point), (ecv_class_init), (ecv_init),
(ecv_atk_component_iface_init), (gal_a11y_e_cell_vbox_get_type),
(gal_a11y_e_cell_vbox_new):
* gal/a11y/e-table/gal-a11y-e-cell-vbox.h:
implement a11y object of ECellVbox.
Fixes #48976
* 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.
* gal/a11y/e-table/gal-a11y-e-table-item-factory.c:
(gal_a11y_e_table_item_factory_create_accessible):
parameters of gal_a11y_e_table_item_new have been changed.
Fixes #68675
Fixes #70324
Fixes #68681
Fixes #68627
* gal/a11y/e-table/gal-a11y-e-table-item.c:
remove the cell_data support.
(item_destroyed): add ATK_STATE_DEFUNCT state and unref selection.
(eti_ref_state_set): just ref state_set.
(eti_dispose): we have unref selection in item_destroyed.
remove the cell_data support.
(eti_ref_child): remove support for column header. use eti_ref_at
instead of atk_table_ref_at.
(eti_get_extents): add support for click to add.
(eti_ref_accessible_at_point): e-tree and e-table are different here.
(cell_destroyed): add a check and unref item. remove the cell_data support.
(eti_ref_at): if e-table-item has DEFUNCT state, return NULL.
remove the cell_data support.
(eti_get_column_header): use column name as the a11y name. set it role
as ATK_ROLE_TABLE_COLUMN_HEADER.
(table_is_row_selected): use view_to_model_row to convert row when
uses source model.
(table_get_selected_rows): if e-table-item has DEFUNCT state, return 0.
(table_remove_row_selection): use view_to_model_row to convert row
when uses source model.
(eti_rows_inserted), (eti_rows_deleted): remove the cell_data support.
(eti_tree_model_node_changed_cb): emit visible-data-changed signal. for
the eti_clear_rows have been removed.
(eti_header_structure_changed): remove the cell_data support.
(eti_class_init): add eti_ref_state_set, remove eti_get_parent
and eti_get_index_in_parent.
(eti_init): init parent and index_in_parent.
(gal_a11y_e_table_item_new): add some states. get name form parents.
init role correctly. add FOCUSED state to focused cell.
remove the cell_data support.
(eti_a11y_selection_changed_cb): if e-table-item has DEFUNCT state,
just return.
(eti_a11y_cursor_changed_cb): remove the FOCUESD state form the old cell.
(selection_add_selection): if it has been focused already, just return.
if another row was focused, clear it first.
(selection_ref_selection): use eti_ref_at instead of atk_table_ref_at.
(gal_a11y_e_table_item_init): add this function.
* gal/a11y/e-table/gal-a11y-e-table-item.h:
add gal_a11y_e_table_item_init and change the parameters of
gal_a11y_e_table_item_new.
* gal/a11y/e-table/gal-a11y-e-table.c:
(find_first_table_item): find the first item of the group.
(eti_get_accessible), (find_table_item): find the first table item.
(init_child_item): ref every group's first item.
(et_ref_accessible_at_point): no need to call init_child_item here.
just ref the item.
(et_get_n_children): add support for multiple ETableItems.
(et_ref_child): add support for multiple ETableItems.
(et_get_layer): Set AtkLayer as ATK_LAYER_WIDGET for e-table.
(et_atk_component_iface_init): add et_get_layer function.
(gal_a11y_e_table_new):ref the a11y and widget, and unref it in
the idle function to avoid crash.
Fixes #71158
* gal/a11y/e-table/gal-a11y-e-tree.c:
(init_child_item): just get the a11y object of the child item.
(et_get_layer): Set AtkLayer as ATK_LAYER_WIDGET for etree.
(et_atk_component_iface_init): add et_get_layer function.
* gal/util/e-marshal.list:
add support for the text_inserted and text_deleted signal.
svn path=/trunk/; revision=28572
Diffstat (limited to 'a11y/e-table/gal-a11y-e-cell.c')
-rw-r--r-- | a11y/e-table/gal-a11y-e-cell.c | 158 |
1 files changed, 112 insertions, 46 deletions
diff --git a/a11y/e-table/gal-a11y-e-cell.c b/a11y/e-table/gal-a11y-e-cell.c index 9df3568e6c..f22b8f6b44 100644 --- a/a11y/e-table/gal-a11y-e-cell.c +++ b/a11y/e-table/gal-a11y-e-cell.c @@ -7,7 +7,10 @@ */ #include <config.h> +#include <string.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 +18,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 +43,28 @@ unref_cell (gpointer user_data, GObject *obj_loc) } #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,43 +77,69 @@ eti_dispose (GObject *object) 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); - g_return_val_if_fail (cell->state_set, NULL); + g_return_val_if_fail (cell->state_set, NULL); + 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); + if (!is_valid (accessible)) + return -1; + return a11y->row * a11y->item->cols + a11y->view_col; } /* 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 @@ eti_get_extents (AtkComponent *component, AtkCoordType coord_type) { GalA11yECell *a11y = GAL_A11Y_E_CELL (component); + GtkWidget *tableOrTree; int row; int col; int xval; @@ -105,14 +156,16 @@ eti_get_extents (AtkComponent *component, 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 @@ eti_get_extents (AtkComponent *component, } 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 @@ eti_grab_focus (AtkComponent *component) /* 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,11 @@ eti_init (GalA11yECell *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); + atk_state_set_add_state (a11y->state_set, ATK_STATE_VISIBLE); } @@ -350,6 +410,10 @@ idle_do_action (gpointer data) 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 +427,9 @@ gal_a11y_e_cell_action_do_action (AtkAction *action, 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 +544,17 @@ gal_a11y_e_cell_get_type (void) 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 +606,16 @@ gal_a11y_e_cell_construct (AtkObject *object, 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 } |