LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-17-2008, 07:05 PM   #1
Guitarist88
Member
 
Registered: Feb 2004
Location: Nz
Posts: 240

Rep: Reputation: 30
Question Get file icon from extension, file type, or mime-type


Is there any way to get a file's icon from its extension? I'm currently making a FTP program in Qt and I want to be able to have the correct file type icons. I'd prefer some way is cross-DE and is capable of working on most linux systems.

Thanks.
 
Old 04-18-2008, 03:47 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,536

Rep: Reputation: 148Reputation: 148
You have /etc/mime.types to check for given mime type when you have extention. Icons, if connected with certain type, are usually DE-specific.
 
Old 04-20-2008, 07:50 PM   #3
Guitarist88
Member
 
Registered: Feb 2004
Location: Nz
Posts: 240

Original Poster
Rep: Reputation: 30
According to this site: http://standards.freedesktop.org/sha...html#s2_layout
I should have a <MIME>/icons folder that maps mime types to icons. I checked and I do not have this folder or the generic-icons folder. I do have the other ones. I tried running update-mime-database but it does not create those folders.

Any idea? This would be what I'm looking for. Is this not implemented yet?

Thanks
 
Old 04-21-2008, 10:58 AM   #4
Guitarist88
Member
 
Registered: Feb 2004
Location: Nz
Posts: 240

Original Poster
Rep: Reputation: 30
I have solved my problem. I made a bash script that when given the file name, greps the mime.types file for the mime type. Then the mimetype is formatted in the icon format, and is found with the find command. This works with DE's that are compliant with that mime standard.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change default icon for file type? LinuxUser101 Linux - Newbie 0 03-08-2008 05:42 PM
Warning ___ specifies undefined mime type/service type mbvpixies78 Linux - Software 0 12-29-2007 10:25 PM
How do I change file type icon ? quanta Fedora 6 10-07-2007 11:36 PM
How do you get the mime type of a file using C++ in KDE? ManuPeng Programming 2 04-02-2007 03:06 PM
Determining MIME Type of a File Jose Muņiz Linux - General 2 08-16-2004 01:44 AM


All times are GMT -5. The time now is 11:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration