Class Dialog
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
- Direct Known Subclasses:
AboutDialog
,AlertDialog
,PreferencesDialog
AdwDialog
is similar to a window, but is shown within another window. It
can be used with Window
and ApplicationWindow
, use
present(org.gnome.gtk.Widget)
to show it.
AdwDialog
is not resizable. Use the Dialog:content-width
and
Dialog:content-height
properties to set its size, or set
Dialog:follows-content-size
to TRUE
to make the dialog track the
content's size as it changes. AdwDialog
can never be larger than its parent
window.
AdwDialog
can be presented as a centered floating window or a bottom sheet.
By default it's automatic depending on the available size.
Dialog:presentation-mode
can be used to change that.
AdwDialog
can be closed via close()
.
When presented as a bottom sheet, AdwDialog
can also be closed via swiping
it down.
The Dialog:can-close
can be used to prevent closing. In that case,
Dialog::close-attempt
gets emitted instead.
Use forceClose()
to close the dialog even when can-close
is set to
FALSE
.
AdwDialog
is transient and doesn't integrate with the window below it, for
example it's not possible to collapse it into a bottom bar. See
BottomSheet
for persistent and more tightly integrated bottom sheets.
Header Bar Integration
When placed inside an AdwDialog
, HeaderBar
will display the dialog
title instead of window title. It will also adjust the decoration layout to
ensure it always has a close button and nothing else. Set
HeaderBar:show-start-title-buttons
and
HeaderBar:show-end-title-buttons
to FALSE
to remove it if it's
unwanted.
Breakpoints
AdwDialog
can be used with Breakpoint
the same way as
BreakpointBin
. Refer to that widget's documentation for details.
Like AdwBreakpointBin
, if breakpoints are used, AdwDialog
doesn't have a
minimum size, and Gtk.Widget:width-request
and
Gtk.Widget:height-request
properties must be set manually.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Dialog.Builder<B extends Dialog.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theCloseAttemptCallback
callback.static interface
Functional interface declaration of theClosedCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
-
Constructor Summary
ConstructorDescriptionDialog()
Creates a newAdwDialog
.Dialog
(MemorySegment address) Create a Dialog proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBreakpoint
(Breakpoint breakpoint) Addsbreakpoint
to this Dialog.protected Dialog
asParent()
Returns this instance as if it were its parent type.static Dialog.Builder
<? extends Dialog.Builder> builder()
ADialog.Builder
object constructs aDialog
with the specified properties.boolean
close()
Attempts to close this Dialog.protected void
protected void
closed()
void
Emits the "close-attempt" signal.void
Emits the "closed" signal.void
Closes this Dialog.boolean
Gets whether this Dialog can be closed.getChild()
Gets the child widget of this Dialog.int
Gets the height of the dialog's contents.int
Gets the width of the dialog's contents.Gets the current breakpoint.Gets the default widget for this Dialog.getFocus()
Gets the focus widget for this Dialog.boolean
Gets whether to size content of this Dialog automatically.static MemoryLayout
The memory layout of the native struct.Gets presentation mode for this Dialog.getTitle()
Gets the title of this Dialog.static Type
getType()
Get the GType of the Dialog classEmitted when the close button or shortcut is used, orclose()
is called whileDialog:can-close
is set toFALSE
.onClosed
(Dialog.ClosedCallback handler) Emitted when the dialog is successfully closed.void
Presents this Dialog withinparent
's window.void
setCanClose
(boolean canClose) Sets whether this Dialog can be closed.void
Sets the child widget of this Dialog.void
setContentHeight
(int contentHeight) Sets the height of the dialog's contents.void
setContentWidth
(int contentWidth) Sets the width of the dialog's contents.void
setDefaultWidget
(@Nullable Widget defaultWidget) Sets the default widget for this Dialog.void
Sets the focus widget for this Dialog.void
setFollowsContentSize
(boolean followsContentSize) Sets whether to size content of this Dialog automatically.void
setPresentationMode
(DialogPresentationMode presentationMode) Sets presentation mode for this Dialog.void
Sets the title of this Dialog.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
-
Constructor Details
-
Dialog
Create a Dialog proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Dialog
public Dialog()Creates a newAdwDialog
.
-
-
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. -
addBreakpoint
Addsbreakpoint
to this Dialog.- Parameters:
breakpoint
- the breakpoint to add
-
close
public boolean close()Attempts to close this Dialog.If the
Dialog:can-close
property is set toFALSE
, theDialog::close-attempt
signal is emitted.See also:
forceClose()
.- Returns:
- whether this Dialog was successfully closed
-
forceClose
public void forceClose()Closes this Dialog.Unlike
close()
, it succeeds even ifDialog:can-close
is set toFALSE
. -
getCanClose
public boolean getCanClose()Gets whether this Dialog can be closed.- Returns:
- whether the dialog can be closed
-
getChild
Gets the child widget of this Dialog.- Returns:
- the child widget of this Dialog
-
getContentHeight
public int getContentHeight()Gets the height of the dialog's contents.- Returns:
- the content height
-
getContentWidth
public int getContentWidth()Gets the width of the dialog's contents.- Returns:
- the content width
-
getCurrentBreakpoint
Gets the current breakpoint.- Returns:
- the current breakpoint
-
getDefaultWidget
Gets the default widget for this Dialog.- Returns:
- the default widget
-
getFocus
-
getFollowsContentSize
public boolean getFollowsContentSize()Gets whether to size content of this Dialog automatically.- Returns:
- whether to size content automatically
-
getPresentationMode
Gets presentation mode for this Dialog.- Returns:
- the presentation mode
-
getTitle
-
present
Presents this Dialog withinparent
's window.If this Dialog is already shown, raises it to the top instead.
If the window is an
Window
orApplicationWindow
, the dialog will be shown within it. Otherwise, it will be a separate window.- Parameters:
parent
- a widget within the toplevel
-
setCanClose
public void setCanClose(boolean canClose) Sets whether this Dialog can be closed.If set to
FALSE
, the close button, shortcuts andclose()
will result inDialog::close-attempt
being emitted instead, and bottom sheet close swipe will be disabled.forceClose()
still works.- Parameters:
canClose
- whether to allow closing
-
setChild
Sets the child widget of this Dialog.- Parameters:
child
- the child widget
-
setContentHeight
public void setContentHeight(int contentHeight) Sets the height of the dialog's contents.Set it to -1 to reset it to the content's natural height.
See also:
Gtk.Window:default-height
- Parameters:
contentHeight
- the content height
-
setContentWidth
public void setContentWidth(int contentWidth) Sets the width of the dialog's contents.Set it to -1 to reset it to the content's natural width.
See also:
Gtk.Window:default-width
- Parameters:
contentWidth
- the content width
-
setDefaultWidget
Sets the default widget for this Dialog.It's activated when the user presses Enter.
- Parameters:
defaultWidget
- the default widget
-
setFocus
Sets the focus widget for this Dialog.If
focus
is not the current focus widget, and is focusable, sets it as the focus widget for the dialog.If focus is
NULL
, unsets the focus widget for this dialog. To set the focus to a particular widget in the dialog, it is usually more convenient to useWidget.grabFocus()
instead of this function.- Parameters:
focus
- the focus widget
-
setFollowsContentSize
public void setFollowsContentSize(boolean followsContentSize) Sets whether to size content of this Dialog automatically.If set to
TRUE
, always use the content's natural size instead ofDialog:content-width
andDialog:content-height
. If the content resizes, the dialog will immediately resize as well.See also:
Gtk.Window:resizable
- Parameters:
followsContentSize
- whether to size content automatically
-
setPresentationMode
Sets presentation mode for this Dialog.When set to
ADW_DIALOG_AUTO
, the dialog appears as a bottom sheet when the following condition is met:max-width: 450px or max-height: 360px
, and as a floating window otherwise.Set it to
ADW_DIALOG_FLOATING
orADW_DIALOG_BOTTOM_SHEET
to always present it a floating window or a bottom sheet respectively, regardless of available size.Presentation mode does nothing for dialogs presented as a window.
- Parameters:
presentationMode
- the new presentation mode
-
setTitle
-
closeAttempt
protected void closeAttempt() -
closed
protected void closed() -
onCloseAttempt
public SignalConnection<Dialog.CloseAttemptCallback> onCloseAttempt(Dialog.CloseAttemptCallback handler) Emitted when the close button or shortcut is used, orclose()
is called whileDialog:can-close
is set toFALSE
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCloseAttempt
public void emitCloseAttempt()Emits the "close-attempt" signal. SeeonCloseAttempt(org.gnome.adw.Dialog.CloseAttemptCallback)
. -
onClosed
Emitted when the dialog is successfully closed.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitClosed
public void emitClosed()Emits the "closed" signal. SeeonClosed(org.gnome.adw.Dialog.ClosedCallback)
. -
builder
ADialog.Builder
object constructs aDialog
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDialog.Builder.build()
.
-