Package ch.bailu.gtk.gtk
Class DropDown
- All Implemented Interfaces:
PointerInterface
`GtkDropDown` is a widget that allows the user to choose an item
from a list of options.
![An example GtkDropDown](drop-down.png)
The `GtkDropDown` displays the selected choice.
The options are given to `GtkDropDown` in the form of `GListModel`
and how the individual options are represented is determined by
a [class@Gtk.ListItemFactory]. The default factory displays simple strings.
`GtkDropDown` knows how to obtain strings from the items in a
[class@Gtk.StringList]; for other models, you have to provide an expression
to find the strings via [method@Gtk.DropDown.set_expression].
`GtkDropDown` can optionally allow search in the popup, which is
useful if the list of options is long. To enable the search entry,
use [method@Gtk.DropDown.set_enable_search].
Here is a UI definition example for `GtkDropDown` with a simple model:
```xml
<object class="GtkDropDown">
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
</property>
</object>
```
# CSS nodes
`GtkDropDown` has a single CSS node with name dropdown,
with the button and popover nodes as children.
# Accessibility
`GtkDropDown` uses the %GTK_ACCESSIBLE_ROLE_COMBO_BOX role.
from a list of options.
![An example GtkDropDown](drop-down.png)
The `GtkDropDown` displays the selected choice.
The options are given to `GtkDropDown` in the form of `GListModel`
and how the individual options are represented is determined by
a [class@Gtk.ListItemFactory]. The default factory displays simple strings.
`GtkDropDown` knows how to obtain strings from the items in a
[class@Gtk.StringList]; for other models, you have to provide an expression
to find the strings via [method@Gtk.DropDown.set_expression].
`GtkDropDown` can optionally allow search in the popup, which is
useful if the list of options is long. To enable the search entry,
use [method@Gtk.DropDown.set_enable_search].
Here is a UI definition example for `GtkDropDown` with a simple model:
```xml
<object class="GtkDropDown">
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
</property>
</object>
```
# CSS nodes
`GtkDropDown` has a single CSS node with name dropdown,
with the button and popover nodes as children.
# Accessibility
`GtkDropDown` uses the %GTK_ACCESSIBLE_ROLE_COMBO_BOX role.
-
Nested Class Summary
Nested 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.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields 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_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionDropDown
(ListModel model, Expression expression) Creates a new `GtkDropDown`.DropDown
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.static ClassHandler
boolean
Returns whether search is enabled.Gets the expression set that is used to obtain strings from items.Gets the factory that's currently used to populate list items.static int
Gets the factory that's currently used to populate list items in the popup.getModel()
Gets the model that provides the displayed items.static long
static TypeSystem.TypeSize
int
Gets the position of the selected item.Gets the selected item.boolean
Returns whether to show an arrow within the widget.static long
static TypeSystem.TypeSize
static DropDown
newFromStringsDropDown
(Strs strings) Creates a new `GtkDropDown` that is populated with
the strings.onActivate
(DropDown.OnActivate signal) Connect to signal "activate".void
setEnableSearch
(boolean enable_search) Sets whether a search entry will be shown in the popup that
allows to search for items in the list.void
setExpression
(Expression expression) Sets the expression that gets evaluated to obtain strings from items.void
setFactory
(ListItemFactory factory) Sets the `GtkListItemFactory` to use for populating list items.void
setListFactory
(ListItemFactory factory) Sets the `GtkListItemFactory` to use for populating list items in the popup.void
Sets the `GListModel` to use.void
setSelected
(int position) Selects the item at the given position.void
setShowArrow
(boolean show_arrow) Sets whether an arrow will be displayed within the widget.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, unsetStateFlags
Methods 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, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_ACTIVATE
- See Also:
-
-
Constructor Details
-
DropDown
-
DropDown
Creates a new `GtkDropDown`.
You may want to call [method@Gtk.DropDown.set_factory]
to set up a way to map its items to widgets.- Parameters:
model
- the model to useexpression
- the expression to use
-
-
Method Details
-
getClassHandler
-
newFromStringsDropDown
Creates a new `GtkDropDown` that is populated with
the strings.- Parameters:
strings
- The strings to put in the dropdown- Returns:
- a new `GtkDropDown`
-
getEnableSearch
public boolean getEnableSearch()Returns whether search is enabled.- Returns:
- %TRUE if the popup includes a search entry
-
getExpression
Gets the expression set that is used to obtain strings from items.
See [method@Gtk.DropDown.set_expression].- Returns:
- a `GtkExpression`
-
getFactory
Gets the factory that's currently used to populate list items.
The factory returned by this function is always used for the
item in the button. It is also used for items in the popup
if [property@Gtk.DropDown:list-factory] is not set.- Returns:
- The factory in use
-
getListFactory
Gets the factory that's currently used to populate list items in the popup.- Returns:
- The factory in use
-
getModel
Gets the model that provides the displayed items.- Returns:
- The model in use
-
getSelected
public int getSelected()Gets the position of the selected item.- Returns:
- the position of the selected item, or %GTK_INVALID_LIST_POSITION if not item is selected
-
getSelectedItem
Gets the selected item. If no item is selected, %NULL is returned.- Returns:
- The selected item
-
getShowArrow
public boolean getShowArrow()Returns whether to show an arrow within the widget.- Returns:
- %TRUE if an arrow will be shown.
-
setEnableSearch
public void setEnableSearch(boolean enable_search) Sets whether a search entry will be shown in the popup that
allows to search for items in the list.
Note that [property@Gtk.DropDown:expression] must be set for
search to work.- Parameters:
enable_search
- whether to enable search
-
setExpression
Sets the expression that gets evaluated to obtain strings from items.
This is used for search in the popup. The expression must have
a value type of %G_TYPE_STRING.- Parameters:
expression
- a `GtkExpression`
-
setFactory
Sets the `GtkListItemFactory` to use for populating list items.- Parameters:
factory
- the factory to use
-
setListFactory
Sets the `GtkListItemFactory` to use for populating list items in the popup.- Parameters:
factory
- the factory to use
-
setModel
Sets the `GListModel` to use.- Parameters:
model
- the model to use
-
setSelected
public void setSelected(int position) Selects the item at the given position.- Parameters:
position
- the position of the item to select, or %GTK_INVALID_LIST_POSITION
-
setShowArrow
public void setShowArrow(boolean show_arrow) Sets whether an arrow will be displayed within the widget.- Parameters:
show_arrow
- whether to show an arrow within the widget
-
onActivate
Connect to signal "activate".
SeeDropDown.OnActivate.onActivate()
for signal description.
FieldSIGNAL_ON_ACTIVATE
contains 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:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-