module Gio::AppInfo
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 Gio::File#path
) when using Gio::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 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#uri
or similar on Gio::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 of Gio::File#uri
. The following snippet
illustrates this:
WARNING ⚠️ The following code is in c ⚠️
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.
Direct including types
Defined in:
lib/gi-crystal/src/auto/gio-2.0/app_info.crConstructors
-
.cast(obj : GObject::Object) : self
Cast a
GObject::Object
toself
, throws aTypeCastError
if the cast can't be made.
Class Method Summary
- .all : GLib::List
- .all_for_type(content_type : String) : GLib::List
- .cast?(obj : GObject::Object) : self | Nil
- .default_for_type(content_type : String, must_support_uris : Bool) : Gio::AppInfo | Nil
- .default_for_type_async(content_type : String, must_support_uris : Bool, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil
- .default_for_uri_scheme(uri_scheme : String) : Gio::AppInfo | Nil
- .default_for_uri_scheme_async(uri_scheme : String, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil
- .fallback_for_type(content_type : String) : GLib::List
- .g_type : UInt64
- .launch_default_for_uri_async(uri : String, context : Gio::AppLaunchContext | Nil, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil
- .recommended_for_type(content_type : String) : GLib::List
- .reset_type_associations(content_type : String) : Nil
Instance Method Summary
- #add_supports_type(content_type : String) : Bool
- #as_default_for_extension=(extension : String) : Bool
- #as_default_for_type=(content_type : String) : Bool
- #as_last_used_for_type=(content_type : String) : Bool
- #can_delete : Bool
- #can_remove_supports_type : Bool
- #commandline : Path | Nil
- #create_from_commandline(commandline : String, application_name : String | Nil, flags : Gio::AppInfoCreateFlags) : Gio::AppInfo
- #default_for_type_finish(result : Gio::AsyncResult) : Gio::AppInfo
- #default_for_uri_scheme_finish(result : Gio::AsyncResult) : Gio::AppInfo
- #delete : Bool
- #description : String | Nil
- #display_name : String
- #dup : Gio::AppInfo
- #equal(appinfo2 : Gio::AppInfo) : Bool
- #executable : Path
- #icon : Gio::Icon | Nil
- #id : String | Nil
- #launch(files : GLib::List | Nil, context : Gio::AppLaunchContext | Nil) : Bool
- #launch_default_for_uri(uri : String, context : Gio::AppLaunchContext | Nil) : Bool
- #launch_default_for_uri_finish(result : Gio::AsyncResult) : Bool
- #launch_uris(uris : GLib::List | Nil, context : Gio::AppLaunchContext | Nil) : Bool
- #launch_uris_async(uris : GLib::List | Nil, context : Gio::AppLaunchContext | Nil, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil
- #launch_uris_finish(result : Gio::AsyncResult) : Bool
- #name : String
- #remove_supports_type(content_type : String) : Bool
- #should_show : Bool
- #supported_types : Enumerable(String)
- #supports_files : Bool
- #supports_uris : Bool
- #to_unsafe