Fix thumbnail preview on XDG Desktops (#4078)
Re: Fix thumbnail preview on XDG Desktops (#4078)
Anyone willing to document this on the wiki?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Fix thumbnail preview on XDG Desktops (#4078)
yes I was going do write anyway for my memory...or lack there of.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Fix thumbnail preview on XDG Desktops (#4078)
Quick question: which wiki do think this should get into?Kunda1 wrote: pinged by pinger macro
Just very minor note: The doc string in freecad-thumbnbails shows:pachiburke wrote: pinged
Code: Select all
...- This executable file should be on the PATH so it can be found
"$ sudo cp freecad-thumbnailer /usr/share/bin"...
Since the files involved are in the FC source, I'm assuming if it is compiled on a given machine, the copying of these files (freecad-thumbnailer, etc.) happens during the install phases of the build/make process.
So it would appear that someone using an appimage (or the PPA?) would need to get a copy of the source from github? Or are they available in the appimage? (or PPA)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Fix thumbnail preview on XDG Desktops (#4078)
Good question, not sure what wiki page
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Fix thumbnail preview on XDG Desktops (#4078)
I was thinking maybe a "link for manual install details" from the save thumbnails with project expand:
https://wiki.freecadweb.org/Preferences_Editor
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Fix thumbnail preview on XDG Desktops (#4078)
While messing with a different issue, I noted that, if the symlink for python is set python3 the following is thrown in syslog and no png is created:
freecad-thumbnailer runs as usual (I can see messages from it in syslog, same messages with python2 or 3)
But, with python sym,link set to python2, no error and a thumbnail is created.
(Why won't the world accept python 2 is dead... )
Code: Select all
org.freedesktop.thumbnails.Thumbnailer1[1834]: libpng error: Not a PNG file
But, with python sym,link set to python2, no error and a thumbnail is created.
(Why won't the world accept python 2 is dead... )
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Fix thumbnail preview on XDG Desktops (#4078)
What happens if you open a Py3 session and run this Python code?
You have to create the project /tmp/test.FCStd beforehand.
Code: Select all
import sys
import zipfile
import getopt
sys.argv=['python3', '-s', '64', '/tmp/test.FCStd', '/tmp/test.png']
opt, par = getopt.getopt(sys.argv[1:], '-s:')
input_file = par[0]
output_file = par[1]
# Read compressed file
zfile = zipfile.ZipFile(input_file)
files = zfile.namelist()
# Check whether we have a FreeCAD document
if "Document.xml" not in files:
print(input_file, " doesn't look like a FreeCAD file")
sys.exit(1)
# Read thumbnail from file or use default icon
image = "thumbnails/Thumbnail.png"
if image in files:
image = zfile.read(image)
else:
# apps should have at least 48x48 icons
freecad = open("/usr/share/icons/hicolor/48x48/apps/freecad.png")
image = freecad.read()
# Write icon to output_file
thumb = open(output_file, "wb")
thumb.write(image)
thumb.close()
Re: Fix thumbnail preview on XDG Desktops (#4078)
OK, I found the problem. It happens for project files without a thumbnail and in this case this code is executed:
It fails because it doesn't open the file in binary mode but in text mode and that's why it raises a UnicodeDecodeError. But I wonder why it doesn't fail with Py2.
Anyway, the fix is trivial. Replace the line
with
Code: Select all
freecad = open("/usr/share/icons/hicolor/48x48/apps/freecad.png")
image = freecad.read()
Anyway, the fix is trivial. Replace the line
Code: Select all
freecad = open("/usr/share/icons/hicolor/48x48/apps/freecad.png")
Code: Select all
freecad = open("/usr/share/icons/hicolor/48x48/apps/freecad.png", "rb")
Re: Fix thumbnail preview on XDG Desktops (#4078)
Did you fix the docstring while you were in there?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."