gio.app_info_mixin
Module for [AppInfo] interface mixin
Templates 2
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.
Adds a content type to the application information to indicate the application is capable of opening files with the given content type.
Parameters
contentType | a string. |
Returns
Throws
Obtains the information whether the #GAppInfo can be deleted. See [gio.app_info.AppInfo.delete_].
Returns
Checks if a supported content type can be removed from an application.
Returns
content types from a given appinfo, false if not.
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
Creates a duplicate of a #GAppInfo.
Returns
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
appinfo2 | the second #GAppInfo. |
Returns
Gets the commandline with which the application will be started.
Returns
or null if this information is not available
Gets a human-readable description of an installed application.
Returns
application appinfo, or null if none.
Gets the display name of the application. The display name is often more descriptive to the user than the name itself.
Returns
no display name is available.
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
binaries name
Gets the icon for the application.
Returns
if there is no default icon.
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
Gets the installed name of the application.
Returns
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
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
files | a #GList of #GFile objects |
context | a #GAppLaunchContext or null |
Returns
Throws
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
uris | a #GList containing URIs to launch. |
context | a #GAppLaunchContext or null |
Returns
Throws
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
uris | a #GList containing URIs to launch. |
context | a #GAppLaunchContext or null |
cancellable | a #GCancellable |
callback | a #GAsyncReadyCallback to call when the request is done |
Finishes a [gio.app_info.AppInfo.launchUrisAsync] operation.
Parameters
result | a #GAsyncResult |
Returns
Throws
Removes a supported type from an application, if possible.
Parameters
contentType | a string. |
Returns
Throws
Sets the application as the default handler for the given file extension.
Parameters
extension | a string containing the file extension (without the dot). |
Returns
Throws
Sets the application as the default handler for a given type.
Parameters
contentType | the content type. |
Returns
Throws
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
contentType | the content type. |
Returns
Throws
Checks if the application info should be shown in menus that list available applications.
Returns
Checks if the application accepts files as arguments.
Returns
Checks if the application supports reading files and directories from URIs.