[gtranslator/leo: 5/5] Use gtk_show_uri_on_window instead callig yelp directly



commit 0d9c97a1249e5e9e4399fcc29d2e00cb796896d0
Author: Daniel Mustieles <daniel mustieles gmail com>
Date:   Thu Oct 10 09:03:55 2019 +0200

    Use gtk_show_uri_on_window instead callig yelp directly

 src/gtr-actions-app.c |  2 +-
 src/gtr-utils.c       | 92 +++------------------------------------------------
 src/gtr-utils.h       |  4 +--
 3 files changed, 7 insertions(+), 91 deletions(-)
---
diff --git a/src/gtr-actions-app.c b/src/gtr-actions-app.c
index 9f1acabe..1ac0e7b8 100644
--- a/src/gtr-actions-app.c
+++ b/src/gtr-actions-app.c
@@ -37,7 +37,7 @@
 void
 gtr_show_help (GtrWindow *window)
 {
-  gtr_utils_help_display (GTK_WINDOW (window), "gtranslator", "");
+  gtr_utils_help_display (GTK_WINDOW (window));
 }
 
 /* Creates and shows the about box for gtranslator */
diff --git a/src/gtr-utils.c b/src/gtr-utils.c
index 33a20c67..36356b2e 100644
--- a/src/gtr-utils.c
+++ b/src/gtr-utils.c
@@ -448,96 +448,14 @@ finally_2:
 /**
  * gtr_utils_help_display:
  * @parent: a #GtkWindow
- * @doc_id: the name of the type of doc
- * @file_name: the name of the doc
- * 
- * Shows the help for an specific document in the default help browser.
+ *
+ * Launches the help viewer on @screen to show gtranslator's help
  */
 void
-gtr_utils_help_display (GtkWindow * parent,
-                        const gchar * doc_id, const gchar * file_name)
+gtr_utils_help_display (GtkWindow * window)
 {
-
-  GError *error = NULL;
-  gchar *command;
-  const gchar *lang;
-  const gchar *const *langs;
-  const gchar *path;
-  gchar *uri = NULL;
-  gint i;
-
-
-  /* FIXME: How to display help on windows. Gedit opens a browser and displays
-     a url with the contents of the help 
-     if (uri == NULL)
-     {
-     GtkWidget *dialog;
-     dialog = gtk_message_dialog_new (parent,
-     GTK_DIALOG_DESTROY_WITH_PARENT,
-     GTK_MESSAGE_ERROR,
-     GTK_BUTTONS_CLOSE,
-     _("Sorry, Translation Editor for windows is unable to display help yet."));
-     gtk_dialog_run (GTK_DIALOG (dialog));
-     gtk_widget_destroy (dialog);
-
-     return;
-     } End of FIXME: How to display help on windows. */
-
-
-  g_return_if_fail (file_name != NULL);
-
-  langs = g_get_language_names ();
-  for (i = 0; langs[i]; i++)
-    {
-      lang = langs[i];
-      if (strchr (lang, '.'))
-        continue;
-
-      path = gtr_dirs_get_gtr_help_dir ();
-      uri = g_build_filename (path, lang,
-                              doc_id, file_name, NULL);
-
-      if (g_file_test (uri, G_FILE_TEST_EXISTS))
-        {
-          break;
-        }
-      g_free (uri);
-      uri = NULL;
-    }
-
-
-  if (uri == NULL)
-    {
-      GtkWidget *dialog;
-      dialog = gtk_message_dialog_new (parent,
-                                       GTK_DIALOG_DESTROY_WITH_PARENT,
-                                       GTK_MESSAGE_ERROR,
-                                       GTK_BUTTONS_CLOSE,
-                                       _("Unable to display help. "
-                                         "Please make sure the Translation Editor "
-                                         "documentation package is installed."));
-      gtk_dialog_run (GTK_DIALOG (dialog));
-      gtk_widget_destroy (dialog);
-
-      return;
-    }
-
-  /* Should be updated to use gtk_show_uri instead, see
-   * https://wiki.gnome.org/Initiatives/GnomeGoals/RemoveGnomeOpenGnomeHelp */
-  command = g_strconcat ("yelp ", uri, NULL);
-  g_free (uri);
-
-  g_spawn_command_line_async (command, &error);
-
-
-  if (error != NULL)
-    {
-      g_warning ("Error executing help application: %s", error->message);
-      g_error_free (error);
-
-      return;
-    }
-  g_free (command);
+  gtk_show_uri_on_window (GTK_WINDOW (window), "help:gtranslator",
+                          gtk_get_current_event_time (), NULL);
 }
 
 gchar *
diff --git a/src/gtr-utils.h b/src/gtr-utils.h
index 8916d879..86e84d49 100644
--- a/src/gtr-utils.h
+++ b/src/gtr-utils.h
@@ -55,9 +55,7 @@ void gtr_utils_menu_position_under_tree_view (GtkMenu * menu,
      gboolean g_utf8_caselessnmatch (const gchar * s1,
                                      const gchar * s2, gssize n1, gssize n2);
 
-     void gtr_utils_help_display (GtkWindow * parent,
-                                  const gchar * doc_id,
-                                  const gchar * file_name);
+     void gtr_utils_help_display (GtkWindow * parent);
 
      gchar *gtr_utils_get_user_config_dir (void);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]