Module: Gio::AppInfo
- Defined in:
- (unknown)
Overview
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 [methodGio.File.get_path]) when using [methodGio.AppInfo.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 [ifaceGio.File] constructors (since GVfs
implements the GVfs extension point). As such, if the application
needs to examine the URI, it needs to use [methodGio.File.get_uri]
or similar on [ifaceGio.File]. In other words, an application cannot
assume that the URI passed to e.g. [funcGio.File.new_for_commandline_arg]
is equal to the result of [methodGio.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.
Instance Method Summary collapse
-
#add_supports_type(appinfo, content_type) ⇒ Boolean
TRUEon success,FALSEon error. -
#as_default_for_extension=(extension) ⇒ Boolean
Sets the application as the default handler for the given file extension.
-
#as_default_for_type=(content_type) ⇒ Boolean
Sets the application as the default handler for a given type.
-
#as_last_used_for_type=(content_type) ⇒ Boolean
Sets the application as the last used application for a given type.
-
#can_delete(appinfo) ⇒ Boolean
TRUEif appinfo can be deleted. -
#can_remove_supports_type(appinfo) ⇒ Boolean
TRUEif it is possible to remove supported content types from a given appinfo,FALSEif not. -
#commandline ⇒ Gio::filename
Gets the commandline with which the application will be started.
-
#delete ⇒ Boolean
Tries to delete a [ifaceGio.AppInfo].
-
#description ⇒ String
Gets a human-readable description of an installed application.
-
#display_name ⇒ String
Gets the display name of the application.
-
#do_delete(appinfo) ⇒ Boolean
TRUEif appinfo has been deleted. -
#dup(appinfo) ⇒ Gio::AppInfo
A duplicate of appinfo.
-
#equal(appinfo1, appinfo2) ⇒ Boolean
TRUEif appinfo1 is equal to appinfo2. -
#executable ⇒ Gio::filename
Gets the executable’s name for the installed application.
-
#get_commandline(appinfo) ⇒ Gio::filename
A string containing the appinfo’s commandline, or
NULLif this information is not available. -
#get_description(appinfo) ⇒ String
application appinfo, or
NULLif none. -
#get_display_name(appinfo) ⇒ String
no display name is available.
-
#get_executable(appinfo) ⇒ Gio::filename
binaries name.
-
#get_icon(appinfo) ⇒ Gio::Icon
The default [ifaceGio.Icon] for appinfo or
NULLif there is no default icon. -
#get_id(appinfo) ⇒ String
A string containing the application’s ID.
-
#get_name(appinfo) ⇒ String
The name of the application for appinfo.
-
#get_supported_types(appinfo) ⇒ Array<String>
A list of content types.
-
#icon ⇒ Gio::Icon
Gets the icon for the application.
-
#id ⇒ String
Gets the ID of an application.
-
#launch(appinfo, files, context) ⇒ Boolean
TRUEon successful launch,FALSEotherwise. -
#launch_uris(appinfo, uris, context) ⇒ Boolean
TRUEon successful launch,FALSEotherwise. - #launch_uris_async(appinfo, uris, context, cancellable, callback, user_data) ⇒ nil
-
#launch_uris_finish(appinfo, result) ⇒ Boolean
TRUEon successful launch,FALSEotherwise. -
#name ⇒ String
Gets the installed name of the application.
-
#remove_supports_type(appinfo, content_type) ⇒ Boolean
TRUEon success,FALSEon error. -
#set_as_default_for_extension(appinfo, extension) ⇒ Boolean
TRUEon success,FALSEon error. -
#set_as_default_for_type(appinfo, content_type) ⇒ Boolean
TRUEon success,FALSEon error. -
#set_as_last_used_for_type(appinfo, content_type) ⇒ Boolean
TRUEon success,FALSEon error. -
#should_show(appinfo) ⇒ Boolean
TRUEif the appinfo should be shown,FALSEotherwise. -
#supported_types ⇒ Array<String>
Retrieves the list of content types that app_info claims to support.
-
#supports_files(appinfo) ⇒ Boolean
TRUEif the appinfo supports files. -
#supports_uris(appinfo) ⇒ Boolean
TRUEif the appinfo supports URIs.
Instance Method Details
#add_supports_type(appinfo, content_type) ⇒ Boolean
Returns TRUE on success, FALSE on error.
#as_default_for_extension=(extension) ⇒ Boolean
Sets the application as the default handler for the given file extension.
#as_default_for_type=(content_type) ⇒ Boolean
Sets the application as the default handler for a given type.
#as_last_used_for_type=(content_type) ⇒ Boolean
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
[funcGio.AppInfo.get_recommended_for_type], regardless of the default
application for that content type.
#can_delete(appinfo) ⇒ Boolean
Returns TRUE if appinfo can be deleted.
#can_remove_supports_type(appinfo) ⇒ Boolean
Returns TRUE if it is possible to remove supported content types from a
given appinfo, FALSE if not.
#commandline ⇒ Gio::filename
Gets the commandline with which the application will be
started.
#delete ⇒ Boolean
Tries to delete a [ifaceGio.AppInfo].
On some platforms, there may be a difference between user-defined
[ifaceGio.AppInfo]s which can be deleted, and system-wide ones which cannot.
See [methodGio.AppInfo.can_delete].
#description ⇒ String
Gets a human-readable description of an installed application.
application appinfo, or NULL if none.
#display_name ⇒ String
Gets the display name of the application. The display name is often more
descriptive to the user than the name itself.
no display name is available.
#do_delete(appinfo) ⇒ Boolean
Returns TRUE if appinfo has been deleted.
#dup(appinfo) ⇒ Gio::AppInfo
Returns a duplicate of appinfo.
#equal(appinfo1, appinfo2) ⇒ Boolean
Returns TRUE if appinfo1 is equal to appinfo2. FALSE otherwise.
#executable ⇒ Gio::filename
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 [methodGio.AppInfo.launch] and related
functions, rather than spawning the return value from this function.
binaries name
#get_commandline(appinfo) ⇒ Gio::filename
Returns a string containing the appinfo’s
commandline, or NULL if this information is not available.
#get_description(appinfo) ⇒ String
application appinfo, or NULL if none.
#get_display_name(appinfo) ⇒ String
no display name is available.
#get_executable(appinfo) ⇒ Gio::filename
binaries name
#get_icon(appinfo) ⇒ Gio::Icon
Returns the default [ifaceGio.Icon] for
appinfo or NULL if there is no default icon.
#get_id(appinfo) ⇒ String
Returns a string containing the application’s ID.
#get_name(appinfo) ⇒ String
Returns the name of the application for appinfo.
#get_supported_types(appinfo) ⇒ Array<String>
Returns a list of content types.
#icon ⇒ Gio::Icon
Gets the icon for the application.
#id ⇒ String
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.
#launch(appinfo, files, context) ⇒ Boolean
Returns TRUE on successful launch, FALSE otherwise.
#launch_uris(appinfo, uris, context) ⇒ Boolean
Returns TRUE on successful launch, FALSE otherwise.
#launch_uris_async(appinfo, uris, context, cancellable, callback, user_data) ⇒ nil
#launch_uris_finish(appinfo, result) ⇒ Boolean
Returns TRUE on successful launch, FALSE otherwise.
#name ⇒ String
Gets the installed name of the application.
#remove_supports_type(appinfo, content_type) ⇒ Boolean
Returns TRUE on success, FALSE on error.
#set_as_default_for_extension(appinfo, extension) ⇒ Boolean
Returns TRUE on success, FALSE on error.
#set_as_default_for_type(appinfo, content_type) ⇒ Boolean
Returns TRUE on success, FALSE on error.
#set_as_last_used_for_type(appinfo, content_type) ⇒ Boolean
Returns TRUE on success, FALSE on error.
#should_show(appinfo) ⇒ Boolean
Returns TRUE if the appinfo should be shown, FALSE otherwise.
#supported_types ⇒ Array<String>
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
[methodGio.AppInfo.add_supports_type], but only those exported directly by
the application.
#supports_files(appinfo) ⇒ Boolean
Returns TRUE if the appinfo supports files.
#supports_uris(appinfo) ⇒ Boolean
Returns TRUE if the appinfo supports URIs.