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.

!An example GtkDropDown

The gtk.drop_down.DropDown displays the 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.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
DropDown self() nothrowReturns `this`, for use in `with` statements.
DropDownGidBuilder builder() static nothrowGet builder for [gtk.drop_down.DropDown] Returns: New builder object
bool enableSearch() @property nothrowGet `enableSearch` property. Returns: Whether to show a search entry in the popup.
void enableSearch(bool propval) @property nothrowSet `enableSearch` property. Params: propval = Whether to show a search entry in the popup.
gtk.expression.Expression expression() @property nothrowGet `expression` property. Returns: An expression to evaluate to obtain strings to match against the search term.
void expression(gtk.expression.Expression propval) @property nothrowSet `expression` property. Params: propval = An expression to evaluate to obtain strings to match against the search term.
gtk.list_item_factory.ListItemFactory factory() @property nothrowGet `factory` property. Returns: Factory for populating list items.
void factory(gtk.list_item_factory.ListItemFactory propval) @property nothrowSet `factory` property. Params: propval = Factory for populating list items.
gtk.list_item_factory.ListItemFactory headerFactory() @property nothrowGet `headerFactory` property. Returns: The factory for creating header widgets for the popup.
void headerFactory(gtk.list_item_factory.ListItemFactory propval) @property nothrowSet `headerFactory` property. Params: propval = The factory for creating header widgets for the popup.
gtk.list_item_factory.ListItemFactory listFactory() @property nothrowGet `listFactory` property. Returns: The factory for populating list items in the popup.
void listFactory(gtk.list_item_factory.ListItemFactory propval) @property nothrowSet `listFactory` property. Params: propval = The factory for populating list items in the popup.
gio.list_model.ListModel model() @property nothrowGet `model` property. Returns: Model for the displayed items.
void model(gio.list_model.ListModel propval) @property nothrowSet `model` property. Params: propval = Model for the displayed items.
gtk.types.StringFilterMatchMode searchMatchMode() @property nothrowGet `searchMatchMode` property. Returns: The match mode for the search filter.
void searchMatchMode(gtk.types.StringFilterMatchMode propval) @property nothrowSet `searchMatchMode` property. Params: propval = The match mode for the search filter.
uint selected() @property nothrowGet `selected` property. Returns: The position of the selected item.
void selected(uint propval) @property nothrowSet `selected` property. Params: propval = The position of the selected item.
gobject.object.ObjectWrap selectedItem() @property nothrowGet `selectedItem` property. Returns: The selected item.
bool showArrow() @property nothrowGet `showArrow` property. Returns: Whether to show an arrow within the GtkDropDown widget.
void showArrow(bool propval) @property nothrowSet `showArrow` property. Params: propval = Whether to show an arrow within the GtkDropDown widget.
gtk.drop_down.DropDown newFromStrings(string[] strings) static nothrowCreates a new [gtk.drop_down.DropDown] that is populated with the strings.
bool getEnableSearch() nothrowReturns whether search is enabled. Returns: true if the popup includes a search entry
gtk.expression.Expression getExpression() nothrowGets the expression set that is used to obtain strings from items.
gtk.list_item_factory.ListItemFactory getFactory() nothrowGets the factory that's currently used to populate list items.
gtk.list_item_factory.ListItemFactory getHeaderFactory() nothrowGets the factory that's currently used to create header widgets for the popup. Returns: The factory in use
gtk.list_item_factory.ListItemFactory getListFactory() nothrowGets the factory that's currently used to populate list items in the popup. Returns: The factory in use
gio.list_model.ListModel getModel() nothrowGets the model that provides the displayed items. Returns: The model in use
gtk.types.StringFilterMatchMode getSearchMatchMode() nothrowReturns the match mode that the search filter is using. Returns: the match mode of the search filter
uint getSelected() nothrowGets the position of the selected item. Returns: the position of the selected item, or [gtk.types.INVALID_LIST_POSITION] if not item is selected
gobject.object.ObjectWrap getSelectedItem() nothrowGets the selected item. If no item is selected, null is returned. Returns: The selected item
bool getShowArrow() nothrowReturns whether to show an arrow within the widget. Returns: true if an arrow will be shown.
void setEnableSearch(bool enableSearch) nothrowSets 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) nothrowSets the expression that gets evaluated to obtain strings from items.
void setFactory(gtk.list_item_factory.ListItemFactory factory = null) nothrowSets the [gtk.list_item_factory.ListItemFactory] to use for populating list items.
void setHeaderFactory(gtk.list_item_factory.ListItemFactory factory = null) nothrowSets the [gtk.list_item_factory.ListItemFactory] to use for creating header widgets for the popup.
void setListFactory(gtk.list_item_factory.ListItemFactory factory = null) nothrowSets the [gtk.list_item_factory.ListItemFactory] to use for populating list items in the popup.
void setModel(gio.list_model.ListModel model = null) nothrowSets the [gio.list_model.ListModel] to use.
void setSearchMatchMode(gtk.types.StringFilterMatchMode searchMatchMode) nothrowSets the match mode for the search filter.
void setSelected(uint position) nothrowSelects the item at the given position.
void setShowArrow(bool showArrow) nothrowSets 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) nothrowConnect to `Activate` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(gio.list_model.ListModel model = null, gtk.expression.Expression expression = null)Creates a new [gtk.drop_down.DropDown].

Fluent builder implementation template for gtk.drop_down.DropDown

Methods
T enableSearch(bool propval) nothrowSet `enableSearch` property. Params: propval = Whether to show a search entry in the popup.
T expression(gtk.expression.Expression propval) nothrowSet `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) nothrowSet `factory` property. Params: propval = Factory for populating list items. Returns: Builder instance for fluent chaining
T headerFactory(gtk.list_item_factory.ListItemFactory propval) nothrowSet `headerFactory` property. Params: propval = The factory for creating header widgets for the popup. Returns: Builder instance for fluent chaining
T listFactory(gtk.list_item_factory.ListItemFactory propval) nothrowSet `listFactory` property. Params: propval = The factory for populating list items in the popup.
T model(gio.list_model.ListModel propval) nothrowSet `model` property. Params: propval = Model for the displayed items. Returns: Builder instance for fluent chaining
T searchMatchMode(gtk.types.StringFilterMatchMode propval) nothrowSet `searchMatchMode` property. Params: propval = The match mode for the search filter. Returns: Builder instance for fluent chaining
T selected(uint propval) nothrowSet `selected` property. Params: propval = The position of the selected item.
T showArrow(bool propval) nothrowSet `showArrow` property. Params: propval = Whether to show an arrow within the GtkDropDown widget. Returns: Builder instance for fluent chaining

Fluent builder for gtk.drop_down.DropDown

Methods
DropDown build() nothrowCreate object from builder. Returns: New object