[pitivi] flatpak: Bundle yelp so that users can see the user manual



commit c0ad6e2b27eab050105f1eae603eaf77f3078892
Author: Thibault Saunier <tsaunier gnome org>
Date:   Wed Jun 1 15:19:29 2016 -0400

    flatpak: Bundle yelp so that users can see the user manual
    
    Fixes T7445
    
    Reviewed-by: Alex Băluț <alexandru balut gmail com>
    Differential Revision: https://phabricator.freedesktop.org/D1046

 build/flatpak/pitivi.template.json |   10 ++++++++++
 pitivi/utils/misc.py               |   31 +++++++++++++++++++++++++------
 2 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/build/flatpak/pitivi.template.json b/build/flatpak/pitivi.template.json
index be8a503..f4b3174 100644
--- a/build/flatpak/pitivi.template.json
+++ b/build/flatpak/pitivi.template.json
@@ -316,6 +316,16 @@
             ]
         },
         {
+            "name": "yelp",
+            "sources": [
+                {
+                    "type": "git",
+                    "url": "https://git.gnome.org/browse/yelp";,
+                    "branch": "3.20.1"
+                }
+            ]
+        },
+        {
             "name": "pitivi",
             "sources": [
                 {
diff --git a/pitivi/utils/misc.py b/pitivi/utils/misc.py
index 66ed87c..2d77e6b 100644
--- a/pitivi/utils/misc.py
+++ b/pitivi/utils/misc.py
@@ -20,6 +20,7 @@
 import bisect
 import hashlib
 import os
+import subprocess
 import threading
 import time
 from gettext import gettext as _
@@ -250,19 +251,37 @@ def show_user_manual(page=None):
     Display the user manual with Yelp.
     Optional: for contextual help, a page ID can be specified.
     """
+    def get_page_uri(uri, page):
+        if page is not None:
+            return uri + "#" + page
+        return uri
+
     time_now = int(time.time())
     uris = (APPMANUALURL_OFFLINE, APPMANUALURL_ONLINE)
     for uri in uris:
-        if page is not None:
-            uri += "#" + page
         try:
-            Gtk.show_uri(None, uri, time_now)
+            Gtk.show_uri(None, get_page_uri(uri, page), time_now)
             return
         except Exception as e:
-            log.debug("utils", "Failed loading URI %s: %s", uri, e)
+            log.info("utils", "Failed loading URI %s: %s", uri, e)
             continue
-    log.warning("utils", "Failed loading URIs")
-    # TODO: Show an error message to the user.
+
+    try:
+        # Last try calling yelp directly (used in flatpak while we do
+        # not have a portal to access system wild apps)
+        subprocess.Popen(["yelp",
+                          get_page_uri(APPMANUALURL_OFFLINE, page)])
+    except FileNotFoundError:
+        log.warning("utils", "Failed loading URIs")
+        dialog = Gtk.MessageDialog(modal=True,
+                                   message_type=Gtk.MessageType.ERROR,
+                                   buttons=Gtk.ButtonsType.OK,
+                                   text=_("Failed to open the user manual."
+                                          " Make sure to have either the `yelp` gnome "
+                                          " documentaion viewer or a web browser"
+                                          " installed"))
+        dialog.run()
+        dialog.destroy()
 
 
 def unicode_error_dialog():


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