diff options
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-text.c')
-rw-r--r-- | a11y/e-table/gal-a11y-e-cell-text.c | 223 |
1 files changed, 187 insertions, 36 deletions
diff --git a/a11y/e-table/gal-a11y-e-cell-text.c b/a11y/e-table/gal-a11y-e-cell-text.c index d94a3640a3..89c1b3a813 100644 --- a/a11y/e-table/gal-a11y-e-cell-text.c +++ b/a11y/e-table/gal-a11y-e-cell-text.c @@ -15,18 +15,84 @@ #include <atk/atktext.h> #include <atk/atkeditabletext.h> #include <atk/atkaction.h> +#include <atk/atkstateset.h> +#include <glib/gi18n.h> #define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yECellTextClass)) static AtkObjectClass *parent_class; #define PARENT_TYPE (gal_a11y_e_cell_get_type ()) /* Static functions */ +static void +ect_dispose (GObject *object) +{ + GObjectClass *g_class; + GalA11yECell *gaec = GAL_A11Y_E_CELL (object); + GalA11yECellText *gaet = GAL_A11Y_E_CELL_TEXT (object); + + if (gaet->inserted_id != 0) { + ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); + + if (ect) { + g_signal_handler_disconnect (ect, gaet->inserted_id); + g_signal_handler_disconnect (ect, gaet->deleted_id); + } + + gaet->inserted_id = 0; + gaet->deleted_id = 0; + } + + g_class = (GObjectClass *)parent_class; + if (g_class->dispose) + g_class->dispose (object); + +} + +static gboolean +ect_check (gpointer a11y) +{ + GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); + ETableItem *item = gaec->item; + + g_return_val_if_fail ((gaec->item != NULL), FALSE); + g_return_val_if_fail ((gaec->cell_view != NULL), FALSE); + g_return_val_if_fail ((gaec->cell_view->ecell != NULL), FALSE); + + if (atk_state_set_contains_state (gaec->state_set, ATK_STATE_DEFUNCT)) + return FALSE; + + if (gaec->row < 0 || gaec->row >= item->rows + || gaec->view_col <0 || gaec->view_col >= item->cols + || gaec->model_col <0 || gaec->model_col >= e_table_model_column_count (item->table_model)) + return FALSE; + + if (!E_IS_CELL_TEXT (gaec->cell_view->ecell)) + return FALSE; + + return TRUE; +} + static G_CONST_RETURN gchar* ect_get_name (AtkObject * a11y) { - GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); - return e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + GalA11yECell *gaec; + char *name; + + if (!ect_check (a11y)) + return NULL; + + gaec = GAL_A11Y_E_CELL (a11y); + name = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); + if (name != NULL) { + ATK_OBJECT_CLASS (parent_class)->set_name (a11y, name); + g_free (name); + } + + if (a11y->name != NULL && strcmp (a11y->name, "")) { + return a11y->name; + } else { + return parent_class->get_name (a11y); + } } static gchar * @@ -35,9 +101,13 @@ ect_get_text (AtkText *text, gint end_offset) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); + gchar *full_text; gchar *ret_val; - gchar *full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + + if (!ect_check (text)) + return NULL; + + full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); if (end_offset == -1) end_offset = strlen (full_text); @@ -48,7 +118,7 @@ ect_get_text (AtkText *text, ret_val = g_strndup (full_text + start_offset, end_offset - start_offset); - e_cell_text_free_text (ect, full_text); + g_free (full_text); return ret_val; } @@ -80,13 +150,16 @@ ect_get_character_at_offset (AtkText *text, gint offset) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); gunichar ret_val; gchar *at_offset; - gchar *full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + + if (!ect_check (text)) + return -1; + + gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); at_offset = g_utf8_offset_to_pointer (full_text, offset); ret_val = g_utf8_get_char_validated (at_offset, -1); - e_cell_text_free_text (ect, full_text); + g_free (full_text); return ret_val; } @@ -108,18 +181,17 @@ static gint ect_get_caret_offset (AtkText *text) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = NULL; gint start, end; - g_return_val_if_fail (gaec && gaec->cell_view && gaec->cell_view->ecell && E_IS_CELL_TEXT (gaec->cell_view->ecell), -1); - ect = E_CELL_TEXT (gaec->cell_view->ecell); + if (!ect_check (text)) + return -1; if (e_cell_text_get_selection (gaec->cell_view, gaec->view_col, gaec->row, &start, &end)) { - gchar *full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); end = g_utf8_pointer_to_offset (full_text, full_text + end); - e_cell_text_free_text (ect, full_text); + g_free (full_text); return end; } @@ -163,13 +235,15 @@ static gint ect_get_character_count (AtkText *text) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); gint ret_val; - gchar *full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + if (!ect_check (text)) + return -1; + + gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); ret_val = g_utf8_strlen (full_text, -1); - e_cell_text_free_text (ect, full_text); + g_free (full_text); return ret_val; } @@ -190,6 +264,10 @@ ect_get_n_selections (AtkText *text) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); gint selection_start, selection_end; + + if (!ect_check (text)) + return 0; + if (e_cell_text_get_selection (gaec->cell_view, gaec->view_col, gaec->row, &selection_start, @@ -207,7 +285,6 @@ ect_get_selection (AtkText *text, gint *end_offset) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); gchar *ret_val; gint selection_start, selection_end; @@ -218,7 +295,7 @@ ect_get_selection (AtkText *text, &selection_end) && selection_start != selection_end) { gint real_start, real_end, len; - gchar *full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); len = strlen (full_text); real_start = MIN (selection_start, selection_end); real_end = MAX (selection_start, selection_end); @@ -234,7 +311,7 @@ ect_get_selection (AtkText *text, *start_offset = real_start; if (end_offset) *end_offset = real_end; - e_cell_text_free_text (ect, full_text); + g_free (full_text); } else { if (start_offset) *start_offset = 0; @@ -253,12 +330,11 @@ ect_add_selection (AtkText *text, gint end_offset) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); if (start_offset != end_offset) { gint real_start, real_end, len; gchar *full_text = - e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); len = g_utf8_strlen (full_text, -1); if (end_offset == -1) @@ -272,7 +348,7 @@ ect_add_selection (AtkText *text, real_start = g_utf8_offset_to_pointer (full_text, real_start) - full_text; real_end = g_utf8_offset_to_pointer (full_text, real_end) - full_text; - e_cell_text_free_text (ect, full_text); + g_free (full_text); if (e_cell_text_set_selection (gaec->cell_view, gaec->view_col, gaec->row, @@ -330,11 +406,10 @@ ect_set_caret_offset (AtkText *text, gint offset) { GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); gchar *full_text; gint len; - full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); len = g_utf8_strlen (full_text, -1); if (offset == -1) @@ -344,7 +419,7 @@ ect_set_caret_offset (AtkText *text, offset = g_utf8_offset_to_pointer (full_text, offset) - full_text; - e_cell_text_free_text (ect, full_text); + g_free (full_text); return e_cell_text_set_selection (gaec->cell_view, gaec->view_col, gaec->row, @@ -382,7 +457,7 @@ ect_insert_text (AtkEditableText *text, GalA11yECell *gaec = GAL_A11Y_E_CELL (text); ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); - gchar *full_text = e_cell_text_get_text (ect, gaec->item->table_model, gaec->model_col, gaec->row); + gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); gchar *result = g_strdup_printf ("%.*s%.*s%s", *position, full_text, length, string, full_text + *position); e_cell_text_set_value (ect, gaec->item->table_model, gaec->model_col, gaec->row, result); @@ -390,7 +465,7 @@ ect_insert_text (AtkEditableText *text, *position += length; g_free (result); - e_cell_text_free_text (ect, full_text); + g_free (full_text); } static void @@ -443,7 +518,43 @@ static void ect_do_action_edit (AtkAction *action) { GalA11yECell *a11y = GAL_A11Y_E_CELL (action); - e_table_item_enter_edit (a11y->item, a11y->view_col, a11y->row); + ETableModel *e_table_model = a11y->item->table_model; + + if (e_table_model_is_cell_editable(e_table_model, a11y->model_col, a11y->row)) { + e_table_item_enter_edit (a11y->item, a11y->view_col, a11y->row); + } +} + +/* text signal handlers */ +static void +ect_text_inserted_cb (ECellText *text, ECellView *cell_view, int pos, int len, int row, int model_col, gpointer data) +{ + GalA11yECellText *gaet; + GalA11yECell *gaec; + + if (!ect_check (data)) + return; + gaet = GAL_A11Y_E_CELL_TEXT (data); + gaec = GAL_A11Y_E_CELL (data); + + if (cell_view == gaec->cell_view && row == gaec->row && model_col == gaec->model_col) { + g_signal_emit_by_name (gaet, "text_changed::insert", pos, len); + + } +} + +static void +ect_text_deleted_cb (ECellText *text, ECellView *cell_view, int pos, int len, int row, int model_col, gpointer data) +{ + GalA11yECellText *gaet; + GalA11yECell *gaec; + if (!ect_check (data)) + return; + gaet = GAL_A11Y_E_CELL_TEXT (data); + gaec = GAL_A11Y_E_CELL (data); + if (cell_view == gaec->cell_view && row == gaec->row && model_col == gaec->model_col) { + g_signal_emit_by_name (gaet, "text_changed::delete", pos, len); + } } static void @@ -483,19 +594,25 @@ ect_atk_editable_text_iface_init (AtkEditableTextIface *iface) static void ect_class_init (GalA11yECellTextClass *klass) { - AtkObjectClass *a11y = ATK_OBJECT_CLASS (klass); + AtkObjectClass *a11y = ATK_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + parent_class = g_type_class_ref (PARENT_TYPE); a11y->get_name = ect_get_name; + object_class->dispose = ect_dispose; } static void -ect_init (GalA11yECellText *a11y) +ect_action_init (GalA11yECellText *a11y) { - gal_a11y_e_cell_add_action (GAL_A11Y_E_CELL (a11y), - "edit", - "begin editing this cell", + GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); + ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); + if (ect->editable && e_table_model_is_cell_editable (gaec->cell_view->e_table_model, gaec->model_col, gaec->row)) + gal_a11y_e_cell_add_action (gaec, + _("edit"), + _("begin editing this cell"), NULL, - (ACTION_FUNC)ect_do_action_edit); + (ACTION_FUNC) ect_do_action_edit); } /** @@ -522,7 +639,7 @@ gal_a11y_e_cell_text_get_type (void) NULL, /* class_data */ sizeof (GalA11yECellText), 0, - (GInstanceInitFunc) ect_init, + (GInstanceInitFunc) NULL, NULL /* value_cell_text */ }; @@ -547,6 +664,14 @@ gal_a11y_e_cell_text_get_type (void) return type; } +static void +cell_text_destroyed (gpointer data) +{ + g_return_if_fail (GAL_A11Y_IS_E_CELL_TEXT (data)); + + g_object_unref (data); +} + AtkObject * gal_a11y_e_cell_text_new (ETableItem *item, ECellView *cell_view, @@ -556,6 +681,9 @@ gal_a11y_e_cell_text_new (ETableItem *item, int row) { AtkObject *a11y; + GalA11yECell *gaec; + GalA11yECellText *gaet; + ECellText *ect; a11y = g_object_new (gal_a11y_e_cell_text_get_type (), NULL); @@ -566,5 +694,28 @@ gal_a11y_e_cell_text_new (ETableItem *item, model_col, view_col, row); + gaet = GAL_A11Y_E_CELL_TEXT (a11y); + + /* will be unrefed in cell_text_destroyed */ + g_object_ref (a11y); + + gaet->inserted_id = g_signal_connect (E_CELL_TEXT (((ECellView *)cell_view)->ecell), + "text_inserted", G_CALLBACK (ect_text_inserted_cb), a11y); + gaet->deleted_id = g_signal_connect (E_CELL_TEXT (((ECellView *)cell_view)->ecell), + "text_deleted", G_CALLBACK (ect_text_deleted_cb), a11y); + + g_object_weak_ref (G_OBJECT (((ECellView *)cell_view)->ecell), + (GWeakNotify) cell_text_destroyed, + a11y); + + ect_action_init (gaet); + + ect = E_CELL_TEXT (cell_view->ecell); + gaec = GAL_A11Y_E_CELL (a11y); + if (ect->editable && e_table_model_is_cell_editable (gaec->cell_view->e_table_model, gaec->model_col, gaec->row)) + gal_a11y_e_cell_add_state (gaec, ATK_STATE_EDITABLE, FALSE); + else + gal_a11y_e_cell_remove_state (gaec, ATK_STATE_EDITABLE, FALSE); + return a11y; } |