Module: Gio::AppInfo
- Defined in:
- (unknown)
Overview
GApp::Info 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 g_file_get_path()) when using g_app_info_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, `sfoo/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 #GFile constructors (since gvfs implements the #GVfs extension point). As such, if the application needs to examine the URI, it needs to use g_file_get_uri() or similar on #GFile. In other words, an application cannot assume that the URI passed to e.g. g_file_new_for_commandline_arg() is equal to the result of g_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) ⇒ TrueClass
True on success, false on error.
-
#as_default_for_extension=(extension) ⇒ TrueClass
Sets the application as the default handler for the given file extension.
-
#as_default_for_type=(content_type) ⇒ TrueClass
Sets the application as the default handler for a given type.
-
#as_last_used_for_type=(content_type) ⇒ TrueClass
Sets the application as the last used application for a given type.
-
#can_delete(appinfo) ⇒ TrueClass
True if appinfo can be deleted.
-
#can_remove_supports_type(appinfo) ⇒ TrueClass
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 ⇒ TrueClass
Tries to delete a GApp::Info.
-
#description ⇒ String
Gets a human-readable description of an installed application.
-
#display_name ⇒ String
Gets the display name of the application.
-
#do_delete(appinfo) ⇒ TrueClass
True if appinfo has been deleted.
-
#dup(appinfo) ⇒ Gio::AppInfo
A duplicate of appinfo.
-
#equal(appinfo1, appinfo2) ⇒ TrueClass
True if appinfo1 is equal to appinfo2.
-
#executable ⇒ Gio::filename
Gets the executable’s name for the installed application.
- #get_commandline(appinfo) ⇒ String
-
#get_description(appinfo) ⇒ String
application appinfo, or nil if none.
-
#get_display_name(appinfo) ⇒ String
no display name is available.
- #get_executable(appinfo) ⇒ String
-
#get_icon(appinfo) ⇒ Gio::Icon
if 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) ⇒ TrueClass
True on successful launch, false otherwise.
-
#launch_uris(appinfo, uris, context) ⇒ TrueClass
True on successful launch, false otherwise.
- #launch_uris_async(appinfo, uris, context, cancellable, callback, user_data) ⇒ nil
-
#launch_uris_finish(appinfo, result) ⇒ TrueClass
True on successful launch, false otherwise.
-
#name ⇒ String
Gets the installed name of the application.
-
#remove_supports_type(appinfo, content_type) ⇒ TrueClass
True on success, false on error.
-
#set_as_default_for_extension(appinfo, extension) ⇒ TrueClass
True on success, false on error.
-
#set_as_default_for_type(appinfo, content_type) ⇒ TrueClass
True on success, false on error.
-
#set_as_last_used_for_type(appinfo, content_type) ⇒ TrueClass
True on success, false on error.
-
#should_show(appinfo) ⇒ TrueClass
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.
-
#supports_files(appinfo) ⇒ TrueClass
True if the appinfo supports files.
-
#supports_uris(appinfo) ⇒ TrueClass
True if the appinfo supports URIs.
Instance Method Details
#add_supports_type(appinfo, content_type) ⇒ TrueClass
Returns true on success, false on error.
#as_default_for_extension=(extension) ⇒ TrueClass
Sets the application as the default handler for the given file extension.
#as_default_for_type=(content_type) ⇒ TrueClass
Sets the application as the default handler for a given type.
#as_last_used_for_type=(content_type) ⇒ TrueClass
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 g_app_info_get_recommended_for_type(), regardless of the default application for that content type.
#can_delete(appinfo) ⇒ TrueClass
Returns true if appinfo can be deleted.
#can_remove_supports_type(appinfo) ⇒ TrueClass
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 ⇒ TrueClass
Tries to delete a GApp::Info.
On some platforms, there may be a difference between user-defined GApp::Infos which can be deleted, and system-wide ones which cannot. See g_app_info_can_delete().
#description ⇒ String
Gets a human-readable description of an installed application. application appinfo, or nil 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) ⇒ TrueClass
Returns true if appinfo has been deleted.
#dup(appinfo) ⇒ Gio::AppInfo
Returns a duplicate of appinfo.
#equal(appinfo1, appinfo2) ⇒ TrueClass
Returns true if appinfo1 is equal to appinfo2. false otherwise.
#executable ⇒ Gio::filename
Gets the executable’s name for the installed application. binaries name
#get_commandline(appinfo) ⇒ String
#get_description(appinfo) ⇒ String
application appinfo, or nil if none.
#get_display_name(appinfo) ⇒ String
no display name is available.
#get_executable(appinfo) ⇒ String
#get_icon(appinfo) ⇒ Gio::Icon
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. if there is no default icon.
#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 nil, depending on how the appinfo has been constructed.
#launch(appinfo, files, context) ⇒ TrueClass
Returns true on successful launch, false otherwise.
#launch_uris(appinfo, uris, context) ⇒ TrueClass
Returns true on successful launch, false otherwise.
#launch_uris_async(appinfo, uris, context, cancellable, callback, user_data) ⇒ nil
#launch_uris_finish(appinfo, result) ⇒ TrueClass
Returns true on successful launch, false otherwise.
#name ⇒ String
Gets the installed name of the application.
#remove_supports_type(appinfo, content_type) ⇒ TrueClass
Returns true on success, false on error.
#set_as_default_for_extension(appinfo, extension) ⇒ TrueClass
Returns true on success, false on error.
#set_as_default_for_type(appinfo, content_type) ⇒ TrueClass
Returns true on success, false on error.
#set_as_last_used_for_type(appinfo, content_type) ⇒ TrueClass
Returns true on success, false on error.
#should_show(appinfo) ⇒ TrueClass
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 nil. This function does not take in consideration associations added with g_app_info_add_supports_type(), but only those exported directly by the application.
#supports_files(appinfo) ⇒ TrueClass
Returns true if the appinfo supports files.
#supports_uris(appinfo) ⇒ TrueClass
Returns true if the appinfo supports URIs.