Package: gtk

Class gtk:search-bar

Superclasses

Documented Subclasses

None

Direct Slots

child
The child property of type gtk:widget (Read / Write / Construct)
The child widget of the search bar.
key-capture-widget
The key-capture-widget property of type gtk:widget (Read / Write / Construct)
The widget that the search bar will capture key events from.
search-mode-enabled
The search-mode-enabled property of type :boolean (Read / Write)
Whether the search mode is on and the search bar shown.
Default value: false
show-close-button
The show-close-button property of type :boolean (Read / Write / Construct)
Whether to show the Close button in the toolbar.
Default value: false

Details

The gtk:search-bar widget is a container made to have a search entry. 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 search mode of the application is toggled on.

Figure: GtkSearchBar

For keyboard presses to start a search, the search bar must be told of a widget to capture key events from through the gtk:search-bar-key-capture-widget function. This widget will typically be the toplevel 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 the gtk:search-bar-connect-entry function.

Examples

The following example shows you how to create a more complex search entry.
(defun do-search-bar (&optional application)
  (let* ((box (make-instance 'gtk:box
                             :orientation :horizontal
                             :spacing 6))
         (searchbar (make-instance 'gtk:search-bar
                                   :child box
                                   :valign :start))
         (window (make-instance 'gtk:window
                                :title "Search Bar"
                                :application application
                                :child searchbar))
         (entry (make-instance 'gtk:search-entry
                               :hexpand t))
         (button (make-instance 'gtk:menu-button)))
    (gtk:search-bar-connect-entry searchbar entry)
    (setf (gtk:search-bar-key-capture-widget searchbar) window)
    (gtk:box-append box entry)
    (gtk:box-append box button)
    (gtk:window-present window)))    

CSS nodes

searchbar
╰── revealer
    ╰── box
         ├── [child]
         ╰── [button.close]    
The gtk:search-bar implementation has a single 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

The gtk:search-bar implementation uses the :search role of the gtk:accessible-role enumeration.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2024-4-20