FileLauncher
Added in version 4.10.
Superclasses: Object
A GtkFileLauncher
object collects the arguments that are needed to open a
file with an application.
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
function.
This API follows the GIO async pattern, and the result can be obtained by
calling launch_finish
.
To launch uris that don’t represent files, use UriLauncher
.
Constructors
- class FileLauncher
- classmethod new(file: File | None = None) FileLauncher
Creates a new
GtkFileLauncher
object.Added in version 4.10.
- Parameters:
file – the file to open
Methods
- class FileLauncher
- get_always_ask() bool
Returns whether to ask the user to choose an app for opening the file.
Added in version 4.12.
- get_writable() bool
Returns whether to make the file writable for the handler.
Added in version 4.14.
- launch(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Launch an application to open the file.
This may present an app chooser dialog to the user.
The
callback
will be called when the operation is completed. It should calllaunch_finish
to obtain the result.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
cancellable – a
GCancellable
to cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- launch_finish(result: AsyncResult) bool
Finishes the
launch
call and returns the result.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- open_containing_folder(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Launch a file manager to show the file in its parent directory.
This is only supported native files. It will fail if
file
is e.g. a http:// uri.The
callback
will be called when the operation is completed. It should callopen_containing_folder_finish
to obtain the result.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
cancellable – a
GCancellable
to cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- open_containing_folder_finish(result: AsyncResult) bool
Finishes the
open_containing_folder
call and returns the result.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- set_always_ask(always_ask: bool) None
Sets whether to awlays ask the user to choose an app for opening the file. If
FALSE
, the file might be opened with a default app or the previous choice.Added in version 4.12.
- Parameters:
always_ask – a
gboolean