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
21 /* This file is a rubbish bin where stuff gets put when it doesn't seem to
28 #include "message-dialog.h"
29 #include <data/data-in.h>
30 #include <data/data-out.h>
31 #include <data/dictionary.h>
32 #include <data/storage-stream.h>
33 #include <libpspp/message.h>
35 #include <libpspp/i18n.h>
39 #include <data/settings.h>
41 #include <language/command.h>
42 #include <data/procedure.h>
43 #include <language/lexer/lexer.h>
44 #include "psppire-data-store.h"
49 /* Formats a value according to FORMAT
50 The returned string must be freed when no longer required */
52 value_to_text (union value v, struct fmt_spec format)
56 s = g_new (gchar, format.w + 1);
57 data_out (&v, &format, s);
67 text_to_value (const gchar *text, union value *v,
68 struct fmt_spec format)
72 if ( format.type != FMT_A)
74 if ( ! text ) return FALSE;
77 const gchar *s = text;
85 if ( !*s) return FALSE;
90 ok = data_in (ss_cstr (text), format.type, 0, 0,
91 v, fmt_var_width (&format));
99 get_widget_assert (GladeXML *xml, const gchar *name)
105 w = glade_xml_get_widget (xml, name);
108 g_warning ("Widget \"%s\" could not be found\n", name);
113 /* Converts a string in the pspp locale to utf-8.
114 The return value must be freed when no longer required*/
116 pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err)
118 return recode_string (CONV_PSPP_TO_UTF8, text, len);
121 #define _(msgid) gettext (msgid)
122 #define N_(msgid) msgid
128 static struct msg m = {
136 m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented."));
142 connect_help (GladeXML *xml)
144 GList *helps = glade_xml_get_widget_prefix (xml, "help_button_");
147 for ( i = g_list_first (helps); i ; i = g_list_next (i))
148 g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0);
154 reference_manual (GtkMenuItem *menu, gpointer data)
157 if ( ! g_spawn_command_line_async ("yelp info:pspp", &err) )
159 msg (ME, _("Cannot open reference manual: %s"), err->message);
161 g_clear_error (&err);
165 extern struct dataset *the_dataset;
166 extern struct source_stream *the_source_stream;
167 extern PsppireDataStore *the_data_store;
170 execute_syntax (struct getl_interface *sss)
174 g_return_val_if_fail (proc_has_source (the_dataset), FALSE);
176 lexer = lex_create (the_source_stream);
178 getl_append_source (the_source_stream, sss);
182 int result = cmd_parse (lexer, the_dataset);
184 if (result == CMD_EOF || result == CMD_FINISH)
188 getl_abort_noninteractive (the_source_stream);
192 /* The GUI must *always* have a data source, even if it's an empty one.
193 Therefore, we find that there is none, (for example NEW FILE was the last
194 item in the syntax) then we create a new one. */
195 if ( ! proc_has_source (the_dataset))
196 proc_set_source (the_dataset,
197 storage_source_create (the_data_store->case_file->flexifile)
200 /* GUI syntax needs this implicit EXECUTE command at the end of
201 every script. Otherwise commands like GET could leave the GUI without
203 return procedure (the_dataset, NULL, NULL);