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 <libpspp/message.h>
14 #include <libpspp/i18n.h>
18 #include <data/settings.h>
20 #include <language/command.h>
21 #include <data/procedure.h>
22 #include <language/lexer/lexer.h>
27 /* Formats a value according to FORMAT
28 The returned string must be freed when no longer required */
30 value_to_text (union value v, struct fmt_spec format)
34 s = g_new (gchar, format.w + 1);
35 data_out (&v, &format, s);
45 text_to_value (const gchar *text, union value *v,
46 struct fmt_spec format)
50 if ( format.type != FMT_A)
52 if ( ! text ) return FALSE;
55 const gchar *s = text;
63 if ( !*s) return FALSE;
68 ok = data_in (ss_cstr (text), format.type, 0, 0,
69 v, fmt_var_width (&format));
77 get_widget_assert (GladeXML *xml, const gchar *name)
83 w = glade_xml_get_widget (xml, name);
86 g_warning ("Widget \"%s\" could not be found\n", name);
91 /* Converts a string in the pspp locale to utf-8 */
93 pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err)
95 return recode_string (CONV_PSPP_TO_UTF8, text, len);
98 #define _(msgid) gettext (msgid)
99 #define N_(msgid) msgid
105 static struct msg m = {
113 m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented."));
119 connect_help (GladeXML *xml)
121 GList *helps = glade_xml_get_widget_prefix (xml, "help_button_");
124 for ( i = g_list_first (helps); i ; i = g_list_next (i))
125 g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0);
131 reference_manual (GtkMenuItem *menu, gpointer data)
134 if ( ! g_spawn_command_line_async ("yelp info:pspp", &err) )
136 msg (ME, _("Cannot open reference manual: %s"), err->message);
138 g_clear_error (&err);
142 extern struct dataset *the_dataset;
143 extern struct source_stream *the_source_stream;
146 execute_syntax (struct getl_interface *sss)
149 g_return_if_fail (proc_has_source (the_dataset));
151 lexer = lex_create (the_source_stream);
153 getl_append_source (the_source_stream, sss);
157 const struct dictionary *dict = dataset_dict (the_dataset);
159 int result = cmd_parse (lexer, the_dataset,
160 dict_get_var_cnt (dict) > 0 ?
161 CMD_STATE_DATA : CMD_STATE_INITIAL);
163 if (result == CMD_EOF || result == CMD_FINISH)
167 getl_abort_noninteractive (the_source_stream);