static gint table_get_selected_rows (AtkTable *table, gint **rows_selected) { ETableItem *item; gint n_selected, row, index_selected; GalA11yETableItemPrivate *priv = GET_PRIVATE (table); if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) return 0; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return 0; n_selected = e_selection_model_selected_count (item->selection); if (rows_selected) { *rows_selected = (gint *) g_malloc (n_selected * sizeof (gint)); index_selected = 0; for (row = 0; row < item->rows && index_selected < n_selected; ++row) { if (atk_table_is_row_selected (table, row)) { (*rows_selected)[index_selected] = row; ++index_selected; } } } return n_selected; }
static void eti_get_extents (AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type) { ETableItem *item; AtkObject *parent; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component))); if (!item) return; parent = ATK_OBJECT (component)->accessible_parent; if (parent && ATK_IS_COMPONENT (parent)) atk_component_get_extents ( ATK_COMPONENT (parent), x, y, width, height, coord_type); if (parent && GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD (parent)) { ETableClickToAdd *etcta = E_TABLE_CLICK_TO_ADD ( atk_gobject_accessible_get_object ( ATK_GOBJECT_ACCESSIBLE (parent))); if (etcta) { *width = etcta->width; *height = etcta->height; } } }
static AtkObject * eti_ref_child (AtkObject *accessible, gint index) { ETableItem *item; gint col, row; g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), NULL); item = E_TABLE_ITEM (eti_a11y_get_gobject (accessible)); if (!item) return NULL; if (index < item->cols) { ETableCol *ecol; AtkObject *child; ecol = e_table_header_get_column (item->header, index); child = gal_a11y_e_table_column_header_new (ecol, item, accessible); return child; } index -= item->cols; col = index % item->cols; row = index / item->cols; return eti_ref_at (ATK_TABLE (accessible), row, col); }
/* Static functions */ static gint eti_get_n_children (AtkObject *accessible) { g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), 0); if (!eti_a11y_get_gobject (accessible)) return 0; return atk_table_get_n_columns (ATK_TABLE (accessible)) * (atk_table_get_n_rows (ATK_TABLE (accessible)) + 1); }
static gint eti_get_n_rows (AtkTable *table) { ETableItem *item; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return -1; return item->rows; }
static gint eti_get_row_at_index (AtkTable *table, gint index) { ETableItem *item; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return -1; return index / item->cols - 1; }
/* 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 gint eti_get_index_at (AtkTable *table, gint row, gint column) { ETableItem *item; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return -1; return column + (row + 1) * item->cols; }
static const gchar * eti_get_column_description (AtkTable *table, gint column) { ETableItem *item; ETableCol *ecol; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return NULL; ecol = e_table_header_get_column (item->header, column); return ecol->text; }
static gboolean table_add_row_selection (AtkTable *table, gint row) { ETableItem *item; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return FALSE; if (table_is_row_selected (table, row)) return TRUE; e_selection_model_toggle_single_row (item->selection, view_to_model_row (item, row)); return TRUE; }
static AtkObject * eti_get_column_header (AtkTable *table, gint column) { ETableItem *item; ETableCol *ecol; AtkObject *atk_obj = NULL; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return NULL; ecol = e_table_header_get_column (item->header, column); if (ecol) { atk_obj = gal_a11y_e_table_column_header_new (ecol, item, ATK_OBJECT (table)); } return atk_obj; }
static gboolean table_is_row_selected (AtkTable *table, gint row) { ETableItem *item; GalA11yETableItemPrivate *priv = GET_PRIVATE (table); if (row < 0) return FALSE; if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) return FALSE; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return FALSE; return e_selection_model_is_row_selected ( item->selection, view_to_model_row (item, row)); }
static AtkObject * eti_ref_accessible_at_point (AtkComponent *component, gint x, gint y, AtkCoordType coord_type) { gint row = -1; gint col = -1; gint x_origin, y_origin; ETableItem *item; GtkWidget *tableOrTree; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component))); if (!item) return NULL; atk_component_get_extents ( component, &x_origin, &y_origin, NULL, NULL, coord_type); x -= x_origin; y -= y_origin; tableOrTree = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas)); if (E_IS_TREE (tableOrTree)) e_tree_get_cell_at (E_TREE (tableOrTree), x, y, &row, &col); else e_table_get_cell_at (E_TABLE (tableOrTree), x, y, &row, &col); if (row != -1 && col != -1) { return eti_ref_at (ATK_TABLE (component), row, col); } else { return NULL; } }
static gint eti_get_row_extent_at (AtkTable *table, gint row, gint column) { ETableItem *item; gint height; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); if (!item) return -1; e_table_item_get_cell_geometry (item, &row, &column, NULL, NULL, NULL, &height); return height; }