Gtk.FileLauncher

g GObject.Object GObject.Object Gtk.FileLauncher Gtk.FileLauncher GObject.Object->Gtk.FileLauncher

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (file)

get_always_ask ()

get_file ()

get_writable ()

launch (parent, cancellable, callback, *user_data)

launch_finish (result)

open_containing_folder (parent, cancellable, callback, *user_data)

open_containing_folder_finish (result)

set_always_ask (always_ask)

set_file (file)

set_writable (writable)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

always-ask

bool

r/w/en

file

Gio.File

r/w/en

writable

bool

r/w/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.FileLauncher(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.FileLauncherClass

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 [method`Gtk`.FileLauncher.launch] function.

To launch uris that don’t represent files, use [class`Gtk`.UriLauncher].

New in version 4.10.

classmethod new(file)[source]
Parameters:

file (Gio.File or None) – the file to open

Returns:

the new GtkFileLauncher

Return type:

Gtk.FileLauncher

Creates a new GtkFileLauncher object.

New in version 4.10.

get_always_ask()[source]
Returns:

true if always asking the user

Return type:

bool

Returns whether to ask the user which app to use.

New in version 4.12.

get_file()[source]
Returns:

the file

Return type:

Gio.File or None

Gets the file that will be opened.

New in version 4.10.

get_writable()[source]
Returns:

true if the file will be made writable

Return type:

bool

Returns whether to make the file writable for the handler.

New in version 4.14.

launch(parent, cancellable, callback, *user_data)[source]
Parameters:

Launches an application to open the file.

This may present an app chooser dialog to the user.

New in version 4.10.

launch_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – the result

Raises:

GLib.Error

Returns:

true if an application was launched

Return type:

bool

Finishes the [method`Gtk`.FileLauncher.launch] call and returns the result.

New in version 4.10.

open_containing_folder(parent, cancellable, callback, *user_data)[source]
Parameters:

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.

New in version 4.10.

open_containing_folder_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – the result

Raises:

GLib.Error

Returns:

true if an application was launched

Return type:

bool

Finishes the [method`Gtk`.FileLauncher.open_containing_folder] call and returns the result.

New in version 4.10.

set_always_ask(always_ask)[source]
Parameters:

always_ask (bool) – whether to 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.

New in version 4.12.

set_file(file)[source]
Parameters:

file (Gio.File or None) – the file

Sets the file that will be opened.

New in version 4.10.

set_writable(writable)[source]
Parameters:

writable (bool) – whether to make the file writable

Sets whether to make the file writable for the handler.

New in version 4.14.

Property Details

Gtk.FileLauncher.props.always_ask
Name:

always-ask

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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.

New in version 4.12.

Gtk.FileLauncher.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The file to launch.

New in version 4.10.

Gtk.FileLauncher.props.writable
Name:

writable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to make the file writable for the handler.

New in version 4.14.