Class NativeDialog
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
FileChooserNative
,NativeDialog.NativeDialogImpl
GtkDialog
.
They are used in order to integrate better with a platform, by looking the same as other native applications and supporting platform specific features.
The Dialog
functions cannot be used on such objects,
but we need a similar API in order to drive them. The GtkNativeDialog
object is an API that allows you to do this. It allows you to set
various common properties on the dialog, as well as show and hide
it and get a Gtk.NativeDialog::response
signal when the user
finished with the dialog.
Note that unlike GtkDialog
, GtkNativeDialog
objects are not
toplevel widgets, and GTK does not keep them alive. It is your
responsibility to keep a reference until you are done with the
object.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
NativeDialog.Builder<B extends NativeDialog.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Class structure forGtkNativeDialog
.static class
The NativeDialogImpl type represents a native instance of the abstract NativeDialog class.static interface
Functional interface declaration of theResponseCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionNativeDialog
(MemorySegment address) Create a NativeDialog proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected NativeDialog
asParent()
Returns this instance as if it were its parent type.static NativeDialog.Builder
<? extends NativeDialog.Builder> builder()
ANativeDialog.Builder
object constructs aNativeDialog
with the specified properties.void
destroy()
Destroys a dialog.void
emitResponse
(int responseId) Emits the "response" signal.static MemoryLayout
The memory layout of the native struct.boolean
getModal()
Returns whether the dialog is modal.getTitle()
Gets the title of theGtkNativeDialog
.Fetches the transient parent for this window.static Type
getType()
Get the GType of the NativeDialog classboolean
Determines whether the dialog is visible.void
hide()
Hides the dialog if it is visible, aborting any interaction.onResponse
(NativeDialog.ResponseCallback handler) Emitted when the user responds to the dialog.protected void
response
(int responseId) class handler for theGtkNativeDialog::response
signalvoid
setModal
(boolean modal) Sets a dialog modal or non-modal.void
Sets the title of theGtkNativeDialog.
void
setTransientFor
(@Nullable Window parent) Dialog windows should be set transient for the main application window they were spawned from.void
show()
Shows the dialog on the display.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, 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
-
NativeDialog
Create a NativeDialog proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
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. -
destroy
public void destroy()Destroys a dialog.When a dialog is destroyed, it will break any references it holds to other objects.
If it is visible it will be hidden and any underlying window system resources will be destroyed.
Note that this does not release any reference to the object (as opposed to destroying a
GtkWindow
) because there is no reference from the windowing system to theGtkNativeDialog
. -
getModal
public boolean getModal()Returns whether the dialog is modal.- Returns:
true
if the dialog is set to be modal
-
getTitle
Gets the title of theGtkNativeDialog
.- Returns:
- the title of the dialog, or
null
if none has been set explicitly. The returned string is owned by the widget and must not be modified or freed.
-
getTransientFor
Fetches the transient parent for this window.- Returns:
- the transient parent for this window,
or
null
if no transient parent has been set.
-
getVisible
public boolean getVisible()Determines whether the dialog is visible.- Returns:
true
if the dialog is visible
-
hide
public void hide()Hides the dialog if it is visible, aborting any interaction.Once this is called the
Gtk.NativeDialog::response
signal will not be emitted until after the next call toshow()
.If the dialog is not visible this does nothing.
-
setModal
public void setModal(boolean modal) Sets a dialog modal or non-modal.Modal dialogs prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use
setTransientFor(org.gnome.gtk.Window)
to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.- Parameters:
modal
- whether the window is modal
-
setTitle
Sets the title of theGtkNativeDialog.
- Parameters:
title
- title of the dialog
-
setTransientFor
Dialog windows should be set transient for the main application window they were spawned from.This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.
Passing
null
forparent
unsets the current transient window.- Parameters:
parent
- parent window
-
show
public void show()Shows the dialog on the display.When the user accepts the state of the dialog the dialog will be automatically hidden and the
Gtk.NativeDialog::response
signal will be emitted.Multiple calls while the dialog is visible will be ignored.
-
response
protected void response(int responseId) class handler for theGtkNativeDialog::response
signal -
onResponse
public SignalConnection<NativeDialog.ResponseCallback> onResponse(NativeDialog.ResponseCallback handler) Emitted when the user responds to the dialog.When this is called the dialog has been hidden.
If you call
hide()
before the user responds to the dialog this signal will not be emitted.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitResponse
public void emitResponse(int responseId) Emits the "response" signal. SeeonResponse(org.gnome.gtk.NativeDialog.ResponseCallback)
. -
builder
ANativeDialog.Builder
object constructs aNativeDialog
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withNativeDialog.Builder.build()
.
-