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 ()

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)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

always-ask

bool

r/w/en

file

Gio.File

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

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 [method`Gtk`.FileLauncher.launch] function. This API follows the GIO async pattern, and the result can be obtained by calling [method`Gtk`.FileLauncher.launch_finish].

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 for app

Return type:

bool

Returns whether to ask the user to choose an app for opening the file.

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.

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

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 call [method`Gtk`.FileLauncher.launch_finish] to obtain the result.

New in version 4.10.

launch_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – a GAsyncResult

Raises:

GLib.Error

Returns:

TRUE if an application was launched, or FALSE and error is set

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:

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 call [method`Gtk`.FileLauncher.open_containing_folder_finish] to obtain the result.

New in version 4.10.

open_containing_folder_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – a GAsyncResult

Raises:

GLib.Error

Returns:

TRUE if an application was launched, or FALSE and error is set

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) – a gboolean

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.

New in version 4.12.

set_file(file)[source]
Parameters:

file (Gio.File or None) – a GFile

Sets the file that will be opened.

New in version 4.10.

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.