gtk.drop_down
Module for [DropDown] class
Types 3
[gtk.drop_down.DropDown] is a widget that allows the user to choose an item from a list of options.
The [gtk.drop_down.DropDown] displays the [selected][gtk.drop_down.DropDown.selected] choice.
The options are given to [gtk.drop_down.DropDown] in the form of [gio.list_model.ListModel] and how the individual options are represented is determined by a [gtk.list_item_factory.ListItemFactory]. The default factory displays simple strings, and adds a checkmark to the selected item in the popup.
To set your own factory, use [gtk.drop_down.DropDown.setFactory]. It is possible to use a separate factory for the items in the popup, with [gtk.drop_down.DropDown.setListFactory].
[gtk.drop_down.DropDown] knows how to obtain strings from the items in a [gtk.string_list.StringList]; for other models, you have to provide an expression to find the strings via [gtk.drop_down.DropDown.setExpression].
[gtk.drop_down.DropDown] can optionally allow search in the popup, which is useful if the list of options is long. To enable the search entry, use [gtk.drop_down.DropDown.setEnableSearch].
Here is a UI definition example for [gtk.drop_down.DropDown] with a simple model:
<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>If a [gtk.drop_down.DropDown] is created in this manner, or with [gtk.drop_down.DropDown.newFromStrings], for instance, the object returned from [gtk.drop_down.DropDown.getSelectedItem] will be a [gtk.string_object.StringObject].
To learn more about the list widget framework, see the
overview.CSS nodes
[gtk.drop_down.DropDown] has a single CSS node with name dropdown, with the button and popover nodes as children.
Accessibility
[gtk.drop_down.DropDown] uses the [gtk.types.AccessibleRole.ComboBox] role.
DropDownGidBuilder builder()Get builder for [gtk.drop_down.DropDown] Returns: New builder objectbool enableSearch() @propertyGet `enableSearch` property. Returns: Whether to show a search entry in the popup.void enableSearch(bool propval) @propertySet `enableSearch` property. Params: propval = Whether to show a search entry in the popup.gtk.expression.Expression expression() @propertyGet `expression` property. Returns: An expression to evaluate to obtain strings to match against the search term.void expression(gtk.expression.Expression propval) @propertySet `expression` property. Params: propval = An expression to evaluate to obtain strings to match against the search term.gtk.list_item_factory.ListItemFactory factory() @propertyGet `factory` property. Returns: Factory for populating list items.void factory(gtk.list_item_factory.ListItemFactory propval) @propertySet `factory` property. Params: propval = Factory for populating list items.gtk.list_item_factory.ListItemFactory headerFactory() @propertyGet `headerFactory` property. Returns: The factory for creating header widgets for the popup.void headerFactory(gtk.list_item_factory.ListItemFactory propval) @propertySet `headerFactory` property. Params: propval = The factory for creating header widgets for the popup.gtk.list_item_factory.ListItemFactory listFactory() @propertyGet `listFactory` property. Returns: The factory for populating list items in the popup.void listFactory(gtk.list_item_factory.ListItemFactory propval) @propertySet `listFactory` property. Params: propval = The factory for populating list items in the popup.gio.list_model.ListModel model() @propertyGet `model` property. Returns: Model for the displayed items.void model(gio.list_model.ListModel propval) @propertySet `model` property. Params: propval = Model for the displayed items.gtk.types.StringFilterMatchMode searchMatchMode() @propertyGet `searchMatchMode` property. Returns: The match mode for the search filter.void searchMatchMode(gtk.types.StringFilterMatchMode propval) @propertySet `searchMatchMode` property. Params: propval = The match mode for the search filter.void selected(uint propval) @propertySet `selected` property. Params: propval = The position of the selected item.gobject.object.ObjectWrap selectedItem() @propertyGet `selectedItem` property. Returns: The selected item.bool showArrow() @propertyGet `showArrow` property. Returns: Whether to show an arrow within the GtkDropDown widget.void showArrow(bool propval) @propertySet `showArrow` property. Params: propval = Whether to show an arrow within the GtkDropDown widget.gtk.drop_down.DropDown newFromStrings(string[] strings)Creates a new [gtk.drop_down.DropDown] that is populated with the strings.bool getEnableSearch()Returns whether search is enabled. Returns: true if the popup includes a search entrygtk.expression.Expression getExpression()Gets the expression set that is used to obtain strings from items.gtk.list_item_factory.ListItemFactory getFactory()Gets the factory that's currently used to populate list items.gtk.list_item_factory.ListItemFactory getHeaderFactory()Gets the factory that's currently used to create header widgets for the popup. Returns: The factory in usegtk.list_item_factory.ListItemFactory getListFactory()Gets the factory that's currently used to populate list items in the popup. Returns: The factory in usegio.list_model.ListModel getModel()Gets the model that provides the displayed items. Returns: The model in usegtk.types.StringFilterMatchMode getSearchMatchMode()Returns the match mode that the search filter is using. Returns: the match mode of the search filteruint getSelected()Gets the position of the selected item. Returns: the position of the selected item, or [gtk.types.INVALIDLISTPOSITION] if not item is selectedgobject.object.ObjectWrap getSelectedItem()Gets the selected item. If no item is selected, null is returned. Returns: The selected itembool getShowArrow()Returns whether to show an arrow within the widget. Returns: true if an arrow will be shown.void setEnableSearch(bool enableSearch)Sets whether a search entry will be shown in the popup that allows to search for items in the list.void setExpression(gtk.expression.Expression expression = null)Sets the expression that gets evaluated to obtain strings from items.void setFactory(gtk.list_item_factory.ListItemFactory factory = null)Sets the [gtk.listitemfactory.ListItemFactory] to use for populating list items.void setHeaderFactory(gtk.list_item_factory.ListItemFactory factory = null)Sets the [gtk.listitemfactory.ListItemFactory] to use for creating header widgets for the popup.void setListFactory(gtk.list_item_factory.ListItemFactory factory = null)Sets the [gtk.listitemfactory.ListItemFactory] to use for populating list items in the popup.void setModel(gio.list_model.ListModel model = null)Sets the [gio.list_model.ListModel] to use.void setSearchMatchMode(gtk.types.StringFilterMatchMode searchMatchMode)Sets the match mode for the search filter.void setSelected(uint position)Selects the item at the given position.void setShowArrow(bool showArrow)Sets whether an arrow will be displayed within the widget.gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.drop_down.DropDown)))
&& Parameters!T.length < 2)Connect to `Activate` signal.this(gio.list_model.ListModel model = null, gtk.expression.Expression expression = null)Creates a new [gtk.drop_down.DropDown].T enableSearch(bool propval)Set `enableSearch` property. Params: propval = Whether to show a search entry in the popup.T expression(gtk.expression.Expression propval)Set `expression` property. Params: propval = An expression to evaluate to obtain strings to match against the search term.T factory(gtk.list_item_factory.ListItemFactory propval)Set `factory` property. Params: propval = Factory for populating list items. Returns: Builder instance for fluent chainingT headerFactory(gtk.list_item_factory.ListItemFactory propval)Set `headerFactory` property. Params: propval = The factory for creating header widgets for the popup. Returns: Builder instance for fluent chainingT listFactory(gtk.list_item_factory.ListItemFactory propval)Set `listFactory` property. Params: propval = The factory for populating list items in the popup.T model(gio.list_model.ListModel propval)Set `model` property. Params: propval = Model for the displayed items. Returns: Builder instance for fluent chainingT searchMatchMode(gtk.types.StringFilterMatchMode propval)Set `searchMatchMode` property. Params: propval = The match mode for the search filter. Returns: Builder instance for fluent chainingT selected(uint propval)Set `selected` property. Params: propval = The position of the selected item.T showArrow(bool propval)Set `showArrow` property. Params: propval = Whether to show an arrow within the GtkDropDown widget. Returns: Builder instance for fluent chaining