1.2 <GAppLaunchContext>

Class: <GAppLaunchContext>

It derives from <GObject>.

Integrating the launch with the launching application. This is used to handle for instance startup notification and launching the new application on the same screen as the launching window.

Fields

parent-instance

Procedures

Method: app-launch-context:get-display self info files ⇒ %return
Method: get-display self info files ⇒ %return

Gets the display string for the self. This is used to ensure new applications are started on the same display as the launching application, by setting the DISPLAY environment variable.

self

Passed: a <GAppLaunchContext>.

the launch context

info

Passed: a <GAppInfo>.

the app info

files

Passed: a list, each a <GFile>.

a list of <GFile> objects

%return

Returned: a string, or #f.

a display string for the display.

Method: app-launch-context:get-environment self ⇒ %return
Method: get-environment self ⇒ %return

Gets the complete environment variable list to be passed to the child process when self is used to launch an application. This is a NULL-terminated array of strings, where each string has the form KEY=VALUE.

self

Passed: a <GAppLaunchContext>.

the launch context

%return

Returned: a vector, each a file name, as a string.

the child’s environment

Method: app-launch-context:get-startup-notify-id self [info] [files] ⇒ %return
Method: get-startup-notify-id self [info] [files] ⇒ %return

Initiates startup notification for the application and returns the XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID for the launched operation, if supported.

The returned token may be referred to equivalently as an ‘activation token’ (using Wayland terminology) or a ‘startup sequence ID’ (using X11 terminology). The two are interoperable.

Activation tokens are defined in the XDG Activation Protocol, and startup notification IDs are defined in the freedesktop.org Startup Notification Protocol.

Support for the XDG Activation Protocol was added in GLib 2.76. Since GLib 2.82 info and files can be NULL. If that’s not supported by the backend, the returned token will be NULL.

self

Passed: a <GAppLaunchContext>.

the launch context

info

Passed, or left out: a <GAppInfo>, or #f.

the app info

files

Passed, or left out: a list, each a <GFile>, or #f.

a list of <GFile> objects

%return

Returned: a string, or #f.

a startup notification ID for the application, or NULL if not supported.

Method: app-launch-context:launch-failed self startup-notify-id
Method: launch-failed self startup-notify-id

Called when an application has failed to launch, so that it can cancel the application startup notification started in app-launch-context:get-startup-notify-id.

self

Passed: a <GAppLaunchContext>.

the launch context

startup-notify-id

Passed: a string.

the startup notification id that was returned by app-launch-context:get-startup-notify-id.

Procedure: app-launch-context:new ⇒ %return

Creates a new application launch context. This is not normally used, instead you instantiate a subclass of this, such as ‘GdkAppLaunchContext‘.

%return

Returned: a <GAppLaunchContext>.

a launch context.

Method: app-launch-context:setenv self variable value
Method: setenv self variable value

Arranges for variable to be set to value in the child’s environment when self is used to launch an application.

self

Passed: a <GAppLaunchContext>.

the launch context

variable

Passed: a file name, as a string.

the environment variable to set

value

Passed: a file name, as a string.

the value for to set the variable to.

Method: app-launch-context:unsetenv self variable
Method: unsetenv self variable

Arranges for variable to be unset in the child’s environment when self is used to launch an application.

self

Passed: a <GAppLaunchContext>.

the launch context

variable

Passed: a file name, as a string.

the environment variable to remove

Signals

Signal: app-launch-context:launch-failed

Connect a handler with (connect object app-launch-context:launch-failed handler). It is called as (handler self startup-notify-id).

The app-launch-context:launch-failed signal is emitted when a <GAppInfo> launch fails. The startup notification id is provided, so that the launcher can cancel the startup notification.

Because a launch operation may involve spawning multiple instances of the target application, you should expect this signal to be emitted multiple times, one for each spawned instance.

self

Passed: a <GAppLaunchContext>.

startup-notify-id

Passed: a string.

the startup notification id for the failed launch

Signal: app-launch-context:launch-started

Connect a handler with (connect object app-launch-context:launch-started handler). It is called as (handler self info platform-data).

The app-launch-context:launch-started signal is emitted when a <GAppInfo> is about to be launched. If non-null the platform-data is an GVariant dictionary mapping strings to variants (ie a{sv}), which contains additional, platform-specific data about this launch. On UNIX, at least the startup-notification-id keys will be present.

The value of the startup-notification-id key (type s) is a startup notification ID corresponding to the format from the [startup-notification specification](https://specifications.freedesktop.org/startup-notification-spec/startup-notification-0.1.txt). It allows tracking the progress of the launchee through startup.

It is guaranteed that this signal is followed by either a app-launch-context:launched or app-launch-context:launch-failed signal.

Because a launch operation may involve spawning multiple instances of the target application, you should expect this signal to be emitted multiple times, one for each spawned instance.

self

Passed: a <GAppLaunchContext>.

info

Passed: a <GAppInfo>.

the <GAppInfo> that is about to be launched

platform-data

Passed: a <GVariant>, or #f.

additional platform-specific data for this launch

Signal: app-launch-context:launched

Connect a handler with (connect object app-launch-context:launched handler). It is called as (handler self info platform-data).

The app-launch-context:launched signal is emitted when a <GAppInfo> is successfully launched.

Because a launch operation may involve spawning multiple instances of the target application, you should expect this signal to be emitted multiple times, one time for each spawned instance.

The platform-data is an GVariant dictionary mapping strings to variants (ie a{sv}), which contains additional, platform-specific data about this launch. On UNIX, at least the pid and startup-notification-id keys will be present.

Since 2.72 the pid may be 0 if the process id wasn’t known (for example if the process was launched via D-Bus). The pid may not be set at all in subsequent releases.

On Windows, pid is guaranteed to be valid only for the duration of the app-launch-context:launched signal emission; after the signal is emitted, GLib will call spawn-close-pid. If you need to keep the GLib.Pid after the signal has been emitted, then you can duplicate pid using DuplicateHandle().

self

Passed: a <GAppLaunchContext>.

info

Passed: a <GAppInfo>.

the <GAppInfo> that was just launched

platform-data

Passed: a <GVariant>.

additional platform-specific data for this launch

Virtual methods

Virtual method: app-launch-context:do-get-display implementor self info files ⇒ %return

Gets the display string for the self. This is used to ensure new applications are started on the same display as the launching application, by setting the DISPLAY environment variable.

To override it in a new class, give register-type #:vfuncs `((get-display . ,procedure)). The procedure is called as (procedure self info files) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GAppLaunchContext>, or a class that derives from it, or its GType number.

self

Passed: a <GAppLaunchContext>.

the launch context

info

Passed: a <GAppInfo>.

the app info

files

Passed: a list, each a <GFile>.

a list of <GFile> objects

%return

Returned: a string, or #f.

a display string for the display.

Virtual method: app-launch-context:do-get-startup-notify-id implementor self [info] [files] ⇒ %return

Initiates startup notification for the application and returns the XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID for the launched operation, if supported.

The returned token may be referred to equivalently as an ‘activation token’ (using Wayland terminology) or a ‘startup sequence ID’ (using X11 terminology). The two are interoperable.

Activation tokens are defined in the XDG Activation Protocol, and startup notification IDs are defined in the freedesktop.org Startup Notification Protocol.

Support for the XDG Activation Protocol was added in GLib 2.76. Since GLib 2.82 info and files can be NULL. If that’s not supported by the backend, the returned token will be NULL.

To override it in a new class, give register-type #:vfuncs `((get-startup-notify-id . ,procedure)). The procedure is called as (procedure self info files) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GAppLaunchContext>, or a class that derives from it, or its GType number.

self

Passed: a <GAppLaunchContext>.

the launch context

info

Passed, or left out: a <GAppInfo>, or #f.

the app info

files

Passed, or left out: a list, each a <GFile>, or #f.

a list of <GFile> objects

%return

Returned: a string, or #f.

a startup notification ID for the application, or NULL if not supported.

Virtual method: app-launch-context:do-launch-failed implementor self startup-notify-id

Called when an application has failed to launch, so that it can cancel the application startup notification started in app-launch-context:get-startup-notify-id.

To override it in a new class, give register-type #:vfuncs `((launch-failed . ,procedure)). The procedure is called as (procedure self startup-notify-id).

implementor

Passed: the class whose implementation to call: <GAppLaunchContext>, or a class that derives from it, or its GType number.

self

Passed: a <GAppLaunchContext>.

the launch context

startup-notify-id

Passed: a string.

the startup notification id that was returned by app-launch-context:get-startup-notify-id.

Virtual method: app-launch-context:do-launch-started implementor self info platform-data

To override it in a new class, give register-type #:vfuncs `((launch-started . ,procedure)). The procedure is called as (procedure self info platform-data).

implementor

Passed: the class whose implementation to call: <GAppLaunchContext>, or a class that derives from it, or its GType number.

self

Passed: a <GAppLaunchContext>.

info

Passed: a <GAppInfo>.

platform-data

Passed: a <GVariant>.

Virtual method: app-launch-context:do-launched implementor self info platform-data

To override it in a new class, give register-type #:vfuncs `((launched . ,procedure)). The procedure is called as (procedure self info platform-data).

implementor

Passed: the class whose implementation to call: <GAppLaunchContext>, or a class that derives from it, or its GType number.

self

Passed: a <GAppLaunchContext>.

info

Passed: a <GAppInfo>.

platform-data

Passed: a <GVariant>.