PDA

View Full Version : MIME and .desktop files in KDE



nupul
13th April 2006, 06:20
Well I am slighlty (understatement ;) ) confused between the use of mime types and .desktop files ...let me tell you w.r.t. KDE what i know.

1. As per the standard, .desktop files are used to know which program is to be used to launch a particular file.

2. We detect the MIME type of a file and then try to figure out which program to use to open a particular type of file - (Does KDE do this? How....is there a central database to refer? Like in GNOME there is an association-registry, a complete list of programs to use to open a particular type of file. A new application can "register" itself along with its associated files in this DB. How can one achieve the same in KDE?)

Well, now the thing is this....if both of the above serve a similar purpose what is it that KDE does?

-How does KDE know which program to associate with a particular type of file (MIME)? Then why the need of .desktop files?

-we can check the file associations and the corresponding applications to use, in Yast>KDE Components>File Associations. Can I add my application's settings to this as well as retrieve the associations from my application? (from some file that is)

also could you please tell me when and why should one use the following commands:

desktop-file-install
update-desktop-database
update-mime-database

-does KDE use these commands for the above mentioned scenario?

...well there are more doubts :crying: but will clarify them based on your answers ;)

Thanks

Nupul.

PS: please don't hastily reply saying look at the KDE sources...I have already done that, but sources help you understand the implementation, not the concept. I wish to understand the working and not it's underlying implementation.

Brandybuck
13th April 2006, 08:25
A .desktop file is a general format used by both KDE and GNOME for various purposes. They're used in the menu, various icons on the desktop, etc. In the case of the trashcan, it says what what the item's URL is (trash:/), text encoding, icon to use, icon to use when empty, and the name of item is in a few dozen languges. Executable .desktop items will have an executable command and MIME type.

Take a look at the KDE development pages for more information on this stuff. http://developer.kde.org/

nupul
13th April 2006, 08:37
A .desktop file is a general format used by both KDE and GNOME for various purposes. They're used in the menu, various icons on the desktop, etc. In the case of the trashcan, it says what what the item's URL is (trash:/), text encoding, icon to use, icon to use when empty, and the name of item is in a few dozen languges. Executable


Correct...I know and understand this bit well enough.



.desktop items will have an executable command and MIME type.


you have used a different term here .desktop items and above you say a .desktop file. What is the difference in their context?

Yes, I am aware that the files have a MIME type...what i am not able to figure out is how does KDE come to know which program to launch for a particular MIME type? i.e who is responsible for setting the value of the "Exec" value in the .desktop file?



Take a look at the KDE development pages for more information on this stuff. http://developer.kde.org/

Thanks...you just reimbursed where i was sitting all day long :D (along with here too ;) )

Nupul

Brandybuck
14th April 2006, 04:42
Yes, I am aware that the files have a MIME type...what i am not able to figure out is how does KDE come to know which program to launch for a particular MIME type?
That I don't know. I always thought it was the files in the mimelnk directory, but now that I look at them, they don't specify which executable to use.


i.e who is responsible for setting the value of the "Exec" value in the .desktop file?
If you're talking about the .desktop file that gets installed with a KDE application, then it's the developer. If you create a small sample application with kapptemplate, for example, it will include a template .desktop file for you to use. That should be enough for most applications. Beyond that I can't help you.

nupul
14th April 2006, 17:30
If you're talking about the .desktop file that gets installed with a KDE application, then it's the developer. If you create a small sample application with kapptemplate, for example, it will include a template .desktop file for you to use. That should be enough for most applications.


Well this is the exact answer I was looking for...thanks for endorsing it :)



Beyond that I can't help you.


You can...keep replying (to my posts ;) ) whenever you know the answer :D

If you wish, I can furnish you with the complete (almost ;) ) answer if you wish...

Thanks

Nupul