Class AlertDialog
- All Implemented Interfaces:
Proxy
GtkAlertDialog
object collects the arguments that
are needed to present a message to the user.
The message is shown with the choose(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
function.
If you don't need to wait for a button to be clicked, you can use
show(org.gnome.gtk.Window)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
AlertDialog.Builder<B extends AlertDialog.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionAlertDialog
(MemorySegment address) Create a AlertDialog proxy instance for the provided memory address.AlertDialog
(String format, Object... varargs) Creates a newGtkAlertDialog
object. -
Method Summary
Modifier and TypeMethodDescriptionprotected AlertDialog
asParent()
Returns this instance as if it were its parent type.static AlertDialog.Builder
<? extends AlertDialog.Builder> builder()
AAlertDialog.Builder
object constructs aAlertDialog
with the specified properties.void
choose
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function shows the alert to the user.int
chooseFinish
(AsyncResult result) Finishes thechoose(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the index of the button that was clicked.String[]
Returns the button labels for the alert.int
Returns the index of the cancel button.int
Returns the index of the default button.Returns the detail text that will be shown in the alert.Returns the message that will be shown in the alert.boolean
getModal()
Returns whether the alert blocks interaction with the parent window while it is presented.static Type
getType()
Get the GType of the AlertDialog classvoid
setButtons
(String[] labels) Sets the button labels for the alert.void
setCancelButton
(int button) Sets the index of the cancel button.void
setDefaultButton
(int button) Sets the index of the default button.void
Sets the detail text that will be shown in the alert.void
setMessage
(String message) Sets the message that will be shown in the alert.void
setModal
(boolean modal) Sets whether the alert blocks interaction with the parent window while it is presented.void
Show the alert to the user.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
-
AlertDialog
Create a AlertDialog proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
AlertDialog
-
-
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. -
choose
public void choose(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function shows the alert to the user.It is ok to pass
NULL
for the callback if the alert does not have more than one button. A simpler API for this case isshow(org.gnome.gtk.Window)
.- Parameters:
parent
- the parentGtkWindow
cancellable
- aGCancellable
to cancel the operationcallback
- a callback to call when the operation is complete
-
chooseFinish
Finishes thechoose(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the index of the button that was clicked.- Parameters:
result
- aGAsyncResult
- Returns:
- the index of the button that was clicked, or -1 if
the dialog was cancelled and
Gtk.AlertDialog:cancel-button
is not set - Throws:
GErrorException
- seeGError
-
getButtons
-
getCancelButton
public int getCancelButton()Returns the index of the cancel button.- Returns:
- the index of the cancel button, or -1
-
getDefaultButton
public int getDefaultButton()Returns the index of the default button.- Returns:
- the index of the default button, or -1
-
getDetail
Returns the detail text that will be shown in the alert.- Returns:
- the detail text
-
getMessage
Returns the message that will be shown in the alert.- Returns:
- the message
-
getModal
public boolean getModal()Returns whether the alert blocks interaction with the parent window while it is presented.- Returns:
TRUE
if the alert is modal
-
setButtons
Sets the button labels for the alert.- Parameters:
labels
- the new button labels
-
setCancelButton
public void setCancelButton(int button) Sets the index of the cancel button.See
Gtk.AlertDialog:cancel-button
for details of how this value is used.- Parameters:
button
- the new cancel button
-
setDefaultButton
public void setDefaultButton(int button) Sets the index of the default button.See
Gtk.AlertDialog:default-button
for details of how this value is used.- Parameters:
button
- the new default button
-
setDetail
Sets the detail text that will be shown in the alert.- Parameters:
detail
- the new detail text
-
setMessage
Sets the message that will be shown in the alert.- Parameters:
message
- the new message
-
setModal
public void setModal(boolean modal) Sets whether the alert blocks interaction with the parent window while it is presented.- Parameters:
modal
- the new value
-
show
Show the alert to the user.This function is a simple version of
choose(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
intended for dialogs with a single button. If you want to cancel the dialog or if the alert has more than one button, you should use that function instead and provide it with aGCancellable
or callback respectively.- Parameters:
parent
- the parentGtkWindow
-
builder
AAlertDialog.Builder
object constructs aAlertDialog
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withAlertDialog.Builder.build()
.
-