Class

GtkSearchBar

[]

Description [src]

final class Gtk.SearchBar : Gtk.Widget
  implements Gtk.Accessible, Gtk.Buildable, Gtk.ConstraintTarget {
  /* No available fields */
}

Reveals a search entry when search is started.

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_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 gtk_search_bar_connect_entry().

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

A simple example

Shortcuts and Gestures

GtkSearchBar supports the following keyboard shortcuts:

  • Escape hides the search bar.

CSS nodes

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.

Accessibility

GtkSearchBar uses the GTK_ACCESSIBLE_ROLE_SEARCH role.

[]

Hierarchy

hierarchy this GtkSearchBar implements_0 GtkAccessible this--implements_0 implements_1 GtkBuildable this--implements_1 implements_2 GtkConstraintTarget this--implements_2 ancestor_0 GtkWidget ancestor_0--this ancestor_1 GInitiallyUnowned ancestor_1--ancestor_0 ancestor_2 GObject ancestor_2--ancestor_1
[]

Constructors

gtk_search_bar_new

Creates a GtkSearchBar.

[]

Instance methods

gtk_search_bar_connect_entry

Connects the GtkEditable widget passed as the one to be used in this search bar.

gtk_search_bar_get_child

Gets the child widget of bar.

gtk_search_bar_get_key_capture_widget

Gets the widget that bar is capturing key events from.

gtk_search_bar_get_search_mode

Returns whether the search mode is on or off.

gtk_search_bar_get_show_close_button

Returns whether the close button is shown.

gtk_search_bar_set_child

Sets the child widget of bar.

gtk_search_bar_set_key_capture_widget

Sets widget as the widget that bar will capture key events from.

gtk_search_bar_set_search_mode

Switches the search mode on or off.

gtk_search_bar_set_show_close_button

Shows or hides the close button.

Methods inherited from GtkWidget (164)
Methods inherited from GObject (43)
Methods inherited from GtkAccessible (20)
Methods inherited from GtkBuildable (1)
[]

Properties

Gtk.SearchBar:child

The child widget.

Gtk.SearchBar:key-capture-widget

The key capture widget.

Gtk.SearchBar:search-mode-enabled

Whether the search mode is on and the search bar shown.

Gtk.SearchBar:show-close-button

Whether to show the close button in the search bar.

Properties inherited from GtkWidget (35)
Properties inherited from GtkAccessible (1)
[]

Signals

Signals inherited from GtkWidget (13)
Signals inherited from GObject (1)