module documentation
(source)

This module contains utilities to work with external applications it is based on the Freedesktop.org (XDG) Desktop Entry specification with some additional logic based on status quo on Gnome / XFCE.

The main class is the DesktopEntryFile which maps the application definition in a specific desktop entry. Typically these are not constructed directly, but requested through the ApplicationManager.

Also there is the OpenWithMenu which is the widget to render a menu with available applications for a specific file plus a dialog so the user can define a new command on the fly.

Class AddApplicationDialog Dialog to prompt the user for a new custom command. Allows to input an application name and a command, and calls ApplicationManager.create().
Class ApplicationComboBox Undocumented
Class ApplicationManager Manager object for dealing with desktop applications. Uses the freedesktop.org (XDG) system to locate desktop entry files for installed applications.
Class Boolean Undocumented
Class CustomizeOpenWithDialog No class docstring; 0/2 instance variable, 1/4 method documented
Class DesktopEntryDict Base class for DesktopEntryFile, defines most of the logic.
Class DesktopEntryFile Class implementing a single desktop entry file with the definition of an external application.
Class DesktopEntryMenuItem Single menu item for the OpenWithMenu. Displays the application name and the icon.
Class IconString Undocumented
Class LocaleString Undocumented
Class NoApplicationFoundError Exception raised when an application was not found
Class OpenWithMenu No summary
Class String Undocumented
Class SystemDefault Stub object that can be used in ApplicationComboBox
Function edit_config_file No summary
Function edit_file Edit a file with and external application.
Function get_mime_description Undocumented
Function get_mime_icon Undocumented
Function get_mimetype No summary
Function open_file Open a file or folder
Function open_folder No summary
Function open_folder_prompt_create Open a folder and prompts to create it if it doesn't exist yet. @param widget: parent for new dialogs, Gtk.Widget or None @param folder: a Folder object
Function open_url No summary
Variable Gio Undocumented
Variable logger Undocumented
Function _application_dirs Undocumented
Function _application_file Undocumented
Function _create_application Undocumented
Function _mimetype_dialog_text Undocumented
Function _open_with Undocumented
Function _open_with_emailclient Undocumented
Function _open_with_filebrowser Undocumented
Function _open_with_webbrowser Undocumented
Function _read_comment_from Undocumented
Function _update_mimeapps_file Undocumented
Variable _last_warning_missing_icon Undocumented
def edit_config_file(widget, configfile): (source)
Edit a config file in an external editor. See edit_file() for details.
Parameters
widgeta gtk widget to use as parent for dialogs or None
configfilea ConfigFile object
def edit_file(widget, file, istextfile=None): (source)

Edit a file with and external application.

This method will show a dialog to block the interface while the external application is running. The dialog is closed automatically when the application exits _after_ modifying the file. If the file is unmodified the user needs to click the "Done" button in the dialog because we can not know if the application was really done or just forked to another process.

Parameters
widgeta gtk widget to use as parent for dialogs or None
filea File object
istextfileif True the text editor is used, otherwise we ask the file browser for the correct application. When None we check the mimetype of the file to determine if it is text or not.
def get_mime_description(mimetype): (source)

Undocumented

def get_mime_icon(file, size): (source)

Undocumented

def get_mimetype(obj): (source)
Convenience method to get the mimetype for a file or url. For URLs this method results in "x-scheme-handler" mimetypes.
Parameters
obja File object, or an URL
Returns
mimetype or None
def open_file(widget, file, mimetype=None, callback=None): (source)
Open a file or folder
Parameters
widgetparent for new dialogs, Gtk.Widget or None
filea File or Folder object
mimetypeoptionally specify the mimetype to force a specific application to open this file
callbackcallback function to be passed on to Application.spawn() (if the application supports a callback, otherwise it is ignored silently)
Raises
FileNotFoundErrorif file does not exist
NoApplicationFoundErrorif a specific mimetype was given, but no default application is known for this mimetype (will not use fallback in this case - fallback would ignore the specified mimetype)
def open_folder(widget, folder): (source)
Open a folder.
Parameters
widgetparent for new dialogs, Gtk.Widget or None
foldera Folder object
Raises
FileNotFoundErrorif folder does not exist see open_folder_prompt_create for alternative behavior when folder does not exist.
def open_folder_prompt_create(widget, folder): (source)
Open a folder and prompts to create it if it doesn't exist yet.
Parameters
widgetparent for new dialogs, Gtk.Widget or None
foldera Folder object
def open_url(widget, url): (source)
Open an URL (or URI) in the web browser or other relevant program. The application is determined based on the URL / URI scheme. Unkown schemes and "file://" URIs are opened with the webbrowser.
Parameters
widgetparent for new dialogs, Gtk.Widget or None
urlan URL or URI as string

Undocumented

logger = (source)

Undocumented

def _application_dirs(): (source)

Undocumented

def _application_file(path, dirs): (source)

Undocumented

def _create_application(dir, basename, Name, Exec, NoDisplay=True, **param): (source)

Undocumented

def _mimetype_dialog_text(mimetype): (source)

Undocumented

def _open_with(widget, entry, uri, callback=None): (source)

Undocumented

def _open_with_emailclient(widget, uri): (source)

Undocumented

def _open_with_filebrowser(widget, uri, callback=None): (source)

Undocumented

def _open_with_webbrowser(widget, url): (source)

Undocumented

def _read_comment_from(file): (source)

Undocumented

def _update_mimeapps_file(file, section, key, value, replace): (source)

Undocumented

_last_warning_missing_icon = (source)

Undocumented