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 _gType() @property
SearchBar self()Returns `this`, for use in `with` statements.
SearchBarGidBuilder builder()Get builder for [gtk.search_bar.SearchBar] Returns: New builder object
gtk.widget.Widget child() @propertyGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget.
gtk.widget.Widget keyCaptureWidget() @propertyGet `keyCaptureWidget` property. Returns: The key capture widget.
void keyCaptureWidget(gtk.widget.Widget propval) @propertySet `keyCaptureWidget` property. Params: propval = The key capture widget.
bool searchModeEnabled() @propertyGet `searchModeEnabled` property. Returns: Whether the search mode is on and the search bar shown.
void searchModeEnabled(bool propval) @propertySet `searchModeEnabled` property. Params: propval = Whether the search mode is on and the search bar shown.
bool showCloseButton() @propertyGet `showCloseButton` property. Returns: Whether to show the close button in the search bar.
void showCloseButton(bool propval) @propertySet `showCloseButton` property. Params: propval = Whether to show the close button in the search bar.
void connectEntry(gtk.editable.Editable entry)Connects the [gtk.editable.Editable] widget passed as the one to be used in this search bar.
gtk.widget.Widget getChild()Gets the child widget of bar. Returns: the child widget of bar
gtk.widget.Widget getKeyCaptureWidget()Gets the widget that bar is capturing key events from. Returns: The key capture widget.
bool getSearchMode()Returns whether the search mode is on or off. Returns: whether search mode is toggled on
bool getShowCloseButton()Returns whether the close button is shown. Returns: whether the close button is shown
void setChild(gtk.widget.Widget child = null)Sets the child widget of bar.
void setKeyCaptureWidget(gtk.widget.Widget widget = null)Sets widget as the widget that bar will capture key events from.
void setSearchMode(bool searchMode)Switches the search mode on or off.
void setShowCloseButton(bool visible)Shows or hides the close button.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a [gtk.search_bar.SearchBar].
Methods
T child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T keyCaptureWidget(gtk.widget.Widget propval)Set `keyCaptureWidget` property. Params: propval = The key capture widget. Returns: Builder instance for fluent chaining
T searchModeEnabled(bool propval)Set `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)Set `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