File: check_solfege-doc_before_launching_help.diff

package info (click to toggle)
solfege 3.23.4-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 29,492 kB
  • sloc: python: 26,937; xml: 4,380; ansic: 1,544; sh: 807; makefile: 656; perl: 8; exp: 7
file content (34 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Author: Francois Mazen <francois@mzf.fr>
Description: Check that solfege-doc package is installed before launching the browser.
Forwarded: not-needed

--- a/solfege/mainwin.py
+++ b/solfege/mainwin.py
@@ -52,6 +52,7 @@
 
 from solfege import i18n
 
+import apt
 
 class SplashWin(Gtk.Window):
 
@@ -502,10 +503,15 @@
             filename = os.path.join(os.getcwd(), "help", lang, fn)
             if os.path.isfile(filename):
                 break
-        try:
-            webbrowser.open(filename)
-        except Exception as e:
-            self.display_error_message2(_("Error opening web browser"), str(e))
+        cache = apt.Cache()
+        if ("solfege-doc" in cache) and cache["solfege-doc"].is_installed:
+            try:
+                webbrowser.open(filename)
+            except Exception as e:
+                self.display_error_message2(_("Error opening web browser"), str(e))
+        else:
+            solfege.win.display_error_message(
+                _("Please install the solfege-doc package to display the documentation."))
 
     def display_user_exercises(self, w):
         self.set_title("GNU Solfege - " + _("User Exercises"))