Class AppLaunchContext

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
AppLaunchContext

@Generated("org.javagi.JavaGI") public class AppLaunchContext extends 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.
  • Constructor Details

    • AppLaunchContext

      public AppLaunchContext(MemorySegment address)
      Create a AppLaunchContext instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • AppLaunchContext

      public AppLaunchContext()
      Create a new AppLaunchContext.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the AppLaunchContext class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected AppLaunchContext asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getDisplay

      public @Nullable String getDisplay(AppInfo info, List<File> files)
      Gets the display string for the context. This is used to ensure new applications are started on the same display as the launching application, by setting the DISPLAY environment variable.
      Parameters:
      info - the app info
      files - a list of File objects
      Returns:
      a display string for the display.
    • getEnvironment

      public String[] getEnvironment()
      Gets the complete environment variable list to be passed to the child process when this AppLaunchContext is used to launch an application. This is a NULL-terminated array of strings, where each string has the form KEY=VALUE.
      Returns:
      the child’s environment
      Since:
      2.32
    • getStartupNotifyId

      public @Nullable String getStartupNotifyId(@Nullable AppInfo info, @Nullable List<File> files)

      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.

      Parameters:
      info - the app info
      files - a list of File objects
      Returns:
      a startup notification ID for the application, or NULL if not supported.
    • launchFailed

      public void launchFailed(String startupNotifyId)
      Called when an application has failed to launch, so that it can cancel the application startup notification started in getStartupNotifyId(AppInfo, List).
      Parameters:
      startupNotifyId - the startup notification id that was returned by getStartupNotifyId(AppInfo, List).
    • setenv

      public void setenv(String variable, String value)
      Arranges for variable to be set to value in the child’s environment when this AppLaunchContext is used to launch an application.
      Parameters:
      variable - the environment variable to set
      value - the value for to set the variable to.
      Since:
      2.32
    • unsetenv

      public void unsetenv(String variable)
      Arranges for variable to be unset in the child’s environment when this AppLaunchContext is used to launch an application.
      Parameters:
      variable - the environment variable to remove
      Since:
      2.32
    • launchStarted

      protected void launchStarted(AppInfo info, Variant platformData)
    • launched

      protected void launched(AppInfo info, Variant platformData)
    • onLaunchFailed

      The Gio.AppLaunchContext::launch-failed signal is emitted when a AppInfo 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.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.36
      See Also:
    • emitLaunchFailed

      public void emitLaunchFailed(String startupNotifyId)
      Emits the "launch-failed" signal. See onLaunchFailed(AppLaunchContext.LaunchFailedCallback).
    • onLaunchStarted

      The Gio.AppLaunchContext::launch-started signal is emitted when a AppInfo is about to be launched. If non-null the platformData 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. It allows tracking the progress of the launchee through startup.

      It is guaranteed that this signal is followed by either a Gio.AppLaunchContext::launched or Gio.AppLaunchContext::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.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.72
      See Also:
    • emitLaunchStarted

      public void emitLaunchStarted(@Nullable AppInfo info, @Nullable Variant platformData)
      Emits the "launch-started" signal. See onLaunchStarted(AppLaunchContext.LaunchStartedCallback).
    • onLaunched

      The Gio.AppLaunchContext::launched signal is emitted when a AppInfo 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 platformData 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 Gio.AppLaunchContext::launched signal emission; after the signal is emitted, GLib will call GLib#spawnClosePid. If you need to keep the GLib.Pid after the signal has been emitted, then you can duplicate pid using DuplicateHandle().

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.36
      See Also:
    • emitLaunched

      public void emitLaunched(@Nullable AppInfo info, @Nullable Variant platformData)
      Emits the "launched" signal. See onLaunched(AppLaunchContext.LaunchedCallback).
    • builder

      public static AppLaunchContext.Builder<? extends AppLaunchContext.Builder> builder()
      A AppLaunchContext.Builder object constructs a AppLaunchContext with the specified properties. Use the various set...() methods to set properties, and finish construction with AppLaunchContext.Builder.build().
      Returns:
      the builder object