Am making an application in Python and I need to provide "Open with" menu to user. Currently I am parsing /usr/share/applications/mimeinfo.cashe
and ~/.local/share/applications/mimeapps.list
but with very poor results. Nautilus has more entries in "Open with" menu.
Do you know a better way for getting list of applications associated with file?
Edit:
There is a simpler way using gnomevfs
module.
mime_type = gnome开发者_运维百科vfs.get_mime_type(filename)
application_list = gnomevfs.mime_get_all_applications(mime_type)
In returned list you get application name, icon name, config file and many other stuff.
I've found a bit more elegant solution. In gnomevfs
module there is function named mime_get_all_applications
which returns proper list of associated applications.
More information can be found here.
Edit:
Since the time this answer was written, GnomeVFS was marked as deprecated. GIO does provide this functionality now with methods like app_info_get_all
and app_info_get_for_type
.
GNOME stores its application lists in those two files:
/etc/gnome/defaults.list
~/.local/share/applications/mimeapps.list
(link to source)
精彩评论