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 transpose_dialog (GObject *o, gpointer data)
53 struct data_editor *de = data;
55 GladeXML *xml = XML_NEW ("psppire.glade");
58 GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
60 PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
62 GtkWidget *dialog = get_widget_assert (xml, "transpose-dialog");
63 GtkWidget *source = get_widget_assert (xml, "source-treeview");
64 GtkWidget *dest = get_widget_assert (xml, "variables-treeview");
65 GtkWidget *selector1 = get_widget_assert (xml, "psppire-selector2");
66 GtkWidget *selector2 = get_widget_assert (xml, "psppire-selector3");
67 GtkWidget *new_name_entry = get_widget_assert (xml, "new-name-entry");
69 attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
71 GTK_SELECTION_MULTIPLE, NULL);
73 set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
75 psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector1),
77 insert_source_row_into_tree_view,
81 psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector2),
82 source, new_name_entry,
83 insert_source_row_into_entry,
84 is_currently_in_entry);
87 response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
93 gchar *syntax = generate_syntax (vs->dict, xml);
94 struct getl_interface *sss = create_syntax_string_source (syntax);
100 case PSPPIRE_RESPONSE_PASTE:
102 gchar *syntax = generate_syntax (vs->dict, xml);
104 struct syntax_editor *se =
105 (struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL);
107 gtk_text_buffer_insert_at_cursor (se->buffer, syntax, -1);
116 g_object_unref (xml);
121 FLIP /VARIABLES=var_list /NEWNAMES=var_name.
124 generate_syntax (PsppireDict *dict, GladeXML *xml)
127 GString *string = g_string_new ("FLIP");
130 GtkWidget *dest = get_widget_assert (xml, "variables-treeview");
131 GtkWidget *entry = get_widget_assert (xml, "new-name-entry");
133 g_string_append (string, " /VARIABLES = ");
135 append_variable_names (string, dict, GTK_TREE_VIEW (dest));
137 text = gtk_entry_get_text (GTK_ENTRY (entry));
140 g_string_append_printf (string, " /NEWNAME = %s", text);
142 g_string_append (string, ".");
144 syntax = string->str;
146 g_string_free (string, FALSE);