Package ch.bailu.gtk.gtk
Class Expander
- All Implemented Interfaces:
PointerInterface
`GtkExpander` allows the user to reveal its child by clicking
on an expander triangle.

This is similar to the triangles used in a `GtkTreeView`.
Normally you use an expander as you would use a frame; you create
the child widget and use [method@Gtk.Expander.set_child] to add it
to the expander. When the expander is toggled, it will take care of
showing and hiding the child automatically.
# Special Usage
There are situations in which you may prefer to show and hide the
expanded widget yourself, such as when you want to actually create
the widget at expansion time. In this case, create a `GtkExpander`
but do not add a child to it. The expander widget has an
[property@Gtk.Expander:expanded[ property which can be used to
monitor its expansion state. You should watch this property with
a signal connection as follows:
```c
static void
expander_callback (GObject *object,
GParamSpec *param_spec,
gpointer user_data)
{
GtkExpander *expander;
expander = GTK_EXPANDER (object);
if (gtk_expander_get_expanded (expander))
{
// Show or create widgets
}
else
{
// Hide or destroy widgets
}
}
static void
create_expander (void)
{
GtkWidget *expander = gtk_expander_new_with_mnemonic ("_More Options");
g_signal_connect (expander, "notify::expanded",
G_CALLBACK (expander_callback), NULL);
// ...
}
```
# GtkExpander as GtkBuildable
The `GtkExpander` implementation of the `GtkBuildable` interface supports
placing a child in the label position by specifying “label” as the
“type” attribute of a <child> element. A normal content child can be
specified without specifying a <child> type attribute.
An example of a UI definition fragment with GtkExpander:
```xml
<object class="GtkExpander">
<child type="label">
<object class="GtkLabel" id="expander-label"/>
</child>
<child>
<object class="GtkEntry" id="expander-content"/>
</child>
</object>
```
# CSS nodes
```
expander
╰── box
├── title
│ ├── arrow
│ ╰── <label widget>
╰── <child>
```
`GtkExpander` has three CSS nodes, the main node with the name expander,
a subnode with name title and node below it with name arrow. The arrow of an
expander that is showing its child gets the :checked pseudoclass added to it.
# Accessibility
`GtkExpander` uses the %GTK_ACCESSIBLE_ROLE_BUTTON role.
on an expander triangle.

This is similar to the triangles used in a `GtkTreeView`.
Normally you use an expander as you would use a frame; you create
the child widget and use [method@Gtk.Expander.set_child] to add it
to the expander. When the expander is toggled, it will take care of
showing and hiding the child automatically.
# Special Usage
There are situations in which you may prefer to show and hide the
expanded widget yourself, such as when you want to actually create
the widget at expansion time. In this case, create a `GtkExpander`
but do not add a child to it. The expander widget has an
[property@Gtk.Expander:expanded[ property which can be used to
monitor its expansion state. You should watch this property with
a signal connection as follows:
```c
static void
expander_callback (GObject *object,
GParamSpec *param_spec,
gpointer user_data)
{
GtkExpander *expander;
expander = GTK_EXPANDER (object);
if (gtk_expander_get_expanded (expander))
{
// Show or create widgets
}
else
{
// Hide or destroy widgets
}
}
static void
create_expander (void)
{
GtkWidget *expander = gtk_expander_new_with_mnemonic ("_More Options");
g_signal_connect (expander, "notify::expanded",
G_CALLBACK (expander_callback), NULL);
// ...
}
```
# GtkExpander as GtkBuildable
The `GtkExpander` implementation of the `GtkBuildable` interface supports
placing a child in the label position by specifying “label” as the
“type” attribute of a <child> element. A normal content child can be
specified without specifying a <child> type attribute.
An example of a UI definition fragment with GtkExpander:
```xml
<object class="GtkExpander">
<child type="label">
<object class="GtkLabel" id="expander-label"/>
</child>
<child>
<object class="GtkEntry" id="expander-content"/>
</child>
</object>
```
# CSS nodes
```
expander
╰── box
├── title
│ ├── arrow
│ ╰── <label widget>
╰── <child>
```
`GtkExpander` has three CSS nodes, the main node with the name expander,
a subnode with name title and node below it with name arrow. The arrow of an
expander that is showing its child gets the :checked pseudoclass added to it.
# Accessibility
`GtkExpander` uses the %GTK_ACCESSIBLE_ROLE_BUTTON role.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealizeNested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify -
Field Summary
FieldsFields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZEFields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceAccessible.Implements interfaceBuildable.Implements interfaceConstraintTarget.getChild()Gets the child widget of @expander.static ClassHandlerbooleanQueries a `GtkExpander` and returns its current state.static intgetLabel()Fetches the text from a label widget.Retrieves the label widget for the frame.static longstatic TypeSystem.TypeSizebooleanReturns whether the expander will resize the toplevel widget
containing the expander upon resizing and collpasing.static longstatic TypeSystem.TypeSizebooleanReturns whether the label’s text is interpreted as Pango markup.booleanReturns whether an underline in the text indicates a mnemonic.static ExpandernewWithMnemonicExpander(Str label) Creates a new expander using @label as the text of the label.static ExpandernewWithMnemonicExpander(String label) Creates a new expander using @label as the text of the label.onActivate(Expander.OnActivate signal) Connect to signal "activate".voidSets the child widget of @expander.voidsetExpanded(boolean expanded) Sets the state of the expander.voidSets the text of the label of the expander to @label.voidSets the text of the label of the expander to @label.voidsetLabelWidget(Widget label_widget) Set the label widget for the expander.voidsetResizeToplevel(boolean resize_toplevel) Sets whether the expander will resize the toplevel widget
containing the expander upon resizing and collpasing.voidsetUseMarkup(boolean use_markup) Sets whether the text of the label contains Pango markup.voidsetUseUnderline(boolean use_underline) If true, an underline in the text indicates a mnemonic.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, 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, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlagsMethods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnrefMethods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacksMethods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNullMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_ACTIVATE
- See Also:
-
-
Constructor Details
-
Expander
-
Expander
Creates a new expander using @label as the text of the label.- Parameters:
label- the text of the label
-
Expander
Creates a new expander using @label as the text of the label.- Parameters:
label- the text of the label
-
-
Method Details
-
getClassHandler
-
newWithMnemonicExpander
Creates a new expander using @label as the text of the label.
If characters in @label are preceded by an underscore, they are
underlined. If you need a literal underscore character in a label,
use “__” (two underscores). The first underlined character represents
a keyboard accelerator called a mnemonic.
Pressing Alt and that key activates the button.- Parameters:
label- the text of the label with an underscore in front of the mnemonic character- Returns:
- a new `GtkExpander` widget.
-
newWithMnemonicExpander
Creates a new expander using @label as the text of the label.
If characters in @label are preceded by an underscore, they are
underlined. If you need a literal underscore character in a label,
use “__” (two underscores). The first underlined character represents
a keyboard accelerator called a mnemonic.
Pressing Alt and that key activates the button.- Parameters:
label- the text of the label with an underscore in front of the mnemonic character- Returns:
- a new `GtkExpander` widget.
-
getChild
Gets the child widget of @expander.- Returns:
- the child widget of @expander
-
getExpanded
public boolean getExpanded()Queries a `GtkExpander` and returns its current state.
Returns %TRUE if the child widget is revealed.- Returns:
- the current state of the expander
-
getLabel
Fetches the text from a label widget.
This is including any embedded underlines indicating mnemonics and
Pango markup, as set by [method@Gtk.Expander.set_label]. If the label
text has not been set the return value will be %NULL. This will be the
case if you create an empty button with gtk_button_new() to use as a
container.- Returns:
- The text of the label widget. This string is owned by the widget and must not be modified or freed.
-
getLabelWidget
Retrieves the label widget for the frame.- Returns:
- the label widget
-
getResizeToplevel
public boolean getResizeToplevel()Returns whether the expander will resize the toplevel widget
containing the expander upon resizing and collpasing.- Returns:
- the “resize toplevel” setting.
-
getUseMarkup
public boolean getUseMarkup()Returns whether the label’s text is interpreted as Pango markup.- Returns:
- %TRUE if the label’s text will be parsed for markup
-
getUseUnderline
public boolean getUseUnderline()Returns whether an underline in the text indicates a mnemonic.- Returns:
- %TRUE if an embedded underline in the expander label indicates the mnemonic accelerator keys
-
setChild
Sets the child widget of @expander.- Parameters:
child- the child widget
-
setExpanded
public void setExpanded(boolean expanded) Sets the state of the expander.
Set to %TRUE, if you want the child widget to be revealed,
and %FALSE if you want the child widget to be hidden.- Parameters:
expanded- whether the child widget is revealed
-
setLabel
Sets the text of the label of the expander to @label.
This will also clear any previously set labels.- Parameters:
label- a string
-
setLabel
Sets the text of the label of the expander to @label.
This will also clear any previously set labels.- Parameters:
label- a string
-
setLabelWidget
Set the label widget for the expander.
This is the widget that will appear embedded alongside
the expander arrow.- Parameters:
label_widget- the new label widget
-
setResizeToplevel
public void setResizeToplevel(boolean resize_toplevel) Sets whether the expander will resize the toplevel widget
containing the expander upon resizing and collpasing.- Parameters:
resize_toplevel- whether to resize the toplevel
-
setUseMarkup
public void setUseMarkup(boolean use_markup) Sets whether the text of the label contains Pango markup.- Parameters:
use_markup- %TRUE if the label’s text should be parsed for markup
-
setUseUnderline
public void setUseUnderline(boolean use_underline) If true, an underline in the text indicates a mnemonic.- Parameters:
use_underline- %TRUE if underlines in the text indicate mnemonics
-
onActivate
Connect to signal "activate".
SeeExpander.OnActivate.onActivate()for signal description.
FieldSIGNAL_ON_ACTIVATEcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
asAccessible
Implements interfaceAccessible. Call this to get access to interface functions.- Overrides:
asAccessiblein classWidget- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable. Call this to get access to interface functions.- Overrides:
asBuildablein classWidget- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget. Call this to get access to interface functions.- Overrides:
asConstraintTargetin classWidget- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-