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 [methodGtk.FileLauncher.launch] function.
To launch uris that don't represent files, use [classGtk.UriLauncher].
<group>Dialogs</group> <gtkada_demo>create_file_chooser.adb</gtkada_demo>
Always_Ask_Property : constant Glib.Properties.Property_Boolean;
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_Property : constant Glib.Properties.Property_Interface;
Type: Glib.GFile.Gfile The file to launch.
type Gasync_Ready_Callback is access procedure
(Source_Object : access Glib.Object.GObject_Record'Class;
Res : Glib.G_Async_Result);
Type definition for a function that will be called back when an asynchronous operation within GIO has been completed. Gasync_Ready_Callback callbacks from Gtask.Gtask are guaranteed to be invoked in a later iteration of the thread-default main context (see [methodGlib.MainContext.push_thread_default]) where the Gtask.Gtask was created. All other users of Gasync_Ready_Callback must likewise call it asynchronously in a later iteration of the main context. The asynchronous operation is guaranteed to have held a reference to Source_Object from the time when the *_async function was called, until after this callback returns.
the object the asynchronous operation was started with.
a Glib.G_Async_Result.
function Get_Always_Ask
(Self : not null access Gtk_File_Launcher_Record) return Boolean
Returns whether to ask the user which app to use. Since: gtk+ 4.12
true if always asking the user
function Get_File
(Self : not null access Gtk_File_Launcher_Record)
return Glib.GFile.Gfile
Gets the file that will be opened. Since: gtk+ 4.10
the file
function Get_Type return Glib.GType
function Get_Writable
(Self : not null access Gtk_File_Launcher_Record) return Boolean
Returns whether to make the file writable for the handler. Since: gtk+ 4.14
true if the file will be made writable
type Gtk_File_Launcher is access all Gtk_File_Launcher_Record'Class;
function Gtk_File_Launcher_New
(File : Glib.GFile.Gfile) return Gtk_File_Launcher
Creates a new GtkFileLauncher object. Since: gtk+ 4.10
the file to open
type Gtk_File_Launcher_Record is new GObject_Record with null record;
procedure Gtk_New (Self : out Gtk_File_Launcher; File : Glib.GFile.Gfile)
Creates a new GtkFileLauncher object. Since: gtk+ 4.10 Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the file to open
procedure Initialize
(Self : not null access Gtk_File_Launcher_Record'Class;
File : Glib.GFile.Gfile)
Creates a new GtkFileLauncher object. Since: gtk+ 4.10 Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the file to open
procedure Launch
(Self : not null access Gtk_File_Launcher_Record;
Parent : access Gtk.Window.Gtk_Window_Record'Class;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
Launches an application to open the file. This may present an app chooser dialog to the user. Since: gtk+ 4.10
the parent window
a cancellable to cancel the operation
a callback to call when the operation is complete
function Launch_Finish
(Self : not null access Gtk_File_Launcher_Record;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Boolean
Finishes the [methodGtk.FileLauncher.launch] call and returns the result. Since: gtk+ 4.10
the result
the return location for a recoverable error
true if an application was launched
procedure Open_Containing_Folder
(Self : not null access Gtk_File_Launcher_Record;
Parent : access Gtk.Window.Gtk_Window_Record'Class;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
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. Since: gtk+ 4.10
the parent window
a cancellable to cancel the operation
a callback to call when the operation is complete
function Open_Containing_Folder_Finish
(Self : not null access Gtk_File_Launcher_Record;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Boolean
Finishes the [methodGtk.FileLauncher.open_containing_folder] call and returns the result. Since: gtk+ 4.10
the result
the return location for a recoverable error
true if an application was launched
procedure Set_Always_Ask
(Self : not null access Gtk_File_Launcher_Record;
Always_Ask : Boolean)
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. Since: gtk+ 4.12
whether to always ask
procedure Set_File
(Self : not null access Gtk_File_Launcher_Record;
File : Glib.GFile.Gfile)
Sets the file that will be opened. Since: gtk+ 4.10
the file
procedure Set_Writable
(Self : not null access Gtk_File_Launcher_Record;
Writable : Boolean)
Sets whether to make the file writable for the handler. Since: gtk+ 4.14
whether to make the file writable
Writable_Property : constant Glib.Properties.Property_Boolean;
Whether to make the file writable for the handler.