Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use GpsPrune to view some gps dumps, unfortunately there is no setting to double-click and open the files in the viewer. In older versions of Ubuntu you could just drag any file to the icon of an application, how do I do that or enable that in 12.10?

share|improve this question
    
It appears as thorugh the bounty period has run out. There's still a grace period left. After that the bounty will have gone to waste. So please consider accepting one of the answers below. –  Glutanimate Mar 14 '13 at 7:21
    
Not quite answering your question, but if you have a GpsPrune window open, you can drag files into it (of any type) and they will be opened. But that's a feature of the latest version of GpsPrune, which hasn't made its way into the Ubuntu repositories yet. –  user150027 Apr 17 '13 at 12:26
add comment

1 Answer

up vote 0 down vote accepted
+50

I don't know what file types GPSprune handles and which, specifically, you are interested in. So for the sake of simplicity let's just say you want to open files with the .foo extension in GPSprune. These files however are recognized as text files or XML files rather than GPSprune specific files. What you will have to do then is to first define a new MIME type that is specific to these files.

To do so you can either use assoGiate, a GUI file type editor, or manually define the new MIME type. In this tutorial I will show how to do this manually.

Create a new text file called foo.xml and open it up in your favorite text editor.

Copy and paste the contents of the following text box:

<?xml version="1.0" encoding="utf-8"?>
<mime-info>
 <mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/foo">
  <glob pattern="*.foo"/>
  <comment>GPSprune GPS dump</comment>
  <comment xml:lang="en">GPSprune GPS dump</comment>
 </mime-type>
</mime-info>

Make sure to replace all instances of .foo with the actual extension and edit the comment/description to your wishes.

Next save the file and move it to ~/.local/share/mime/packages. Update the mime database by typing in a terminal:

update-mime-database ~/.local/share/mime

Your .foo files are now recognized as a separate MIME entity. You can check whether everything worked by right clicking on a .foo file of your choice and looking at the file type listed under Properties.

Let's add an association to GPSprune now:

Open ~/.local/share/applications/mimeapps.list in an editor of your choice. Search for the [Default Applications] entry or create it if it doesn't exist yet. Then add the following line under default applications:

[Default Applications]
application/foo=gpsprune.desktop

You should now be able to immediately open up your .foo files with GPSprune and likely also to drag and drop them on the respective launcher.


Sources and related Q&As:

Add custom command in the open with dialog?

How can I deal with file association in different application(not in Nautilus)?

How to associate file extension (not file type) for a particular application?

https://ubuntugenius.wordpress.com/2009/11/19/create-your-own-file-types-in-ubuntu-with-assogiate/

share|improve this answer
    
Nice! Unfortunately there's an error in your first XML file, but assoGiate works nicely for that. –  NoBugs Mar 15 '13 at 1:13
    
While this is a solution to my specific problem, there doesn't seem to be any way to drag-drop to any application to see what it will do with said file. I assume this is not possible? –  NoBugs Mar 15 '13 at 2:09
    
I am glad you found my answer useful. I found the mistake in the XML code and corrected it. The DnD operation seems to be context-sensitive and as far as I know that's hard-coded into the system. So I don't think it's possible, at least not with the Unity launcher. –  Glutanimate Mar 15 '13 at 3:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.