static void esm_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { ESelectionModel *esm = E_SELECTION_MODEL (object); switch (property_id) { case PROP_SORTER: drop_sorter (esm); add_sorter ( esm, g_value_get_object (value) ? E_SORTER (g_value_get_object (value)) : NULL); break; case PROP_SELECTION_MODE: esm->mode = g_value_get_int (value); if (esm->mode == GTK_SELECTION_SINGLE) { gint cursor_row = e_selection_model_cursor_row (esm); gint cursor_col = e_selection_model_cursor_col (esm); e_selection_model_do_something (esm, cursor_row, cursor_col, 0); } break; case PROP_CURSOR_MODE: esm->cursor_mode = g_value_get_int (value); break; } }
static gint move_selection (ESelectionModel *selection, gboolean up, GdkModifierType state) { int row = e_selection_model_cursor_row(selection); int col = e_selection_model_cursor_col(selection); int row_count; /* there is no selected row when row is -1 */ if (row != -1) row = e_sorter_model_to_sorted (selection->sorter, row); if (up) row--; else row++; if (row < 0) row = 0; row_count = e_selection_model_row_count(selection); if (row >= row_count) row = row_count - 1; row = e_sorter_sorted_to_model(selection->sorter, row); e_selection_model_select_as_key_press (selection, row, col, state); return TRUE; }
/* 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; }
void e_selection_model_right_click_down (ESelectionModel *selection, guint row, guint col, GdkModifierType state) { if (selection->mode == GTK_SELECTION_SINGLE) { selection->old_selection = e_selection_model_cursor_row (selection); e_selection_model_select_single_row (selection, row); } else { e_selection_model_maybe_do_something (selection, row, col, state); } }
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); }
/** * e_selection_model_key_press * @selection: #ESelectionModel to affect. * @key: The event. * * This routine does whatever is appropriate as if the user pressed * the given key. * * Returns: %TRUE if the #ESelectionModel used the key. */ gint e_selection_model_key_press (ESelectionModel *selection, GdkEventKey *key) { selection->old_selection = -1; switch (key->keyval) { case GDK_Up: case GDK_KP_Up: return move_selection(selection, TRUE, key->state); case GDK_Down: case GDK_KP_Down: return move_selection(selection, FALSE, key->state); case GDK_space: case GDK_KP_Space: if (selection->mode != GTK_SELECTION_SINGLE) { int row = e_selection_model_cursor_row(selection); int col = e_selection_model_cursor_col(selection); if (row == -1) break; e_selection_model_toggle_single_row (selection, row); g_signal_emit(selection, e_selection_model_signals[CURSOR_ACTIVATED], 0, row, col); return TRUE; } break; case GDK_Return: case GDK_KP_Enter: if (selection->mode != GTK_SELECTION_SINGLE) { int row = e_selection_model_cursor_row(selection); int col = e_selection_model_cursor_col(selection); e_selection_model_select_single_row (selection, row); g_signal_emit(selection, e_selection_model_signals[CURSOR_ACTIVATED], 0, row, col); return TRUE; } break; case GDK_Home: case GDK_KP_Home: if (selection->cursor_mode == E_CURSOR_LINE) { int row = 0; int cursor_col = e_selection_model_cursor_col(selection); row = e_sorter_sorted_to_model(selection->sorter, row); e_selection_model_select_as_key_press (selection, row, cursor_col, key->state); return TRUE; } break; case GDK_End: case GDK_KP_End: if (selection->cursor_mode == E_CURSOR_LINE) { int row = e_selection_model_row_count(selection) - 1; int cursor_col = e_selection_model_cursor_col(selection); row = e_sorter_sorted_to_model(selection->sorter, row); e_selection_model_select_as_key_press (selection, row, cursor_col, key->state); return TRUE; } break; } return FALSE; }