psppire-output-view: Set tooltips on tables from table_item notes.
[pspp] / src / ui / gui / help-menu.c
index b5b38757c355ef5a6791b83605ce71b662d14dcf..f203ea773eb3622641e88f7a352b1ec6518bf4e7 100644 (file)
 
 #include <gtk/gtk.h>
 
-#include <libpspp/copyleft.h>
-#include <libpspp/version.h>
-#include "help-menu.h"
-#include <libpspp/message.h>
+#include "libpspp/cast.h"
+#include "libpspp/copyleft.h"
+#include "libpspp/message.h"
+#include "libpspp/version.h"
+#include "ui/gui/help-menu.h"
 
 #include "gl/configmake.h"
 #include "gl/relocatable.h"
 /* Try to open html documentation uri via the default
    browser on the operating system */
 #ifdef __APPLE__
-#define HTMLOPENARGV {"open", 0, 0}
+#define HTMLOPENAPP "open"
 #elif  _WIN32
-#define HTMLOPENARGV {"wscript", 0, 0}
+#define HTMLOPENAPP "wscript"
 #else
-#define HTMLOPENARGV {"xdg-open", 0, 0}
+#define HTMLOPENAPP "xdg-open"
 #endif
 
 static const gchar *artists[] = { "Bastián Díaz", "Hugo Alejandro", NULL};
@@ -72,13 +73,13 @@ about_new (GtkMenuItem *mmm, GtkWindow *parent)
   gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about),
                                  "Free Software Foundation");
 
-  gtk_about_dialog_set_translator_credits 
+  gtk_about_dialog_set_translator_credits
     (
      GTK_ABOUT_DIALOG (about),
      /* TRANSLATORS: Do not translate this string.  Instead, put the names of the people
        who have helped in the translation. */
      _("translator-credits")
-     );
+);
 
   gtk_window_set_transient_for (GTK_WINDOW (about), parent);
 
@@ -113,7 +114,7 @@ static gboolean open_windows_help (const gchar *helpuri,
   if (!result)
     goto error;
 
-  gchar *argv[] = {"wscript",vbsfilename,0};
+  gchar *argv[] = {CONST_CAST (gchar *, "wscript"), vbsfilename, 0};
 
   result = g_spawn_async (NULL, argv,
                           NULL, G_SPAWN_SEARCH_PATH,
@@ -131,17 +132,13 @@ static gboolean open_windows_help (const gchar *helpuri,
 void
 online_help (const char *page)
 {
-  GError *err = NULL;
   GError *htmlerr = NULL;
-  gchar *argv[3] = { "yelp", 0, 0};
-  gchar *htmlargv[3] = HTMLOPENARGV;
   gchar *htmlfilename = NULL;
   gchar *htmlfullname = NULL;
   gchar *htmluri = NULL;
 
   if (page == NULL)
     {
-      argv[1] = g_strdup_printf ("file://%s", relocate (DOCDIR "/pspp.xml"));
       htmlfilename = g_strdup ("index.html");
     }
   else
@@ -149,8 +146,6 @@ online_help (const char *page)
       gchar **tokens = NULL;
       const int maxtokens = 5;
       int idx ;
-      argv[1] = g_strdup_printf ("file://%s#%s",
-                                 relocate (DOCDIR "/pspp.xml"), page);
       /* The page will be translated to the htmlfilename
          page                   htmlfilename
          GRAPH#SCATTERPLOT      SCATTERPLOT.html
@@ -181,38 +176,31 @@ online_help (const char *page)
                                htmlfilename);
   g_free (htmlfullname);
   g_free (htmlfilename);
-  htmlargv[1] = htmluri;
 
   /* The following **SHOULD** work but it does not on 28.5.2016
      g_app_info_launch_default_for_uri (htmluri, NULL, &err);
      osx: wine is started to launch the uri...
      windows: not so bad, but the first access does not work*/
 
-  if (! (g_spawn_async (NULL, argv,
-                        NULL, G_SPAWN_SEARCH_PATH,
-                        NULL, NULL,   NULL,   &err) ||
 #ifdef _WIN32
-         open_windows_help (htmluri, &htmlerr))
+  bool ok = open_windows_help (htmluri, &htmlerr);
 #else
-         g_spawn_async (NULL, htmlargv,
-                        NULL, G_SPAWN_SEARCH_PATH,
-                        NULL, NULL,   NULL,   &htmlerr))
+  gchar *htmlargv[3] = {CONST_CAST (char *, HTMLOPENAPP), htmluri, 0};
+  bool ok = g_spawn_async (NULL, htmlargv,
+                           NULL, G_SPAWN_SEARCH_PATH,
+                           NULL, NULL, NULL, &htmlerr);
 #endif
-      )
+  if (!ok)
     {
-      msg (ME, _("Cannot open reference manual via yelp: %s. "
-                 "Cannot open via html: %s "
+      msg (ME, _("Cannot open via html: %s "
                  "with uri: %s "
                  "The PSSP manual is also available at %s"),
-                  err->message,
                   htmlerr->message,
                   htmluri,
                   PACKAGE_URL "documentation.html");
     }
 
-  g_free (argv[1]);
   g_free (htmluri);
-  g_clear_error (&err);
   g_clear_error (&htmlerr);
 }
 
@@ -232,7 +220,7 @@ create_help_menu (GtkWindow *toplevel)
   GtkWidget *help_ref = gtk_menu_item_new_with_mnemonic (_("_Reference Manual"));
 
   GtkAccelGroup *accel_group = gtk_accel_group_new ();
-  
+
   gtk_window_add_accel_group (toplevel, accel_group);
 
   gtk_widget_add_accelerator (help_ref,
@@ -245,10 +233,12 @@ create_help_menu (GtkWindow *toplevel)
 
   g_signal_connect (help_about, "activate", G_CALLBACK (about_new), toplevel);
   g_signal_connect (help_ref, "activate", G_CALLBACK (reference_manual), NULL);
-  
+
   g_object_set (menuitem, "submenu", menu, NULL);
 
   gtk_widget_show_all (menuitem);
-  
+
+  g_object_unref (accel_group);
+
   return menuitem;
 }