2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2007 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include "psppire-var-select.h"
24 #include <glade/glade.h>
28 #include "psppire-var-store.h"
29 #include "weight-cases-dialog.h"
31 #include "psppire-dialog.h"
33 #define _(msgid) gettext (msgid)
34 #define N_(msgid) msgid
37 refresh_var_select (PsppireVarSelect *vs)
39 struct variable *weight;
41 psppire_var_select_deselect_all (vs);
43 weight = psppire_dict_get_weight_variable (vs->dict);
46 psppire_var_select_set_variable (vs, weight);
51 on_refresh (GtkWidget *dialog, gpointer data)
53 refresh_var_select (data);
58 on_radiobutton_toggle (GtkToggleButton *button, gpointer data)
60 PsppireVarSelect *vs = data;
61 if ( gtk_toggle_button_get_active (button) )
63 psppire_var_select_deselect_all (vs);
68 /* Callback for when new variable is selected.
69 IDX is the dict index of the variable selected.
70 Updates the label and toggle buttons in the dialog box
71 to reflect this new selection. */
73 select_var_callback (PsppireVarSelect *vs, gint idx, gpointer data)
75 GladeXML * xml = data;
77 GtkWidget *label = get_widget_assert (xml, "weight-status-label");
79 GtkWidget *radiobutton2 = get_widget_assert (xml, "radiobutton2");
81 struct variable *var = psppire_dict_get_variable (vs->dict, idx);
83 gtk_label_set_text (GTK_LABEL (label), var_get_name(var));
85 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton2), TRUE);
91 deselect_all (PsppireVarSelect *vs, gpointer data)
93 GladeXML * xml = data;
95 GtkWidget *label = get_widget_assert (xml, "weight-status-label");
97 GtkWidget *radiobutton1 = get_widget_assert (xml, "radiobutton1");
99 gtk_label_set_text (GTK_LABEL (label), _("Do not weight cases"));
101 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton1), TRUE);
107 create_weight_dialog (PsppireVarSelect *select, GladeXML *xml)
109 GtkWidget *dialog = get_widget_assert (xml, "weight-cases-dialog");
110 GtkWidget *radiobutton1 = get_widget_assert (xml, "radiobutton1");
112 g_signal_connect (dialog, "refresh", G_CALLBACK (on_refresh), select);
114 g_signal_connect (select, "variable-selected",
115 G_CALLBACK (select_var_callback), xml);
117 g_signal_connect (select, "deselect-all",
118 G_CALLBACK (deselect_all), xml);
120 g_signal_connect (radiobutton1, "toggled",
121 G_CALLBACK (on_radiobutton_toggle),
124 refresh_var_select (select);
126 return PSPPIRE_DIALOG (dialog);