Frequencies.ui: Adjust widget packing properties.
[pspp] / src / ui / gui / t-test-paired-samples.c
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2011  Free Software Foundation
3
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.
8
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.
13
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/>.
16 */
17
18 #include <config.h>
19 #include <gtk/gtk.h>
20
21 #include "t-test-options.h"
22 #include "t-test-paired-samples.h"
23
24 #include "psppire-data-window.h"
25 #include "psppire-selector.h"
26 #include "psppire-var-view.h"
27
28 #include "psppire-dict.h"
29 #include "psppire-var-store.h"
30
31 #include "dialog-common.h"
32 #include "psppire-dialog.h"
33
34 #include "executor.h"
35
36 #include "helper.h"
37
38 #include "psppire-var-ptr.h"
39
40 #include "paired-dialog.h"
41
42 #include <gettext.h>
43 #define _(msgid) gettext (msgid)
44 #define N_(msgid) msgid
45
46
47 static void
48 refresh (void *aux)
49 {
50 }
51
52
53 static gboolean
54 valid (void *aux)
55 {
56   return TRUE;
57 }
58
59 static gchar *
60 generate_syntax (const struct paired_samples_dialog *d, const struct tt_options_dialog *opt)
61 {
62   gchar *text = NULL;
63   GString *str =   g_string_new ("T-TEST \n\tPAIRS = ");
64
65   psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 0, str);
66
67   g_string_append (str, " WITH ");
68
69   psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 1, str);
70
71   g_string_append (str, " (PAIRED)");
72   g_string_append (str, "\n");
73
74   tt_options_dialog_append_syntax (opt, str);
75
76   g_string_append (str, ".\n");
77
78   text = str->str;
79   g_string_free (str, FALSE);
80
81   return text;
82 }
83
84 /* Pops up the dialog box */
85 void
86 t_test_paired_samples_dialog (PsppireDataWindow *de)
87 {
88   gint response;
89   struct paired_samples_dialog *tt_d = two_sample_dialog_create (de);
90   struct tt_options_dialog *opts = tt_options_dialog_create (GTK_WINDOW (de));
91
92   GtkWidget *bb = gtk_hbutton_box_new ();
93   GtkWidget *opt = gtk_button_new_with_mnemonic (_("_Options"));
94   gtk_box_pack_start (GTK_BOX (bb), opt, TRUE, TRUE, 5);
95
96   gtk_widget_show_all (bb);
97   two_sample_dialog_add_widget (tt_d, bb);
98   
99   g_signal_connect_swapped (opt, "clicked", G_CALLBACK (tt_options_dialog_run), opts);
100
101   tt_d->refresh = refresh;
102   tt_d->valid = valid;
103   tt_d->aux = opts;
104
105   gtk_window_set_title (GTK_WINDOW (tt_d->dialog), _("Paired Samples T Test"));
106
107   response = psppire_dialog_run (PSPPIRE_DIALOG (tt_d->dialog));
108
109   switch (response)
110     {
111     case GTK_RESPONSE_OK:
112       g_free (execute_syntax_string (de, generate_syntax (tt_d, opts)));
113       break;
114     case PSPPIRE_RESPONSE_PASTE:
115       g_free (paste_syntax_to_window (generate_syntax (tt_d, opts)));
116       break;
117     default:
118       break;
119     }
120
121   two_sample_dialog_destroy (tt_d);
122   tt_options_dialog_destroy (opts);
123 }