### Interface

# Gio AppInfo

#### Description [src]

    interface Gio.AppInfo : GObject.Object

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

`GAppInfo` and `GAppLaunchContext` 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 `g_file_get_path()`) when using `g_app_info_launch()` even if the application requested an URI and not a POSIX path. For example for a desktop-file based application with the following Exec key:

    Exec=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 `GFile` constructors (since GVfs implements the GVfs extension point). As such, if the application needs to examine the URI, it needs to use `g_file_get_uri()` or similar on `GFile`. In other words, an application cannot assume that the URI passed to e.g. `g_file_new_for_commandline_arg()` is equal to the result of `g_file_get_uri()`. The following snippet illustrates this:

    GFile *f;
    char *uri;

    file = g_file_new_for_commandline_arg (uri_from_commandline);

    uri = g_file_get_uri (file);
    strcmp (uri, uri_from_commandline) == 0;
    g_free (uri);

    if (g_file_has_uri_scheme (file, "cdda"))
      {
        // do something special with uri
      }
    g_object_unref (file);

This code will work when both `cdda://sr0/Track 1.wav` and `/home/user/.gvfs/cdda on sr0/Track 1.wav` is passed to the application. It should be noted that it’s generally not safe for applications to rely on the format of a particular URIs. Different launcher applications (e.g. file managers) may have different ideas of what a given URI means.

#### Prerequisite

In order to implement AppInfo, your type must inherit from`GObject`.

#### Implementations

- GDesktopAppInfo

#### Functions

###### g_app_info_create_from_commandline

Creates a new `GAppInfo` from the given information.

###### g_app_info_get_all

Gets a list of all of the applications currently registered on this system.

###### g_app_info_get_all_for_type

Gets a list of all `GAppInfo`s for a given content type, including the recommended and fallback `GAppInfo`s. See `g_app_info_get_recommended_for_type()` and `g_app_info_get_fallback_for_type()`.

###### g_app_info_get_default_for_type

Gets the default `GAppInfo` for a given content type.

###### g_app_info_get_default_for_type_async

Asynchronously gets the default `GAppInfo` for a given content type.

since: 2.74

###### g_app_info_get_default_for_type_finish

Finishes a default `GAppInfo` lookup started by `g_app_info_get_default_for_type_async()`.

since: 2.74

###### g_app_info_get_default_for_uri_scheme

Gets the default application for handling URIs with the given URI scheme.

###### g_app_info_get_default_for_uri_scheme_async

Asynchronously gets the default application for handling URIs with the given URI scheme. A URI scheme is the initial part of the URI, up to but not including the `:`, e.g. `http`, `ftp` or `sip`.

since: 2.74

###### g_app_info_get_default_for_uri_scheme_finish

Finishes a default `GAppInfo` lookup started by `g_app_info_get_default_for_uri_scheme_async()`.

since: 2.74

###### g_app_info_get_fallback_for_type

Gets a list of fallback `GAppInfo`s for a given content type, i.e. those applications which claim to support the given content type by MIME type subclassing and not directly.

since: 2.28

###### g_app_info_get_recommended_for_type

Gets a list of recommended `GAppInfo`s for a given content type, i.e. those applications which claim to support the given content type exactly, and not by MIME type subclassing.

since: 2.28

###### g_app_info_launch_default_for_uri

Utility function that launches the default application registered to handle the specified uri. Synchronous I/O is done on the uri to detect the type of the file if required.

###### g_app_info_launch_default_for_uri_async

Async version of `g_app_info_launch_default_for_uri()`.

since: 2.50

###### g_app_info_launch_default_for_uri_finish

Finishes an asynchronous launch-default-for-uri operation.

since: 2.50

###### g_app_info_reset_type_associations

Removes all changes to the type associations done by `g_app_info_set_as_default_for_type()`, `g_app_info_set_as_default_for_extension()`, `g_app_info_add_supports_type()` or `g_app_info_remove_supports_type()`.

since: 2.20

#### Instance methods

###### g_app_info_add_supports_type

Adds a content type to the application information to indicate the application is capable of opening files with the given content type.

###### g_app_info_can_delete

Obtains the information whether the `GAppInfo` can be deleted. See `g_app_info_delete()`.

since: 2.20

###### g_app_info_can_remove_supports_type

Checks if a supported content type can be removed from an application.

###### g_app_info_delete

Tries to delete a `GAppInfo`.

since: 2.20

###### g_app_info_dup

Creates a duplicate of a `GAppInfo`.

###### g_app_info_equal

Checks if two `GAppInfo`s are equal.

###### g_app_info_get_commandline

Gets the commandline with which the application will be started.

since: 2.20

###### g_app_info_get_description

Gets a human-readable description of an installed application.

###### g_app_info_get_display_name

Gets the display name of the application. The display name is often more descriptive to the user than the name itself.

since: 2.24

###### g_app_info_get_executable

Gets the executable’s name for the installed application.

###### g_app_info_get_icon

Gets the icon for the application.

###### g_app_info_get_id

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.

###### g_app_info_get_name

Gets the installed name of the application.

###### g_app_info_get_supported_types

Retrieves the list of content types that `app_info` claims to support. If this information is not provided by the environment, this function will return `NULL`.

since: 2.34

###### g_app_info_launch

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

###### g_app_info_launch_uris

Launches the application. This passes the `uris` to the launched application as arguments, using the optional `context` to get information about the details of the launcher (like what screen it is on). On error, `error` will be set accordingly. If the application only supports one URI per invocation as part of their command-line, multiple instances of the application will be spawned.

###### g_app_info_launch_uris_async

Async version of `g_app_info_launch_uris()`.

since: 2.60

###### g_app_info_launch_uris_finish

Finishes a `g_app_info_launch_uris_async()` operation.

since: 2.60

###### g_app_info_remove_supports_type

Removes a supported type from an application, if possible.

###### g_app_info_set_as_default_for_extension

Sets the application as the default handler for the given file extension.

###### g_app_info_set_as_default_for_type

Sets the application as the default handler for a given type.

###### g_app_info_set_as_last_used_for_type

Sets the application as the last used application for a given type. This will make the application appear as first in the list returned by `g_app_info_get_recommended_for_type()`, regardless of the default application for that content type.

###### g_app_info_should_show

Checks if the application info should be shown in menus that list available applications.

###### g_app_info_supports_files

Checks if the application accepts files as arguments.

###### g_app_info_supports_uris

Checks if the application supports reading files and directories from URIs.

#### Interface structure

    struct GioAppInfoIface {
      GTypeInterface g_iface;
      GAppInfo* (* dup) (
        GAppInfo* appinfo
      );
      gboolean (* equal) (
        GAppInfo* appinfo1,
        GAppInfo* appinfo2
      );
      const char* (* get_id) (
        GAppInfo* appinfo
      );
      const char* (* get_name) (
        GAppInfo* appinfo
      );
      const char* (* get_description) (
        GAppInfo* appinfo
      );
      const char* (* get_executable) (
        GAppInfo* appinfo
      );
      GIcon* (* get_icon) (
        GAppInfo* appinfo
      );
      gboolean (* launch) (
        GAppInfo* appinfo,
        GList* files,
        GAppLaunchContext* context,
        GError** error
      );
      gboolean (* supports_uris) (
        GAppInfo* appinfo
      );
      gboolean (* supports_files) (
        GAppInfo* appinfo
      );
      gboolean (* launch_uris) (
        GAppInfo* appinfo,
        GList* uris,
        GAppLaunchContext* context,
        GError** error
      );
      gboolean (* should_show) (
        GAppInfo* appinfo
      );
      gboolean (* set_as_default_for_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      );
      gboolean (* set_as_default_for_extension) (
        GAppInfo* appinfo,
        const char* extension,
        GError** error
      );
      gboolean (* add_supports_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      );
      gboolean (* can_remove_supports_type) (
        GAppInfo* appinfo
      );
      gboolean (* remove_supports_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      );
      gboolean (* can_delete) (
        GAppInfo* appinfo
      );
      gboolean (* do_delete) (
        GAppInfo* appinfo
      );
      const char* (* get_commandline) (
        GAppInfo* appinfo
      );
      const char* (* get_display_name) (
        GAppInfo* appinfo
      );
      gboolean (* set_as_last_used_for_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      );
      const char** (* get_supported_types) (
        GAppInfo* appinfo
      );
      void (* launch_uris_async) (
        GAppInfo* appinfo,
        GList* uris,
        GAppLaunchContext* context,
        GCancellable* cancellable,
        GAsyncReadyCallback callback,
        gpointer user_data
      );
      gboolean (* launch_uris_finish) (
        GAppInfo* appinfo,
        GAsyncResult* result,
        GError** error
      );

    }

Application Information interface, for operating system portability.

###### Interface members

`g_iface`

    GTypeInterface

| The parent interface.

`dup`

    GAppInfo* (* dup) (
        GAppInfo* appinfo
      )

| Copies a `GAppInfo`.

`equal`

    gboolean (* equal) (
        GAppInfo* appinfo1,
        GAppInfo* appinfo2
      )

| Checks two `GAppInfo`s for equality.

`get_id`

    const char* (* get_id) (
        GAppInfo* appinfo
      )

| Gets a string identifier for a `GAppInfo`.

`get_name`

    const char* (* get_name) (
        GAppInfo* appinfo
      )

| Gets the name of the application for a `GAppInfo`.

`get_description`

    const char* (* get_description) (
        GAppInfo* appinfo
      )

| Gets a short description for the application described by the `GAppInfo`.

`get_executable`

    const char* (* get_executable) (
        GAppInfo* appinfo
      )

| Gets the executable name for the `GAppInfo`.

`get_icon`

    GIcon* (* get_icon) (
        GAppInfo* appinfo
      )

| Gets the `GIcon` for the `GAppInfo`.

`launch`

    gboolean (* launch) (
        GAppInfo* appinfo,
        GList* files,
        GAppLaunchContext* context,
        GError** error
      )

| Launches an application specified by the `GAppInfo`.

`supports_uris`

    gboolean (* supports_uris) (
        GAppInfo* appinfo
      )

| Indicates whether the application specified supports launching URIs.

`supports_files`

    gboolean (* supports_files) (
        GAppInfo* appinfo
      )

| Indicates whether the application specified accepts filename arguments.

`launch_uris`

    gboolean (* launch_uris) (
        GAppInfo* appinfo,
        GList* uris,
        GAppLaunchContext* context,
        GError** error
      )

| Launches an application with a list of URIs.

`should_show`

    gboolean (* should_show) (
        GAppInfo* appinfo
      )

| Returns whether an application should be shown (e.g. when getting a list of installed applications). FreeDesktop.Org Startup Notification Specification.

`set_as_default_for_type`

    gboolean (* set_as_default_for_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      )

| Sets an application as default for a given content type.

`set_as_default_for_extension`

    gboolean (* set_as_default_for_extension) (
        GAppInfo* appinfo,
        const char* extension,
        GError** error
      )

| Sets an application as default for a given file extension.

`add_supports_type`

    gboolean (* add_supports_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      )

| Adds to the `GAppInfo` information about supported file types.

`can_remove_supports_type`

    gboolean (* can_remove_supports_type) (
        GAppInfo* appinfo
      )

| Checks for support for removing supported file types from a `GAppInfo`.

`remove_supports_type`

    gboolean (* remove_supports_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      )

| Removes a supported application type from a `GAppInfo`.

`can_delete`

    gboolean (* can_delete) (
        GAppInfo* appinfo
      )

| Checks if a `GAppInfo` can be deleted. (Since 2.20).

`do_delete`

    gboolean (* do_delete) (
        GAppInfo* appinfo
      )

| Deletes a `GAppInfo`. (Since 2.20).

`get_commandline`

    const char* (* get_commandline) (
        GAppInfo* appinfo
      )

| Gets the commandline for the `GAppInfo`. (Since 2.20).

`get_display_name`

    const char* (* get_display_name) (
        GAppInfo* appinfo
      )

| Gets the display name for the `GAppInfo`. (Since 2.24).

`set_as_last_used_for_type`

    gboolean (* set_as_last_used_for_type) (
        GAppInfo* appinfo,
        const char* content_type,
        GError** error
      )

| Sets the application as the last used. See `g_app_info_set_as_last_used_for_type()`.

`get_supported_types`

    const char** (* get_supported_types) (
        GAppInfo* appinfo
      )

| Retrieves the list of content types that `app_info` claims to support.

`launch_uris_async`

    void (* launch_uris_async) (
        GAppInfo* appinfo,
        GList* uris,
        GAppLaunchContext* context,
        GCancellable* cancellable,
        GAsyncReadyCallback callback,
        gpointer user_data
      )

| Asynchronously launches an application with a list of URIs. (Since: 2.60).

`launch_uris_finish`

    gboolean (* launch_uris_finish) (
        GAppInfo* appinfo,
        GAsyncResult* result,
        GError** error
      )

| Finishes an operation started with `launch_uris_async`. (Since: 2.60).

#### Virtual methods

###### Gio.AppInfo.add_supports_type

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

Obtains the information whether the `GAppInfo` can be deleted. See `g_app_info_delete()`.

since: 2.20

###### Gio.AppInfo.can_remove_supports_type

Checks if a supported content type can be removed from an application.

###### Gio.AppInfo.do_delete

Tries to delete a `GAppInfo`.

since: 2.20

###### Gio.AppInfo.dup

Creates a duplicate of a `GAppInfo`.

###### Gio.AppInfo.equal

Checks if two `GAppInfo`s are equal.

###### Gio.AppInfo.get_commandline

Gets the commandline with which the application will be started.

since: 2.20

###### Gio.AppInfo.get_description

Gets a human-readable description of an installed application.

###### Gio.AppInfo.get_display_name

Gets the display name of the application. The display name is often more descriptive to the user than the name itself.

since: 2.24

###### Gio.AppInfo.get_executable

Gets the executable’s name for the installed application.

###### Gio.AppInfo.get_icon

Gets the icon for the application.

###### Gio.AppInfo.get_id

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.

###### Gio.AppInfo.get_name

Gets the installed name of the application.

###### Gio.AppInfo.get_supported_types

Retrieves the list of content types that `app_info` claims to support. If this information is not provided by the environment, this function will return `NULL`.

since: 2.34

###### Gio.AppInfo.launch

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

###### Gio.AppInfo.launch_uris

Launches the application. This passes the `uris` to the launched application as arguments, using the optional `context` to get information about the details of the launcher (like what screen it is on). On error, `error` will be set accordingly. If the application only supports one URI per invocation as part of their command-line, multiple instances of the application will be spawned.

###### Gio.AppInfo.launch_uris_async

Async version of `g_app_info_launch_uris()`.

since: 2.60

###### Gio.AppInfo.launch_uris_finish

Finishes a `g_app_info_launch_uris_async()` operation.

since: 2.60

###### Gio.AppInfo.remove_supports_type

Removes a supported type from an application, if possible.

###### Gio.AppInfo.set_as_default_for_extension

Sets the application as the default handler for the given file extension.

###### Gio.AppInfo.set_as_default_for_type

Sets the application as the default handler for a given type.

###### Gio.AppInfo.set_as_last_used_for_type

Sets the application as the last used application for a given type. This will make the application appear as first in the list returned by `g_app_info_get_recommended_for_type()`, regardless of the default application for that content type.

###### Gio.AppInfo.should_show

Checks if the application info should be shown in menus that list available applications.

###### Gio.AppInfo.supports_files

Checks if the application accepts files as arguments.

###### Gio.AppInfo.supports_uris

Checks if the application supports reading files and directories from URIs.