X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fmissing-val-dialog.c;h=7d22c928efb3995bd8f828e3169e2f14cd184902;hb=782d25daa41a6e267b0c7c6482835fac12964bbc;hp=351279883542e8206be470e549b59ba45a6cee65;hpb=bc02bc027697df3207f827de722c26d8cc87e824;p=pspp-builds.git diff --git a/src/ui/gui/missing-val-dialog.c b/src/ui/gui/missing-val-dialog.c index 35127988..7d22c928 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 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 */ @@ -67,11 +64,11 @@ err_dialog (const gchar *msg, GtkWindow *window) hbox = gtk_hbox_new (FALSE, 10); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox); - gtk_box_pack_start (GTK_BOX(hbox), icon, TRUE, FALSE, 10); - gtk_box_pack_start (GTK_BOX(hbox), label, TRUE, TRUE, 10); + gtk_box_pack_start (GTK_BOX (hbox), icon, TRUE, FALSE, 10); + gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 10); gtk_widget_show_all (dialog); } @@ -90,11 +87,11 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) gint nvals = 0; gint badvals = 0; gint i; - mv_clear (&dialog->mvl); - for (i = 0 ; i < 3 ; ++i ) + mv_clear(&dialog->mvl); + for(i = 0 ; i < 3 ; ++i ) { gchar *text = - g_strdup (gtk_entry_get_text (GTK_ENTRY(dialog->mv[i]))); + g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->mv[i]))); union value v; if ( !text || strlen (g_strstrip (text)) == 0 ) @@ -115,7 +112,7 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) if ( nvals == 0 || badvals > 0 ) { err_dialog (_("Incorrect value for variable type"), - GTK_WINDOW(dialog->window)); + GTK_WINDOW (dialog->window)); return ; } } @@ -126,8 +123,8 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) union value low_val ; union value high_val; - const gchar *low_text = gtk_entry_get_text (GTK_ENTRY(dialog->low)); - const gchar *high_text = gtk_entry_get_text (GTK_ENTRY(dialog->high)); + 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) && @@ -136,22 +133,22 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) if ( low_val.f > high_val.f ) { err_dialog (_("Incorrect range specification"), - GTK_WINDOW(dialog->window)); + GTK_WINDOW (dialog->window)); return ; } } else { err_dialog (_("Incorrect range specification"), - GTK_WINDOW(dialog->window)); + GTK_WINDOW (dialog->window)); return; } discrete_text = - g_strdup (gtk_entry_get_text (GTK_ENTRY(dialog->discrete))); + 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 ) { @@ -160,7 +157,7 @@ missing_val_dialog_accept (GtkWidget *w, gpointer data) *write_spec)) { err_dialog (_("Incorrect value for variable type"), - GTK_WINDOW(dialog->window) ); + GTK_WINDOW (dialog->window) ); g_free (discrete_text); return; } @@ -207,25 +204,43 @@ range (GtkToggleButton *button, gpointer data) } + +/* Callback for when the Missing Value dialog is closed using + the window delete button.*/ +static gint +on_delete (GtkWidget *w, GdkEvent *e, gpointer data) +{ + struct missing_val_dialog *dialog = data; + + gtk_widget_hide (dialog->window); + + return TRUE; +} + + /* Creates the dialog structure from the xml */ struct missing_val_dialog * missing_val_dialog_create (GladeXML *xml) { struct missing_val_dialog *dialog = g_malloc (sizeof (*dialog)); + connect_help (xml); + 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), + GTK_WINDOW (get_widget_assert (xml, "data_editor"))); g_signal_connect_swapped (get_widget_assert (xml, "missing_val_cancel"), - "clicked", G_CALLBACK(gtk_widget_hide), dialog->window); + "clicked", G_CALLBACK (gtk_widget_hide), dialog->window); g_signal_connect (get_widget_assert (xml, "missing_val_ok"), - "clicked", G_CALLBACK(missing_val_dialog_accept), dialog); + "clicked", G_CALLBACK (missing_val_dialog_accept), dialog); + g_signal_connect (dialog->window, "delete-event", + G_CALLBACK (on_delete), dialog); dialog->mv[0] = get_widget_assert (xml, "mv0"); dialog->mv[1] = get_widget_assert (xml, "mv1"); @@ -237,20 +252,20 @@ missing_val_dialog_create (GladeXML *xml) dialog->button_none = - GTK_TOGGLE_BUTTON(get_widget_assert (xml, "no_missing")); + GTK_TOGGLE_BUTTON (get_widget_assert (xml, "no_missing")); dialog->button_discrete = - GTK_TOGGLE_BUTTON(get_widget_assert (xml, "discrete_missing")); + GTK_TOGGLE_BUTTON (get_widget_assert (xml, "discrete_missing")); dialog->button_range = - GTK_TOGGLE_BUTTON(get_widget_assert (xml, "range_missing")); + GTK_TOGGLE_BUTTON (get_widget_assert (xml, "range_missing")); - g_signal_connect (G_OBJECT(dialog->button_discrete), "toggled", - G_CALLBACK(discrete), dialog); + g_signal_connect (G_OBJECT (dialog->button_discrete), "toggled", + G_CALLBACK (discrete), dialog); - g_signal_connect (G_OBJECT(dialog->button_range), "toggled", - G_CALLBACK(range), dialog); + g_signal_connect (G_OBJECT (dialog->button_range), "toggled", + G_CALLBACK (range), dialog); return dialog; } @@ -270,20 +285,20 @@ missing_val_dialog_show (struct missing_val_dialog *dialog) write_spec = var_get_write_format (dialog->pv); /* Blank all entry boxes and make them insensitive */ - gtk_entry_set_text (GTK_ENTRY(dialog->low), ""); - gtk_entry_set_text (GTK_ENTRY(dialog->high), ""); - gtk_entry_set_text (GTK_ENTRY(dialog->discrete), ""); + gtk_entry_set_text (GTK_ENTRY (dialog->low), ""); + gtk_entry_set_text (GTK_ENTRY (dialog->high), ""); + gtk_entry_set_text (GTK_ENTRY (dialog->discrete), ""); gtk_widget_set_sensitive (dialog->low, FALSE); gtk_widget_set_sensitive (dialog->high, FALSE); gtk_widget_set_sensitive (dialog->discrete, FALSE); - gtk_widget_set_sensitive (GTK_WIDGET(dialog->button_range), + gtk_widget_set_sensitive (GTK_WIDGET (dialog->button_range), var_is_numeric (dialog->pv)); for (i = 0 ; i < 3 ; ++i ) { - gtk_entry_set_text (GTK_ENTRY(dialog->mv[i]), ""); + gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), ""); gtk_widget_set_sensitive (dialog->mv[i], FALSE); } @@ -292,13 +307,13 @@ 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); - gtk_entry_set_text (GTK_ENTRY(dialog->low), low_text); - gtk_entry_set_text (GTK_ENTRY(dialog->high), high_text); + gtk_entry_set_text (GTK_ENTRY (dialog->low), low_text); + gtk_entry_set_text (GTK_ENTRY (dialog->high), high_text); g_free (low_text); g_free (high_text); @@ -306,9 +321,9 @@ missing_val_dialog_show (struct missing_val_dialog *dialog) { gchar *text; union value value; - mv_peek_value (&dialog->mvl, &value, 0); + mv_get_value (&dialog->mvl, &value, 0); text = value_to_text (value, *write_spec); - gtk_entry_set_text (GTK_ENTRY(dialog->discrete), text); + gtk_entry_set_text (GTK_ENTRY (dialog->discrete), text); g_free (text); } @@ -329,9 +344,9 @@ missing_val_dialog_show (struct missing_val_dialog *dialog) gchar *text ; union value value; - mv_peek_value (&dialog->mvl, &value, i); + mv_get_value (&dialog->mvl, &value, i); text = value_to_text (value, *write_spec); - gtk_entry_set_text (GTK_ENTRY(dialog->mv[i]), text); + gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), text); g_free (text); } gtk_widget_set_sensitive (dialog->mv[i], TRUE);