This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to create new mimetype

Tags: None
(comma "," separated)
wernerf
Registered Member
Posts
22
Karma
0
OS

How to create new mimetype

Mon May 31, 2010 3:01 pm
Hi all,
I search a description how I can integrate my own tool 'tkBurn' into KDE4. In KDE3 it was easy via some files in:
~/.kde/share/applnk
~/.kde/share/icons
~/.kde/share/mimelnk
but especially for new mimetypes I found currently no way how I can create a new one with a appropriate icon and how I should associate the tool.
For new menu entries and new icons I can use the files in /usr/share/applications/*

Is there a description available or can anybody give me a hint ?

Thanks a lot

Werner

thBurn: http://home.arcor.de/wfranke/tkburn/index.html
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: How to create new mimetype

Tue Jun 01, 2010 4:46 am
You need to provide a mimetype xml file, as specified by http://www.freedesktop.org/standards/shared-mime-info


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
wernerf
Registered Member
Posts
22
Karma
0
OS

Re: How to create new mimetype

Thu Jun 03, 2010 9:42 am
Thanks bcooksley,

due to your hint I found the files under /usr/share/mime.
I assume during the installation of my tool I must copy a new mime xml file to
the right directory (e.g. /usr/share/mime/application).
But beside the mime xml file I found also some ascii files at /usr/share/mime (e.g globs, generic-icons).
I'm not clear how I have/must add lines to this files during installation of my tool.
The shared-mime-info-spec mention the command "update-mime-database" but no example.

Please can you more explain it or exist a example somewhere ?

Thanks Werner
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: How to create new mimetype

Thu Jun 03, 2010 9:50 am
KDE itself installs its mime types to /usr/share/mime/packages only. The text files in the top level directory ( and the other sub-directories ) are maintained by update-mime-database, which can be run during installation using the following CMake macro:

Code: Select all
update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})


Note that XDG_MIME_INSTALL_DIR is the sub-directory where they were installed.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
wernerf
Registered Member
Posts
22
Karma
0
OS

Re: How to create new mimetype

Thu Jun 03, 2010 10:31 am
Thanks again :) ,

Hmmm, I assume the CMake macro is somewhat in RPM ?
I'm still not familiar with that. Up to now I not build a RPM packet.

I hope my next question join not in a never-ending story.

Where I found the contents of the CMake macro ?

I like to realize the tool installation as shell script (until I understand the RPM way)
I hope the CMake macro give me the information I need for that ?

Concerning Icons and desktop files: Does support KDE4 still the mechanism behind $KDEDIRS of KDE3 ?

Werner
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: How to create new mimetype

Fri Jun 04, 2010 5:17 am
Yes, KDE 4 still supports $KDEDIRS.

I don't know where the CMake macro is however, other than the fact that kdelibs itself uses it. You may be able to find further information in the update-mime-database man page ( man update-mime-database )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

Re: How to create new mimetype

Sun Jun 06, 2010 11:50 am
wernerf wrote:Hmmm, I assume the CMake macro is somewhat in RPM ?


No, it is part of the build system.

For example in Akonadi we install this file

http://websvn.kde.org/trunk/kdesupport/ ... iew=markup

for subtypes of text/calendar, like this:
Code: Select all
install(FILES akonadi-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})


See http://websvn.kde.org/trunk/kdesupport/ ... iew=markup

No idea how that is transformed into an RPM post-install hook, maybe you can check your distribution's package for Akonadi.
[/quote]

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

Re: How to create new mimetype

Sat Oct 02, 2010 2:03 pm
jasmine25 wrote:i tried many times to create mimetype file but i am always fail to create...please explain me each and every step clearly to create mimetype file


First step: create an XML file describing your MIME type.
See http://websvn.kde.org/trunk/KDE/kdepim/ ... iew=markup

This file describes two new MIME types:
1) application/x-vnd.kde.notes
a sub type of the generic "text/plain" type

2) text/x-vnd.akonadi.note
a sub type of the more specific "message/rfc822" type

This file is then being processed during installation, by use of these additions to the CMakeLists.txt build file
(see http://websvn.kde.org/trunk/KDE/kdepim/ ... iew=markup)

Code: Select all
set(SHARED_MIME_INFO_MINIMUM_VERSION "0.30")
find_package(SharedMimeInfo)
macro_log_feature(SHARED_MIME_INFO_FOUND "SMI" "SharedMimeInfo" "http://freedesktop.org/wiki/Software/shared-mime-info" TRUE "0.30" "SharedMimeInfo is required.")


These three lines let the build system check for the availability of the shared MIME type data base (shared between Free Software desktop projects such as KDE, GNOME, etc.)

The following lines than take care of installing the XML file describing the new MIME types

Code: Select all
install(FILES kdepim-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})


Summarizing the three necessary steps are:
1) create XML file describing the new MIME type(s)
2) installing this file (first line in the snippet above)
3) updating MIME database (second line in the snippet above)

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient