Get files in my own file format for its own dynamic icon

0 votes
The file format of my application is very similar to the OpenDocument file format, i.e. zipped with a manifest file, a thumbnail image, etc. (check - http://en.wikipedia.org/wiki/OpenDocument). Now, in both Windows and Linux, the OpenOffice files have a preview image of the Open Office file as their icons. Can the same be done for my files, i.e. a dynamic icon based on the internal thumbnail.png? Plus, some info or links to how OpenOffice does their IconHandler stuff would be very helpful as it is similar to that of my app. TIA!
Jan 8, 2019 in Others by Bharani
• 4,660 points
1,136 views

1 answer to this question.

0 votes

Regarding MAC support, "The Mac and Windows operating systems have different methods of enabling this type of thumbnail, and in the case of the Mac OS, this support has been inconsistent from version to version so it hasn't been pursued [for Adobe InDesign]."

Windows

An Icon Handler is what you are looking for. It is also known as a Thumbnail Handler. Check out this sample example written as an active x control. Also, look up Property Handlers, which points to the latest and the best way of having dynamic metadata handled properly in windows.

Now, you won't be needing such dynamic solutions if you just want an icon to be associated with all your files. So, use them only when you'd want windows explorer to display an icon based on the file's content and not just the extension. That means when the file changes, the icon is also updated to reflect those changes. But, it doesn't necessarily have to be an image of that file itself as the thumbnail handler can generate any image based on what's in the file.

Since the property handler updates other metadata such as audio or video length, you can use all the metadata that Windows Explorer supports.

OS X

The Launch Services Database determines the icons for Mac OSX. But, it refers to a static icon file for all files handled by a registered application. So, it's not based on the extension. Rather, each file has attached metadata to determine its respective application. Although, extensions do help when no metadata exists, like when getting the file from a different OS or file system. The dynamic icon functionality in OSX seems to be provided by Finder.

Gnome

You can use a thumbnailer for Gnome. It's a very simple program, which has 3 command line arguments:

  • input file name, the file you are describing with the thumbnail (or URI if you're accepting those instead)
  • output file name, where you need to write the PNG
  • size in pixels, a number that describes the maximum square image size you should produce (128 --> 128x128 or smaller)

In contrast to all the difficult to implement plugins on other systems, this system is simpler but doesn't support animation and a few other features.

KDE

Konqueror is the file manager here and displays the icons. So, it supports dynamic icons for some inbuilt types, but I can't say if they are hardcoded or are  just plugins that you can write. Read: Embedded Components Tutorial for more info.
Also, there's this new or upcoming feature called Plasma that deals with icons and icon functionality. Here's the announcment.
You might have to dig into the source of Konqueror to underdstand how they did it for text files and other files that are already implemented.

answered Jan 8, 2019 by DataKing99
• 8,250 points

Related Questions In Others

0 votes
1 answer

Change the permission for a file created by me in linux

If you are the system administrator or ...READ MORE

answered Mar 8, 2019 in Others by Nabarupa
1,102 views
0 votes
1 answer
0 votes
1 answer

Language independent way to get "My Documents" folder in VBA Excel 2003

 Hello :)  This code may help you in your ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
830 views
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,300 points
1,820 views
0 votes
1 answer

When to use file vs open in Python?

File() has been removed since Python 3.0 ...READ MORE

answered Oct 30, 2018 in Python by SDeb
• 13,300 points
1,278 views
0 votes
1 answer

How to write to CSV line by line in python

The simple way of doing this will ...READ MORE

answered Nov 15, 2018 in Python by findingbugs
• 3,260 points
5,682 views
0 votes
1 answer

Open file in Python

There is this code I used for ...READ MORE

answered Nov 16, 2018 in Python by Jino
• 5,820 points
805 views
0 votes
1 answer

Reducing sequences in an array of strings

I've written a C# app to solves ...READ MORE

answered Nov 2, 2018 in Others by DataKing99
• 8,250 points
922 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP