diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2001-01-28 06:21:10 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-01-28 06:21:10 +0800 |
commit | a7a767287fa0bc03c9e56d5ef3a791bcc1302d57 (patch) | |
tree | cd14125a84c1e7eaab9071dd91f538f349782cb3 | |
parent | 613b4a4b5c420cbb45e35e3251f00258b02fb0f8 (diff) | |
download | gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.tar gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.tar.gz gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.tar.bz2 gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.tar.lz gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.tar.xz gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.tar.zst gsoc2013-evolution-a7a767287fa0bc03c9e56d5ef3a791bcc1302d57.zip |
Make home and end keys move to the beginning and end of the row if cursor
2001-01-27 Christopher James Lahey <clahey@helixcode.com>
* e-table-item.c (eti_event): Make home and end keys move to the
beginning and end of the row if cursor mode is set to
E_TABLE_CURSOR_SIMPLE. Otherwise have %ETableSelectionModel
handle them.
* e-table-selection-model.c, e-table-selection-model.h: Added a
"cursor_mode" argument.
(e_table_selection_model_key_press): Made home and end keys move
the beginning and end of the table if cursor_mode is
E_TABLE_CURSOR_MODE_LINE.
* e-table.c: Set the cursor-mode argument of our
%ETableSelectionModel.
svn path=/trunk/; revision=7864
-rw-r--r-- | widgets/table/e-table-item.c | 16 | ||||
-rw-r--r-- | widgets/table/e-table-selection-model.c | 44 | ||||
-rw-r--r-- | widgets/table/e-table-selection-model.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table.c | 1 |
4 files changed, 62 insertions, 0 deletions
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 06428f343e..8df30e5dab 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -1858,6 +1858,22 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) return_val = FALSE; break; #endif + case GDK_Home: + case GDK_KP_Home: + if (eti->cursor_mode == E_TABLE_CURSOR_SIMPLE) { + eti_cursor_move (eti, model_to_view_row(eti, cursor_row), 0); + return_val = TRUE; + } else + return_val = e_table_selection_model_key_press(eti->selection, (GdkEventKey *) e); + break; + case GDK_End: + case GDK_KP_End: + if (eti->cursor_mode == E_TABLE_CURSOR_SIMPLE) { + eti_cursor_move (eti, model_to_view_row(eti, cursor_row), eti->cols - 1); + return_val = TRUE; + } else + return_val = e_table_selection_model_key_press(eti->selection, (GdkEventKey *) e); + break; case GDK_Tab: case GDK_KP_Tab: case GDK_ISO_Left_Tab: diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c index fba3821f8d..0f2c9cd7e4 100644 --- a/widgets/table/e-table-selection-model.c +++ b/widgets/table/e-table-selection-model.c @@ -45,6 +45,7 @@ enum { ARG_CURSOR_ROW, ARG_CURSOR_COL, ARG_SELECTION_MODE, + ARG_CURSOR_MODE, }; static void @@ -222,6 +223,10 @@ etsm_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_SELECTION_MODE: GTK_VALUE_ENUM(*arg) = etsm->mode; break; + + case ARG_CURSOR_MODE: + GTK_VALUE_ENUM(*arg) = etsm->cursor_mode; + break; } } @@ -255,6 +260,10 @@ etsm_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) e_table_selection_model_do_something(etsm, etsm->cursor_row, etsm->cursor_col, 0); } break; + + case ARG_CURSOR_MODE: + etsm->cursor_mode = GTK_VALUE_ENUM(*arg); + break; } } @@ -268,6 +277,7 @@ e_table_selection_model_init (ETableSelectionModel *selection) selection->cursor_row = -1; selection->cursor_col = -1; selection->mode = GTK_SELECTION_MULTIPLE; + selection->cursor_mode = E_TABLE_CURSOR_SIMPLE; } static void @@ -323,6 +333,8 @@ e_table_selection_model_class_init (ETableSelectionModelClass *klass) GTK_ARG_READWRITE, ARG_CURSOR_COL); gtk_object_add_arg_type ("ETableSelectionModel::selection_mode", GTK_TYPE_ENUM, GTK_ARG_READWRITE, ARG_SELECTION_MODE); + gtk_object_add_arg_type ("ETableSelectionModel::cursor_mode", GTK_TYPE_ENUM, + GTK_ARG_READWRITE, ARG_CURSOR_MODE); } E_MAKE_TYPE(e_table_selection_model, "ETableSelectionModel", ETableSelectionModel, @@ -676,6 +688,38 @@ e_table_selection_model_key_press (ETableSelectionModel *selection, return TRUE; } break; + case GDK_Home: + case GDK_KP_Home: + if (selection->cursor_mode == E_TABLE_CURSOR_LINE) { + int row = 0; + + row = e_table_sorter_sorted_to_model(selection->sorter, row); + selection->cursor_row = row; + + etsm_select_single_row (selection, selection->cursor_row); + gtk_signal_emit(GTK_OBJECT(selection), + e_table_selection_model_signals[CURSOR_CHANGED], selection->cursor_row, selection->cursor_col); + gtk_signal_emit(GTK_OBJECT(selection), + e_table_selection_model_signals[CURSOR_ACTIVATED], selection->cursor_row, selection->cursor_col); + return TRUE; + } + break; + case GDK_End: + case GDK_KP_End: + if (selection->cursor_mode == E_TABLE_CURSOR_LINE) { + int row = selection->row_count - 1; + + row = e_table_sorter_sorted_to_model(selection->sorter, row); + selection->cursor_row = row; + + etsm_select_single_row (selection, selection->cursor_row); + gtk_signal_emit(GTK_OBJECT(selection), + e_table_selection_model_signals[CURSOR_CHANGED], selection->cursor_row, selection->cursor_col); + gtk_signal_emit(GTK_OBJECT(selection), + e_table_selection_model_signals[CURSOR_ACTIVATED], selection->cursor_row, selection->cursor_col); + return TRUE; + } + break; } return FALSE; } diff --git a/widgets/table/e-table-selection-model.h b/widgets/table/e-table-selection-model.h index 2761301747..b4e08ed6fe 100644 --- a/widgets/table/e-table-selection-model.h +++ b/widgets/table/e-table-selection-model.h @@ -34,6 +34,7 @@ typedef struct { guint group_info_changed : 1; GtkSelectionMode mode; + ETableCursorMode cursor_mode; } ETableSelectionModel; typedef struct { diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 3c9c2d2659..238183ec8d 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -1010,6 +1010,7 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete, gtk_object_set(GTK_OBJECT(e_table->selection), "selection_mode", specification->selection_mode, + "cursor_mode", specification->cursor_mode, NULL); e_table->model = etm; |