Results 1 to 10 of 10

Thread: Associating file extensions

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Re: Associating file extensions

    Quote Originally Posted by fullmetalcoder
    Anyone know how to programatically associate a file extension with a app? I searched the web a bit but didn't find anything relevant...

    I'd need tips to do that under Win, Linux and Mac...
    well as wysota mentioned...i've already put forth this doubt...and here's the answer

    on KDE you have need to look in $XDG_DATA_DIR environ variable...this is where all the apps are installed...

    eg: /usr/share/applications

    look in mimeinfo.cache in this folder...
    you will find a list of file formats and the corresponding apps that can be used for opening them i.e. ".desktop" files that will be found in the same directory.

    Now if you want to associate a particular extension with an app you need to add the relevant details to the mimeinfo.cache and provide the apt .desktop file for handling it.

    on GNOME you have a file by the name gnome-application-registry (something similar )
    where you store the similar type of data. (use the locate tool to find a file of this name)

    if you want more (rather lots more info...i'can mail them to you later...)

    There is no need to look in the sources...just go on www.freedesktop.org and look for shared-mime-info-spec.....you'll get all the info you need (only if you read that with some concentration and an open mind )

    Nupul

  2. The following user says thank you to nupul for this useful post:

    fullmetalcoder (10th May 2006)

  3. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Associating file extensions

    Interesting but, as you've already played with that, have you some code snippets ??? And what about Mac and Win? No info at all???
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #3
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Re: Associating file extensions

    Quote Originally Posted by fullmetalcoder
    Interesting but, as you've already played with that, have you some code snippets ??? And what about Mac and Win? No info at all???

    hmmm...I took another work around in linux...

    for KDE I used "kfmclient"

    for GNOME i used "gnome-open"

    just pass the --help as an arguement to see how to use the system

    Now as for working for associating a file is concerned...you need to do this:

    1. download the latest freedesktop-mime-database.
    2. create your own file following the standard and add it to database
    3. run update-mime-database command
    4. run update-desktop-database command
    so you see there is technically no code snippet just a series of commands...

    now re-read the info-spec i pointed out previously....you'll understand more completely...what i just said will act as a glue to merge all the not-so-clear spec

    Now for Windows: You'll have to play with MFCs/Win32 API for this...look through the docs...am not very well versed this But here is the shortcut....create a custom extension, open it through explorer...and choose app to open that file!!!!....you could also physically do it by setting the "file type" from the tool>options etc....you know the story)

    MAC: hmmmm well MAC was a closed source system...they have now started to release out the API, so try getting your hands on it. I haven't used MAC much, but from what i know, it's a harrowing task to find the API...but i think some googling around would help...

    NOTE: The concept of MIME types is present in all systems (i.e. all systems are merging towards this)...try exploiting this...

    in one of the threads by munna, he asked how to open a a .swf by using the default app...here's the link....someone put a code snippet that was damn good...it could be of use to you...

    here's the link:

    http://www.qtcentre.org/forum/showthread.php?t=2029

    see how the registry is accesed using Qt and you could use it to your benefit!!

    Nupul

Similar Threads

  1. Can you specify a file engine?
    By skimber in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2008, 15:54
  2. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  3. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. Associating icon with a file type
    By munna in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.