class Gdk::AppLaunchContext

Overview

Gdk::AppLaunchContext handles launching an application in a graphical context.

It is an implementation of GAppLaunchContext that provides startup notification and allows to launch applications on a specific workspace.

Launching an application

WARNING ⚠️ The following code is in c ⚠️

Gdk::AppLaunchContext *context;

context = gdk_display_get_app_launch_context (display);

gdk_app_launch_context_set_timestamp (gdk_event_get_time (event));

if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error))
  g_warning ("Launching failed: %s\n", error->message);

g_object_unref (context);

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/app_launch_context.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Gio::AppLaunchContext

==(other : self) ==, display(info : Gio::AppInfo, files : GLib::List) : String | Nil display, environment : Enumerable(String) environment, hash(hasher) hash, launch_failed(startup_notify_id : String) : Nil launch_failed, launch_failed_signal launch_failed_signal, launch_started_signal launch_started_signal, launched_signal launched_signal, setenv(variable : String, value : String) : Nil setenv, startup_notify_id(info : Gio::AppInfo, files : GLib::List) : String | Nil startup_notify_id, unsetenv(variable : String) : Nil unsetenv

Constructor methods inherited from class Gio::AppLaunchContext

new : self new

Class methods inherited from class Gio::AppLaunchContext

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

==(other : self) ==, 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) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, 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) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil 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, 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

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : 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

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new #

Initialize a new AppLaunchContext.


[View source]
def self.new(*, display : Gdk::Display | Nil = nil) #

[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def desktop=(desktop : Int32) : Nil #

Sets the workspace on which applications will be launched.

This only works when running under a window manager that supports multiple workspaces, as described in the Extended Window Manager Hints. Specifically this sets the _NET_WM_DESKTOP property described in that spec.

This only works when using the X11 backend.

When the workspace is not specified or desktop is set to -1, it is up to the window manager to pick one, typically it will be the current workspace.


[View source]
def display : Gdk::Display #

Gets the Gdk::Display that context is for.


[View source]
def display=(value : Gdk::Display | Nil) : Gdk::Display | Nil #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def icon=(icon : Gio::Icon | Nil) : Nil #

Sets the icon for applications that are launched with this context.

Window Managers can use this information when displaying startup notification.

See also Gdk::AppLaunchContext#icon_name=.


[View source]
def icon_name=(icon_name : String | Nil) : Nil #

Sets the icon for applications that are launched with this context.

The icon_name will be interpreted in the same way as the Icon field in desktop files. See also Gdk::AppLaunchContext#icon=.

If both icon and icon_name are set, the icon_name takes priority. If neither icon or icon_name is set, the icon is taken from either the file that is passed to launched application or from the GAppInfo for the launched application itself.


[View source]
def timestamp=(timestamp : UInt32) : Nil #

Sets the timestamp of context.

The timestamp should ideally be taken from the event that triggered the launch.

Window managers can use this information to avoid moving the focus to the newly launched application when the user is busy typing in another window. This is also known as 'focus stealing prevention'.


[View source]