Dropping file on icon

Asked by Laszlo Boros

Hi everybody!

I want to create a small Python application, and place its icon on my dock, to drop files onto. But when I place the applications icon on the dock, I can't drop files on it, because Docky thinks that my program wouldn't be able handle it, so instead Docky creates icon for the file on the dock I wanted to _drop_.
My Python application is just a .py file with executable privileges.
How could I tell Docky to drop that file (=open it with my python application) rather than create a new dock item for the file?

Hope it was understandable,
Laci

Question information

Language:
English Edit question
Status:
Solved
For:
Docky Edit question
Assignee:
No assignee Edit question
Solved by:
Robert Dyer
Solved:
Last query:
Last reply:
Revision history for this message
Robert Dyer (psybers) said :
#1

Instead of dragging your script to the dock, youll want to create a custom launcher (.desktop file) and inside that set the MimeType that it accepts.

Revision history for this message
Laszlo Boros (semmu) said :
#2

Yes, I created a .desktop file, but the problem was the same, so I thought I better ask it.
Now I'm going to try it out, big thanks for your fast reply!

Revision history for this message
Robert Dyer (psybers) said :
#3

Did you set the proper MimeType in that launcher?

Also you might have to quit Docky, and then delete the files in ~/.cache/docky/ which parses/caches the contents of the launchers.

Revision history for this message
Laszlo Boros (semmu) said :
#4

Now just for try I set the MimeType to text/html. (to be honest I want it to accept every file, but this is just for testing)
So this is my .desktop file:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Icon[hu_HU]=python
Name[hu_HU]=Teszt
Exec=python /home/semmu/Asztal/test.py
Name=Teszt
Icon=default
MimeType=text/html

Now I'm able to drop a file to it, but the application won't start. (It should write a file, so I could track it, but now there are no output.)
What am I doing wrong?

Revision history for this message
Best Robert Dyer (psybers) said :
#5

Your Exec line doesnt pass in the arguments.

Exec=python /home/semmu/Asztal/test.py %F

http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables

Revision history for this message
Laszlo Boros (semmu) said :
#6

Oh, I didn't know that I have to "manually" pass the filename as a parameter. Thanks for it!
But my last problem is: how can my program accept every file, no matter what kind of is it? I don't really want to list all the MimeTypes, and the "MimeType=*" does not work :/

Revision history for this message
Robert Dyer (psybers) said :
#7

I suppose this is perhaps a problem with Docky.

It would make most sense to me that if you completely OMIT the MimeType in the launcher, then Docky should just assume 'any' file and accept. I honestly don't know if that is what it currently does, but that makes the most sense to me.

Revision history for this message
Robert Dyer (psybers) said :
#8

Verified: if no MimeType is specified it wont accept any files at all.

So please file a bug and I will add this functionality. It's 2 lines of code and I already wrote and tested it, but we need to track it via a bug request. :)

You will have to be using a source compiled version of Docky or using our development PPA to get the change (whenever that PPA updates).

Revision history for this message
Laszlo Boros (semmu) said :
#9

Hmm, to bad. Then I will just list the common MimeTypes, until the new version comes out. (and now I'm using the development PPA, my current version is 2.2.0)

Thanks for your help, now it works as it should!

Revision history for this message
Laszlo Boros (semmu) said :
#10

Thanks Robert Dyer, that solved my question.

Revision history for this message
Robert Dyer (psybers) said :
#11

I guess it was a bit more than 2 lines of code. But 11 lines is still easy to do. ;-)

Once you file the bug, I'll push the change.

The logic dictates that if there is a MimeType, we only let you drop matching types. If there is no MimeType and the Exec line stipulates it accepts files/uris then we assume any file can be dropped. Otherwise we assume no file drops allowed.

Revision history for this message
Laszlo Boros (semmu) said :
#12

Okay, I filed the bug, hope I done it right... :D
Your explanation is logical, so I would be very thankful if You implemented it :D :)