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 = gnomevfs.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)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top