Class PrintDialog
- All Implemented Interfaces:
Proxy
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 setup(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) function.
The actual printing can be done with print(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) or
printFile(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.File, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback). These APIs follows the GIO async pattern,
and the results can be obtained by calling the corresponding finish methods.
- Since:
- 4.14
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPrintDialog.Builder<B extends PrintDialog.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new PrintDialog.PrintDialog(MemorySegment address) Create a PrintDialog proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected PrintDialogasParent()Returns this instance as if it were its parent type.static PrintDialog.Builder<? extends PrintDialog.Builder> builder()APrintDialog.Builderobject constructs aPrintDialogwith the specified properties.Returns the label that will be shown on the accept button of the print dialog.booleangetModal()Returns whether the print dialog blocks interaction with the parent window while it is presented.@Nullable PageSetupReturns the page setup.@Nullable PrintSettingsReturns the print settings for the print dialog.getTitle()Returns the title that will be shown on the print dialog.static @Nullable TypegetType()Get the GType of the PrintDialog classvoidprint(@Nullable Window parent, @Nullable PrintSetup setup, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function prints content from a stream.voidprintFile(@Nullable Window parent, @Nullable PrintSetup setup, File file, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function prints a file.booleanprintFileFinish(AsyncResult result) Finishes theprintFile(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.File, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the results.printFinish(AsyncResult result) Finishes theprint(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the results.voidsetAcceptLabel(String acceptLabel) Sets the label that will be shown on the accept button of the print dialog shown forsetup(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).voidsetModal(boolean modal) Sets whether the print dialog blocks interaction with the parent window while it is presented.voidsetPageSetup(PageSetup pageSetup) Set the page setup for the print dialog.voidsetPrintSettings(PrintSettings printSettings) Sets the print settings for the print dialog.voidSets the title that will be shown on the print dialog.voidsetup(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function presents a print dialog to let the user select a printer, and set up print settings and page setup.setupFinish(AsyncResult result) Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
PrintDialog
Create a PrintDialog proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
PrintDialog
public PrintDialog()Creates a new PrintDialog.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getAcceptLabel
Returns the label that will be shown on the accept button of the print dialog.- Returns:
- the accept label
- Since:
- 4.14
-
getModal
public boolean getModal()Returns whether the print dialog blocks interaction with the parent window while it is presented.- Returns:
- whether the print dialog is modal
- Since:
- 4.14
-
getPageSetup
Returns the page setup.- Returns:
- the page setup
- Since:
- 4.14
-
getPrintSettings
Returns the print settings for the print dialog.- Returns:
- the settings
- Since:
- 4.14
-
getTitle
Returns the title that will be shown on the print dialog.- Returns:
- the title
- Since:
- 4.14
-
print
public void print(@Nullable Window parent, @Nullable PrintSetup setup, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function prints content from a stream.If you pass
NULLassetup,then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction.The
callbackwill be called when the printing is done.- Parameters:
parent- the parentGtkWindowsetup- theGtkPrintSetupto usecancellable- aGCancellableto cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.14
-
printFile
public void printFile(@Nullable Window parent, @Nullable PrintSetup setup, File file, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function prints a file.If you pass
NULLassetup,then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction.- Parameters:
parent- the parentGtkWindowsetup- theGtkPrintSetupto usefile- theGFileto printcancellable- aGCancellableto cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.14
-
printFileFinish
Finishes theprintFile(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.File, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the results.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- aGAsyncResult- Returns:
- Whether the call was successful
- Throws:
GErrorException- seeGError- Since:
- 4.14
-
printFinish
Finishes theprint(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the results.If the call was successful, the content to be printed should be written to the returned output stream. Otherwise,
NULLis returned.The overall results of the print operation will be returned in the
OutputStream.close(org.gnome.gio.Cancellable)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
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- aGAsyncResult- Returns:
- a
OutputStream - Throws:
GErrorException- seeGError- Since:
- 4.14
-
setAcceptLabel
Sets the label that will be shown on the accept button of the print dialog shown forsetup(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).- Parameters:
acceptLabel- the new accept label- Since:
- 4.14
-
setModal
public void setModal(boolean modal) Sets whether the print dialog blocks interaction with the parent window while it is presented.- Parameters:
modal- the new value- Since:
- 4.14
-
setPageSetup
Set the page setup for the print dialog.- Parameters:
pageSetup- the new page setup- Since:
- 4.14
-
setPrintSettings
Sets the print settings for the print dialog.- Parameters:
printSettings- the new print settings- Since:
- 4.14
-
setTitle
Sets the title that will be shown on the print dialog.- Parameters:
title- the new title- Since:
- 4.14
-
setup
public void setup(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function presents a print dialog to let the user select a printer, and set up print settings and page setup.The
callbackwill be called when the dialog is dismissed. The obtainedGtk.PrintSetupcan then be passed toprint(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)orprintFile(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.File, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).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
print(org.gnome.gtk.Window, org.gnome.gtk.PrintSetup, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)on this PrintDialog to do the printing without further user interaction.- Parameters:
parent- the parentGtkWindowcancellable- aGCancellableto cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.14
-
setupFinish
Finishes thesetup(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.If the call was successful, it returns a
Gtk.PrintSetupwhich contains the print settings and page setup information that will be used to print.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- aGAsyncResult- Returns:
- the resulting
[struct@Gtk.PrintSetup] - Throws:
GErrorException- seeGError- Since:
- 4.14
-
builder
APrintDialog.Builderobject constructs aPrintDialogwith the specified properties. Use the variousset...()methods to set properties, and finish construction withPrintDialog.Builder.build().- Returns:
- the builder object
-