/* atk table */ static AtkObject * eti_ref_at (AtkTable *table, gint row, gint column) { ETableItem *item; AtkObject * ret; GalA11yETableItemPrivate *priv = GET_PRIVATE (table); if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) return NULL; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return NULL; if (column >= 0 && column < item->cols && row >= 0 && row < item->rows && item->cell_views_realized) { ECellView *cell_view = item->cell_views[column]; ETableCol *ecol = e_table_header_get_column (item->header, column); ret = gal_a11y_e_cell_registry_get_object ( NULL, item, cell_view, ATK_OBJECT (table), ecol->spec->model_col, column, row); if (ATK_IS_OBJECT (ret)) { g_object_weak_ref ( G_OBJECT (ret), (GWeakNotify) cell_destroyed, ret); /* if current cell is focused, add FOCUSED state */ if (e_selection_model_cursor_row (item->selection) == GAL_A11Y_E_CELL (ret)->row && e_selection_model_cursor_col (item->selection) == GAL_A11Y_E_CELL (ret)->model_col) gal_a11y_e_cell_add_state ( GAL_A11Y_E_CELL (ret), ATK_STATE_FOCUSED, FALSE); } else ret = NULL; return ret; } return NULL; }
static gboolean gal_a11y_e_cell_grab_focus (AtkComponent *component) { GalA11yECell *a11y; gint index; GtkWidget *toplevel; GalA11yETableItem *a11yTableItem; a11y = GAL_A11Y_E_CELL (component); /* for e_cell_vbox's children, we just grab the e_cell_vbox */ if (GAL_A11Y_IS_E_CELL_VBOX (a11y->parent)) { return atk_component_grab_focus (ATK_COMPONENT (a11y->parent)); } 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_is_toplevel (toplevel)) gtk_window_present (GTK_WINDOW (toplevel)); return TRUE; }
static void gal_a11y_e_cell_dispose (GObject *object) { GalA11yECell *a11y = GAL_A11Y_E_CELL (object); #if 0 if (a11y->item) g_object_unref (a11y->item); /*, unref_item, a11y); */ if (a11y->cell_view) g_object_unref (a11y->cell_view); /*, unref_cell, a11y); */ if (a11y->parent) g_object_unref (a11y->parent); #endif if (a11y->state_set) { g_object_unref (a11y->state_set); a11y->state_set = NULL; } if (a11y->action_list) { g_list_foreach (a11y->action_list, _gal_a11y_e_cell_destroy_action_info, NULL); g_list_free (a11y->action_list); a11y->action_list = NULL; } if (parent_class->dispose) parent_class->dispose (object); }
/* AtkComponet interface */ static AtkObject * ecv_ref_accessible_at_point (AtkComponent *component, gint x, gint y, AtkCoordType coord_type) { gint x0, y0, width, height; gint subcell_height, i; GalA11yECell *gaec = GAL_A11Y_E_CELL (component); ECellVboxView *ecvv = (ECellVboxView *) (gaec->cell_view); atk_component_get_extents (component, &x0, &y0, &width, &height, coord_type); x -= x0; y -= y0; if (x < 0 || x > width || y < 0 || y > height) return NULL; for (i = 0; i < ecvv->subcell_view_count; i++) { subcell_height = e_cell_height ( ecvv->subcell_views[i], ecvv->model_cols[i], gaec->view_col, gaec->row); if ( 0 <= y && y <= subcell_height) { return ecv_ref_child ((AtkObject *) component, i); } else y -= subcell_height; } return NULL; }
static void unref_cell (gpointer user_data, GObject *obj_loc) { GalA11yECell *a11y = GAL_A11Y_E_CELL (user_data); a11y->cell_view = NULL; g_object_unref (a11y); }
static gint 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 + 1) * a11y->item->cols + a11y->view_col; }
static void eti_a11y_reset_focus_object (GalA11yETableItem *a11y, ETableItem *item, gboolean notify) { ESelectionModel * esm; gint cursor_row, cursor_col, view_row, view_col; AtkObject *cell, *old_cell; esm = item->selection; g_return_if_fail (esm); cursor_row = e_selection_model_cursor_row (esm); cursor_col = e_selection_model_cursor_col (esm); view_row = model_to_view_row (item, cursor_row); view_col = model_to_view_col (item, cursor_col); if (view_row == -1) view_row = 0; if (view_col == -1) view_col = 0; old_cell = (AtkObject *) g_object_get_data (G_OBJECT (a11y), "gail-focus-object"); if (old_cell && GAL_A11Y_IS_E_CELL (old_cell)) gal_a11y_e_cell_remove_state ( GAL_A11Y_E_CELL (old_cell), ATK_STATE_FOCUSED, FALSE); if (old_cell) g_object_unref (old_cell); cell = eti_ref_at (ATK_TABLE (a11y), view_row, view_col); if (cell != NULL) { g_object_set_data (G_OBJECT (a11y), "gail-focus-object", cell); gal_a11y_e_cell_add_state ( GAL_A11Y_E_CELL (cell), ATK_STATE_FOCUSED, FALSE); } else g_object_set_data (G_OBJECT (a11y), "gail-focus-object", NULL); if (notify && cell) g_signal_emit_by_name (a11y, "active-descendant-changed", cell); }
static AtkStateSet * 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_object_ref (cell->state_set); return cell->state_set; }
static void cell_destroyed (gpointer data) { GalA11yECell * cell; g_return_if_fail (GAL_A11Y_IS_E_CELL (data)); cell = GAL_A11Y_E_CELL (data); g_return_if_fail (cell->item && G_IS_OBJECT (cell->item)); if (cell->item) { g_object_unref (cell->item); cell->item = NULL; } }
/* Static functions */ static const 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 void subcell_destroyed (gpointer data) { GalA11yECell *cell; AtkObject *parent; GalA11yECellVbox *gaev; g_return_if_fail (GAL_A11Y_IS_E_CELL (data)); cell = GAL_A11Y_E_CELL (data); parent = atk_object_get_parent (ATK_OBJECT (cell)); g_return_if_fail (GAL_A11Y_IS_E_CELL_VBOX (parent)); gaev = GAL_A11Y_E_CELL_VBOX (parent); if (cell->view_col < gaev->a11y_subcell_count) gaev->a11y_subcells[cell->view_col] = NULL; }
static AtkObject * ecv_ref_child (AtkObject *a11y, gint i) { GalA11yECellVbox *gaev = GAL_A11Y_E_CELL_VBOX (a11y); GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); ECellVboxView *ecvv = (ECellVboxView *) (gaec->cell_view); AtkObject *ret; if (i < gaev->a11y_subcell_count) { if (gaev->a11y_subcells[i] == NULL) { ECellView *subcell_view; gint model_col, row; row = gaec->row; model_col = ecvv->model_cols[i]; subcell_view = ecvv->subcell_views[i]; /* FIXME Should the view column use a fake * one or the same as its parent? */ ret = gal_a11y_e_cell_registry_get_object ( NULL, gaec->item, subcell_view, a11y, model_col, gaec->view_col, row); gaev->a11y_subcells[i] = ret; g_object_ref (ret); g_object_weak_ref ( G_OBJECT (ret), (GWeakNotify) subcell_destroyed, ret); } else { ret = (AtkObject *) gaev->a11y_subcells[i]; if (ATK_IS_OBJECT (ret)) g_object_ref (ret); else ret = NULL; } } else { ret = NULL; } return ret; }
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; }
/* Component IFace */ static void gal_a11y_e_cell_get_extents (AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type) { GalA11yECell *a11y = GAL_A11Y_E_CELL (component); GtkWidget *tableOrTree; gint row; gint col; gint xval; gint yval; row = a11y->row; col = a11y->view_col; 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_extents ( ATK_COMPONENT (a11y->parent), x, y, NULL, NULL, coord_type); if (x && *x != G_MININT) *x += xval; if (y && *y != G_MININT) *y += yval; }
static void gal_a11y_e_cell_dispose (GObject *object) { GalA11yECell *a11y = GAL_A11Y_E_CELL (object); #if 0 if (a11y->item) g_object_unref (a11y->item); /*, unref_item, a11y); */ if (a11y->cell_view) g_object_unref (a11y->cell_view); /*, unref_cell, a11y); */ if (a11y->parent) g_object_unref (a11y->parent); #endif if (a11y->state_set) { g_object_unref (a11y->state_set); a11y->state_set = NULL; } if (parent_class->dispose) parent_class->dispose (object); }
static AtkObject * gal_a11y_e_cell_get_parent (AtkObject *accessible) { GalA11yECell *a11y = GAL_A11Y_E_CELL (accessible); return a11y->parent; }