[yoshimi] Opening a compressed user manual

  • From: Ichthyostega <prg@xxxxxxxxxxxxxxx>
  • To: Will Godfrey <willgodfrey@xxxxxxxxxxxxxxx>, yoshimi@xxxxxxxxxxxxx
  • Date: Sun, 3 Jun 2018 18:10:30 +0200


Hello Will,

while creating DEB packages, I noticed another minor inconvenience:
Debian installs the documentation gzip compressed. This is already built
into the "debhelper" tooling for creating packages. It is also required
by the "Debian Policy", which basically means, there is no way debating
it for official packages, while you might find some way to tweak it
for private/custom made packages.

Anyway, now the problem is that yoshimi's built-in "locate the manual"
function is not able to cope with the additional *.gz extension.
But actually this only a problem with the search routine, since the
xdg-open action itself can display a *.pdf.gz just fine.


For the latest iteration of the DEB packages I have just included a
patch to work around that nasty little detail. See attachment...

Cheers,
Hermann




From c4b9d74e9e4c1799fb5e57620c0c063d6cd8d070 Mon Sep 17 00:00:00 2001
From: Ichthyostega <prg@xxxxxxxxxxxxxxx>
Date: Sun, 3 Jun 2018 17:05:36 +0200
Subject: [PATCH] Allow for gzip compressed user manual

Yoshimi provides a menu entry to search for the user manual and display it with 
the system editor.
Unfortunately, Debian installs most documentation gzip compressed (this is 
require
by Debian policy and built into the debhelper tools for packaging).

Since xdg-open is able to display a gzip compressed PDF, all we need to do
is also to search for *.pdf.gz in the installed directories.
---
 src/Misc/MiscFuncs.cpp | 6 +++++-
 src/UI/MasterUI.fl     | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/Misc/MiscFuncs.cpp b/src/Misc/MiscFuncs.cpp
index e84c6d12..171cc22f 100644
--- a/src/Misc/MiscFuncs.cpp
+++ b/src/Misc/MiscFuncs.cpp
@@ -267,7 +267,11 @@ string MiscFuncs::findfile(string path, string filename, 
string extension)
     fscanf(fp,"%[^\n]", line);
     pclose(fp);
 
-    if (findleafname(line) == filename)
+    string fullName(line);
+    // Extension might contain a dot (like .pdf.gz).
+    // Strip the known extension, but retain trailing dot as marker
+    fullName = fullName.substr(0, fullName.length()-extension.length() + 1);
+    if (findleafname(fullName) == filename)
         return line;
     return "";
 }
diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl
index 08ad33e0..a0678767 100644
--- a/src/UI/MasterUI.fl
+++ b/src/UI/MasterUI.fl
@@ -338,6 +338,8 @@ class MasterUI {: {private GuiUpdates}
                 --count;
                 path = findfile("/usr/", (manfile + to_string(count)).c_str(), 
"pdf");
                 if (path == "")
+                   path = findfile("/usr/", (manfile + 
to_string(count)).c_str(), "pdf.gz");
+                if (path == "")
                    path = findfile("/home/", (manfile + 
to_string(count)).c_str(), "pdf");
             }
 
-- 
2.11.0

Other related posts:

  • » [yoshimi] Opening a compressed user manual - Ichthyostega