From fc476dc25391d72bad99a307946aff0cae902a9a Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 21 Nov 2008 14:20:49 +0900 Subject: [PATCH] Prevent traversing to cells for which there is no variable --- src/ui/gui/psppire-data-editor.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index a3a9334d..784a7319 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -136,6 +136,9 @@ on_data_column_clicked (PsppireDataEditor *de, gint col, gpointer data) } + + + /* Callback which occurs when the var sheet's row title button is double clicked */ static gboolean @@ -164,6 +167,23 @@ on_var_row_clicked (PsppireDataEditor *de, gint row, gpointer data) } +/* Moves the focus to a new cell. + Returns TRUE iff the move should be disallowed */ +static gboolean +traverse_cell_callback (GtkSheet *sheet, + gint row, gint column, + gint *new_row, gint *new_column, + gpointer data) +{ + PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data); + const PsppireDict *dict = de->data_store->dict; + + if ( *new_column >= psppire_dict_get_var_cnt (dict)) + return TRUE; + + return FALSE; +} + enum { @@ -604,6 +624,10 @@ init_sheet (PsppireDataEditor *de, int i, gtk_container_add (GTK_CONTAINER (de->sheet_bin[i]), de->data_sheet[i]); + + g_signal_connect (de->data_sheet[i], "traverse", + G_CALLBACK (traverse_cell_callback), de); + gtk_widget_show (de->sheet_bin[i]); } -- 2.30.2