Class FileLauncher

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class FileLauncher extends GObject

Asynchronous API to open a file with an application.

GtkFileLauncher collects the arguments that are needed to open the file.

Depending on system configuration, user preferences and available APIs, this may or may not show an app chooser dialog or launch the default application right away.

The operation is started with the launch(Window, Cancellable, AsyncReadyCallback) function.

To launch uris that don't represent files, use UriLauncher.

Since:
4.10
  • Constructor Details

    • FileLauncher

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

      public FileLauncher(@Nullable File file)
      Creates a new GtkFileLauncher object.
      Parameters:
      file - the file to open
      Since:
      4.10
    • FileLauncher

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

    • getType

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

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

      protected FileLauncher 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
    • getAlwaysAsk

      public boolean getAlwaysAsk()
      Returns whether to ask the user which app to use.
      Returns:
      true if always asking the user
      Since:
      4.12
    • getFile

      public @Nullable File getFile()
      Gets the file that will be opened.
      Returns:
      the file
      Since:
      4.10
    • getWritable

      public boolean getWritable()
      Returns whether to make the file writable for the handler.
      Returns:
      true if the file will be made writable
      Since:
      4.14
    • launch

      public void launch(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Launches an application to open the file.

      This may present an app chooser dialog to the user.

      Parameters:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      Since:
      4.10
    • launchFinish

      public boolean launchFinish(AsyncResult result) throws GErrorException
      Finishes the launch(Window, Cancellable, AsyncReadyCallback) call and returns the result.
      Parameters:
      result - the result
      Returns:
      true if an application was launched
      Throws:
      GErrorException - see GError
      Since:
      4.10
    • openContainingFolder

      public void openContainingFolder(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Launches a file manager to show the file in its parent directory.

      This is only supported for native files. It will fail if file is e.g. a http:// uri.

      Parameters:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      Since:
      4.10
    • openContainingFolderFinish

      public boolean openContainingFolderFinish(AsyncResult result) throws GErrorException
      Finishes the openContainingFolder(Window, Cancellable, AsyncReadyCallback) call and returns the result.
      Parameters:
      result - the result
      Returns:
      true if an application was launched
      Throws:
      GErrorException - see GError
      Since:
      4.10
    • setAlwaysAsk

      public void setAlwaysAsk(boolean alwaysAsk)

      Sets whether to always ask the user which app to use.

      If false, the file might be opened with a default app or the previous choice.

      Parameters:
      alwaysAsk - whether to always ask
      Since:
      4.12
    • setFile

      public void setFile(@Nullable File file)
      Sets the file that will be opened.
      Parameters:
      file - the file
      Since:
      4.10
    • setWritable

      public void setWritable(boolean writable)
      Sets whether to make the file writable for the handler.
      Parameters:
      writable - whether to make the file writable
      Since:
      4.14
    • builder

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