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 eti_tree_model_node_changed_cb (ETreeModel *model, ETreePath node, ETableItem *eti) { AtkObject *atk_obj; GalA11yETableItem *a11y; g_return_if_fail (E_IS_TABLE_ITEM (eti)); atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti)); a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj); /* we can't figure out which rows are changed, so just send out a signal ... */ if (GET_PRIVATE (a11y)->rows > 0) g_signal_emit_by_name (a11y, "visible-data-changed"); }
static void eti_dispose (GObject *object) { GalA11yETableItem *a11y = GAL_A11Y_E_TABLE_ITEM (object); GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y); if (priv->columns) { free_columns (priv->columns); priv->columns = NULL; } if (priv->item) { g_object_weak_unref (G_OBJECT (priv->item), item_finalized, a11y); priv->item = NULL; } if (parent_class->dispose) parent_class->dispose (object); }
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 item_finalized (gpointer user_data, GObject *gone_item) { GalA11yETableItem *a11y; GalA11yETableItemPrivate *priv; a11y = GAL_A11Y_E_TABLE_ITEM (user_data); priv = GET_PRIVATE (a11y); priv->item = NULL; atk_state_set_add_state (priv->state_set, ATK_STATE_DEFUNCT); atk_object_notify_state_change (ATK_OBJECT (a11y), ATK_STATE_DEFUNCT, TRUE); if (priv->selection) gal_a11y_e_table_item_unref_selection (a11y); g_object_unref (a11y); }
static void eti_rows_inserted (ETableModel *model, gint row, gint count, AtkObject *table_item) { gint n_cols,n_rows,i,j; GalA11yETableItem * item_a11y; gint old_nrows; g_return_if_fail (table_item); item_a11y = GAL_A11Y_E_TABLE_ITEM (table_item); n_cols = atk_table_get_n_columns (ATK_TABLE (table_item)); n_rows = atk_table_get_n_rows (ATK_TABLE (table_item)); old_nrows = GET_PRIVATE (item_a11y)->rows; g_return_if_fail (n_cols > 0 && n_rows > 0); g_return_if_fail (old_nrows == n_rows - count); GET_PRIVATE (table_item)->rows = n_rows; g_signal_emit_by_name ( table_item, "row-inserted", row, count, NULL); for (i = row; i < (row + count); i++) { for (j = 0; j < n_cols; j++) { g_signal_emit_by_name ( table_item, "children_changed::add", (((i + 1) * n_cols) + j), NULL, NULL); } } g_signal_emit_by_name (table_item, "visible-data-changed"); }
/* * 1. Check what actually happened: column reorder, remove or add * 2. Update cache * 3. Emit signals */ static void eti_header_structure_changed (ETableHeader *eth, AtkObject *a11y) { gboolean reorder_found = FALSE, added_found = FALSE, removed_found = FALSE; GalA11yETableItem * a11y_item; ETableCol ** cols, **prev_cols; GalA11yETableItemPrivate *priv; gint *state = NULL, *prev_state = NULL, *reorder = NULL; gint i,j,n_rows,n_cols, prev_n_cols; a11y_item = GAL_A11Y_E_TABLE_ITEM (a11y); priv = GET_PRIVATE (a11y_item); /* Assume rows do not changed. */ n_rows = priv->rows; prev_n_cols = priv->cols; prev_cols = priv->columns; cols = e_table_header_get_columns (eth); n_cols = eth->col_count; g_return_if_fail (cols && prev_cols && n_cols > 0); /* Init to ETI_HEADER_UNCHANGED. */ state = g_malloc0 (sizeof (gint) * (MAX (prev_n_cols, n_cols) + 1)); prev_state = g_malloc0 (sizeof (gint) * (MAX (prev_n_cols, n_cols) + 1)); reorder = g_malloc0 (sizeof (gint) * (MAX (prev_n_cols, n_cols) + 1)); /* Compare with previously saved column headers. */ for (i = 0; i < n_cols && cols[i]; i++) { for (j = 0; j < prev_n_cols && prev_cols[j]; j++) { if (prev_cols[j] == cols[i] && i != j) { reorder_found = TRUE; state[i] = ETI_HEADER_REORDERED; reorder[i] = j; break; } else if (prev_cols[j] == cols[i]) { /* OK, this column is not changed. */ break; } } /* cols[i] is new added column. */ if (j == prev_n_cols) { added_found = TRUE; state[i] = ETI_HEADER_NEW_ADDED; } } /* Now try to find if there are removed columns. */ for (i = 0; i < prev_n_cols && prev_cols[i]; i++) { for (j = 0; j < n_cols && cols[j]; j++) if (prev_cols[j] == cols[i]) break; /* Removed columns found. */ if (j == n_cols) { removed_found = TRUE; prev_state[j] = ETI_HEADER_REMOVED; } } /* If nothing interesting just return. */ if (!reorder_found && !added_found && !removed_found) return; /* Emit signals */ if (reorder_found) g_signal_emit_by_name (a11y_item, "column_reordered"); if (removed_found) { for (i = 0; i < prev_n_cols; i++) { if (prev_state[i] == ETI_HEADER_REMOVED) { g_signal_emit_by_name ( a11y_item, "column-deleted", i, 1); for (j = 0; j < n_rows; j++) g_signal_emit_by_name ( a11y_item, "children_changed::remove", ((j + 1) * prev_n_cols + i), NULL, NULL); } } } if (added_found) { for (i = 0; i < n_cols; i++) { if (state[i] == ETI_HEADER_NEW_ADDED) { g_signal_emit_by_name ( a11y_item, "column-inserted", i, 1); for (j = 0; j < n_rows; j++) g_signal_emit_by_name ( a11y_item, "children_changed::add", ((j + 1) * n_cols + i), NULL, NULL); } } } priv->cols = n_cols; g_free (state); g_free (reorder); g_free (prev_state); free_columns (priv->columns); priv->columns = cols; }