gio.AppInfo — Information about an installed application and methods to launch it (with file arguments).
class gio.AppInfo(gobject.GInterface): |
Functionsdef 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
)
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
().
gio.AppInfo(commandline
, application_name
=None, flags
=gio.APP_INFO_CREATE_NONE)
| the commandline to use |
| the application name, or None to use commandline.
|
| 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.
def add_supports_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.
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
().
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.
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
().
def dup()
Returns : | A duplicate of appinfo. |
The dup
() method creates a duplicate of a
gio.AppInfo
.
def equal(icon2
)
| 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.
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.
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.
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.
def get_icon()
Returns : | the default
gio.Icon for appinfo.
|
The get_icon
() method gets the icon for the application.
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.
def get_name()
Returns : | the name of the application for appinfo. |
The get_name
() method gets the installed
name of the application.
def launch(files
, launch_context
)
| a list of gio.File objects.
|
| 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.
def launch_uris(uris
, launch_context
)
| a list containing URIs to launch. |
| 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.
def remove_supports_type(content_type
)
| A string. |
The remove_supports_type
() method removes a
supported type from an application, if possible.
def set_as_default_for_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.
def set_as_default_for_type(content_type
)
| The content type. |
The set_as_default_for_type
() method sets the
application as the default handler for a given type.
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.
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.
def app_info_get_all_for_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.
def app_info_get_default_for_type(content_type
, must_support_uris
)
| the content type to find a
gio.AppInfo
for. |
| 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.
def app_info_get_default_for_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".
def app_info_reset_type_association(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
().