1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2007, 2009, 2010, 2011, 2012, 2014, 2016 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-var-view.h"
22 #include "psppire-dialog-action-recode-same.h"
23 #include "builder-wrapper.h"
24 #include <ui/gui/dialog-common.h>
26 #include "psppire-acr.h"
28 #include "psppire-selector.h"
29 #include "psppire-val-chooser.h"
32 #include <ui/syntax-gen.h>
35 #define _(msgid) gettext (msgid)
36 #define N_(msgid) msgid
39 difx_variable_treeview_is_populated (PsppireDialogActionRecode *rd)
44 gtk_tree_view_get_model (GTK_TREE_VIEW (rd->variable_treeview));
46 if (!gtk_tree_model_get_iter_first (vars, ¬_used))
53 /* Dialog is valid iff at least one variable has been selected,
54 AND the list of mappings is not empty.
57 dialog_state_valid (gpointer data)
59 PsppireDialogActionRecode *rd = data;
65 if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map),
69 return difx_variable_treeview_is_populated (rd);
76 psppire_dialog_action_recode_same_class_init (PsppireDialogActionRecodeSameClass *class);
78 G_DEFINE_TYPE (PsppireDialogActionRecodeSame, psppire_dialog_action_recode_same, PSPPIRE_TYPE_DIALOG_ACTION_RECODE);
81 refresh (PsppireDialogAction *rd)
83 psppire_dialog_action_recode_refresh (rd);
87 on_old_new_show (PsppireDialogActionRecode *rd)
89 gtk_toggle_button_set_active
90 (GTK_TOGGLE_BUTTON (rd->toggle[BUTTON_NEW_VALUE]), TRUE);
92 g_signal_emit_by_name (rd->toggle[BUTTON_NEW_VALUE], "toggled");
94 gtk_widget_hide (rd->toggle[BUTTON_NEW_COPY]);
95 gtk_widget_hide (rd->new_copy_label);
96 gtk_widget_hide (rd->strings_box);
100 psppire_dialog_action_recode_same_activate (PsppireDialogAction *a, GVariant *param)
102 PsppireDialogActionRecode *act = PSPPIRE_DIALOG_ACTION_RECODE (a);
103 PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
105 GtkBuilder *xml = psppire_dialog_action_recode_pre_activate (act, NULL);
107 gtk_window_set_title (GTK_WINDOW (pda->dialog),
108 _("Recode into Same Variables"));
110 g_signal_connect_swapped (act->old_and_new_dialog, "show",
111 G_CALLBACK (on_old_new_show), act);
113 gtk_window_set_title (GTK_WINDOW (act->old_and_new_dialog),
114 _("Recode into Same Variables: Old and New Values"));
116 gtk_widget_hide (act->output_variable_box);
118 psppire_dialog_action_set_refresh (pda, refresh);
120 psppire_dialog_action_set_valid_predicate (pda,
127 null_op (const PsppireDialogActionRecode *rd, struct string *dds)
132 same_generate_syntax (const PsppireDialogAction *act)
134 return psppire_dialog_action_recode_generate_syntax (act, null_op, null_op, null_op);
138 target_is_string (const PsppireDialogActionRecode *rd)
140 return rd->input_var_is_string;
145 psppire_dialog_action_recode_same_class_init (PsppireDialogActionRecodeSameClass *class)
147 PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_recode_same_activate;
149 PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = same_generate_syntax;
150 PSPPIRE_DIALOG_ACTION_RECODE_CLASS (class)->target_is_string = target_is_string;
155 psppire_dialog_action_recode_same_init (PsppireDialogActionRecodeSame *act)