X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fmissing-val-dialog.c;h=16a7f6f34ba7bde4aea39394305def0327824a57;hb=a5097a183f00ab2d2dc538ba7094a4696e2fea04;hp=86f7d86f464c8a7fce6824e1f7f1b1fc74e67c8f;hpb=92c09e564002d356d20fc1e2e131027ef89f6748;p=pspp-builds.git diff --git a/src/ui/gui/missing-val-dialog.c b/src/ui/gui/missing-val-dialog.c index 86f7d86f..16a7f6f3 100644 --- a/src/ui/gui/missing-val-dialog.c +++ b/src/ui/gui/missing-val-dialog.c @@ -1,21 +1,18 @@ -/* - PSPPIRE --- A Graphical User Interface for PSPP - Copyright (C) 2005, 2006 Free Software Foundation +/* PSPPIRE - a graphical user interface for PSPP. + 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ /* This module describes the behaviour of the Missing Values dialog box, used for input of the missing values in the variable sheet */ @@ -27,6 +24,7 @@ #include "helper.h" +#include #include "missing-val-dialog.h" #include #include @@ -34,7 +32,6 @@ #include -#include #include @@ -91,7 +88,7 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) gint badvals = 0; gint i; mv_clear(&dialog->mvl); - for(i = 0 ; i < 3 ; ++i ) + for(i = 0 ; i < 3 ; ++i ) { gchar *text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->mv[i]))); @@ -103,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); @@ -129,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 ) { @@ -151,12 +149,13 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->discrete))); mv_clear (&dialog->mvl); - mv_add_num_range (&dialog->mvl, low_val.f, high_val.f); + mv_add_range (&dialog->mvl, low_val.f, high_val.f); if ( discrete_text && strlen (g_strstrip (discrete_text)) > 0 ) { union value discrete_val; if ( !text_to_value (discrete_text, &discrete_val, + dialog->dict, *write_spec)) { err_dialog (_("Incorrect value for variable type"), @@ -221,20 +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 (GladeXML *xml) +missing_val_dialog_create (GtkWindow *toplevel) { - struct missing_val_dialog *dialog = g_malloc (sizeof (*dialog)); + GtkBuilder *xml = builder_new ("var-sheet-dialogs.ui"); - connect_help (xml); + 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); @@ -242,7 +239,7 @@ missing_val_dialog_create (GladeXML *xml) g_signal_connect (get_widget_assert (xml, "missing_val_ok"), "clicked", G_CALLBACK (missing_val_dialog_accept), dialog); - g_signal_connect (GTK_OBJECT (dialog->window), "delete-event", + g_signal_connect (dialog->window, "delete-event", G_CALLBACK (on_delete), dialog); dialog->mv[0] = get_widget_assert (xml, "mv0"); @@ -264,12 +261,14 @@ missing_val_dialog_create (GladeXML *xml) GTK_TOGGLE_BUTTON (get_widget_assert (xml, "range_missing")); - g_signal_connect (G_OBJECT (dialog->button_discrete), "toggled", + g_signal_connect (dialog->button_discrete, "toggled", G_CALLBACK (discrete), dialog); - g_signal_connect (G_OBJECT (dialog->button_range), "toggled", + g_signal_connect (dialog->button_range, "toggled", G_CALLBACK (range), dialog); + g_object_unref (xml); + return dialog; } @@ -310,10 +309,11 @@ missing_val_dialog_show (struct missing_val_dialog *dialog) union value low, high; gchar *low_text; gchar *high_text; - mv_peek_range (&dialog->mvl, &low.f, &high.f); + 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); @@ -323,9 +323,7 @@ missing_val_dialog_show (struct missing_val_dialog *dialog) if ( mv_has_value (&dialog->mvl)) { gchar *text; - union value value; - mv_peek_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); } @@ -345,10 +343,9 @@ missing_val_dialog_show (struct missing_val_dialog *dialog) if ( i < n) { gchar *text ; - union value value; - mv_peek_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); }