Asynchronous API to present a print dialog to the user.
GtkPrintDialog collects the arguments that are needed to present the dialog, such as a title for the dialog and whether it should be modal.
The dialog is shown with the [methodGtk.PrintDialog.setup] function.
The actual printing can be done with [methodGtk.PrintDialog.print] or [methodGtk.PrintDialog.print_file]. These APIs follows the GIO async pattern, and the results can be obtained by calling the corresponding finish methods.
Accept_Label_Property : constant Glib.Properties.Property_String;
A label that may be shown on the accept button of a print dialog that is presented by [methodGtk.PrintDialog.setup].
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_Accept_Label
(Self : not null access Gtk_Print_Dialog_Record) return UTF8_String
Returns the label that will be shown on the accept button of the print dialog. Since: gtk+ 4.14
the accept label
function Get_Modal
(Self : not null access Gtk_Print_Dialog_Record) return Boolean
Returns whether the print dialog blocks interaction with the parent window while it is presented. Since: gtk+ 4.14
whether the print dialog is modal
function Get_Page_Setup
(Self : not null access Gtk_Print_Dialog_Record)
return Gtk.Page_Setup.Gtk_Page_Setup
Returns the page setup. Since: gtk+ 4.14
the page setup. Has transfer-ownership='none'.
function Get_Print_Settings
(Self : not null access Gtk_Print_Dialog_Record)
return Gtk.Print_Settings.Gtk_Print_Settings
Returns the print settings for the print dialog. Since: gtk+ 4.14
the settings. Has transfer-ownership='none'.
function Get_Title
(Self : not null access Gtk_Print_Dialog_Record) return UTF8_String
Returns the title that will be shown on the print dialog. Since: gtk+ 4.14
the title
function Get_Type return Glib.GType
procedure Gtk_New (Self : out Gtk_Print_Dialog)
Creates a new GtkPrintDialog object. Since: gtk+ 4.14 Initialize does nothing if the object was already created with another call to Initialize* or G_New.
type Gtk_Print_Dialog is access all Gtk_Print_Dialog_Record'Class;
function Gtk_Print_Dialog_New return Gtk_Print_Dialog
Creates a new GtkPrintDialog object. Since: gtk+ 4.14
type Gtk_Print_Dialog_Record is new GObject_Record with null record;
procedure Initialize
(Self : not null access Gtk_Print_Dialog_Record'Class)
Creates a new GtkPrintDialog object. Since: gtk+ 4.14 Initialize does nothing if the object was already created with another call to Initialize* or G_New.
Modal_Property : constant Glib.Properties.Property_Boolean;
Whether the print dialog is modal.
Page_Setup_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Page_Setup.Gtk_Page_Setup The page setup to use.
procedure Print
(Self : not null access Gtk_Print_Dialog_Record;
Parent : access Gtk.Window.Gtk_Window_Record'Class;
Setup : Gtk.Print_Setup.Gtk_Print_Setup;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
This function prints content from a stream. If you pass NULL as Setup, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction. The Callback will be called when the printing is done. Since: gtk+ 4.14
the parent GtkWindow
the GtkPrintSetup to use
a GCancellable to cancel the operation
a callback to call when the operation is complete
procedure Print_File
(Self : not null access Gtk_Print_Dialog_Record;
Parent : access Gtk.Window.Gtk_Window_Record'Class;
Setup : Gtk.Print_Setup.Gtk_Print_Setup;
File : Glib.GFile.Gfile;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
This function prints a file. If you pass NULL as Setup, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction. Since: gtk+ 4.14
the parent GtkWindow
the GtkPrintSetup to use
the GFile to print
a GCancellable to cancel the operation
a callback to call when the operation is complete
function Print_File_Finish
(Self : not null access Gtk_Print_Dialog_Record;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Boolean
Finishes the [methodGtk.PrintDialog.print_file] call and returns the results. Note that this function returns a [errorGtk.DialogError.DISMISSED] error if the user cancels the dialog. Since: gtk+ 4.14
a GAsyncResult
the return location for a recoverable error
Whether the call was successful
function Print_Finish
(Self : not null access Gtk_Print_Dialog_Record;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError)
return Glib.Output_Stream.Goutput_Stream
Finishes the [methodGtk.PrintDialog.print] call and returns the results. If the call was successful, the content to be printed should be written to the returned output stream. Otherwise, NULL is returned. The overall results of the print operation will be returned in the [methodGio.OutputStream.close] call, so if you are interested in the results, you need to explicitly close the output stream (it will be closed automatically if you just unref it). Be aware that the close call may not be instant as it operation will for the printer to finish printing. Note that this function returns a [errorGtk.DialogError.DISMISSED] error if the user cancels the dialog. Since: gtk+ 4.14
a GAsyncResult
the return location for a recoverable error
a [classGio.OutputStream]. Has transfer-ownership='full'.
Print_Settings_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Print_Settings.Gtk_Print_Settings The print settings to use.
procedure Set_Accept_Label
(Self : not null access Gtk_Print_Dialog_Record;
Accept_Label : UTF8_String)
Sets the label that will be shown on the accept button of the print dialog shown for [methodGtk.PrintDialog.setup]. Since: gtk+ 4.14
the new accept label
procedure Set_Modal
(Self : not null access Gtk_Print_Dialog_Record;
Modal : Boolean)
Sets whether the print dialog blocks interaction with the parent window while it is presented. Since: gtk+ 4.14
the new value
procedure Set_Page_Setup
(Self : not null access Gtk_Print_Dialog_Record;
Page_Setup : not null access Gtk.Page_Setup.Gtk_Page_Setup_Record'Class)
Set the page setup for the print dialog. Since: gtk+ 4.14
the new page setup
procedure Set_Print_Settings
(Self : not null access Gtk_Print_Dialog_Record;
Print_Settings : not null access Gtk.Print_Settings.Gtk_Print_Settings_Record'Class)
Sets the print settings for the print dialog. Since: gtk+ 4.14
the new print settings
procedure Set_Title
(Self : not null access Gtk_Print_Dialog_Record;
Title : UTF8_String)
Sets the title that will be shown on the print dialog. Since: gtk+ 4.14
the new title
procedure Setup
(Self : not null access Gtk_Print_Dialog_Record;
Parent : access Gtk.Window.Gtk_Window_Record'Class;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
This function presents a print dialog to let the user select a printer, and set up print settings and page setup. The Callback will be called when the dialog is dismissed. The obtained [structGtk.PrintSetup] can then be passed to [methodGtk.PrintDialog.print] or [methodGtk.PrintDialog.print_file]. One possible use for this method is to have the user select a printer, then show a page setup UI in the application (e.g. to arrange images on a page), then call [methodGtk.PrintDialog.print] on Self to do the printing without further user interaction. Since: gtk+ 4.14
the parent GtkWindow
a GCancellable to cancel the operation
a callback to call when the operation is complete
function Setup_Finish
(Self : not null access Gtk_Print_Dialog_Record;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError)
return Gtk.Print_Setup.Gtk_Print_Setup
Finishes the [methodGtk.PrintDialog.setup] call. If the call was successful, it returns a [structGtk.PrintSetup] which contains the print settings and page setup information that will be used to print. Note that this function returns a [errorGtk.DialogError.DISMISSED] error if the user cancels the dialog. Since: gtk+ 4.14
a GAsyncResult
the return location for a recoverable error
the resulting [structGtk.PrintSetup]. Has transfer-ownership='full'.
Title_Property : constant Glib.Properties.Property_String;
A title that may be shown on the print dialog that is presented by [methodGtk.PrintDialog.setup].