gio.app_info_mixin

Module for [AppInfo] interface mixin

Templates 2

tmplAppInfoT()

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

[gio.app_info.AppInfo] and [gio.app_launch_context.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.File.getPath]) when using [gio.app_info.AppInfo.launch] even if the application requested an URI and not a POSIX path. For example for a 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.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.File.getUri] or similar on [gio.file.File]. In other words, an application cannot assume that the URI passed to e.g. [gio.file.File.newForCommandlineArg] is equal to the result of [gio.file.File.getUri]. The following snippet illustrates this: CODEBLOCK0 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.

Functions
bool addSupportsType(string contentType)

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

Parameters

contentTypea string.

Returns

true on success, false on error.

Throws

[ErrorWrap]
bool canDelete()

Obtains the information whether the #GAppInfo can be deleted. See [gio.app_info.AppInfo.delete_].

Returns

true if appinfo can be deleted
bool canRemoveSupportsType()

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

Returns

true if it is possible to remove supported

content types from a given appinfo, false if not.

bool delete_()

Tries to delete a #GAppInfo.

On some platforms, there may be a difference between user-defined #GAppInfos which can be deleted, and system-wide ones which cannot. See [gio.app_info.AppInfo.canDelete].

Returns

true if appinfo has been deleted

Creates a duplicate of a #GAppInfo.

Returns

a duplicate of appinfo.
bool equal(gio.app_info.AppInfo appinfo2)

Checks if two #GAppInfos are equal.

Note that the check may not compare each individual field, and only does an identity check. In case detecting changes in the contents is needed, program code must additionally compare relevant fields.

Parameters

appinfo2the second #GAppInfo.

Returns

true if appinfo1 is equal to appinfo2. false otherwise.
string getCommandline()

Gets the commandline with which the application will be started.

Returns

a string containing the appinfo's commandline,

or null if this information is not available

string getDescription()

Gets a human-readable description of an installed application.

Returns

a string containing a description of the

application appinfo, or null if none.

string getDisplayName()

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

Returns

the display name of the application for appinfo, or the name if

no display name is available.

string getExecutable()

Gets the executable's name for the installed application.

This is intended to be used for debugging or labelling what program is going to be run. To launch the executable, use [gio.app_info.AppInfo.launch] and related functions, rather than spawning the return value from this function.

Returns

a string containing the appinfo's application

binaries name

gio.icon.Icon getIcon()

Gets the icon for the application.

Returns

the default #GIcon for appinfo or null

if there is no default icon.

string getId()

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 null, depending on how the appinfo has been constructed.

Returns

a string containing the application's ID.
string getName()

Gets the installed name of the application.

Returns

the name of the application for appinfo.
string[] getSupportedTypes()

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. This function does not take in consideration associations added with [gio.app_info.AppInfo.addSupportsType], but only those exported directly by the application.

Returns

a list of content types.
bool launch(gio.file.File[] files = null, gio.app_launch_context.AppLaunchContext context = null)

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.

To launch the application without arguments pass a null 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 GFile (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.app_info.AppInfo.launchUris] instead.

The launched application inherits the environment of the launching process, but it can be modified with [gio.app_launch_context.AppLaunchContext.setenv] and [gio.app_launch_context.AppLaunchContext.unsetenv].

On UNIX, this function sets the GIO_LAUNCHED_DESKTOP_FILE environment variable with the path of the launched desktop file and GIO_LAUNCHED_DESKTOP_FILE_PID to the process id of the launched process. This can be used to ignore GIO_LAUNCHED_DESKTOP_FILE, should it be inherited by further processes. The DISPLAY, XDG_ACTIVATION_TOKEN and DESKTOP_STARTUP_ID environment variables are also set, based on information provided in context.

Parameters

filesa #GList of #GFile objects
contexta #GAppLaunchContext or null

Returns

true on successful launch, false otherwise.

Throws

[ErrorWrap]
bool launchUris(string[] uris = null, gio.app_launch_context.AppLaunchContext context = null)

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.

To launch the application without arguments pass a null uris 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.

Parameters

urisa #GList containing URIs to launch.
contexta #GAppLaunchContext or null

Returns

true on successful launch, false otherwise.

Throws

[ErrorWrap]
void launchUrisAsync(string[] uris = null, gio.app_launch_context.AppLaunchContext context = null, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)

Async version of [gio.app_info.AppInfo.launchUris].

The callback is invoked immediately after the application launch, but it waits for activation in case of D-Bus–activated applications and also provides extended error information for sandboxed applications, see notes for [gio.app_info.AppInfo.launchDefaultForUriAsync].

Parameters

urisa #GList containing URIs to launch.
contexta #GAppLaunchContext or null
cancellablea #GCancellable
callbacka #GAsyncReadyCallback to call when the request is done
bool launchUrisFinish(gio.async_result.AsyncResult result)

Finishes a [gio.app_info.AppInfo.launchUrisAsync] operation.

Parameters

resulta #GAsyncResult

Returns

true on successful launch, false otherwise.

Throws

[ErrorWrap]
bool removeSupportsType(string contentType)

Removes a supported type from an application, if possible.

Parameters

contentTypea string.

Returns

true on success, false on error.

Throws

[ErrorWrap]
bool setAsDefaultForExtension(string extension)

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

Parameters

extensiona string containing the file extension (without the dot).

Returns

true on success, false on error.

Throws

[ErrorWrap]
bool setAsDefaultForType(string contentType)

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

Parameters

contentTypethe content type.

Returns

true on success, false on error.

Throws

[ErrorWrap]
bool setAsLastUsedForType(string contentType)

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 [gio.app_info.AppInfo.getRecommendedForType], regardless of the default application for that content type.

Parameters

contentTypethe content type.

Returns

true on success, false on error.

Throws

[ErrorWrap]
bool shouldShow()

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

Returns

true if the appinfo should be shown, false otherwise.
bool supportsFiles()

Checks if the application accepts files as arguments.

Returns

true if the appinfo supports files.
bool supportsUris()

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

Returns

true if the appinfo supports URIs.
tmplAppInfoGidBuilderT()