Added a dict parameter to data_in and dealt with the consequences.
[pspp-builds.git] / src / ui / gui / missing-val-dialog.c
index c80362da6bc3cefae99f6ae2297e85b83d076f41..16a7f6f34ba7bde4aea39394305def0327824a57 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2005, 2006  Free Software Foundation
+   Copyright (C) 2005, 2006, 2009  Free Software Foundation
 
    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
@@ -100,7 +100,8 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data)
              continue;
            }
 
-         if ( text_to_value (text, &v, *write_spec))
+         if ( text_to_value (text, &v, 
+                             dialog->dict, *write_spec))
            {
              nvals++;
              mv_add_value (&dialog->mvl, &v);
@@ -126,9 +127,9 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data)
       const gchar *low_text = gtk_entry_get_text (GTK_ENTRY (dialog->low));
       const gchar *high_text = gtk_entry_get_text (GTK_ENTRY (dialog->high));
 
-      if ( text_to_value (low_text, &low_val, *write_spec)
+      if ( text_to_value (low_text, &low_val, dialog->dict, *write_spec)
           &&
-          text_to_value (high_text, &high_val, *write_spec) )
+          text_to_value (high_text, &high_val, dialog->dict, *write_spec) )
        {
          if ( low_val.f > high_val.f )
            {
@@ -154,6 +155,7 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data)
        {
          union value discrete_val;
          if ( !text_to_value (discrete_text, &discrete_val,
+                              dialog->dict,
                              *write_spec))
            {
              err_dialog (_("Incorrect value for variable type"),
@@ -218,18 +220,18 @@ on_delete (GtkWidget *w, GdkEvent *e, gpointer data)
 }
 
 
-/* Creates the dialog structure from the xml */
+/* Creates the dialog structure */
 struct missing_val_dialog *
-missing_val_dialog_create (GtkBuilder *xml)
+missing_val_dialog_create (GtkWindow *toplevel)
 {
+  GtkBuilder *xml = builder_new ("var-sheet-dialogs.ui");
+
   struct missing_val_dialog *dialog = g_malloc (sizeof (*dialog));
 
   dialog->window = get_widget_assert (xml, "missing_values_dialog");
 
   gtk_window_set_transient_for
-    (GTK_WINDOW (dialog->window),
-     GTK_WINDOW (get_widget_assert (xml, "data_editor")));
-
+    (GTK_WINDOW (dialog->window), toplevel);
 
   g_signal_connect_swapped (get_widget_assert (xml, "missing_val_cancel"),
                   "clicked", G_CALLBACK (gtk_widget_hide), dialog->window);
@@ -265,6 +267,8 @@ missing_val_dialog_create (GtkBuilder *xml)
   g_signal_connect (dialog->button_range, "toggled",
                   G_CALLBACK (range), dialog);
 
+  g_object_unref (xml);
+
   return dialog;
 }
 
@@ -307,8 +311,9 @@ missing_val_dialog_show (struct missing_val_dialog *dialog)
       gchar *high_text;
       mv_get_range (&dialog->mvl, &low.f, &high.f);
 
-      low_text = value_to_text (low, *write_spec);
-      high_text = value_to_text (high, *write_spec);
+
+      low_text = value_to_text (low, dialog->dict, *write_spec);
+      high_text = value_to_text (high, dialog->dict,  *write_spec);
 
       gtk_entry_set_text (GTK_ENTRY (dialog->low), low_text);
       gtk_entry_set_text (GTK_ENTRY (dialog->high), high_text);
@@ -318,9 +323,7 @@ missing_val_dialog_show (struct missing_val_dialog *dialog)
       if ( mv_has_value (&dialog->mvl))
        {
          gchar *text;
-         union value value;
-         mv_get_value (&dialog->mvl, &value, 0);
-         text = value_to_text (value, *write_spec);
+         text = value_to_text (*mv_get_value (&dialog->mvl, 0), dialog->dict, *write_spec);
          gtk_entry_set_text (GTK_ENTRY (dialog->discrete), text);
          g_free (text);
        }
@@ -340,10 +343,9 @@ missing_val_dialog_show (struct missing_val_dialog *dialog)
          if ( i < n)
            {
              gchar *text ;
-             union value value;
 
-             mv_get_value (&dialog->mvl, &value, i);
-             text = value_to_text (value, *write_spec);
+             text = value_to_text (*mv_get_value (&dialog->mvl, i), dialog->dict,
+                                    *write_spec);
              gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), text);
              g_free (text);
            }