Added menuitem to display the PSPP reference manual.
[pspp-builds.git] / src / ui / gui / helper.c
index ae645a61477bb867a3c70f557cf92ff759ab62d3..7deb4cbb0cf0736aa3082f48fd0c609469d965b2 100644 (file)
@@ -1,6 +1,8 @@
 #include <config.h>
 
+#include <glib.h>
 #include "helper.h"
+#include "message-dialog.h"
 #include <data/data-in.h>
 #include <data/data-out.h>
 #include <libpspp/message.h>
@@ -11,6 +13,9 @@
 #include <string.h>
 #include <data/settings.h>
 
+
+#include <gettext.h>
+
 /* Formats a value according to FORMAT
    The returned string must be freed when no longer required */
 gchar *
@@ -82,3 +87,45 @@ pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err)
   return recode_string (CONV_PSPP_TO_UTF8, text, len);
 }
 
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
+static void
+give_help (void)
+{
+  static struct msg m = {
+    MSG_GENERAL,
+    MSG_NOTE,
+    {0, -1},
+    0,
+  };
+
+  if (! m.text)
+    m.text=g_strdup (_("Sorry. The help system hasn't yet been implemented."));
+
+  popup_message (&m);
+}
+
+void
+connect_help (GladeXML *xml)
+{
+  GList *helps = glade_xml_get_widget_prefix (xml, "help_button_");
+
+  GList *i;
+  for ( i = g_list_first (helps); i ; i = g_list_next (i))
+    g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0);
+}
+
+
+
+void
+reference_manual (GtkMenuItem *menu, gpointer data)
+{
+  GError *err = NULL;
+  if ( ! g_spawn_command_line_async ("yelp info:pspp", &err) )
+    {
+      msg (ME, _("Cannot open reference manual: %s"), err->message);
+    }
+  g_clear_error (&err);
+}