gio.AppInfo
Prev | PyGio Class Reference | Next

## gio.AppInfo

gio.AppInfo — Information about an installed application and methods to launch it (with file arguments).

## Synopsis

    class gio.AppInfo(gobject.GInterface):
        gio.AppInfo(commandline, application_name=None, flags=gio.APP_INFO_CREATE_NONE)
        def add_supports_type(content_type)
        def can_delete()
        def can_remove_supports_type()
        def delete()
        def dup()
        def equal(appinfo2)
        def get_commandline()
        def get_description()
        def get_executable()
        def get_icon()
        def get_id()
        def get_name()
        def launch(files, launch_context)
        def launch_uris(uris, launch_context)
        def remove_supports_type(content_type)
        def set_as_default_for_extension(extension)
        def set_as_default_for_type(content_type)
        def should_show()
        def supports_files()
        def supports_uris()

    Functions

        def gio.app_info_get_all()
        def gio.app_info_get_all_for_type(content_type)
        def gio.app_info_get_default_for_type(content_type, must_support_uris)
        def gio.app_info_get_default_for_uri_scheme(uri_scheme)
        def gio.app_info_reset_type_association(content_type)

## Ancestry

    +-- gobject.GInterface
      +-- gio.AppInfo

## Known Implementation

`gio.AppInfo` is implemented by `gio.DesktopAppInfo`

## Description

`gio.AppInfo` and `gio.AppLaunchContext` are used for describing and launching applications installed on the system.

As of GLib 2.20, URIs will always be converted to POSIX paths (using `gio.File.get_path`()) when using `gio.AppInfo.launch`() even if the application requested an URI and not a POSIX path. For example for an desktop-file based application with Exec key totem %U and a single URI, sftp://foo/file.avi, then /home/user/.gvfs/sftp on foo/file.avi will be passed. This will only work if a set of suitable GIO extensions (such as gvfs 2.26 compiled with FUSE support), is available and operational; if this is not the case, the URI will be passed unmodified to the application. Some URIs, such as mailto:, of course cannot be mapped to a POSIX path (in gvfs there's no FUSE mount for it); such URIs will be passed unmodified to the application.

Specifically for gvfs 2.26 and later, the POSIX URI will be mapped back to the GIO URI in the `gio.File` constructors (since gvfs implements the GVfs extension point). As such, if the application needs to examine the URI, it needs to use `gio.File.get_uri`() or similar on `gio.File`. In other words, an application cannot assume that the URI passed to e.g. `gio.File`() constructor is equal to the result of `gio.File.get_uri`().

## Constructor

        gio.AppInfo(commandline, application_name=None, flags=gio.APP_INFO_CREATE_NONE)

`commandline` : | the commandline to use
`application_name` : | the application name, or `None` to use commandline.
`flags` : | flags that can specify details of the created, from Gio AppInfo Create Flags Constants
Returns : | a new `gio.AppInfo` for given command.

Creates a new `gio.AppInfo` from the given information.

## Methods

### gio.AppInfo.add_supports_type

        def add_supports_type(content_type)

`content_type` : | A string.

The `add_supports_type`() method adds a content type to the application information to indicate the application is capable of opening files with the given content type.

### gio.AppInfo.can_delete

        def can_delete()

Returns : | `True` if appinfo can be deleted.

The `can_delete`() method obtains the information whether the `gio.AppInfo` can be deleted. See `gio.AppInfo.delete`().

### gio.AppInfo.can_remove_supports_type

        def can_remove_supports_type()

Returns : | `True` if it is possible to remove supported content types from a given appinfo, `False` if not.

The `can_remove_supports_type`() method checks if a supported content type can be removed from an application.

### gio.AppInfo.delete

        def delete()

Returns : | `True` if appinfo has been deleted.

The `delete`() method tries to delete an `gio.AppInfo`.

On some platforms, there may be a difference between user-defined `gio.AppInfo`s which can be deleted, and system-wide ones which cannot. See `gio.AppInfo.can_delete`().

### gio.AppInfo.dup

        def dup()

Returns : | A duplicate of appinfo.

The `dup`() method creates a duplicate of a `gio.AppInfo`.

### gio.AppInfo.equal

        def equal(icon2)

`appinfo2` : | the second `gio.AppInfo`
Returns : | `True` if appinfo1 is equal to appinfo2. `False` otherwise.

The `equal`() method checks if two `gio.AppInfo`s are equal.

### gio.AppInfo.get_commandline

        def get_commandline()

Returns : | a string containing the appinfo's commandline, or `None` if this information is not available.

The `get_commandline`() method gets the commandline with which the application will be started.

### gio.AppInfo.get_description

        def get_description()

Returns : | A string containing a description of the application appinfo, or `None` if none.

The `get_description`() method gets a human-readable description of an installed application.

### gio.AppInfo.get_executable

        def get_executable()

Returns : | a string containing the appinfo's application binary's name.

The `get_description`() method gets the executable's name for the installed application.

### gio.AppInfo.get_icon

        def get_icon()

Returns : | the default `gio.Icon` for appinfo.

The `get_icon`() method gets the icon for the application.

### gio.AppInfo.get_id

        def get_id()

Returns : | a string containing the application's ID.

The `get_id`() method gets the ID of an application. An id is a string that identifies the application. The exact format of the id is platform dependent. For instance, on Unix this is the desktop file id from the xdg menu specification.

Note that the returned ID may be `None`, depending on how the appinfo has been constructed.

### gio.AppInfo.get_name

        def get_name()

Returns : | the name of the application for appinfo.

The `get_name`() method gets the installed name of the application.

### gio.AppInfo.launch

        def launch(files, launch_context)

`files` : | a list of `gio.File` objects.
`launch_context` : | a `gio.AppLaunchContext` or `None`.
Returns : | `True` on successful launch, `False` otherwise.

The `launch`() method launches the application. Passes files to the launched application as arguments, using the optional launch_context to get information about the details of the launcher (like what screen it is on). On error, error will be set accordingly.

To lauch the application without arguments pass a `None` for files list.

Note that even if the launch is successful the application launched can fail to start if it runs into problems during startup. There is no way to detect this.

Some URIs can be changed when passed through a `gio.File` (for instance unsupported uris with strange formats like mailto:), so if you have a textual uri you want to pass in as argument, consider using `gio.File.launch_uris`() instead.

### gio.AppInfo.launch_uris

        def launch_uris(uris, launch_context)

`uris` : | a list containing URIs to launch.
`launch_context` : | a `gio.AppLaunchContext` or `None`.
Returns : | `True` on successful launch, `False` otherwise.

The `launch_uris`() method launches the application. Passes uris to the launched application as arguments, using the optional launch_context to get information about the details of the launcher (like what screen it is on). On error, error will be set accordingly.

To lauch the application without arguments pass a `None` for files list.

Note that even if the launch is successful the application launched can fail to start if it runs into problems during startup. There is no way to detect this.

### gio.AppInfo.remove_supports_type

        def remove_supports_type(content_type)

`content_type` : | A string.

The `remove_supports_type`() method removes a supported type from an application, if possible.

### gio.AppInfo.set_as_default_for_extension

        def set_as_default_for_extension(extension)

`extension` : | A string containing the file extension (without the dot).

The `set_as_default_for_extension`() method sets the application as the default handler for the given file extention.

### gio.AppInfo.set_as_default_for_type

        def set_as_default_for_type(content_type)

`content_type` : | The content type.

The `set_as_default_for_type`() method sets the application as the default handler for a given type.

### gio.AppInfo.should_show

        def should_show()

Returns : | `True` if the appinfo should be shown, `False` otherwise.

The `should_show`() method checks if the application info should be shown in menus that list available applications.

### gio.AppInfo.supports_files

        def supports_files()

Returns : | `True` if the appinfo supports files.

The `supports_files`() method checks if the application accepts files as arguments.

### gio.AppInfo.supports_uris

        def supports_uris()

Returns : | `True` if the appinfo supports uris.

The `supports_uris`() method checks if the application accepts uris as arguments.

## Functions

### gio.app_info_get_all

        def app_info_get_all()

Returns : | A list of `gio.AppInfo`s.

The `app_info_get_all`() function gets a list of all of the applications currently registered on this system.

For desktop files, this includes applications that have NoDisplay=true set or are excluded from display by means of OnlyShowIn or NotShowIn. See `gio.AppInfo.should_show`(). The returned list does not include applications which have the Hidden key set.

### gio.app_info_get_all_for_type

        def app_info_get_all_for_type(content_type)

`content_type` : | the content type to find a `gio.AppInfo` for.
Returns : | A list of `gio.AppInfo`s for a given content type or `None` on error.

The `app_info_get_all_for_type`() function gets a list of all `gio.AppInfo`s for a given content type.

### gio.app_info_get_default_for_type

        def app_info_get_default_for_type(content_type, must_support_uris)

`content_type` : | the content type to find a `gio.AppInfo` for.
`must_support_uris` : | if `True`, the `gio.AppInfo` is expected to support URIs
Returns : | `gio.AppInfo` for given content_type or `None` on error.

The `app_info_get_default_for_type`() function gets the `gio.AppInfo` that correspond to a given content type.

### gio.app_info_get_default_for_uri_scheme

        def app_info_get_default_for_uri_scheme(uri_scheme)

`uri_scheme` : | a string containing a URI scheme.
Returns : | `gio.AppInfo` for given uri_scheme or `None` on error.

The `app_info_get_default_for_uri_scheme`() function gets the default application for launching applications using this URI scheme. A URI scheme is the initial part of the URI, up to but not including the ':', e.g. "http", "ftp" or "sip".

### gio.app_info_reset_type_association

        def app_info_reset_type_association(content_type)

`content_type` : | a content type

The `app_info_reset_type_association`() function removes all changes to the type associations done by `set_as_default_for_type`(), `set_as_default_for_extension`(), `add_supports_type`() or `remove_supports_type`().

Prev | Up | Next
PyGio Class Reference | Home | gio.AppLaunchContext