On Tuesday 02 November 2010 20:15:57 Pedro Lopez-Cabanillas wrote: > On Tuesday 02 November 2010, Milian Wolff wrote: > > Hey there, > > > > how do I associate an app with a mimetype, so it gets started by default > > when > > > the user tries to open some file of that type? > > > > I'd also have the additional hurdle that my mimetype is not yet > > registered. > > I > > > want to associate massif.out.$PID files with massif-visualizer. So I'd > > somehow > > > need to create some x-massif-data mimetype or similar? How does one do > > this? > > > > And to make it yet harder: I transparently support to open .gz / .bz2 > > versions > > > of said files... > > > > I know that KMimeType can look into the contents of an url, is that > > plugin based? I.e. could I look at the first few lines of the file > > (maybe unpacked via KFilterDev)? > > > > Any documentation pointers would be appreciated. > > The Shared MIME-info Database Specification: > http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spe > c- latest.html > > In addition to the examples cited by Albert, Drumstick defines two mime > types of music related file formats using this XML file: > http://drumstick.svn.sourceforge.net/viewvc/drumstick/trunk/drumstick.xml?v > iew=markup > > This file is registered at install time with the help of some CMake macros > http://drumstick.svn.sourceforge.net/viewvc/drumstick/trunk/CMakeLists.txt? > view=markup > > This is the relevant section of CMakeLists.txt: > # XML mime types > set( SHARED_MIME_INFO_MINIMUM_VERSION "0.30" ) > set( XDG_MIME_INSTALL_DIR "share/mime/packages" ) > find_package( SharedMimeInfo ) > if( SHARED_MIME_INFO_FOUND ) > install( FILES drumstick.xml DESTINATION > ${XDG_MIME_INSTALL_DIR} ) > update_xdg_mimetypes( ${XDG_MIME_INSTALL_DIR} ) > endif( SHARED_MIME_INFO_FOUND )
Thanks, this works quite nice. Is "application/x-valgrind-massif" a good name? And where can I find documentation on what to write into .desktop files, to make it possible to open a massif file in my visualizer from e.g. dolphin? This is after all the lone reason I work on this... Maybe I can use simple glob- patterns in the desktop file as well, or do I really need a mimetype here? I ask because the limited match/glob capabilities give me headaches: 1) massif has no real file extension, the generated files are called: massif.out.PID ok, easy to support: massif.out.* 2) since they tend to get huge, I gzip it and - thanks to KFilterDev - can still open them transparently in my tool. But well, the file is now called: massif.out.PID.gz It is matched by the above glob pattern and hence it's mimetype is application/x-valgrind-massif. This in turn makes this fail: QIODevice* device = KFilterDev::deviceForFile (file.toLocalFile(), mimeType, false); As it will not find a filter for this mimetype... -- Milian Wolff m...@milianw.de http://milianw.de
signature.asc
Description: This is a digitally signed message part.
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<