gtk.search_bar

Module for [SearchBar] class

Types 3

#GtkSearchBar is a container made to have a search entry (possibly with additional connex widgets, such as drop-down menus, or buttons) built-in. 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, events will need to be forwarded from the top-level window that contains the search bar. See gtk.search_bar.SearchBar.handleEvent for example code. 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. The following example shows you how to create a more complex search entry.

CSS nodes

GtkSearchBar has a single CSS node with name searchbar.

Creating a search bar

A simple example

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
bool searchModeEnabled() @property nothrow
void searchModeEnabled(bool propval) @property nothrow
bool showCloseButton() @property nothrow
void showCloseButton(bool propval) @property nothrow
void connectEntry(gtk.entry.Entry entry) nothrowConnects the #GtkEntry widget passed as the one to be used in this search bar. The entry should be a descendant of the search bar. This is only required if the entry isn’t the direct child of the...
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
bool handleEvent(gdk.event.Event event) nothrowThis function should be called when the top-level window which contains the search bar received a key event.
void setSearchMode(bool searchMode) nothrowSwitches the search mode on or off.
void setShowCloseButton(bool visible) nothrowShows or hides the close button. Applications that already have a “search” toggle button should not show a close button in their search bar, as it duplicates the role of the toggle button.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a #GtkSearchBar. You will need to tell it about which widget is going to be your text entry using [gtk.search_bar.SearchBar.connectEntry]. Returns: a new #GtkSearchBar

Fluent builder implementation template for gtk.search_bar.SearchBar

Methods
T searchModeEnabled(bool propval) nothrow
T showCloseButton(bool propval) nothrow

Fluent builder for gtk.search_bar.SearchBar

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