Change traverse signal to take GtkSheetCell instead of gint,gint
[pspp-builds.git] / src / ui / gui / psppire-data-editor.c
index a3a9334d0c4a7c8a3316536917df6c18ad98b004..072e55bad3dc54e2bffe5e50d589563123faa18c 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyrigght (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 #include <config.h>
 #include <gtk/gtksignal.h>
 #include <gtk/gtk.h>
-#include <gtksheet/gtksheet.h>
+#include <gtksheet/gtkextra-sheet.h>
 #include "psppire-data-editor.h"
 #include "psppire-var-sheet.h"
 
@@ -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,
+                       GtkSheetCell *existing_cell,
+                       GtkSheetCell *new_cell,
+                       gpointer data)
+{
+  PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+  const PsppireDict *dict = de->data_store->dict;
+
+  if ( new_cell->col >= psppire_dict_get_var_cnt (dict))
+    return TRUE;
+
+  return FALSE;
+}
+
 
 enum
   {
@@ -604,6 +624,9 @@ 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]);
 }