maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   How To : Associate MPlayer, Transmission, and other apps as default handlers (https://talk.maemo.org/showthread.php?t=17757)

rebhana 2010-06-11 22:31

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by qole (Post 711308)
dbus-switchboard currently only handles files with file extensions.

The simple solution here is to download files and add extensions, then use the file manager to open the files with dbus-switchboard.

Since I need that so often, this is at least no good for me.

Quote:

The more complex, but far better, solution is to figure out how to pass the detected mime type to dbus-switchboard and use that to determine the handler, rather than the file extension.
I would like to know how qwerty did it for evince. His evince.desktop file contains
Code:

Exec=evince
StartupNotify=true
Terminal=false
Type=Application
Icon=evince
X-Osso-Service=org.gnome.evince.ApplicationService
X-Osso-Type=application/x-executable
MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-dvi;application/x-bzdvi;application/x-gzdvi;image/vnd.djvu;image/tiff;application/x-cbr;application/x-cbz;application/x-cb7;image/*;application/vnd.sun.xml.impress;application/vnd.oasis.opendocument.presentation;

Could something like that be done for "debbie evince" as well?

qwerty12 2010-06-11 22:40

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by rebhana (Post 711354)
I would like to know how qwerty did it for evince. His evince.desktop file contains
Code:

Exec=evince
StartupNotify=true
Terminal=false
Type=Application
Icon=evince
X-Osso-Service=org.gnome.evince.ApplicationService
X-Osso-Type=application/x-executable
MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-dvi;application/x-bzdvi;application/x-gzdvi;image/vnd.djvu;image/tiff;application/x-cbr;application/x-cbz;application/x-cb7;image/*;application/vnd.sun.xml.impress;application/vnd.oasis.opendocument.presentation;

Could something like that be done for "debbie evince" as well?

I don't recall doing anything special for Evince. What I did do was add those entries to the desktop file, adding an XML describing the new types (dpkg -L evince / evince-common should pick it up) and adding an handler to Evince to open each file it recieves by name over D-Bus, which DBus Switchboard does.

I don't think you are passed the mimetype, but you are passed the full path which is enough to figure out the MIME type in your program (I think GnomeVFS has functions for this).

rebhana 2010-06-11 22:53

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
I had only inspected dpkg -L evince, not evince-common, so I missed
/usr/share/dbus-1/services/evince.service
Code:

[D-BUS Service]
Name=org.gnome.evince.ApplicationService
Exec=/usr/bin/evince

My question is whether there is a fundamental obstacle to have Easy Debian applications like "debbie evince" substituting /usr/bin/evince.

Btw, the Maemo port of evince is great - I'm just sorely missing postscript support.

qwerty12 2010-06-11 23:03

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Apologies if I'm misunderstanding you. I don't use Easy Debian so I'm unfamilar with its workings, but I believe you'd have to go through DBus Switchboard and get it to run Easy Debian Evince as the script wouldn't know of recieving arguments via D-Bus, which is part of how "associations" work in Maemo. Wow, reading that, I realise I bring nothing new... again, apologies.

Quote:

Originally Posted by rebhana (Post 711393)
Btw, the Maemo port of evince is great - I'm just sorely missing postscript support.

Thank you. Postscript support required several large dependencies to be uploaded, last I checked. Being the lazy prick I am...

I should get to get to updating it though and making some interface changes. I think moving the contents list to a HildonTouchSelector would be nice...

rebhana 2010-06-11 23:11

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by qwerty12 (Post 711406)
Apologies if I'm misunderstanding you. I don't use Easy Debian so I'm unfamilar with its workings, but I believe you'd have to go through DBus Switchboard and get it to run Easy Debian Evince as the script wouldn't know of recieving arguments via D-Bus, which is part of how "associations" work in Maemo.

I have to excuse for my silly questions I'm afraid.

Dbus-switchboard is in fact working for the Easy Debian applications. Only trouble is that it depends on explicit file types.

qole 2010-06-11 23:14

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by qwerty12 (Post 711375)
...but you are passed the full path which is enough to figure out the MIME type in your program (I think GnomeVFS has functions for this).

Does anyone know how to do this in Python? What library would one use?

qwerty12 2010-06-11 23:25

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by qole (Post 711424)
Does anyone know how to do this in Python? What library would one use?

python-gnome was already installed here, so this worked:
from gnome import gnomevfs
print "%s" % gnomevfs.get_mime_type("/home/user/MyDocs/treeview-tutorial.pdf")

Python also has a standard mimetypes module if an external dependency is not your thing.

(Sorry it's not got CODE tags around it, but my JS is disabled in Tear and the symbol input fails to come up if the clipboard is populated)

rebhana 2010-06-12 07:02

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by rebhana (Post 711298)
Btw, I noticed that the deinstallation is not restoring everything to the previous state. Before, /usr/share/applications/defaults.list was a symlink to /etc/gnome/defaults.list, and now they are separate with different contents. That doesn't seem to have any effects as far as I see, though.

On second thought - could that possibly interfere with other packages if they assume that /etc/gnome/defaults.list will be read by mime updates?

debernardis 2010-06-12 07:08

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
Quote:

Originally Posted by rebhana (Post 711658)
On second thought - could that possibly interfere with other packages if they assume that /etc/gnome/defaults.list will be read by mime updates?

I fear that it's exactly so, and I have already written down to myself to restore the link if I ever uninstall dbus-switchboard (unless Qole can correct the postinst script).

Back to the problem, an interim solution could be make dbus-switchboard ask for a manual xref when it can't find a known extension.

qole 2010-06-13 03:20

Re: How To : Associate MPlayer, Transmission, and other apps as default handlers
 
I find it interesting that Maemo pretends to use the /etc/gnome/defaults.list file but it doesn't really, it still uses the /usr/share/applications/defaults.list ...

I find it interesting, too, that I copy the original file to a safe location, and then copy it back in my postrm file. But how is it that the file that my postrm script copies back upon removal of dbus-switchboard is different than the file it was supposedly linked to?


All times are GMT. The time now is 12:14.

vBulletin® Version 3.8.8