Set the cell value when the reference entry changes
[pspp] / src / ui / gui / psppire-data-editor.c
index f1712ad4b7f683b74110ebbdc641dd8af13840a8..0efd8ce835186de958d58e28f704b1ff9c38e83d 100644 (file)
@@ -218,7 +218,6 @@ psppire_data_editor_switch_page (GtkNotebook     *notebook,
                                  guint            page_num)
 {
   GTK_NOTEBOOK_CLASS (parent_class)->switch_page (notebook, w, page_num);
-
 }
 
 static void
@@ -226,7 +225,6 @@ psppire_data_editor_set_focus_child (GtkContainer *container,
                                      GtkWidget    *widget)
 {
   GTK_CONTAINER_CLASS (parent_class)->set_focus_child (container, widget);
-
 }
 
 static void
@@ -347,8 +345,23 @@ refresh_entry (PsppireDataEditor *de)
 }
 
 static void
-on_datum_entry_activate (PsppireValueEntry *entry, PsppireDataEditor *de)
+on_datum_entry_activate (GtkEntry *entry, PsppireDataEditor *de)
 {
+  gint row, col;
+  if (ssw_sheet_get_active_cell (SSW_SHEET (de->data_sheet), &col, &row))
+    {
+      union value val;
+      const struct variable *var = psppire_dict_get_variable (de->dict, col);
+      if (var == NULL)
+       return;
+
+      value_init (&val, var_get_width (var));
+
+      if (psppire_value_entry_get_value (de->datum_entry, &val, var_get_width (var)))
+       {
+         psppire_data_store_set_value (de->data_store, row, var, &val);
+       }
+    }
 }
 
 
@@ -509,7 +522,6 @@ psppire_data_editor_init (PsppireDataEditor *de)
       g_free (fontname);
       set_font_recursively (GTK_WIDGET (de), de->font);
     }
-
 }
 
 GtkWidget*