Class AlertDialog
- All Implemented Interfaces:
Proxy
Collects the arguments that are needed to present a message to the user.
The message is shown with the choose(Window, Cancellable, AsyncReadyCallback)
function.
If you don't need to wait for a button to be clicked, you can use
show(Window).
- Since:
- 4.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classAlertDialog.Builder<B extends AlertDialog.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new AlertDialog.AlertDialog(MemorySegment address) Create a AlertDialog instance for the provided memory address.AlertDialog(String format, Object... varargs) Creates a newGtkAlertDialogobject. -
Method Summary
Modifier and TypeMethodDescriptionprotected AlertDialogasParent()Return this instance as if it were its parent type.static AlertDialog.Builder<? extends AlertDialog.Builder> builder()AAlertDialog.Builderobject constructs aAlertDialogwith the specified properties.voidchoose(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Shows the alert to the user.intchooseFinish(AsyncResult result) Finishes thechoose(Window, Cancellable, AsyncReadyCallback)call.@Nullable String @Nullable []Returns the button labels for the alert.intReturns the index of the cancel button.intReturns the index of the default button.Returns the detail text that will be shown in the alert.static MemoryLayoutThe memory layout of the native struct.Returns the message that will be shown in the alert.booleangetModal()Returns whether the alert blocks interaction with the parent window while it is presented.static @Nullable TypegetType()Get the GType of the AlertDialog class.voidsetButtons(@Nullable String @Nullable [] labels) Sets the button labels for the alert.voidsetCancelButton(int button) Sets the index of the cancel button.voidsetDefaultButton(int button) Sets the index of the default button.voidSets the detail text that will be shown in the alert.voidsetMessage(String message) Sets the message that will be shown in the alert.voidsetModal(boolean modal) Sets whether the alert blocks interaction with the parent window while it is presented.voidShows the alert to the user.Methods inherited from class 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, 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 TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
AlertDialog
Create a AlertDialog instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
AlertDialog
-
AlertDialog
public AlertDialog()Create a new AlertDialog.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
choose
public void choose(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Shows the alert to the user.
It is ok to pass
NULLfor the callback if the alert does not have more than one button. A simpler API for this case isshow(Window).- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
chooseFinish
Finishes thechoose(Window, Cancellable, AsyncReadyCallback)call.- Parameters:
result- the result- Returns:
- the index of the button that was clicked, or -1 if
the dialog was cancelled and
Gtk.AlertDialog:cancel-buttonis not set - Throws:
GErrorException- seeGError- Since:
- 4.10
-
getButtons
Returns the button labels for the alert.- Returns:
- the button labels
- Since:
- 4.10
-
getCancelButton
public int getCancelButton()Returns the index of the cancel button.- Returns:
- the index of the cancel button, or -1
- Since:
- 4.10
-
getDefaultButton
public int getDefaultButton()Returns the index of the default button.- Returns:
- the index of the default button, or -1
- Since:
- 4.10
-
getDetail
Returns the detail text that will be shown in the alert.- Returns:
- the detail text
- Since:
- 4.10
-
getMessage
Returns the message that will be shown in the alert.- Returns:
- the message
- Since:
- 4.10
-
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
- Since:
- 4.10
-
setButtons
Sets the button labels for the alert.- Parameters:
labels- the new button labels- Since:
- 4.10
-
setCancelButton
public void setCancelButton(int button) Sets the index of the cancel button.
See
Gtk.AlertDialog:cancel-buttonfor details of how this value is used.- Parameters:
button- the new cancel button- Since:
- 4.10
-
setDefaultButton
public void setDefaultButton(int button) Sets the index of the default button.
See
Gtk.AlertDialog:default-buttonfor details of how this value is used.- Parameters:
button- the new default button- Since:
- 4.10
-
setDetail
Sets the detail text that will be shown in the alert.- Parameters:
detail- the new detail text- Since:
- 4.10
-
setMessage
Sets the message that will be shown in the alert.- Parameters:
message- the new message- Since:
- 4.10
-
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- Since:
- 4.10
-
show
Shows the alert to the user.
This function is a simpler version of
choose(Window, Cancellable, 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 a
Cancellableand callback respectively.- Parameters:
parent- the parent window- Since:
- 4.10
-
builder
AAlertDialog.Builderobject constructs aAlertDialogwith the specified properties. Use the variousset...()methods to set properties, and finish construction withAlertDialog.Builder.build().- Returns:
- the builder object
-