GtkSearchBar
GtkSearchBar — A toolbar to integrate a search entry with
|
 |
Implemented Interfaces
GtkSearchBar implements
AtkImplementorIface and GtkBuildable.
Includes
#include <gtk/gtk.h>
Description
GtkSearchBar is a container made to have a search entry (possibly
with additional connex widgets, such as drop-down menus, or buttons)
built-in. 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, events will need to be
forwarded from the top-level window that contains the search bar.
See gtk_search_bar_handle_event() for example code. 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.
CSS nodes
GtkSearchBar has a single CSS node with name searchbar.
Functions
gtk_search_bar_connect_entry ()
void
gtk_search_bar_connect_entry (GtkSearchBar *bar,
GtkEntry *entry);
Connects the GtkEntry widget passed as the one to be used in
this search bar. The entry should be a descendant of the search bar.
This is only required if the entry isn’t the direct child of the
search bar (as in our main example).
Since: 3.10
gtk_search_bar_get_search_mode ()
gboolean
gtk_search_bar_get_search_mode (GtkSearchBar *bar);
Returns whether the search mode is on or off.
Returns
whether search mode is toggled on
Since: 3.10
gtk_search_bar_set_search_mode ()
void
gtk_search_bar_set_search_mode (GtkSearchBar *bar,
gboolean search_mode);
Switches the search mode on or off.
Since: 3.10
gtk_search_bar_get_show_close_button ()
gboolean
gtk_search_bar_get_show_close_button (GtkSearchBar *bar);
Returns whether the close button is shown.
Returns
whether the close button is shown
Since: 3.10
gtk_search_bar_set_show_close_button ()
void
gtk_search_bar_set_show_close_button (GtkSearchBar *bar,
gboolean 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.
Since: 3.10
gtk_search_bar_handle_event ()
gboolean
gtk_search_bar_handle_event (GtkSearchBar *bar,
GdkEvent *event);
This function should be called when the top-level
window which contains the search bar received a key event.
If the key event is handled by the search bar, the bar will
be shown, the entry populated with the entered text and GDK_EVENT_STOP
will be returned. The caller should ensure that events are
not propagated further.
If no entry has been connected to the search bar, using
gtk_search_bar_connect_entry(), this function will return
immediately with a warning.
Showing the search bar on key presses
Returns
GDK_EVENT_STOP if the key press event resulted
in text being entered in the search entry (and revealing
the search bar if necessary), GDK_EVENT_PROPAGATE otherwise.
Since: 3.10
Types and Values
struct GtkSearchBar
struct GtkSearchBar;
struct GtkSearchBarClass
struct GtkSearchBarClass {
GtkBinClass parent_class;
};
Property Details
The “search-mode-enabled” property
“search-mode-enabled” gboolean
Whether the search mode is on and the search bar shown.
Owner: GtkSearchBar
Flags: Read / Write
Default value: FALSE
The “show-close-button” property
“show-close-button” gboolean
Whether to show the close button in the toolbar.
Owner: GtkSearchBar
Flags: Read / Write / Construct
Default value: FALSE