Replace gsheet-column interface by psppire-axis
[pspp-builds.git] / src / ui / gui / psppire-data-editor.c
index 82a835bed044b18f30308502c6f65247f29e6354..fe4fcb62a5ed8b81d5035e4326fe02f41a96f44a 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
 #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"
 
-#include <gtksheet/gsheet-hetero-column.h>
 #include <language/syntax-string-source.h>
 #include "psppire-data-store.h"
 #include "helper.h"
@@ -136,6 +135,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 +166,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
   {
@@ -201,7 +220,6 @@ psppire_data_editor_set_property (GObject         *object,
       for (i = 0 ; i < 4 ; ++i )
        g_object_set (de->data_sheet[i],
                      "row-geometry", de->data_store,
-                     "column-geometry", de->data_store,
                      "model", de->data_store,
                      NULL);
       break;
@@ -493,7 +511,10 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass)
 
 /* Update the data_ref_entry with the reference of the active cell */
 static gint
-update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
+update_data_ref_entry (const GtkSheet *sheet,
+                      gint row, gint col,
+                      gint old_row, gint old_col,
+                      gpointer data)
 {
   PsppireDataEditor *de = data;
 
@@ -567,7 +588,6 @@ datum_entry_activate (GtkEntry *entry, gpointer data)
 }
 
 static void on_activate (PsppireDataEditor *de);
-static void on_deactivate (PsppireDataEditor *de);
 static gboolean on_switch_page (PsppireDataEditor *de, GtkNotebookPage *p, gint pagenum, gpointer data);
 static void on_select_range (PsppireDataEditor *de);
 
@@ -591,6 +611,7 @@ static void
 init_sheet (PsppireDataEditor *de, int i,
            GtkAdjustment *hadj, GtkAdjustment *vadj)
 {
+  PsppireAxis *haxis = psppire_axis_new (100);
   de->sheet_bin[i] = gtk_scrolled_window_new (hadj, vadj);
 
   de->data_sheet[i] = gtk_sheet_new (NULL, NULL, NULL);
@@ -600,8 +621,15 @@ init_sheet (PsppireDataEditor *de, int i,
                "shadow-type",  GTK_SHADOW_ETCHED_IN,
                NULL);
 
+  g_object_set (de->data_sheet[i],
+               "horizontal-axis", haxis,
+               NULL);
+
   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]);
 }
 
@@ -725,10 +753,6 @@ psppire_data_editor_init (PsppireDataEditor *de)
                            G_CALLBACK (on_activate),
                            de);
 
-  g_signal_connect_swapped (de->data_sheet[0], "deactivate",
-                           G_CALLBACK (on_deactivate),
-                           de);
-
   g_signal_connect_swapped (de->data_sheet[0], "select-range",
                            G_CALLBACK (on_select_range),
                            de);
@@ -1145,12 +1169,6 @@ on_activate (PsppireDataEditor *de)
 }
 
 
-static void
-on_deactivate (PsppireDataEditor *de)
-{
-  emit_selected_signal (de);
-}
-
 static void
 on_select_range (PsppireDataEditor *de)
 {