1 /* This file is a rubbish bin where stuff gets put when it doesn't seem to
8 #include "message-dialog.h"
9 #include <data/data-in.h>
10 #include <data/data-out.h>
11 #include <data/dictionary.h>
12 #include <data/storage-stream.h>
13 #include <libpspp/message.h>
15 #include <libpspp/i18n.h>
19 #include <data/settings.h>
21 #include <language/command.h>
22 #include <data/procedure.h>
23 #include <language/lexer/lexer.h>
24 #include "psppire-data-store.h"
29 /* Formats a value according to FORMAT
30 The returned string must be freed when no longer required */
32 value_to_text (union value v, struct fmt_spec format)
36 s = g_new (gchar, format.w + 1);
37 data_out (&v, &format, s);
47 text_to_value (const gchar *text, union value *v,
48 struct fmt_spec format)
52 if ( format.type != FMT_A)
54 if ( ! text ) return FALSE;
57 const gchar *s = text;
65 if ( !*s) return FALSE;
70 ok = data_in (ss_cstr (text), format.type, 0, 0,
71 v, fmt_var_width (&format));
79 get_widget_assert (GladeXML *xml, const gchar *name)
85 w = glade_xml_get_widget (xml, name);
88 g_warning ("Widget \"%s\" could not be found\n", name);
93 /* Converts a string in the pspp locale to utf-8 */
95 pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err)
97 return recode_string (CONV_PSPP_TO_UTF8, text, len);
100 #define _(msgid) gettext (msgid)
101 #define N_(msgid) msgid
107 static struct msg m = {
115 m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented."));
121 connect_help (GladeXML *xml)
123 GList *helps = glade_xml_get_widget_prefix (xml, "help_button_");
126 for ( i = g_list_first (helps); i ; i = g_list_next (i))
127 g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0);
133 reference_manual (GtkMenuItem *menu, gpointer data)
136 if ( ! g_spawn_command_line_async ("yelp info:pspp", &err) )
138 msg (ME, _("Cannot open reference manual: %s"), err->message);
140 g_clear_error (&err);
144 extern struct dataset *the_dataset;
145 extern struct source_stream *the_source_stream;
146 extern PsppireDataStore *the_data_store;
149 execute_syntax (struct getl_interface *sss)
153 g_return_val_if_fail (proc_has_source (the_dataset), FALSE);
155 lexer = lex_create (the_source_stream);
157 getl_append_source (the_source_stream, sss);
161 int result = cmd_parse (lexer, the_dataset);
163 if (result == CMD_EOF || result == CMD_FINISH)
167 getl_abort_noninteractive (the_source_stream);
171 /* The GUI must *always* have a data source, even if it's an empty one.
172 Therefore, we find that there is none, (for example NEW FILE was the last
173 item in the syntax) then we create a new one. */
174 if ( ! proc_has_source (the_dataset))
175 proc_set_source (the_dataset,
176 storage_source_create (the_data_store->case_file->flexifile)
179 /* GUI syntax needs this implicit EXECUTE command at the end of
180 every script. Otherwise commands like GET could leave the GUI without
182 return procedure (the_dataset, NULL, NULL);