FreeCAD document icon

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

FreeCAD document icon

Postby NormandC » Sat May 14, 2011 9:18 pm

Hi guys,

I opened a feature request in Mantis for FreeCAD to use a thumbnail as the icon for FreeCAD documents. There's a setting in Preferences to generate such a thumbnail and save it in the project file, but it does not seem to be used at the moment. Having it for the file's icon would be cool!

But I understand it may require coding, so meanwhile, I'd like to use a custom icon. It is easy to do in Windows, but in GNOME, all I'm able to do is set it to one file only through its preferences. What do you think would be required for me to set it to all .fcstd files on Ubuntu?

The file I want to use is here.

Thanks!
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeCAD document icon

Postby NormandC » Sat May 14, 2011 9:24 pm

I may have found the way, it has to do with mimetypes.

I'm reading this document right now: https://help.ubuntu.com/community/AddingMimeTypes

I'll update this message a little later.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeCAD document icon

Postby NormandC » Sat May 14, 2011 11:35 pm

Well it doesn't work. The Ubuntu wiki page talks about editing the /etc/mime.types file, then copying the wanted icon in /usr/share/icons/gnome/scalable/mimetypes.

I tried the following combinations in the /etc/mime.types file:

Code: Select all

application/fcstd				fcstd FCStd
application/freecad				fcstd FCStd
model/fcstd					fcstd FCStd
model/freecad					fcstd FCStd
text/fcstd					fcstd FCStd
text/freecad					fcstd FCStd
text/step					stp step STP STEP
Nothing works. The last one I tried to see if the problem was that the FreeCAD document is actually a zip container. But even with a step file, which is just text, it doesn't work.

Oh well... :(
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeCAD document icon

Postby NormandC » Sun May 15, 2011 12:21 am

Ok,

I found this page which uses a python script to get info on a file: https://help.ubuntu.com/community/Pytho ... /MIMETypes

With this script, I was able to determine the actual freecad document mime type:

Code: Select all

File type: application/x-extension-fcstd
Default Application: FreeCAD
Other Applications:
	FreeCAD (Command: /usr/bin/freecad )
	FreeCAD (Command: /usr/bin/freecad )
Description: FreeCAD document files
So I thought, the mime type is already known by the system, I just need to copy my icon to the right place and with the right name.

I named it application-x-extension-fcstd.svg and copied it in two places:
/usr/share/icons/gnome/scalable/mimetypes
/usr/share/icons/Humanity/mimes/48 (which seems to host most of the icons on Ubuntu Lucid)

Logged off for the umpteenth time, logged in... still no custom icon. I though, maybe my svg (made from merging with Inkscape an existing text document svg icon with freecad.svg from /freecad/src/Gui/icons) was not valid. So I replaced it with some other existing svg icon. No luck, it still won't work.

Then I thought, the script finds the mimetype, but the /etc/mime.types does not list it. So I add it to the file, annnnd... still nothing.

That's it, before I start banging my head on the wall for such a stupid thing, I think I'm gonna give up and forget all about it. :roll:
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeCAD document icon

Postby NormandC » Sun May 15, 2011 12:42 am

I know, I was supposed to give up. :roll:

I just realized the mimetype was shown in the properties of a fcstd file, doh! :oops:

There's an x-extension-fcstd.xml file in /usr/share/mime/application, but this files doesn't include icon info. None of the other xml files do so...
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: FreeCAD document icon

Postby NormandC » Sun May 15, 2011 1:38 am

... Resuming my monologue :lol:

Yeah, you must think I'm crazy to waste so much time on such an insignificant thing as icons. But that's me, if there's one thing I hate, it's having my computer get the best of me. :roll:

So I did some more digging, and unexpectedly, I found the solution with... a Gui tool. (link)

I installed the assogiate package, which is launched with the Applications > System Tools > File Types Editor menu, and was able to set a default icon for fcstd documents. I also added the FCStd extension.
freecadicon.jpg
freecadicon.jpg (2.04 KiB) Viewed 2286 times
Boy am I glad this is over! :lol:
wmayer
Site Admin
Posts: 14635
Joined: Thu Feb 19, 2009 10:32 am

Re: FreeCAD document icon

Postby wmayer » Sun May 15, 2011 11:59 am

What you're actually looking for is a so called thumbnailer. For FreeCAD we have implemented this quite some time ago but it's not used at the moment. Have a look into the mime directory of the debian directory. I again have to check how to re-activate this again...
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: FreeCAD document icon

Postby yorik » Sun May 15, 2011 4:53 pm

Actually the thumbnailer used to work perfectly for me until the last update of Thunar... But my other thumbnailers (pdf, etc...) don't work anymore either...
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: FreeCAD document icon

Postby yorik » Mon May 16, 2011 2:47 am

Hm refreshed the whole stuff, other thumbnailers now work correctly, only freecad doesn't... Must be some little thing that changed.
@Normand, you can also install a mime icon file by just putting it in ~/.icons
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: FreeCAD document icon

Postby jriegel » Tue May 17, 2011 12:16 pm

Im not quit sure we mixing things up at the moment.

There are two things. One the FreeCAD icon shown in a file explorer which rest on a .fcstd file. The other is the
thumb-nailer which Werner mentioned. This piece of software (a ActivX control in Windows) retrieve a presaved
picture of the parts in the FreeCAD project file and shows it in the explorer. Very nice if you brows through
lots of files in the explorer. You recognize very intuitive the thing you looking for...

Both concepts have actually nothing to do with FreeCAD itself. Its mostly about the packaging and the used
Desktop environment. Under Windows its easy, the Windows explorer retrieves the Icon from the .exe and
shows accociated files with this Icon. For the thumb-nailer exists a interface and a ActiveX control (which Werner programmed) which gets
registered in the registry. Every time you switch in Windows explorer to the thumbnail view the control get called
and retrieve the thumbnail picture out of the .fcstd file (its embeded in the zip).

For Linux now I have no idea if there is a standard way for the different desktops (KDE, Gnome, ....) to
handle file icons and thumbnail plugins. Especially the thumb-nailer (as software) will be highly dependent
on the Desktop and its libraries....
Stop whining - start coding!