Gtk.FileLauncher¶
class — extends GObject.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 FileLauncher.launch function.
To launch uris that don't represent files, use UriLauncher.
Constructors¶
new¶
Creates a new GtkFileLauncher object.
Parameters:
file— the file to open
Methods¶
get_always_ask¶
Returns whether to ask the user which app to use.
get_file¶
Gets the file that will be opened.
get_writable¶
Returns whether to make the file writable for the handler.
launch¶
def launch(self, parent: Window | None = ..., cancellable: Gio.Cancellable | None = ..., callback: Gio.AsyncReadyCallback | None = ...) -> None
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
launch_finish¶
Finishes the FileLauncher.launch call and
returns the result.
Parameters:
result— the result
open_containing_folder¶
def open_containing_folder(self, parent: Window | None = ..., cancellable: Gio.Cancellable | None = ..., callback: Gio.AsyncReadyCallback | 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 file
is 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
open_containing_folder_finish¶
Finishes the FileLauncher.open_containing_folder
call and returns the result.
Parameters:
result— the result
set_always_ask¶
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:
always_ask— whether to always ask
set_file¶
Sets the file that will be opened.
Parameters:
file— the file
set_writable¶
Sets whether to make the file writable for the handler.
Parameters:
writable— whether to make the file writable
Properties¶
always_ask¶
Whether to 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.
file¶
The file to launch.
writable¶
Whether to make the file writable for the handler.