gtk.search_bar

Module for [SearchBar] class

Types 3

gtk.search_bar.SearchBar is a container made to have a search entry.

!An example GtkSearchBar

It can also contain additional widgets, such as drop-down menus, or buttons. The search bar would appear when a search is started through typing on the keyboard, or the application’s search mode is toggled on.

For keyboard presses to start a search, the search bar must be told of a widget to capture key events from through gtk.search_bar.SearchBar.setKeyCaptureWidget. This widget will typically be the top-level window, or a parent container of the search bar. Common shortcuts such as Ctrl+F should be handled as an application action, or through the menu items.

You will also need to tell the search bar about which entry you are using as your search entry using gtk.search_bar.SearchBar.connectEntry.

Creating a search bar

The following example shows you how to create a more complex search entry.

A simple example

CSS nodes

searchbar
╰── revealer
    ╰── box
         ├── [child]
         ╰── [button.close]

gtk.search_bar.SearchBar has a main CSS node with name searchbar. It has a child node with name revealer that contains a node with name box. The box node contains both the CSS node of the child widget as well as an optional button node which gets the .close style class applied.

Accessibility

gtk.search_bar.SearchBar uses the gtk.types.AccessibleRole.Search role.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
SearchBar self() nothrowReturns `this`, for use in `with` statements.
SearchBarGidBuilder builder() static nothrowGet builder for [gtk.search_bar.SearchBar] Returns: New builder object
gtk.widget.Widget child() @property nothrowGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget.
gtk.widget.Widget keyCaptureWidget() @property nothrowGet `keyCaptureWidget` property. Returns: The key capture widget.
void keyCaptureWidget(gtk.widget.Widget propval) @property nothrowSet `keyCaptureWidget` property. Params: propval = The key capture widget.
bool searchModeEnabled() @property nothrowGet `searchModeEnabled` property. Returns: Whether the search mode is on and the search bar shown.
void searchModeEnabled(bool propval) @property nothrowSet `searchModeEnabled` property. Params: propval = Whether the search mode is on and the search bar shown.
bool showCloseButton() @property nothrowGet `showCloseButton` property. Returns: Whether to show the close button in the search bar.
void showCloseButton(bool propval) @property nothrowSet `showCloseButton` property. Params: propval = Whether to show the close button in the search bar.
void connectEntry(gtk.editable.Editable entry) nothrowConnects the [gtk.editable.Editable] widget passed as the one to be used in this search bar.
gtk.widget.Widget getChild() nothrowGets the child widget of bar. Returns: the child widget of bar
gtk.widget.Widget getKeyCaptureWidget() nothrowGets the widget that bar is capturing key events from. Returns: The key capture widget.
bool getSearchMode() nothrowReturns whether the search mode is on or off. Returns: whether search mode is toggled on
bool getShowCloseButton() nothrowReturns whether the close button is shown. Returns: whether the close button is shown
void setChild(gtk.widget.Widget child = null) nothrowSets the child widget of bar.
void setKeyCaptureWidget(gtk.widget.Widget widget = null) nothrowSets widget as the widget that bar will capture key events from.
void setSearchMode(bool searchMode) nothrowSwitches the search mode on or off.
void setShowCloseButton(bool visible) nothrowShows or hides the close button.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a [gtk.search_bar.SearchBar].

Fluent builder implementation template for gtk.search_bar.SearchBar

Methods
T child(gtk.widget.Widget propval) nothrowSet `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T keyCaptureWidget(gtk.widget.Widget propval) nothrowSet `keyCaptureWidget` property. Params: propval = The key capture widget. Returns: Builder instance for fluent chaining
T searchModeEnabled(bool propval) nothrowSet `searchModeEnabled` property. Params: propval = Whether the search mode is on and the search bar shown. Returns: Builder instance for fluent chaining
T showCloseButton(bool propval) nothrowSet `showCloseButton` property. Params: propval = Whether to show the close button in the search bar. Returns: Builder instance for fluent chaining

Fluent builder for gtk.search_bar.SearchBar

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