diff options
-rw-r--r-- | widgets/misc/e-selection-model.c | 64 | ||||
-rw-r--r-- | widgets/misc/e-selection-model.h | 94 | ||||
-rw-r--r-- | widgets/table/e-table.c | 8 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 8 |
4 files changed, 88 insertions, 86 deletions
diff --git a/widgets/misc/e-selection-model.c b/widgets/misc/e-selection-model.c index 8734bd58ad..5b53619519 100644 --- a/widgets/misc/e-selection-model.c +++ b/widgets/misc/e-selection-model.c @@ -434,31 +434,17 @@ e_selection_model_maybe_do_something (ESelectionModel *selection, } } -static gint -move_selection (ESelectionModel *selection, - gboolean up, - GdkModifierType state) +void +e_selection_model_select_as_key_press (ESelectionModel *selection, + guint row, + guint col, + GdkModifierType state) { - int row = e_selection_model_cursor_row(selection); - int col = e_selection_model_cursor_col(selection); int cursor_activated = TRUE; - int row_count; gint shift_p = state & GDK_SHIFT_MASK; gint ctrl_p = state & GDK_CONTROL_MASK; - 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); - switch (selection->mode) { case GTK_SELECTION_BROWSE: if (shift_p) { @@ -482,6 +468,30 @@ move_selection (ESelectionModel *selection, gtk_signal_emit(GTK_OBJECT(selection), e_selection_model_signals[CURSOR_ACTIVATED], row, col); } +} + +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; + + 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; } @@ -535,13 +545,7 @@ e_selection_model_key_press (ESelectionModel *selection, int cursor_col = e_selection_model_cursor_col(selection); row = e_sorter_sorted_to_model(selection->sorter, row); - e_selection_model_change_cursor(selection, row, cursor_col); - - e_selection_model_select_single_row (selection, row); - gtk_signal_emit(GTK_OBJECT(selection), - e_selection_model_signals[CURSOR_CHANGED], row, cursor_col); - gtk_signal_emit(GTK_OBJECT(selection), - e_selection_model_signals[CURSOR_ACTIVATED], row, cursor_col); + e_selection_model_select_as_key_press (selection, row, cursor_col, key->state); return TRUE; } break; @@ -552,13 +556,7 @@ e_selection_model_key_press (ESelectionModel *selection, int cursor_col = e_selection_model_cursor_col(selection); row = e_sorter_sorted_to_model(selection->sorter, row); - e_selection_model_change_cursor(selection, row, cursor_col); - - e_selection_model_select_single_row (selection, row); - gtk_signal_emit(GTK_OBJECT(selection), - e_selection_model_signals[CURSOR_CHANGED], row, cursor_col); - gtk_signal_emit(GTK_OBJECT(selection), - e_selection_model_signals[CURSOR_ACTIVATED], row, cursor_col); + e_selection_model_select_as_key_press (selection, row, cursor_col, key->state); return TRUE; } break; diff --git a/widgets/misc/e-selection-model.h b/widgets/misc/e-selection-model.h index cdd161f96a..f83d2631eb 100644 --- a/widgets/misc/e-selection-model.h +++ b/widgets/misc/e-selection-model.h @@ -71,58 +71,61 @@ typedef struct { } ESelectionModelClass; - -GtkType e_selection_model_get_type (void); -void e_selection_model_do_something (ESelectionModel *esm, - guint row, - guint col, - GdkModifierType state); -void e_selection_model_maybe_do_something (ESelectionModel *esm, - guint row, - guint col, - GdkModifierType state); -gint e_selection_model_key_press (ESelectionModel *esm, - GdkEventKey *key); +GtkType e_selection_model_get_type (void); +void e_selection_model_do_something (ESelectionModel *esm, + guint row, + guint col, + GdkModifierType state); +void e_selection_model_maybe_do_something (ESelectionModel *esm, + guint row, + guint col, + GdkModifierType state); +gint e_selection_model_key_press (ESelectionModel *esm, + GdkEventKey *key); +void e_selection_model_select_as_key_press (ESelectionModel *esm, + guint row, + guint col, + GdkModifierType state); /* Virtual functions */ -gboolean e_selection_model_is_row_selected (ESelectionModel *esm, - gint n); -void e_selection_model_foreach (ESelectionModel *esm, - EForeachFunc callback, - gpointer closure); -void e_selection_model_clear (ESelectionModel *esm); -gint e_selection_model_selected_count (ESelectionModel *esm); -void e_selection_model_select_all (ESelectionModel *esm); -void e_selection_model_invert_selection (ESelectionModel *esm); -int e_selection_model_row_count (ESelectionModel *esm); +gboolean e_selection_model_is_row_selected (ESelectionModel *esm, + gint n); +void e_selection_model_foreach (ESelectionModel *esm, + EForeachFunc callback, + gpointer closure); +void e_selection_model_clear (ESelectionModel *esm); +gint e_selection_model_selected_count (ESelectionModel *esm); +void e_selection_model_select_all (ESelectionModel *esm); +void e_selection_model_invert_selection (ESelectionModel *esm); +int e_selection_model_row_count (ESelectionModel *esm); /* Private virtual Functions */ -void e_selection_model_change_one_row (ESelectionModel *esm, - int row, - gboolean on); -void e_selection_model_change_cursor (ESelectionModel *esm, - int row, - int col); -int e_selection_model_cursor_row (ESelectionModel *esm); -int e_selection_model_cursor_col (ESelectionModel *esm); -void e_selection_model_select_single_row (ESelectionModel *selection, - int row); -void e_selection_model_toggle_single_row (ESelectionModel *selection, - int row); -void e_selection_model_move_selection_end (ESelectionModel *selection, - int row); -void e_selection_model_set_selection_end (ESelectionModel *selection, - int row); +void e_selection_model_change_one_row (ESelectionModel *esm, + int row, + gboolean on); +void e_selection_model_change_cursor (ESelectionModel *esm, + int row, + int col); +int e_selection_model_cursor_row (ESelectionModel *esm); +int e_selection_model_cursor_col (ESelectionModel *esm); +void e_selection_model_select_single_row (ESelectionModel *selection, + int row); +void e_selection_model_toggle_single_row (ESelectionModel *selection, + int row); +void e_selection_model_move_selection_end (ESelectionModel *selection, + int row); +void e_selection_model_set_selection_end (ESelectionModel *selection, + int row); /* Signals */ -void e_selection_model_cursor_changed (ESelectionModel *selection, - int row, - int col); -void e_selection_model_cursor_activated (ESelectionModel *selection, - int row, - int col); -void e_selection_model_selection_changed (ESelectionModel *selection); +void e_selection_model_cursor_changed (ESelectionModel *selection, + int row, + int col); +void e_selection_model_cursor_activated (ESelectionModel *selection, + int row, + int col); +void e_selection_model_selection_changed (ESelectionModel *selection); #ifdef __cplusplus } @@ -130,3 +133,4 @@ void e_selection_model_selection_changed (ESelectionModel *selection); #endif /* _E_SELECTION_MODEL_H_ */ + diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 8b6a1b8d0d..a11d940bfe 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -490,8 +490,8 @@ group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et y -= vadj->value; e_table_get_cell_at (et, 30, y, &row_local, &col_local); row_local = e_table_view_to_model_row (et, row_local); - col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->selection)); - e_selection_model_do_something(E_SELECTION_MODEL (et->selection), row_local, col_local, key->state); + col_local = e_selection_model_cursor_col (E_SELECTION_MODEL (et->selection)); + e_selection_model_select_as_key_press (E_SELECTION_MODEL (et->selection), row_local, col_local, key->state); return_val = 1; break; case GDK_Page_Up: @@ -500,8 +500,8 @@ group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et y -= vadj->value; e_table_get_cell_at (et, 30, y, &row_local, &col_local); row_local = e_table_view_to_model_row (et, row_local); - col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->selection)); - e_selection_model_do_something(E_SELECTION_MODEL (et->selection), row_local, col_local, key->state); + col_local = e_selection_model_cursor_col (E_SELECTION_MODEL (et->selection)); + e_selection_model_select_as_key_press (E_SELECTION_MODEL (et->selection), row_local, col_local, key->state); return_val = 1; break; default: diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 29555ed785..4af1cc2dab 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -539,8 +539,8 @@ item_key_press (ETableItem *eti, int row, int col, GdkEvent *event, ETree *et) y -= vadj->value; e_tree_get_cell_at (et, 30, y, &row_local, &col_local); row_local = e_tree_view_to_model_row (et, row_local); - col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->priv->selection)); - e_selection_model_do_something(E_SELECTION_MODEL (et->priv->selection), row_local, col_local, key->state); + col_local = e_selection_model_cursor_col (E_SELECTION_MODEL (et->priv->selection)); + e_selection_model_select_as_key_press (E_SELECTION_MODEL (et->priv->selection), row_local, col_local, key->state); return_val = 1; break; case GDK_Page_Up: @@ -549,8 +549,8 @@ item_key_press (ETableItem *eti, int row, int col, GdkEvent *event, ETree *et) y -= vadj->value; e_tree_get_cell_at (et, 30, y, &row_local, &col_local); row_local = e_tree_view_to_model_row (et, row_local); - col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->priv->selection)); - e_selection_model_do_something(E_SELECTION_MODEL (et->priv->selection), row_local, col_local, key->state); + col_local = e_selection_model_cursor_col (E_SELECTION_MODEL (et->priv->selection)); + e_selection_model_select_as_key_press (E_SELECTION_MODEL (et->priv->selection), row_local, col_local, key->state); return_val = 1; break; case '=': |