2
"""Support file to show FreeCAD thumbnails on Free Desktop Environments (like GNOME or KDE)
5
- This executable file should be on the PATH so it can be found
6
"$ sudo cp freecad-thumbnailer /usr/bin"
7
and must have execution rights
8
"$ sudo chmod +x /usr/bin/freecad-thumbnailer"
10
- If a FreeCAD project file doesn't include a thumbnail the file org.freecad.FreeCAD.png is used.
11
Thus, the file src/Gui/Icons/freecad-icon-48.png must be installed.
12
"$ sudo cp freecad-icon-48.png /usr/share/icons/hicolor/48x48/apps/org.freecad.FreeCAD.png"
14
- The application/x-extension-fcstd MIME type should be registered
15
Check that a corresponding /usr/share/mime/packages/freecad.xml file exists
16
Make sure the MIME database is up to date
17
"$ sudo update-mime-database /usr/share/mime"
19
- Register this thumbnailer
20
Adding a file /usr/share/thumbnailers/FreeCAD.thumbnailer with the following content:
23
TryExec=freecad-thumbnailer
24
Exec=freecad-thumbnailer -s %s %i %o
25
MimeType=application/x-extension-fcstd;
27
HINT: Make sure that the symlink /usr/bin/python exists and points to the Python executable
29
NOTE: To make sure FreeCAD saves thumbnail information:
31
Edit -> Preferences... -> Document -> Save thumbnail into project when saving document
37
opt, par = getopt.getopt(sys.argv[1:], "-s:")
42
# Read compressed file
43
zfile = zipfile.ZipFile(input_file)
44
files = zfile.namelist()
46
# Check whether we have a FreeCAD document
47
if "Document.xml" not in files:
48
print(input_file, " doesn't look like a FreeCAD file")
51
# Read thumbnail from file or use default icon
52
image = "thumbnails/Thumbnail.png"
54
image = zfile.read(image)
56
# apps should have at least 48x48 icons
57
freecad = open("/usr/share/icons/hicolor/48x48/apps/org.freecad.FreeCAD.png", "rb")
58
image = freecad.read()
60
# Write icon to output_file
61
thumb = open(output_file, "wb")
66
print("Error creating FreeCAD thumbnail for file ", input_file)