1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2012, 2013 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/>. */
20 #include "psppire-dialog-action-1sks.h"
22 #include "psppire-var-view.h"
24 #include "psppire-dialog.h"
25 #include "builder-wrapper.h"
27 static void psppire_dialog_action_1sks_init (PsppireDialogAction1sks *act);
28 static void psppire_dialog_action_1sks_class_init (PsppireDialogAction1sksClass *class);
30 G_DEFINE_TYPE (PsppireDialogAction1sks, psppire_dialog_action_1sks, PSPPIRE_TYPE_DIALOG_ACTION);
42 append_fragment (GString *string, const gchar *dist, PsppireVarView *vv)
44 g_string_append (string, "\n\t/KOLMOGOROV-SMIRNOV");
46 g_string_append (string, " ( ");
47 g_string_append (string, dist);
48 g_string_append (string, " ) = ");
50 psppire_var_view_append_names (vv, 0, string);
55 generate_syntax (PsppireDialogAction *act)
57 PsppireDialogAction1sks *rd = PSPPIRE_DIALOG_ACTION_1SKS (act);
60 GString *string = g_string_new ("NPAR TEST");
62 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_NORMAL])))
63 append_fragment (string, "NORMAL", PSPPIRE_VAR_VIEW (rd->variables));
65 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_UNIFORM])))
66 append_fragment (string, "UNIFORM", PSPPIRE_VAR_VIEW (rd->variables));
68 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_POISSON])))
69 append_fragment (string, "POISSON", PSPPIRE_VAR_VIEW (rd->variables));
71 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_EXPONENTIAL])))
72 append_fragment (string, "EXPONENTIAL", PSPPIRE_VAR_VIEW (rd->variables));
74 g_string_append (string, ".\n");
78 g_string_free (string, FALSE);
85 dialog_state_valid (gpointer data)
88 PsppireDialogAction1sks *fd = PSPPIRE_DIALOG_ACTION_1SKS (data);
90 GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (fd->variables));
92 if (gtk_tree_model_iter_n_children (liststore, NULL) < 1)
95 for (i = 0; i < 4; ++i)
97 if ( TRUE == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->cb[i])))
107 refresh (PsppireDialogAction *rd_)
109 PsppireDialogAction1sks *fd = PSPPIRE_DIALOG_ACTION_1SKS (rd_);
111 GtkTreeModel *liststore =
112 gtk_tree_view_get_model (GTK_TREE_VIEW (fd->variables));
113 gtk_list_store_clear (GTK_LIST_STORE (liststore));
115 for (i = 0; i < 4; ++i)
116 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->cb[i]), FALSE);
120 psppire_dialog_action_1sks_activate (GtkAction *a)
122 PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
123 PsppireDialogAction1sks *act = PSPPIRE_DIALOG_ACTION_1SKS (a);
125 GtkBuilder *xml = builder_new ("ks-one-sample.ui");
126 pda->dialog = get_widget_assert (xml, "ks-one-sample-dialog");
127 pda->source = get_widget_assert (xml, "dict-view");
129 act->variables = get_widget_assert (xml, "psppire-var-view1");
131 act->cb[CB_NORMAL] = get_widget_assert (xml, "checkbutton-normal");
132 act->cb[CB_POISSON] = get_widget_assert (xml, "checkbutton-poisson");
133 act->cb[CB_UNIFORM] = get_widget_assert (xml, "checkbutton-uniform");
134 act->cb[CB_EXPONENTIAL] = get_widget_assert (xml, "checkbutton-exp");
136 psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
137 psppire_dialog_action_set_refresh (pda, refresh);
139 g_object_unref (xml);
141 if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_1sks_parent_class)->activate)
142 PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_1sks_parent_class)->activate (pda);
146 psppire_dialog_action_1sks_class_init (PsppireDialogAction1sksClass *class)
148 GtkActionClass *action_class = GTK_ACTION_CLASS (class);
150 action_class->activate = psppire_dialog_action_1sks_activate;
151 PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
156 psppire_dialog_action_1sks_init (PsppireDialogAction1sks *act)