module Gio::AppInfo

Overview

#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 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, 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 #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.

Direct including types

Defined in:

lib/gi-crystal/src/auto/gio-2.0/app_info.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.cast(obj : GObject::Object) : self #

Cast a GObject::Object to self, throws a TypeCastError if the cast can't be made.


[View source]

Class Method Detail

def self.all : GLib::List #

[View source]
def self.all_for_type(content_type : String) : GLib::List #

[View source]
def self.cast?(obj : GObject::Object) : self | Nil #

[View source]
def self.default_for_type(content_type : String, must_support_uris : Bool) : Gio::AppInfo | Nil #

[View source]
def self.default_for_uri_scheme(uri_scheme : String) : Gio::AppInfo | Nil #

[View source]
def self.fallback_for_type(content_type : String) : GLib::List #

[View source]
def self.g_type : UInt64 #

[View source]
def self.launch_default_for_uri_async(uri : String, context : Gio::AppLaunchContext | Nil, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil #

[View source]
def self.recommended_for_type(content_type : String) : GLib::List #

[View source]
def self.reset_type_associations(content_type : String) : Nil #

[View source]

Instance Method Detail

def add_supports_type(content_type : String) : Bool #

[View source]
def as_default_for_extension=(extension : String) : Bool #

[View source]
def as_default_for_type=(content_type : String) : Bool #

[View source]
def as_last_used_for_type=(content_type : String) : Bool #

[View source]
def can_delete : Bool #

[View source]
def can_remove_supports_type : Bool #

[View source]
def commandline : Path | Nil #

[View source]
def create_from_commandline(commandline : String, application_name : String | Nil, flags : Gio::AppInfoCreateFlags) : Gio::AppInfo #

[View source]
def delete : Bool #

[View source]
def description : String | Nil #

[View source]
def display_name : String #

[View source]
def dup : Gio::AppInfo #

[View source]
def equal(appinfo2 : Gio::AppInfo) : Bool #

[View source]
def executable : Path #

[View source]
def icon : Gio::Icon | Nil #

[View source]
def id : String | Nil #

[View source]
def launch(files : GLib::List | Nil, context : Gio::AppLaunchContext | Nil) : Bool #

[View source]
def launch_default_for_uri(uri : String, context : Gio::AppLaunchContext | Nil) : Bool #

[View source]
def launch_default_for_uri_finish(result : Gio::AsyncResult) : Bool #

[View source]
def launch_uris(uris : GLib::List | Nil, context : Gio::AppLaunchContext | Nil) : Bool #

[View source]
def launch_uris_async(uris : GLib::List | Nil, context : Gio::AppLaunchContext | Nil, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil #

[View source]
def launch_uris_finish(result : Gio::AsyncResult) : Bool #

[View source]
def name : String #

[View source]
def remove_supports_type(content_type : String) : Bool #

[View source]
def should_show : Bool #

[View source]
def supported_types : Enumerable(String) #

[View source]
def supports_files : Bool #

[View source]
def supports_uris : Bool #

[View source]
abstract def to_unsafe #

[View source]