1.169 <GtkSearchEntry>

Class: <GtkSearchEntry>

It derives from <GtkWidget>.

A single-line text entry widget for use as a search entry.

The main API for interacting with a <GtkSearchEntry> as entry is the <GtkEditable> interface.

It will show an inactive symbolic “find” icon when the search entry is empty, and a symbolic “clear” icon when there is text. Clicking on the “clear” icon will empty the search entry.

To make filtering appear more reactive, it is a good idea to not react to every change in the entry text immediately, but only after a short delay. To support this, <GtkSearchEntry> emits the search-entry:search-changed signal which can be used instead of the editable:changed signal.

The search-entry:previous-match, search-entry:next-match and search-entry:stop-search signals can be used to implement moving between search results and ending the search.

Often, <GtkSearchEntry> will be fed events by means of being placed inside a <GtkSearchBar>. If that is not the case, you can use search-entry:set-key-capture-widget to let it capture key input from another widget.

<GtkSearchEntry> provides only minimal API and should be used with the <GtkEditable> API.

Shortcuts and Gestures

The following signals have default keybindings:

CSS Nodes

entry.search
╰── text

<GtkSearchEntry> has a single CSS node with name entry that carries a .search style class, and the text node is a child of that.

Accessibility

<GtkSearchEntry> uses the Gtk.AccessibleRole.search_box role.

Properties

Property: search-entry:activates-default self

Whether to activate the default widget when Enter is pressed.

Its value is a boolean.

Set it with (set! (search-entry:activates-default self) value).

Property: search-entry:input-hints self

The hints about input for the <GtkSearchEntry> used to alter the behaviour of input methods.

Its value is a <GtkInputHints> (or, to set it, a list of its symbols, or one of them).

Set it with (set! (search-entry:input-hints self) value).

Property: search-entry:input-purpose self

The purpose for the <GtkSearchEntry> input used to alter the behaviour of input methods.

Its value is a <GtkInputPurpose> (or, to set it, one of its symbols).

Set it with (set! (search-entry:input-purpose self) value).

Property: search-entry:key-capture-widget self

The widget that the entry will use to capture key events.

Key events are consumed by the search entry to start or continue a search.

Its value is a <GtkWidget>, or #f.

Set it with (set! (search-entry:key-capture-widget self) value).

Property: search-entry:placeholder-text self

The text that will be displayed in the <GtkSearchEntry> when it is empty and unfocused.

Its value is a string, or #f.

Set it with (set! (search-entry:placeholder-text self) value).

Property: search-entry:search-delay self

The delay in milliseconds from last keypress to the search changed signal.

Its value is an unsigned 32-bit integer.

Set it with (set! (search-entry:search-delay self) value).

Procedures

Method: search-entry:get-input-hints self ⇒ %return
Method: get-input-hints self ⇒ %return

Gets the input purpose for self.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

%return

Returned: a <GtkInputHints>.

The input hints

Method: search-entry:get-input-purpose self ⇒ %return
Method: get-input-purpose self ⇒ %return

Gets the input purpose of self.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

%return

Returned: a <GtkInputPurpose>.

The input hints

Method: search-entry:get-key-capture-widget self ⇒ %return
Method: get-key-capture-widget self ⇒ %return

Gets the widget that self is capturing key events from.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

%return

Returned: a <GtkWidget>, or #f.

The key capture widget.

Method: search-entry:get-placeholder-text self ⇒ %return
Method: get-placeholder-text self ⇒ %return

Gets the placeholder text associated with self.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

%return

Returned: a string, or #f.

The placeholder text.

Method: search-entry:get-search-delay self ⇒ %return
Method: get-search-delay self ⇒ %return

Get the delay to be used between the last keypress and the search-entry:search-changed signal being emitted.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

%return

Returned: an unsigned 32-bit integer.

a delay in milliseconds.

Procedure: search-entry:new ⇒ %return

Creates a <GtkSearchEntry>.

%return

Returned: a <GtkWidget>.

a new <GtkSearchEntry>

Method: search-entry:set-input-hints self hints
Method: set-input-hints self hints

Sets the input hints for self.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

hints

Passed: a <GtkInputHints>, or a list of its symbols, or one of them.

the new input hints

Method: search-entry:set-input-purpose self purpose
Method: set-input-purpose self purpose

Sets the input purpose of self.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

purpose

Passed: a <GtkInputPurpose>, or one of its symbols.

the new input purpose

Method: search-entry:set-key-capture-widget self [widget]
Method: set-key-capture-widget self [widget]

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

Key events are consumed by the search entry to start or continue a search.

If the entry is part of a <GtkSearchBar>, it is preferable to call search-bar:set-key-capture-widget instead, which will reveal the entry in addition to triggering the search entry.

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

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

widget

Passed, or left out: a <GtkWidget>, or #f.

a <GtkWidget>

Method: search-entry:set-placeholder-text self [text]
Method: set-placeholder-text self [text]

Sets the placeholder text associated with self.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

text

Passed, or left out: a string, or #f.

the text to set as a placeholder

Method: search-entry:set-search-delay self delay
Method: set-search-delay self delay

Set the delay to be used between the last keypress and the search-entry:search-changed signal being emitted.

self

Passed: a <GtkSearchEntry>.

a <GtkSearchEntry>

delay

Passed: an unsigned 32-bit integer.

a delay in milliseconds

Signals

Signal: search-entry:activate

Connect a handler with (connect object search-entry:activate handler). It is called as (handler self).

Emitted when the entry is activated.

The keybindings for this signal are all forms of the Enter key.

self

Passed: a <GtkSearchEntry>.

Signal: search-entry:next-match

Connect a handler with (connect object search-entry:next-match handler). It is called as (handler self).

Emitted when the user initiates a move to the next match for the current search string.

This is a keybinding signal.

Applications should connect to it, to implement moving between matches.

The default bindings for this signal is Ctrl+g.

self

Passed: a <GtkSearchEntry>.

Signal: search-entry:previous-match

Connect a handler with (connect object search-entry:previous-match handler). It is called as (handler self).

Emitted when the user initiates a move to the previous match for the current search string.

This is a keybinding signal.

Applications should connect to it, to implement moving between matches.

The default bindings for this signal is Ctrl+Shift+g.

self

Passed: a <GtkSearchEntry>.

Signal: search-entry:search-changed

Connect a handler with (connect object search-entry:search-changed handler). It is called as (handler self).

Emitted with a delay. The length of the delay can be changed with the search-entry:search-delay property.

self

Passed: a <GtkSearchEntry>.

Signal: search-entry:search-started

Connect a handler with (connect object search-entry:search-started handler). It is called as (handler self).

Emitted when the user initiated a search on the entry.

self

Passed: a <GtkSearchEntry>.

Signal: search-entry:stop-search

Connect a handler with (connect object search-entry:stop-search handler). It is called as (handler self).

Emitted when the user stops a search via keyboard input.

This is a keybinding signal.

Applications should connect to it, to implement hiding the search entry in this case.

The default bindings for this signal is Escape.

self

Passed: a <GtkSearchEntry>.