Anyone know how I could hook PackageKit into this UI so that it handles some recognised formats?
For instance, in this case, we could prompt to install Inkscape to view the file. But I don’t want to do lots of waiting if PackageKit can’t find anything that matches the mimetype. Ideas welcome, as I’m really not sure how this code works at all. I’m guessing nautilus, but it could be gio for all I know….
Published by
hughsie
Richard has over 10 years of experience developing open source software. He is the maintainer of GNOME Software, PackageKit, GNOME Packagekit, GNOME Power Manager, GNOME Color Manager, colord, and UPower and also contributes to many other projects and opensource standards. Richard has three main areas of interest on the free desktop, color management, package management, and power management.
Richard graduated a few years ago from the University of Surrey with a Masters in Electronics Engineering. He now works for Red Hat in the desktop group, and also manages a company selling open source calibration equipment. Richard's outside interests include taking photos and eating good food.
View all posts by hughsie
How does this work?
I would say not very well – http://bugzilla.gnome.org/show_bug.cgi?id=92497
Inkscape can’t open cdr files.
Suggert you have a look at ubuntu nautilus patchs as gnome-app-install does this already
gnome-app-install
–mime-type=MIME_TYPE
Show only applications that handle the given file type
http://www.google.com/codesearch?hl=en&q=+gnome-app-install+nautilus+mime-type+show:d_xW7luglZA:pERfhuwTefM:pBX7cDoFMGM&sa=N&cd=2&ct=rc&cs_p=http://utnubu.alioth.debian.org&cs_f=scottish/by_maint/joss%40debian.org/large/nautilus_1:2.19.2-0ubuntu2#first
>Inkscape can’t open cdr files.
It can
Sorry I’m no help, but it sounds like an amazing feature to have! I’m a Debian user currently, but if politics prevents an awesome project like this from being available to me… I’ll switch!
Keep up the good work!
Ubuntu already does something like this, I don’t know which package it is though. There is also this:
http://packages.ubuntu.com/intrepid/command-not-found
“JustAGuy Says: ”
Unrelated to this issue. And we’re always looking for patches, so if you want to provide it…
“Richard Hughes says:
Anyone know how I could hook PackageKit into this UI so that it handles some recognised formats?”
To programmatically set an application as default for a type or extension, see g_app_info_set_as_default_for_type() and g_app_info_set_as_default_for_extension(). To just add an application as supporting the type, g_app_info_add_supports_type(). Pretty simple actually.
(re-read the post): If you want to put a “Search for applications to install and use for this type” button in that dialog, that will require some Nautilus work, but mostly work on your part (you’d need to have a list of installable applications by supported mime-type database somewhere, which I don’t think any package manager currently supports, though it probably wouldn’t be hard to do inside of your tool, you just need to index .desktop files).
Such “smart features” should be optional. Yeah my head will explode if too much ubuntuism spreads.
However, one way to solve it here which would be unobtrusive and nice, would be just to add a button “Help me find an application”/”Search for application”/whatever, that takes you to some sort of package kit helper.
Hi Richard,
You want to look at nautilus/libnautilus-private/nautilus-mime-actions.c, I believe this dialog is created there.
– Neil
>Yeah my head will explode if too much ubuntuism spreads
Ubuntuism? Seems pretty obvious to me.
It might be obvious, but is it relying on the extension name? Or will it try to detect the actual type of file?
Hi Richard,
Is the intention here to have it display a list of applications, and make
it easy to install them from this dialog, or to just provide a button to pop
up a further dialog in which to search/install applications?
Thanks,
James
Well, a proper dialog saying:
Do you want to search for applications?
[yes] [no]
(as this takes a few seconds to complete)
and then a list of applications that can be chosen and installed – we can make this very pretty – icons and localisations and that sort of thing.
Richard.
I would say that this information would have to be integrated with yum. That way it could be updated when new packages could handle different file types and also it would re-use the cache system that already exists.
Yes, I agree. Trying to maintain an out-of-band data source is not going to work. I’m working on adding a script to rpm to automatically pull out the mimetypes and add them as rpm-provides. This means we can just use yum and rpm for the yum backend. I think apt has a desktop file cache for this as well.
Unfortunatly, this means that we have to wait for F10 until this feature can be used in Fedora, as it needs all the applications to be rebuilt with the new provides :-(
Hi Richard,
apt doesn’t have this capability, but Ubuntu ships the information in a separate
package for the gnome-app-install tool. I’m not sure if mime types are there, but
they certainly could be.
The information could obviously be made available through apt as well.
Thanks,
James
Hey Richard, I think this script would do the trick:
for f in `find /usr/share/applications -name ‘*.desktop’`; do
sed -n ‘s/^ *MimeType=\(.*\)/\1/p’ $f | \
awk -F’;’ ‘{for(i=1;i<=NF;i++) if ($i) printf “mime(%s)\n”, $i}’
done
Adjusting the find to operate on $RPM_BUILD_ROOT and supplying the rpm macro magic as needed. Probably you could drop the sed and get it all in awk, but I’m not that talented. If you want any more help with this, I’m pretty keen to rpm and how it handles reqprov.
Inkscape does support CDR, but doesn’t update it’s mime types so that it gets listed. :( According to the desktop file we’re SVG only, and that kinda comes from the fact that other things need to be installed to make it work. So if you have Uniconverter and Inkscape, then you can view CDR files. I realize that’s complex, but I’m not sure how you’ll be able to represent that in the provides section of an RPM or DEB.
Ted,
You could put it in and then use libpackagekit to install uniconverter from inkscape
if asked to open a CDR file.
James
Please, take a look at this (proposed) freedesktop specification:
http://www.freedesktop.org/wiki/Specifications/mime-actions-spec
If I remember correctly, KDE implements it.