FileLauncher#
Added in version 4.10.
Superclasses: Object
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 function.
To launch uris that don’t represent files, use UriLauncher.
Constructors#
- class FileLauncher
- classmethod new(file: File | None = None) FileLauncher#
Creates a new
GtkFileLauncherobject.Added in version 4.10.
- Parameters:
file – the file to open
Methods#
- class FileLauncher
-
- get_writable() bool#
Returns whether to make the file writable for the handler.
Added in version 4.14.
- async launch(self, parent: Window | None = None) bool#
This is the awaitable version of
launch().Added in version 4.10.
- Parameters:
parent – the parent window
- launch(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Launches an application to open the file.
This may present an app chooser dialog to the user.
Added in version 4.10.
- Parameters:
parent – the parent window
cancellable – a cancellable to cancel the operation
callback – a callback to call when the operation is complete
user_data – data to pass to
callback
- launch_finish(result: AsyncResult) bool#
Finishes the
launchcall and returns the result.Added in version 4.10.
- Parameters:
result – the result
- async open_containing_folder(self, parent: Window | None = None) bool#
This is the awaitable version of
open_containing_folder().Added in version 4.10.
- Parameters:
parent – the parent window
- open_containing_folder(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
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.Added in version 4.10.
- Parameters:
parent – the parent window
cancellable – a cancellable to cancel the operation
callback – 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_foldercall and returns the result.Added in version 4.10.
- Parameters:
result – the result
- set_always_ask(always_ask: bool) None#
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.
Added in version 4.12.
- Parameters:
always_ask – whether to always ask