Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: SearchBar

[34:7] extends: object

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 [method@Gtk.SearchBar.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 [method@Gtk.SearchBar.connect_entry]. ## Creating a search bar 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 [enum@Gtk.AccessibleRole.search] role.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • SearchBar ()

    Creates a GtkSearchBar. You will need to tell it about which widget is going to be your text entry using [method@Gtk.SearchBar.connect_entry].

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asWidget ()

    Wraps this handle as Widget.

    • @r A Widget object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setChild (object Value)

    The child widget.

    • @p Value is the new property value.
    • @r None.
  • setKeycapturewidget (object Value)

    The key capture widget.

    • @p Value is the new property value.
    • @r None.
  • setSearchmodeenabled (bool Value)

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

    • @p Value is the new property value.
    • @r None.
  • setShowclosebutton (bool Value)

    Whether to show the close button in the search bar.

    • @p Value is the new property value.
    • @r None.
  • connect_entry (object entry)

    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).

    • @p entry is a GtkEditable.
    • @r None.
  • get_child ()

    Gets the child widget of @bar.

  • get_key_capture_widget ()

    Gets the widget that @bar is capturing key events from.

  • get_search_mode ()

    Returns whether the search mode is on or off.

  • get_show_close_button ()

    Returns whether the close button is shown.

  • set_child (object child)

    Sets the child widget of @bar.

    • @p child is the child widget.
    • @r None.
  • set_key_capture_widget (object widget)

    Sets @widget as the widget that @bar 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 [method@Gtk.EventControllerKey.forward].

    • @p widget is a GtkWidget.
    • @r None.
  • set_search_mode (bool search_mode)

    Switches the search mode on or off.

    • @p search_mode is the new state of the search mode.
    • @r None.
  • set_show_close_button (bool visible)

    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.

    • @p visible is whether the close button will be shown or not.
    • @r None.

class: SearchBarMeta

[313:14] static extends: object

Generated metadata helpers for SearchBar class surfaces.

Methods

  • properties ()

    Returns property metadata for SearchBar.

    • @r A list.