Prevent data sheet from traversing into an invalid column.
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 22 Feb 2009 07:36:40 +0000 (16:36 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 22 Feb 2009 07:36:40 +0000 (16:36 +0900)
Thanks to James R. Van Zandt for reporting this problem.

src/ui/gui/psppire-data-editor.c

index 3a6152a587b3021615c62fd1b18edf22f5adec64..916c8838a05a3fff8b8221b623c291e4c631b420 100644 (file)
@@ -562,6 +562,19 @@ on_map (GtkWidget *w)
   g_signal_connect (clip, "owner-change", G_CALLBACK (on_owner_change), w);
 }
 
+static gboolean
+traverse_cell_callback (GtkSheet *sheet,
+                       gint row, gint column,
+                       gint *new_row, gint *new_column,
+                       gpointer data)
+{
+  PsppireDataStore *data_store = PSPPIRE_DATA_STORE (data);
+
+  if ( *new_column >= psppire_dict_get_var_cnt (data_store->dict))
+    return FALSE;
+
+  return TRUE;
+}
 
 static void
 psppire_data_editor_init (PsppireDataEditor *de)
@@ -670,6 +683,9 @@ psppire_data_editor_new (PsppireVarStore *var_store,
                          "data-store",  data_store,
                          NULL);
 
+  g_signal_connect (PSPPIRE_DATA_EDITOR(widget)->data_sheet, "traverse",
+                   G_CALLBACK (traverse_cell_callback), data_store);
+
   return widget;
 }