1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2007, 2012 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "psppire-dialog.h"
23 #include <gl/xalloc.h>
24 #include "builder-wrapper.h"
26 #include "t-test-options.h"
28 #include "widget-io.h"
29 #include "psppire-scanf.h"
32 #define _(msgid) gettext (msgid)
33 #define N_(msgid) msgid
42 struct tt_options_dialog
46 GtkWidget *confidence;
47 GtkSpinButton *conf_percent;
48 GtkToggleButton *analysis;
49 GtkToggleButton *listwise;
51 gdouble confidence_interval;
52 gboolean non_default_options;
53 enum exclude_mode excl;
57 struct tt_options_dialog *
58 tt_options_dialog_create (GtkWindow *parent)
60 struct tt_options_dialog *tto = xmalloc (sizeof (*tto));
62 tto->xml = builder_new ("t-test.ui");
65 psppire_scanf_new (_("Confidence Interval: %2d %%"), &tto->conf_percent);
67 tto->dialog = get_widget_assert (tto->xml, "options-dialog");
69 tto->box = get_widget_assert (tto->xml, "vbox1");
71 tto->analysis = GTK_TOGGLE_BUTTON (get_widget_assert (tto->xml, "radiobutton1"));
72 tto->listwise = GTK_TOGGLE_BUTTON (get_widget_assert (tto->xml, "radiobutton2"));
74 gtk_widget_show (tto->confidence);
76 psppire_box_pack_start_defaults (GTK_BOX (tto->box), tto->confidence);
78 gtk_window_set_transient_for (GTK_WINDOW (tto->dialog), parent);
80 tto->confidence_interval = 95;
81 tto->excl = EXCL_ANALYSIS;
88 tt_options_dialog_destroy (struct tt_options_dialog *tto)
90 gtk_container_remove (GTK_CONTAINER (tto->box), tto->confidence);
91 g_object_unref (tto->xml);
97 tt_options_dialog_run (struct tt_options_dialog *tto)
101 if ( tto->excl == EXCL_ANALYSIS)
102 gtk_toggle_button_set_active (tto->analysis, TRUE);
104 gtk_toggle_button_set_active (tto->listwise, TRUE);
106 gtk_spin_button_set_value (tto->conf_percent, tto->confidence_interval);
108 response = psppire_dialog_run (PSPPIRE_DIALOG (tto->dialog));
110 if ( response == PSPPIRE_RESPONSE_CONTINUE)
112 tto->non_default_options = TRUE;
114 tto->confidence_interval = gtk_spin_button_get_value (tto->conf_percent);
115 if ( gtk_toggle_button_get_active (tto->analysis) )
116 tto->excl = EXCL_ANALYSIS;
118 tto->excl = EXCL_LISTWISE;
123 tt_options_dialog_append_syntax (const struct tt_options_dialog *tto, GString *str)
125 g_string_append (str, "\t/MISSING=");
127 if ( tto->excl == EXCL_ANALYSIS )
128 g_string_append (str, "ANALYSIS");
130 g_string_append (str, "LISTWISE");
133 g_string_append_printf (str, "\n\t/CRITERIA=CIN(%g)",
134 tto->confidence_interval/100.0);