It derives from <GtkWidget>.
Reveals a search entry when search is started.
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 search-bar:set-key-capture-widget. 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 search-bar:connect-entry.
The following example shows you how to create a more complex search entry.
<GtkSearchBar> supports the following keyboard
shortcuts:
searchbar
╰── revealer
╰── box
├── [child]
╰── [button.close]
<GtkSearchBar> 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.
<GtkSearchBar> uses the
Gtk.AccessibleRole.search role.
The child widget.
Its value is a <GtkWidget>, or #f.
Set it with (set! (search-bar:child self) value).
The key capture widget.
Its value is a <GtkWidget>, or #f.
Set it with (set! (search-bar:key-capture-widget self) value).
Whether the search mode is on and the search bar shown.
Its value is a boolean.
Set it with (set! (search-bar:search-mode-enabled self) value).
Whether to show the close button in the search bar.
Its value is a boolean.
Set it with (set! (search-bar:show-close-button self) value).
Connects the <GtkEditable> widget passed as the
one to be used in this search bar.
The entry should be a descendant of the search bar. Calling this function manually is only required if the entry isn’t the direct child of the search bar (as in our main example).
Passed: a <GtkSearchBar>.
Passed: a <GtkEditable>.
Gets the child widget of self.
Passed: a <GtkSearchBar>.
Returned: a <GtkWidget>, or #f.
the child widget of self
Gets the widget that self is capturing key events from.
Passed: a <GtkSearchBar>.
Returned: a <GtkWidget>, or #f.
The key capture widget.
Returns whether the search mode is on or off.
Passed: a <GtkSearchBar>.
Returned: a boolean.
whether search mode is toggled on
Returns whether the close button is shown.
Passed: a <GtkSearchBar>.
Returned: a boolean.
whether the close button is shown
Creates a <GtkSearchBar>.
You will need to tell it about which widget is going to be your text
entry using search-bar:connect-entry.
Returned: a <GtkWidget>.
a new <GtkSearchBar>
Sets the child widget of self.
Passed: a <GtkSearchBar>.
Passed, or left out: a <GtkWidget>, or #f.
the child widget
Sets widget as the widget that self will capture key events from.
If key events are handled by the search bar, the bar will be shown, and the entry populated with the entered text.
Note that despite the name of this function, the events are only
’captured’ in the bubble phase, which means that editable child widgets
of widget will receive text input before it gets captured. If
that is not desired, you can capture and forward the events yourself
with event-controller-key:forward?.
Passed: a <GtkSearchBar>.
Passed, or left out: a <GtkWidget>, or #f.
Switches the search mode on or off.
Passed: a <GtkSearchBar>.
Passed: a boolean.
the new state of the search mode
Shows 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.
Passed: a <GtkSearchBar>.
Passed: a boolean.
whether the close button will be shown or not