Class PrintDialog
- All Implemented Interfaces:
Proxy
GtkPrintDialog
object collects the arguments that
are needed to present a print dialog to the user, 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
PrintDialog.Builder<B extends PrintDialog.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a newGtkPrintDialog
object.PrintDialog
(MemorySegment address) Create a PrintDialog proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected PrintDialog
asParent()
Returns this instance as if it were its parent type.static PrintDialog.Builder
<? extends PrintDialog.Builder> builder()
APrintDialog.Builder
object constructs aPrintDialog
with the specified properties.Returns the label that will be shown on the accept button of the print dialog.boolean
getModal()
Returns whether the print dialog blocks interaction with the parent window while it is presented.Returns the page setup.Returns the print settings for the print dialog.getTitle()
Returns the title that will be shown on the print dialog.static Type
getType()
Get the GType of the PrintDialog classvoid
print
(@Nullable Window parent, @Nullable PrintSetup setup, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function prints content from a stream.void
printFile
(@Nullable Window parent, @Nullable PrintSetup setup, File file, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function prints a file.boolean
printFileFinish
(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.void
setAcceptLabel
(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)
.void
setModal
(boolean modal) Sets whether the print dialog blocks interaction with the parent window while it is presented.void
setPageSetup
(PageSetup pageSetup) Set the page setup for the print dialog.void
setPrintSettings
(PrintSettings printSettings) Sets the print settings for the print dialog.void
Sets the title that will be shown on the print dialog.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.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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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 newGtkPrintDialog
object.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, 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
-
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
-
getPageSetup
-
getPrintSettings
Returns the print settings for the print dialog.- Returns:
- the settings
-
getTitle
Returns the title that will be shown on the print dialog.- Returns:
- the title
-
print
public void print(@Nullable @Nullable Window parent, @Nullable @Nullable PrintSetup setup, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function prints content from a stream.If you pass
NULL
assetup
, 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.- Parameters:
parent
- the parentGtkWindow
setup
- theGtkPrintSetup
to usecancellable
- aGCancellable
to cancel the operationcallback
- a callback to call when the operation is complete
-
printFile
public void printFile(@Nullable @Nullable Window parent, @Nullable @Nullable PrintSetup setup, File file, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function prints a file.If you pass
NULL
assetup
, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction.- Parameters:
parent
- the parentGtkWindow
setup
- theGtkPrintSetup
to usefile
- theGFile
to printcancellable
- aGCancellable
to cancel the operationcallback
- a callback to call when the operation is complete
-
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.- Parameters:
result
- aGAsyncResult
- Returns:
- Whether the call was successful
- Throws:
GErrorException
- seeGError
-
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,
NULL
is 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.- Parameters:
result
- aGAsyncResult
- Returns:
- a
OutputStream
- Throws:
GErrorException
- seeGError
-
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
-
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
-
setPageSetup
Set the page setup for the print dialog.- Parameters:
pageSetup
- the new page setup
-
setPrintSettings
Sets the print settings for the print dialog.- Parameters:
printSettings
- the new print settings
-
setTitle
Sets the title that will be shown on the print dialog.- Parameters:
title
- the new title
-
setup
public void setup(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed. The obtainedGtk.PrintSetup
can 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 parentGtkWindow
cancellable
- aGCancellable
to cancel the operationcallback
- a callback to call when the operation is complete
-
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.PrintSetup
which contains the print settings and page setup information that will be used to print.- Parameters:
result
- aGAsyncResult
- Returns:
- The
GtkPrintSetup
object that resulted from the call, orNULL
if the call was not successful - Throws:
GErrorException
- seeGError
-
builder
APrintDialog.Builder
object constructs aPrintDialog
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withPrintDialog.Builder.build()
.
-