Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / src / ui / gui / goto-case-dialog.c
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2007  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 "goto-case-dialog.h"
20 #include "helper.h"
21 #include "psppire-dialog.h"
22 #include "data-editor.h"
23 #include "psppire-data-store.h"
24
25
26 static void
27 refresh (const struct data_editor *de, GladeXML *xml)
28 {
29   PsppireDataStore *ds = NULL;
30   casenumber case_count ;
31
32   GtkWidget *case_num_entry = get_widget_assert (xml, "goto-case-case-num-entry");
33
34   g_object_get (de->data_editor, "data-store", &ds, NULL);
35
36   case_count =  psppire_data_store_get_case_count (ds);
37
38   gtk_spin_button_set_range (GTK_SPIN_BUTTON (case_num_entry),
39                              1, case_count);
40 }
41
42 void
43 goto_case_dialog (GObject *o, gpointer data)
44 {
45   gint response;
46   GladeXML *xml = XML_NEW ("psppire.glade");
47   struct data_editor *de = data;
48
49   GtkWidget *dialog = get_widget_assert   (xml, "goto-case-dialog");
50
51
52   gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window);
53
54   refresh (de, xml);
55
56   response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
57
58   if ( response == PSPPIRE_RESPONSE_GOTO )
59     {
60       glong case_num;
61       GtkWidget *case_num_entry =
62         get_widget_assert (xml, "goto-case-case-num-entry");
63
64       case_num = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (case_num_entry))
65         - FIRST_CASE_NUMBER ;
66
67       g_object_set (de->data_editor, "current-case", case_num, NULL);
68     }
69 }