Created this function for key presses that move in some way other than

2001-07-11  Christopher James Lahey  <clahey@ximian.com>

	* gal/widgets/e-selection-model.c, gal/widgets/e-selection-model.h
	(e_selection_model_select_as_key_press): Created this function for
	key presses that move in some way other than just to the next or
	previous row.
	(e_selection_model_key_press): Use
	e_selection_model_select_as_key_press for handling home and end
	here.

svn path=/trunk/; revision=10993
This commit is contained in:
Christopher James Lahey
2001-07-11 10:30:51 +00:00
committed by Chris Lahey
parent 0a71e607b1
commit 7b9622f8e0
4 changed files with 88 additions and 86 deletions

View File

@ -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;

View File

@ -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_ */

View File

@ -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:

View File

@ -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 '=':