class Gio::DesktopAppInfo

Overview

#GDesktopAppInfo is an implementation of #GAppInfo based on desktop files.

Note that <gio/gdesktopappinfo.h> belongs to the UNIX-specific GIO interfaces, thus you have to use the gio-unix-2.0.pc pkg-config file when using it.

Included Modules

Defined in:

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

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gio::AppInfo

add_supports_type(content_type : String) : Bool add_supports_type, as_default_for_extension=(extension : String) : Bool as_default_for_extension=, as_default_for_type=(content_type : String) : Bool as_default_for_type=, as_last_used_for_type=(content_type : String) : Bool as_last_used_for_type=, can_delete : Bool can_delete, can_remove_supports_type : Bool can_remove_supports_type, commandline : Path? commandline, create_from_commandline(commandline : String, application_name : String?, flags : Gio::AppInfoCreateFlags) : Gio::AppInfo create_from_commandline, default_for_type_finish(result : Gio::AsyncResult) : Gio::AppInfo default_for_type_finish, default_for_uri_scheme_finish(result : Gio::AsyncResult) : Gio::AppInfo default_for_uri_scheme_finish, delete : Bool delete, description : String? description, display_name : String display_name, dup : Gio::AppInfo dup, equal(appinfo2 : Gio::AppInfo) : Bool equal, executable : Path executable, icon : Gio::Icon? icon, id : String? id, launch(files : GLib::List?, context : Gio::AppLaunchContext?) : Bool launch, launch_default_for_uri(uri : String, context : Gio::AppLaunchContext?) : Bool launch_default_for_uri, launch_default_for_uri_finish(result : Gio::AsyncResult) : Bool launch_default_for_uri_finish, launch_uris(uris : GLib::List?, context : Gio::AppLaunchContext?) : Bool launch_uris, launch_uris_async(uris : GLib::List?, context : Gio::AppLaunchContext?, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil launch_uris_async, launch_uris_finish(result : Gio::AsyncResult) : Bool launch_uris_finish, name : String name, remove_supports_type(content_type : String) : Bool remove_supports_type, should_show : Bool should_show, supported_types : Enumerable(String) supported_types, supports_files : Bool supports_files, supports_uris : Bool supports_uris, to_unsafe to_unsafe

Class methods inherited from module Gio::AppInfo

all : GLib::List all, all_for_type(content_type : String) : GLib::List all_for_type, default_for_type(content_type : String, must_support_uris : Bool) : Gio::AppInfo? default_for_type, default_for_type_async(content_type : String, must_support_uris : Bool, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil default_for_type_async, default_for_uri_scheme(uri_scheme : String) : Gio::AppInfo? default_for_uri_scheme, default_for_uri_scheme_async(uri_scheme : String, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil default_for_uri_scheme_async, fallback_for_type(content_type : String) : GLib::List fallback_for_type, g_type : UInt64 g_type, launch_default_for_uri_async(uri : String, context : Gio::AppLaunchContext?, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil launch_default_for_uri_async, recommended_for_type(content_type : String) : GLib::List recommended_for_type, reset_type_associations(content_type : String) : Nil reset_type_associations

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new(desktop_id : String) : self? #

Creates a new #GDesktopAppInfo based on a desktop file id.

A desktop file id is the basename of the desktop file, including the .desktop extension. GIO is looking for a desktop file with this name in the applications subdirectories of the XDG data directories (i.e. the directories specified in the XDG_DATA_HOME and XDG_DATA_DIRS environment variables). GIO also supports the prefix-to-subdirectory mapping that is described in the Menu Spec (i.e. a desktop id of kde-foo.desktop will match /usr/share/applications/kde/foo.desktop).


def self.new #

Initialize a new DesktopAppInfo.


def self.new(*, filename : String? = nil) #

def self.new_from_filename(filename : String) : self? #

Creates a new #GDesktopAppInfo.


def self.new_from_keyfile(key_file : GLib::KeyFile) : self? #

Creates a new #GDesktopAppInfo.


Class Method Detail

def self.desktop_env=(desktop_env : String) : Nil #

Sets the name of the desktop that the application is running in. This is used by g_app_info_should_show() and g_desktop_app_info_get_show_in() to evaluate the OnlyShowIn and NotShowIn desktop entry fields.

Should be called only once; subsequent calls are ignored.


def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


def self.implementations(interface : String) : GLib::List #

Gets all applications that implement @interface.

An application implements an interface if that interface is listed in the Implements= line of the desktop file of the application.


def self.search(search_string : String) : Enumerable(Enumerable(String)) #

Searches desktop files for ones that match @search_string.

The return value is an array of strvs. Each strv contains a list of applications that matched @search_string with an equal score. The outer list is sorted by score so that the first strv contains the best-matching applications, and so on. The algorithm for determining matches is undefined and may change at any time.

None of the search results are subjected to the normal validation checks performed by g_desktop_app_info_new() (for example, checking that the executable referenced by a result exists), and so it is possible for g_desktop_app_info_new() to return nil when passed an app ID returned by this function. It is expected that calling code will do this when subsequently creating a #GDesktopAppInfo for each result.


Instance Method Detail

def action_name(action_name : String) : String #

Gets the user-visible display name of the "additional application action" specified by @action_name.

This corresponds to the "Name" key within the keyfile group for the action.


def boolean(key : String) : Bool #

Looks up a boolean value in the keyfile backing @info.

The @key is looked up in the "Desktop Entry" group.


def categories : String? #

Gets the categories from the desktop file.


def filename : Path? #

When @info was created from a known filename, return it. In some situations such as the #GDesktopAppInfo returned from g_desktop_app_info_new_from_keyfile(), this function will return nil.


def filename=(value : String) : String #

def generic_name : String? #

Gets the generic name from the desktop file.


def has_key(key : String) : Bool #

Returns whether @key exists in the "Desktop Entry" group of the keyfile backing @info.


def is_hidden : Bool #

A desktop file is hidden if the Hidden key in it is set to True.


def keywords : Enumerable(String) #

Gets the keywords from the desktop file.


def launch_action(action_name : String, launch_context : Gio::AppLaunchContext?) : Nil #

Activates the named application action.

You may only call this function on action names that were returned from g_desktop_app_info_list_actions().

Note that if the main entry of the desktop file indicates that the application supports startup notification, and @launch_context is non-nil, then startup notification will be used when activating the action (and as such, invocation of the action on the receiving side must signal the end of startup notification when it is completed). This is the expected behaviour of applications declaring additional actions, as per the desktop file specification.

As with g_app_info_launch() there is no way to detect failures that occur while using this function.


def launch_uris_as_manager(uris : GLib::List, launch_context : Gio::AppLaunchContext?, spawn_flags : GLib::SpawnFlags, user_setup : GLib::SpawnChildSetupFunc?, user_setup_data : Pointer(Void)?, pid_callback : Gio::DesktopAppLaunchCallback?, pid_callback_data : Pointer(Void)?) : Bool #

This function performs the equivalent of g_app_info_launch_uris(), but is intended primarily for operating system components that launch applications. Ordinary applications should use g_app_info_launch_uris().

If the application is launched via GSpawn, then @spawn_flags, @user_setup and @user_setup_data are used for the call to g_spawn_async(). Additionally, @pid_callback (with @pid_callback_data) will be called to inform about the PID of the created process. See g_spawn_async_with_pipes() for information on certain parameter conditions that can enable an optimized posix_spawn() codepath to be used.

If application launching occurs via some other mechanism (eg: D-Bus activation) then @spawn_flags, @user_setup, @user_setup_data, @pid_callback and @pid_callback_data are ignored.


def launch_uris_as_manager_with_fds(uris : GLib::List, launch_context : Gio::AppLaunchContext?, spawn_flags : GLib::SpawnFlags, user_setup : GLib::SpawnChildSetupFunc?, user_setup_data : Pointer(Void)?, pid_callback : Gio::DesktopAppLaunchCallback?, pid_callback_data : Pointer(Void)?, stdin_fd : Int32, stdout_fd : Int32, stderr_fd : Int32) : Bool #

Equivalent to g_desktop_app_info_launch_uris_as_manager() but allows you to pass in file descriptors for the stdin, stdout and stderr streams of the launched process.

If application launching occurs via some non-spawn mechanism (e.g. D-Bus activation) then @stdin_fd, @stdout_fd and @stderr_fd are ignored.


def list_actions : Enumerable(String) #

Returns the list of "additional application actions" supported on the desktop file, as per the desktop file specification.

As per the specification, this is the list of actions that are explicitly listed in the "Actions" key of the [Desktop Entry] group.


def locale_string(key : String) : String? #

Looks up a localized string value in the keyfile backing @info translated to the current locale.

The @key is looked up in the "Desktop Entry" group.


def nodisplay : Bool #

Gets the value of the NoDisplay key, which helps determine if the application info should be shown in menus. See %G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY and g_app_info_should_show().


def show_in(desktop_env : String?) : Bool #

Checks if the application info should be shown in menus that list available applications for a specific name of the desktop, based on the OnlyShowIn and NotShowIn keys.

@desktop_env should typically be given as nil, in which case the XDG_CURRENT_DESKTOP environment variable is consulted. If you want to override the default mechanism then you may specify @desktop_env, but this is not recommended.

Note that g_app_info_should_show() for @info will include this check (with nil for @desktop_env) as well as additional checks.


def startup_wm_class : String? #

Retrieves the StartupWMClass field from @info. This represents the WM_CLASS property of the main window of the application, if launched through @info.


def string(key : String) : String? #

Looks up a string value in the keyfile backing @info.

The @key is looked up in the "Desktop Entry" group.


def string_list(key : String) : Enumerable(String) #

Looks up a string list value in the keyfile backing @info.

The @key is looked up in the "Desktop Entry" group.