Prevent traversing to cells for which there is no variable
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 21 Nov 2008 05:20:49 +0000 (14:20 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 21 Nov 2008 05:20:49 +0000 (14:20 +0900)
src/ui/gui/psppire-data-editor.c

index a3a9334d0c4a7c8a3316536917df6c18ad98b004..784a731900309e1a4fea2c8d55476c99bb3d2b59 100644 (file)
@@ -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]);
 }