Gio.AppInfo¶
| Implementations: | |
|---|---|
Gio.DesktopAppInfo |
|
Methods¶
Virtual Methods¶
do_add_supports_type (content_type) |
|
do_can_delete () |
|
do_can_remove_supports_type () |
|
do_do_delete () |
|
do_dup () |
|
do_equal (appinfo2) |
|
do_get_commandline () |
|
do_get_description () |
|
do_get_display_name () |
|
do_get_executable () |
|
do_get_icon () |
|
do_get_id () |
|
do_get_name () |
|
do_get_supported_types () |
|
do_launch (files, context) |
|
do_launch_uris (uris, context) |
|
do_launch_uris_async (uris, context, cancellable, callback, *user_data) |
|
do_launch_uris_finish (result) |
|
do_remove_supports_type (content_type) |
|
do_set_as_default_for_extension (extension) |
|
do_set_as_default_for_type (content_type) |
|
do_set_as_last_used_for_type (content_type) |
|
do_should_show () |
|
do_supports_files () |
|
do_supports_uris () |
Properties¶
None
Signals¶
None
Fields¶
None
Class Details¶
-
class
Gio.AppInfo¶ Bases: GObject.GInterfaceStructure: Gio.AppInfoIfaceGio.AppInfoandGio.AppLaunchContextare 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 usingGio.AppInfo.launch() even if the application requested an URI and not a POSIX path. For example for a desktop-file based application with Exec keytotem %Uand a single URI,sftp://foo/file.avi, then/home/user/.gvfs/sftp on foo/file.aviwill 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 asmailto:, 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.Fileconstructors (since gvfs implements theGio.Vfsextension point). As such, if the application needs to examine the URI, it needs to useGio.File.get_uri() or similar onGio.File. In other words, an application cannot assume that the URI passed to e.g.Gio.File.new_for_commandline_arg() is equal to the result ofGio.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.wavand/home/user/.gvfs/cdda on sr0/Track 1.wavis 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.-
classmethod
create_from_commandline(commandline, application_name, flags)[source]¶ Parameters: - commandline (
str) – the commandline to use - application_name (
strorNone) – the application name, orNoneto use commandline - flags (
Gio.AppInfoCreateFlags) – flags that can specify details of the createdGio.AppInfo
Raises: Returns: new
Gio.AppInfofor given command.Return type: Creates a new
Gio.AppInfofrom the given information.Note that for commandline, the quoting rules of the Exec key of the freedesktop.org Desktop Entry Specification are applied. For example, if the commandline contains percent-encoded URIs, the percent-character must be doubled in order to prevent it from being swallowed by Exec key unquoting. See the specification for exact quoting rules.
- commandline (
-
classmethod
get_all()[source]¶ Returns: a newly allocated GLib.Listof references toGio.AppInfos.Return type: [ Gio.AppInfo]Gets a list of all of the applications currently registered on this system.
For desktop files, this includes applications that have
NoDisplay=trueset or are excluded from display by means ofOnlyShowInorNotShowIn. SeeGio.AppInfo.should_show(). The returned list does not include applications which have theHiddenkey set.
-
classmethod
get_all_for_type(content_type)[source]¶ Parameters: content_type ( str) – the content type to find aGio.AppInfoforReturns: GLib.ListofGio.AppInfosfor given content_type orNoneon error.Return type: [ Gio.AppInfo]Gets a list of all
Gio.AppInfosfor a given content type, including the recommended and fallbackGio.AppInfos. SeeGio.AppInfo.get_recommended_for_type() andGio.AppInfo.get_fallback_for_type().
-
classmethod
get_default_for_type(content_type, must_support_uris)[source]¶ Parameters: - content_type (
str) – the content type to find aGio.AppInfofor - must_support_uris (
bool) – ifTrue, theGio.AppInfois expected to support URIs
Returns: Gio.AppInfofor given content_type orNoneon error.Return type: Gio.AppInfoorNoneGets the default
Gio.AppInfofor a given content type.- content_type (
-
classmethod
get_default_for_uri_scheme(uri_scheme)[source]¶ Parameters: uri_scheme ( str) – a string containing a URI scheme.Returns: Gio.AppInfofor given uri_scheme orNoneon error.Return type: Gio.AppInfoorNoneGets 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”.
-
classmethod
get_fallback_for_type(content_type)[source]¶ Parameters: content_type ( str) – the content type to find aGio.AppInfoforReturns: GLib.ListofGio.AppInfosfor given content_type orNoneon error.Return type: [ Gio.AppInfo]Gets a list of fallback
Gio.AppInfosfor a given content type, i.e. those applications which claim to support the given content type by MIME type subclassing and not directly.New in version 2.28.
-
classmethod
get_recommended_for_type(content_type)[source]¶ Parameters: content_type ( str) – the content type to find aGio.AppInfoforReturns: GLib.ListofGio.AppInfosfor given content_type orNoneon error.Return type: [ Gio.AppInfo]Gets a list of recommended
Gio.AppInfosfor a given content type, i.e. those applications which claim to support the given content type exactly, and not by MIME type subclassing. Note that the first application of the list is the last used one, i.e. the last one for whichGio.AppInfo.set_as_last_used_for_type() has been called.New in version 2.28.
-
classmethod
launch_default_for_uri(uri, context)[source]¶ Parameters: - uri (
str) – the uri to show - context (
Gio.AppLaunchContextorNone) – an optionalGio.AppLaunchContext
Raises: Returns: Return type: 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.
The D-Bus–activated applications don’t have to be started if your application terminates too soon after this function. To prevent this, use
Gio.AppInfo.launch_default_for_uri_async() instead.- uri (
-
classmethod
launch_default_for_uri_async(uri, context, cancellable, callback, *user_data)[source]¶ Parameters: - uri (
str) – the uri to show - context (
Gio.AppLaunchContextorNone) – an optionalGio.AppLaunchContext - cancellable (
Gio.CancellableorNone) – aGio.Cancellable - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is done - user_data (
objectorNone) – data to pass to callback
Async version of
Gio.AppInfo.launch_default_for_uri().This version is useful if you are interested in receiving error information in the case where the application is sandboxed and the portal may present an application chooser dialog to the user.
This is also useful if you want to be sure that the D-Bus–activated applications are really started before termination and if you are interested in receiving error information from their activation.
New in version 2.50.
- uri (
-
classmethod
launch_default_for_uri_finish(result)[source]¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultRaises: GLib.ErrorReturns: Trueif the launch was successful,Falseif error is setReturn type: boolFinishes an asynchronous launch-default-for-uri operation.
New in version 2.50.
-
classmethod
reset_type_associations(content_type)[source]¶ Parameters: content_type ( str) – a content typeRemoves all changes to the type associations done by
Gio.AppInfo.set_as_default_for_type(),Gio.AppInfo.set_as_default_for_extension(),Gio.AppInfo.add_supports_type() orGio.AppInfo.remove_supports_type().New in version 2.20.
-
add_supports_type(content_type)[source]¶ Parameters: content_type ( str) – a string.Raises: GLib.ErrorReturns: Trueon success,Falseon error.Return type: boolAdds a content type to the application information to indicate the application is capable of opening files with the given content type.
-
can_delete()[source]¶ Returns: Trueif self can be deletedReturn type: boolObtains the information whether the
Gio.AppInfocan be deleted. SeeGio.AppInfo.delete().New in version 2.20.
-
can_remove_supports_type()[source]¶ Returns: Trueif it is possible to remove supported content types from a given self,Falseif not.Return type: boolChecks if a supported content type can be removed from an application.
-
delete()[source]¶ Returns: Trueif self has been deletedReturn type: boolTries to delete a
Gio.AppInfo.On some platforms, there may be a difference between user-defined
Gio.AppInfoswhich can be deleted, and system-wide ones which cannot. SeeGio.AppInfo.can_delete().New in version 2.20.
-
dup()[source]¶ Returns: a duplicate of self. Return type: Gio.AppInfoCreates a duplicate of a
Gio.AppInfo.
-
equal(appinfo2)[source]¶ Parameters: appinfo2 ( Gio.AppInfo) – the secondGio.AppInfo.Returns: Trueif self is equal to appinfo2.Falseotherwise.Return type: boolChecks if two
Gio.AppInfosare 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.
-
get_commandline()[source]¶ Returns: a string containing the self’s commandline, or Noneif this information is not availableReturn type: strGets the commandline with which the application will be started.
New in version 2.20.
-
get_description()[source]¶ Returns: a string containing a description of the application self, or Noneif none.Return type: strGets a human-readable description of an installed application.
-
get_display_name()[source]¶ Returns: the display name of the application for self, or the name if no display name is available. Return type: strGets the display name of the application. The display name is often more descriptive to the user than the name itself.
New in version 2.24.
-
get_executable()[source]¶ Returns: a string containing the self’s application binaries name Return type: strGets the executable’s name for the installed application.
-
get_icon()[source]¶ Returns: the default Gio.Iconfor self orNoneif there is no default icon.Return type: Gio.IconGets the icon for the application.
-
get_id()[source]¶ Returns: a string containing the application’s ID. Return type: strGets 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 self has been constructed.
-
get_name()[source]¶ Returns: the name of the application for self. Return type: strGets the installed name of the application.
-
get_supported_types()[source]¶ Returns: a list of content types. Return type: [ str]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
None. This function does not take in consideration associations added withGio.AppInfo.add_supports_type(), but only those exported directly by the application.New in version 2.34.
-
launch(files, context)[source]¶ Parameters: - files ([
Gio.File] orNone) – aGLib.ListofGio.Fileobjects - context (
Gio.AppLaunchContextorNone) – aGio.AppLaunchContextorNone
Raises: Returns: Return type: 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
Nonefiles 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 usingGio.AppInfo.launch_uris() instead.The launched application inherits the environment of the launching process, but it can be modified with
Gio.AppLaunchContext.setenv() andGio.AppLaunchContext.unsetenv().On UNIX, this function sets the
GIO_LAUNCHED_DESKTOP_FILEenvironment variable with the path of the launched desktop file andGIO_LAUNCHED_DESKTOP_FILE_PIDto the process id of the launched process. This can be used to ignoreGIO_LAUNCHED_DESKTOP_FILE, should it be inherited by further processes. TheDISPLAYandDESKTOP_STARTUP_IDenvironment variables are also set, based on information provided in context.- files ([
-
launch_uris(uris, context)[source]¶ Parameters: - uris ([
str] orNone) – aGLib.Listcontaining URIs to launch. - context (
Gio.AppLaunchContextorNone) – aGio.AppLaunchContextorNone
Raises: Returns: Return type: 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.
To launch the application without arguments pass a
Noneuris 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.
- uris ([
-
launch_uris_async(uris, context, cancellable, callback, *user_data)[source]¶ Parameters: - uris ([
str] orNone) – aGLib.Listcontaining URIs to launch. - context (
Gio.AppLaunchContextorNone) – aGio.AppLaunchContextorNone - cancellable (
Gio.CancellableorNone) – aGio.Cancellable - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is done - user_data (
objectorNone) – data to pass to callback
Async version of
Gio.AppInfo.launch_uris().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.AppInfo.launch_default_for_uri_async().New in version 2.60.
- uris ([
-
launch_uris_finish(result)[source]¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultRaises: GLib.ErrorReturns: Trueon successful launch,Falseotherwise.Return type: boolFinishes a
Gio.AppInfo.launch_uris_async() operation.New in version 2.60.
-
remove_supports_type(content_type)[source]¶ Parameters: content_type ( str) – a string.Raises: GLib.ErrorReturns: Trueon success,Falseon error.Return type: boolRemoves a supported type from an application, if possible.
-
set_as_default_for_extension(extension)[source]¶ Parameters: extension ( str) – a string containing the file extension (without the dot).Raises: GLib.ErrorReturns: Trueon success,Falseon error.Return type: boolSets the application as the default handler for the given file extension.
-
set_as_default_for_type(content_type)[source]¶ Parameters: content_type ( str) – the content type.Raises: GLib.ErrorReturns: Trueon success,Falseon error.Return type: boolSets the application as the default handler for a given type.
-
set_as_last_used_for_type(content_type)[source]¶ Parameters: content_type ( str) – the content type.Raises: GLib.ErrorReturns: Trueon success,Falseon error.Return type: boolSets 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.AppInfo.get_recommended_for_type(), regardless of the default application for that content type.
-
should_show()[source]¶ Returns: Trueif the self should be shown,Falseotherwise.Return type: boolChecks if the application info should be shown in menus that list available applications.
-
supports_files()[source]¶ Returns: Trueif the self supports files.Return type: boolChecks if the application accepts files as arguments.
-
supports_uris()[source]¶ Returns: Trueif the self supports URIs.Return type: boolChecks if the application supports reading files and directories from URIs.
-
do_add_supports_type(content_type) virtual¶ Parameters: content_type ( str) – a string.Returns: Trueon success,Falseon error.Return type: boolAdds a content type to the application information to indicate the application is capable of opening files with the given content type.
-
do_can_delete() virtual¶ Returns: Trueif appinfo can be deletedReturn type: boolObtains the information whether the
Gio.AppInfocan be deleted. SeeGio.AppInfo.delete().New in version 2.20.
-
do_can_remove_supports_type() virtual¶ Returns: Trueif it is possible to remove supported content types from a given appinfo,Falseif not.Return type: boolChecks if a supported content type can be removed from an application.
-
do_do_delete() virtual¶ Returns: Trueif appinfo has been deletedReturn type: boolTries to delete a
Gio.AppInfo.On some platforms, there may be a difference between user-defined
Gio.AppInfoswhich can be deleted, and system-wide ones which cannot. SeeGio.AppInfo.can_delete().New in version 2.20.
-
do_dup() virtual¶ Returns: a duplicate of appinfo. Return type: Gio.AppInfoCreates a duplicate of a
Gio.AppInfo.
-
do_equal(appinfo2) virtual¶ Parameters: appinfo2 ( Gio.AppInfo) – the secondGio.AppInfo.Returns: Trueif appinfo1 is equal to appinfo2.Falseotherwise.Return type: boolChecks if two
Gio.AppInfosare 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.
-
do_get_description() virtual¶ Returns: a string containing a description of the application appinfo, or Noneif none.Return type: strGets a human-readable description of an installed application.
-
do_get_display_name() virtual¶ Returns: the display name of the application for appinfo, or the name if no display name is available. Return type: strGets the display name of the application. The display name is often more descriptive to the user than the name itself.
New in version 2.24.
-
do_get_icon() virtual¶ Returns: the default Gio.Iconfor appinfo orNoneif there is no default icon.Return type: Gio.IconGets the icon for the application.
-
do_get_id() virtual¶ Returns: a string containing the application’s ID. Return type: strGets 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.
-
do_get_name() virtual¶ Returns: the name of the application for appinfo. Return type: strGets the installed name of the application.
-
do_get_supported_types() virtual¶ Returns: a list of content types. Return type: [ str]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
None. This function does not take in consideration associations added withGio.AppInfo.add_supports_type(), but only those exported directly by the application.New in version 2.34.
-
do_launch(files, context) virtual¶ Parameters: - files ([
Gio.File] orNone) – aGLib.ListofGio.Fileobjects - context (
Gio.AppLaunchContextorNone) – aGio.AppLaunchContextorNone
Returns: Return type: 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
Nonefiles 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 usingGio.AppInfo.launch_uris() instead.The launched application inherits the environment of the launching process, but it can be modified with
Gio.AppLaunchContext.setenv() andGio.AppLaunchContext.unsetenv().On UNIX, this function sets the
GIO_LAUNCHED_DESKTOP_FILEenvironment variable with the path of the launched desktop file andGIO_LAUNCHED_DESKTOP_FILE_PIDto the process id of the launched process. This can be used to ignoreGIO_LAUNCHED_DESKTOP_FILE, should it be inherited by further processes. TheDISPLAYandDESKTOP_STARTUP_IDenvironment variables are also set, based on information provided in context.- files ([
-
do_launch_uris(uris, context) virtual¶ Parameters: - uris ([
str] orNone) – aGLib.Listcontaining URIs to launch. - context (
Gio.AppLaunchContextorNone) – aGio.AppLaunchContextorNone
Returns: Return type: 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.
To launch the application without arguments pass a
Noneuris 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.
- uris ([
-
do_launch_uris_async(uris, context, cancellable, callback, *user_data) virtual¶ Parameters: - uris ([
str] orNone) – aGLib.Listcontaining URIs to launch. - context (
Gio.AppLaunchContextorNone) – aGio.AppLaunchContextorNone - cancellable (
Gio.CancellableorNone) – aGio.Cancellable - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is done - user_data (
objectorNone) – data to pass to callback
Async version of
Gio.AppInfo.launch_uris().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.AppInfo.launch_default_for_uri_async().New in version 2.60.
- uris ([
-
do_launch_uris_finish(result) virtual¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultReturns: Trueon successful launch,Falseotherwise.Return type: boolFinishes a
Gio.AppInfo.launch_uris_async() operation.New in version 2.60.
-
do_remove_supports_type(content_type) virtual¶ Parameters: content_type ( str) – a string.Returns: Trueon success,Falseon error.Return type: boolRemoves a supported type from an application, if possible.
-
do_set_as_default_for_extension(extension) virtual¶ Parameters: extension ( str) – a string containing the file extension (without the dot).Returns: Trueon success,Falseon error.Return type: boolSets the application as the default handler for the given file extension.
-
do_set_as_default_for_type(content_type) virtual¶ Parameters: content_type ( str) – the content type.Returns: Trueon success,Falseon error.Return type: boolSets the application as the default handler for a given type.
-
do_set_as_last_used_for_type(content_type) virtual¶ Parameters: content_type ( str) – the content type.Returns: Trueon success,Falseon error.Return type: boolSets 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.AppInfo.get_recommended_for_type(), regardless of the default application for that content type.
-
do_should_show() virtual¶ Returns: Trueif the appinfo should be shown,Falseotherwise.Return type: boolChecks if the application info should be shown in menus that list available applications.
-
classmethod