FileLauncher#

Added in version 4.10.

class FileLauncher(**properties: Any)#

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.

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_file() File | None#

Gets the file that will be opened.

Added in version 4.10.

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.

Added in version 4.10.

Parameters:
  • parent – the parent GtkWindow

  • cancellable – a GCancellable 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 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.

Added in version 4.10.

Parameters:
  • parent – the parent GtkWindow

  • cancellable – a GCancellable 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_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

set_file(file: File | None = None) None#

Sets the file that will be opened.

Added in version 4.10.

Parameters:

file – a GFile

set_writable(writable: bool) None#

Sets whether to make the file writable for the handler.

Added in version 4.14.

Parameters:

writable – a gboolean

Properties#

class FileLauncher
props.always_ask: bool#

The type of the None singleton.

Added in version 4.12.

props.file: File#

The type of the None singleton.

Added in version 4.10.

props.writable: bool#

The type of the None singleton.

Added in version 4.14.