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
22 #include "transpose-dialog.h"
23 #include "psppire-selector.h"
24 #include "psppire-dialog.h"
26 #include "data-editor.h"
27 #include "dict-display.h"
28 #include <language/syntax-string-source.h>
29 #include "syntax-editor.h"
31 #include "dialog-common.h"
34 #include <glade/glade.h>
38 #define _(msgid) gettext (msgid)
39 #define N_(msgid) msgid
42 /* FIXME: These shouldn't be here */
43 #include <gtksheet/gtksheet.h>
44 #include "psppire-var-store.h"
47 static gchar * generate_syntax (PsppireDict *dict, GladeXML *xml);
50 refresh (PsppireDialog *dialog, gpointer data)
53 GtkWidget *dest = get_widget_assert (xml, "variables-treeview");
54 GtkWidget *entry = get_widget_assert (xml, "new-name-entry");
55 GtkTreeModel *dmodel = gtk_tree_view_get_model (GTK_TREE_VIEW (dest));
57 gtk_list_store_clear (GTK_LIST_STORE (dmodel));
58 gtk_entry_set_text (GTK_ENTRY (entry), "");
62 transpose_dialog (GObject *o, gpointer data)
65 struct data_editor *de = data;
67 GladeXML *xml = XML_NEW ("psppire.glade");
70 GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
72 PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
74 GtkWidget *dialog = get_widget_assert (xml, "transpose-dialog");
75 GtkWidget *source = get_widget_assert (xml, "source-treeview");
76 GtkWidget *dest = get_widget_assert (xml, "variables-treeview");
77 GtkWidget *selector1 = get_widget_assert (xml, "psppire-selector2");
78 GtkWidget *selector2 = get_widget_assert (xml, "psppire-selector3");
79 GtkWidget *new_name_entry = get_widget_assert (xml, "new-name-entry");
81 attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
83 GTK_SELECTION_MULTIPLE, NULL);
85 set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
87 psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector1),
89 insert_source_row_into_tree_view,
93 psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector2),
94 source, new_name_entry,
95 insert_source_row_into_entry,
96 is_currently_in_entry);
99 g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), xml);
101 response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
105 case GTK_RESPONSE_OK:
107 gchar *syntax = generate_syntax (vs->dict, xml);
108 struct getl_interface *sss = create_syntax_string_source (syntax);
109 execute_syntax (sss);
114 case PSPPIRE_RESPONSE_PASTE:
116 gchar *syntax = generate_syntax (vs->dict, xml);
118 struct syntax_editor *se =
119 (struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL);
121 gtk_text_buffer_insert_at_cursor (se->buffer, syntax, -1);
130 g_object_unref (xml);
135 FLIP /VARIABLES=var_list /NEWNAMES=var_name.
138 generate_syntax (PsppireDict *dict, GladeXML *xml)
141 GString *string = g_string_new ("FLIP");
144 GtkWidget *dest = get_widget_assert (xml, "variables-treeview");
145 GtkWidget *entry = get_widget_assert (xml, "new-name-entry");
147 g_string_append (string, " /VARIABLES = ");
149 append_variable_names (string, dict, GTK_TREE_VIEW (dest));
151 text = gtk_entry_get_text (GTK_ENTRY (entry));
154 g_string_append_printf (string, " /NEWNAME = %s", text);
156 g_string_append (string, ".");
158 syntax = string->str;
160 g_string_free (string, FALSE);