1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2011, 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/>.
21 #include "psppire-data-window.h"
22 #include "psppire-selector.h"
23 #include "psppire-var-view.h"
25 #include "psppire-dict.h"
27 #include "dialog-common.h"
28 #include "psppire-dialog.h"
34 #include "psppire-var-ptr.h"
36 #include "paired-dialog.h"
37 #include "npar-two-sample-related.h"
40 #define _(msgid) gettext (msgid)
41 #define N_(msgid) msgid
62 struct ts_test *tst = aux;
64 for (i = 0 ; i < n_Tests; ++i)
66 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tst[i].button), FALSE);
75 struct ts_test *tst = aux;
77 for (i = 0 ; i < n_Tests; ++i)
79 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tst[i].button)))
89 generate_syntax (struct paired_samples_dialog *psd, const struct ts_test *test)
93 GString *str = g_string_new ("NPAR TEST");
95 for (i = 0 ; i < n_Tests; ++i)
97 if (! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (test[i].button)))
100 g_string_append (str, "\n\t");
101 g_string_append (str, test[i].syntax);
103 psppire_var_view_append_names (PSPPIRE_VAR_VIEW (psd->pairs_treeview), 0, str);
105 g_string_append (str, " WITH ");
107 psppire_var_view_append_names (PSPPIRE_VAR_VIEW (psd->pairs_treeview), 1, str);
109 g_string_append (str, " (PAIRED)");
112 g_string_append (str, ".\n");
115 g_string_free (str, FALSE);
120 /* Pops up the dialog box */
122 two_related_dialog (PsppireDataWindow *de)
125 struct ts_test nts[n_Tests];
126 struct paired_samples_dialog *tt_d = two_sample_dialog_create (de);
128 GtkWidget *frame = gtk_frame_new (_("Test Type"));
129 GtkWidget *bb = gtk_vbutton_box_new ();
131 strcpy (nts[NT_WILCOXON].syntax, "/WILCOXON");
132 strcpy (nts[NT_SIGN].syntax, "/SIGN");
133 strcpy (nts[NT_MCNEMAR].syntax, "/MCNEMAR");
135 nts[NT_WILCOXON].button = gtk_check_button_new_with_mnemonic (_("_Wilcoxon"));
136 nts[NT_SIGN].button = gtk_check_button_new_with_mnemonic (_("_Sign"));
137 nts[NT_MCNEMAR].button = gtk_check_button_new_with_mnemonic (_("_McNemar"));
139 gtk_box_pack_start (GTK_BOX (bb), nts[NT_WILCOXON].button, FALSE, FALSE, 5);
140 gtk_box_pack_start (GTK_BOX (bb), nts[NT_SIGN].button, FALSE, FALSE, 5);
141 gtk_box_pack_start (GTK_BOX (bb), nts[NT_MCNEMAR].button, FALSE, FALSE, 5);
143 gtk_container_add (GTK_CONTAINER (frame), bb);
145 gtk_widget_show_all (frame);
146 two_sample_dialog_add_widget (tt_d, frame);
148 tt_d->refresh = refresh;
152 gtk_window_set_title (GTK_WINDOW (tt_d->dialog), _("Two-Related-Samples Tests"));
154 response = psppire_dialog_run (PSPPIRE_DIALOG (tt_d->dialog));
158 case GTK_RESPONSE_OK:
159 g_free (execute_syntax_string (de, generate_syntax (tt_d, nts)));
161 case PSPPIRE_RESPONSE_PASTE:
162 g_free (paste_syntax_to_window (generate_syntax (tt_d, nts)));
168 two_sample_dialog_destroy (tt_d);