/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2006, 2007, 2010 Free Software Foundation
+ Copyright (C) 2006, 2007, 2010, 2011, 2012, 2013, 2015, 2016 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
+#ifdef __APPLE__
+#define HTMLOPENAPP "open"
+#elif _WIN32
+#define HTMLOPENAPP "start"
+#else
+#define HTMLOPENAPP "xdg-open"
+#endif
-static const gchar *artists[] = { "Patrick Brunier", "Dondi Bogusky", NULL};
+static const gchar *artists[] = { "Bastián Díaz", "Hugo Alejandro", NULL};
static void
-about_new (GtkMenuItem *m, GtkWindow *parent)
+about_new (GtkMenuItem *mmm, GtkWindow *parent)
{
GtkWidget *about = gtk_about_dialog_new ();
- GdkPixbuf *pb =
- gdk_pixbuf_new_from_file_at_size (relocate (PKGDATADIR "/pspplogo.png"),
- 64, 64, 0);
-
- gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (about), pb);
-
+ gtk_about_dialog_set_logo_icon_name (GTK_ABOUT_DIALOG (about), "pspp");
gtk_window_set_icon_name (GTK_WINDOW (about), "pspp");
gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (about), PACKAGE_URL);
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about),
- bare_version);
+ announced_version);
gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (about),
(const gchar **) authors);
gtk_about_dialog_set_translator_credits
(
GTK_ABOUT_DIALOG (about),
- /* TRANSLATORS: Use this string to list the people who have helped with
- translation to your language. */
+ /* TRANSLATORS: Do not translate this string. Instead, put the names of the people
+ who have helped in the translation. */
_("translator-credits")
);
gtk_widget_hide (about);
}
-
-static void
-reference_manual (GtkMenuItem *menu, gpointer data)
+/* Open the manual at PAGE */
+void
+online_help (const char *page)
{
GError *err = NULL;
- gchar *cmd = g_strdup_printf ("yelp file://%s", relocate (DOCDIR "/pspp.xml"));
+ GError *htmlerr = NULL;
+ gchar *argv[3] = { "yelp", 0, 0};
+ gchar *htmlargv[3] = { HTMLOPENAPP, 0, 0};
+ gchar *htmlfilename = NULL;
+ gchar *htmlfullname = NULL;
- if ( ! g_spawn_command_line_async (cmd, &err) )
+ if (page == NULL)
{
- msg (ME, _("Cannot open reference manual: %s. The PSPP user manual is "
- "also available at %s"),
+ argv[1] = g_strdup_printf ("file://%s", relocate (DOCDIR "/pspp.xml"));
+ htmlfilename = g_strdup ("index.html");
+ htmlargv[1] = g_strdup_printf ("file://%s", htmlfilename);
+ }
+ else
+ {
+ gchar **tokens = NULL;
+ const int maxtokens = 5;
+ int idx = 0;
+ argv[1] = g_strdup_printf ("file://%s#%s",
+ relocate (DOCDIR "/pspp.xml"), page);
+ tokens = g_strsplit (page, "#", maxtokens);
+ for(;tokens[idx] && idx < maxtokens;idx++);
+ htmlfilename = g_strdup_printf ("%s.html", tokens[idx-1]);
+ g_strfreev (tokens);
+ }
+
+ htmlfullname = g_strdup_printf ("%s/%s", relocate (DOCDIR "/pspp.html"),
+ htmlfilename);
+ if (g_file_test (relocate (DOCDIR "/pspp.html"), G_FILE_TEST_EXISTS))
+ htmlargv[1] = g_strdup_printf ("file://%s", htmlfullname);
+ else
+ htmlargv[1] = g_strdup_printf (PACKAGE_URL "manual/html_node/%s",
+ htmlfilename);
+
+ g_free (htmlfullname);
+ g_free (htmlfilename);
+
+ if (! (g_spawn_async (NULL, argv,
+ NULL, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, &err) ||
+ g_spawn_async (NULL, htmlargv,
+ NULL, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, &htmlerr))
+ )
+ {
+ msg (ME, _("Cannot open reference manual via yelp: %s. "
+ "Cannot open via html: %s "
+ "The PSSP manual is also available at %s"),
err->message,
+ htmlerr->message,
PACKAGE_URL "documentation.html");
}
- g_free (cmd);
+ g_free (argv[1]);
+ g_free (htmlargv[1]);
g_clear_error (&err);
+ g_clear_error (&htmlerr);
}
-void
-merge_help_menu (GtkUIManager *uim)
+static void
+reference_manual (GtkMenuItem *menu, gpointer data)
+{
+ online_help (NULL);
+}
+
+GtkWidget *
+create_help_menu (GtkWindow *toplevel)
{
- GtkActionGroup *action_group = gtk_action_group_new ("help");
+ GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_Help"));
+ GtkWidget *menu = gtk_menu_new ();
- static const GtkActionEntry entries[] =
- {
- {
- "help", NULL, /* name, stock id */
- N_("_Help"), NULL, /* label, accelerator */
- NULL,
- NULL,
- },
-
- {
- "help_reference", GTK_STOCK_HELP, /* name, stock id */
- N_("_Reference Manual"), NULL, /* label, accelerator */
- NULL, /* tooltip */
- G_CALLBACK (reference_manual)
- },
-
- {
- "help_about", GTK_STOCK_ABOUT,
- NULL, NULL, NULL,
- G_CALLBACK (about_new)
- },
- };
-
- gtk_action_group_set_translation_domain (action_group, PACKAGE);
-
- gtk_ui_manager_add_ui_from_string (uim, "\
- <menubar name=\"menubar\">\
- <menu action=\"help\">\
- <menuitem action=\"help_reference\"/>\
- <menuitem action=\"help_about\"/>\
- </menu>\
- </menubar>\
- ", -1, 0);
-
- gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries), NULL);
-
- gtk_ui_manager_insert_action_group (uim, action_group, 0);
+ GtkWidget *help_about = gtk_menu_item_new_with_mnemonic (_("_About"));
+ 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,
+ "activate", accel_group,
+ GDK_KEY_F1, 0,
+ GTK_ACCEL_VISIBLE);
+
+ gtk_menu_attach (GTK_MENU (menu), help_ref, 0, 1, 0, 1);
+ gtk_menu_attach (GTK_MENU (menu), help_about, 0, 1, 1, 2);
+
+ 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);
+
+ return menuitem;
}