From 33a1687123f37ddea0d9bea13977c38f5f73b212 Mon Sep 17 00:00:00 2001 From: Tim Wo Date: Fri, 21 Nov 2003 04:28:04 +0000 Subject: override the function in base class, to retrieve the content of the text. 2003-11-21 Tim Wo * gal/a11y/e-table/gal-a11y-e-cell-text.c: (ect_get_name): override the function in base class, to retrieve the content of the text. (ect_do_action_edit): begin edit the cell when issuing the action. (ect_class_init): override the "get_name" function. (ect_init): add an action "edit" to the object. (gal_a11y_e_cell_text_get_type): add AtkAction interface to this type. * gal/a11y/e-table/gal-a11y-e-cell-toggle.c (gal_a11y_e_cell_toggle_dispose): disconnect the connected signal when disposing. (gal_a11y_e_cell_toggle_class_init): to override the dispose function. (toggle_cell_action): set position of the click event more precisely. (model_change_cb): set or remove the ATK_STATE_CHECKED flag according to the value in the model when it changes. (gal_a11y_e_cell_toggle_new): init the ATK_STATE_CHECKED flag and connect to the model cell change signal. * gal/a11y/e-table/gal-a11y-e-cell-toggle.h: add one member to save the connected signal id. * gal/a11y/e-table/gal-a11y-e-cell.c: (gal_a11y_e_cell_grab_focus): notify the selection model that the cursor has been changed. * gal/a11y/e-table/gal-a11y-e-table-item.c: (eti_a11y_cursor_changed_cb): emiting a signal to notify the AT applictions that the active descendant has been changed. (#51055) svn path=/trunk/; revision=23466 --- a11y/e-table/gal-a11y-e-cell-toggle.c | 62 +++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'a11y/e-table/gal-a11y-e-cell-toggle.c') diff --git a/a11y/e-table/gal-a11y-e-cell-toggle.c b/a11y/e-table/gal-a11y-e-cell-toggle.c index 2daa7e7271..497483d255 100644 --- a/a11y/e-table/gal-a11y-e-cell-toggle.c +++ b/a11y/e-table/gal-a11y-e-cell-toggle.c @@ -3,8 +3,25 @@ #include #include +#define PARENT_TYPE (gal_a11y_e_cell_get_type ()) +static GObjectClass *parent_class; + static void gal_a11y_e_cell_toggle_class_init (GalA11yECellToggleClass *klass); +static void +gal_a11y_e_cell_toggle_dispose (GObject *object) +{ + GalA11yECellToggle *a11y = GAL_A11Y_E_CELL_TOGGLE (object); + + ETableModel *e_table_model = GAL_A11Y_E_CELL (a11y)->cell_view->e_table_model; + + if (e_table_model) + g_signal_handler_disconnect (e_table_model, a11y->model_id); + + if (parent_class->dispose) + parent_class->dispose (object); +} + GType gal_a11y_e_cell_toggle_get_type (void) { @@ -39,6 +56,10 @@ gal_a11y_e_cell_toggle_get_type (void) static void gal_a11y_e_cell_toggle_class_init (GalA11yECellToggleClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = gal_a11y_e_cell_toggle_dispose; + parent_class = g_type_class_ref (PARENT_TYPE); } static void @@ -55,8 +76,10 @@ toggle_cell_action (GalA11yECell *cell) e_table_item_get_cell_geometry (cell->item, &row, &col, &x, &y, &width, &height); - event.x = x ; - event.y = y ; + + event.x = x + width / 2 + (int)(GNOME_CANVAS_ITEM (cell->item)->x1); + event.y = y + height / 2 + (int)(GNOME_CANVAS_ITEM (cell->item)->y1); + event.type = GDK_BUTTON_PRESS; event.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(cell->item)->canvas)->bin_window; event.button = 1; @@ -67,6 +90,27 @@ toggle_cell_action (GalA11yECell *cell) g_signal_emit_by_name (cell->item, "event", &event, &finished); } +static void +model_change_cb (ETableModel *etm, + gint row, + gint col, + GalA11yECell *cell) +{ + gint value; + + if (col == cell->model_col && row == cell->row) { + + value = GPOINTER_TO_INT ( + e_table_model_value_at (cell->cell_view->e_table_model, + cell->model_col, cell->row)); + if (value) + gal_a11y_e_cell_add_state (cell, ATK_STATE_CHECKED, TRUE); + else + gal_a11y_e_cell_remove_state (cell, ATK_STATE_CHECKED, TRUE); + } +} + + AtkObject* gal_a11y_e_cell_toggle_new (ETableItem *item, ECellView *cell_view, @@ -78,6 +122,7 @@ gal_a11y_e_cell_toggle_new (ETableItem *item, AtkObject *a11y; GalA11yECell *cell; GalA11yECellToggle *toggle_cell; + gint value; a11y = ATK_OBJECT(g_object_new (GAL_A11Y_TYPE_E_CELL_TOGGLE, NULL)); @@ -101,5 +146,18 @@ gal_a11y_e_cell_toggle_new (ETableItem *item, NULL, /* action keybinding */ toggle_cell_action); + toggle_cell->model_id = g_signal_connect (cell_view->e_table_model, + "model_cell_changed", + (GCallback) model_change_cb, + a11y); + + value = GPOINTER_TO_INT ( + e_table_model_value_at (cell->cell_view->e_table_model, + cell->model_col, cell->row)); + if (value) + gal_a11y_e_cell_add_state (cell, ATK_STATE_CHECKED, FALSE); + else + gal_a11y_e_cell_remove_state (cell, ATK_STATE_CHECKED, FALSE); + return a11y; } -- cgit v1.2.3