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.
94 The return value must be freed when no longer required*/
96 pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err)
98 return recode_string (CONV_PSPP_TO_UTF8, text, len);
101 #define _(msgid) gettext (msgid)
102 #define N_(msgid) msgid
108 static struct msg m = {
116 m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented."));
122 connect_help (GladeXML *xml)
124 GList *helps = glade_xml_get_widget_prefix (xml, "help_button_");
127 for ( i = g_list_first (helps); i ; i = g_list_next (i))
128 g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0);
134 reference_manual (GtkMenuItem *menu, gpointer data)
137 if ( ! g_spawn_command_line_async ("yelp info:pspp", &err) )
139 msg (ME, _("Cannot open reference manual: %s"), err->message);
141 g_clear_error (&err);
145 extern struct dataset *the_dataset;
146 extern struct source_stream *the_source_stream;
147 extern PsppireDataStore *the_data_store;
150 execute_syntax (struct getl_interface *sss)
154 g_return_val_if_fail (proc_has_source (the_dataset), FALSE);
156 lexer = lex_create (the_source_stream);
158 getl_append_source (the_source_stream, sss);
162 int result = cmd_parse (lexer, the_dataset);
164 if (result == CMD_EOF || result == CMD_FINISH)
168 getl_abort_noninteractive (the_source_stream);
172 /* The GUI must *always* have a data source, even if it's an empty one.
173 Therefore, we find that there is none, (for example NEW FILE was the last
174 item in the syntax) then we create a new one. */
175 if ( ! proc_has_source (the_dataset))
176 proc_set_source (the_dataset,
177 storage_source_create (the_data_store->case_file->flexifile)
180 /* GUI syntax needs this implicit EXECUTE command at the end of
181 every script. Otherwise commands like GET could leave the GUI without
183 return procedure (the_dataset, NULL, NULL);