Class FileLauncher
- All Implemented Interfaces:
Proxy
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFileLauncher.Builder<B extends FileLauncher.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new FileLauncher.FileLauncher(MemorySegment address) Create a FileLauncher instance for the provided memory address.FileLauncher(@Nullable File file) Creates a newGtkFileLauncherobject. -
Method Summary
Modifier and TypeMethodDescriptionprotected FileLauncherasParent()Return this instance as if it were its parent type.static FileLauncher.Builder<? extends FileLauncher.Builder> builder()AFileLauncher.Builderobject constructs aFileLauncherwith the specified properties.booleanReturns whether to ask the user which app to use.@Nullable FilegetFile()Gets the file that will be opened.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the FileLauncher class.booleanReturns whether to make the file writable for the handler.voidlaunch(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Launches an application to open the file.booleanlaunchFinish(AsyncResult result) Finishes thelaunch(Window, Cancellable, AsyncReadyCallback)call and returns the result.voidopenContainingFolder(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Launches a file manager to show the file in its parent directory.booleanFinishes theopenContainingFolder(Window, Cancellable, AsyncReadyCallback)call and returns the result.voidsetAlwaysAsk(boolean alwaysAsk) Sets whether to always ask the user which app to use.voidSets the file that will be opened.voidsetWritable(boolean writable) Sets whether to make the file writable for the handler.Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
FileLauncher
Create a FileLauncher instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
FileLauncher
Creates a newGtkFileLauncherobject.- Parameters:
file- the file to open- Since:
- 4.10
-
FileLauncher
public FileLauncher()Create a new FileLauncher.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
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
-
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 windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
launchFinish
Finishes thelaunch(Window, Cancellable, AsyncReadyCallback)call and returns the result.- Parameters:
result- the result- Returns:
- true if an application was launched
- Throws:
GErrorException- seeGError- 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
fileis e.g. a http:// uri.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
openContainingFolderFinish
Finishes theopenContainingFolder(Window, Cancellable, AsyncReadyCallback)call and returns the result.- Parameters:
result- the result- Returns:
- true if an application was launched
- Throws:
GErrorException- seeGError- 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
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
AFileLauncher.Builderobject constructs aFileLauncherwith the specified properties. Use the variousset...()methods to set properties, and finish construction withFileLauncher.Builder.build().- Returns:
- the builder object
-