Class: Handy::SearchBar
- Inherits:
-
Gtk::Bin
- Object
- Gtk::Bin
- Handy::SearchBar
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#connect_entry(entry) ⇒ nil
Sets the entry widget passed as the one to be used in this search bar.
-
#handle_event(event) ⇒ Boolean
Handles key press events.
-
#initialize ⇒ Gtk::Widget
constructor
Creates a new `HdySearchBar.
-
#search_mode ⇒ Boolean
Gets whether the search mode is on.
-
#search_mode=(search_mode) ⇒ nil
Switches the search mode on or off.
-
#search_mode_enabled=(search_mode_enabled) ⇒ Boolean
Whether the search mode is on and the search bar shown.
-
#search_mode_enabled? ⇒ Boolean
Whether the search mode is on and the search bar shown.
-
#show_close_button ⇒ Boolean
Gets whether the close button is shown.
-
#show_close_button=(show_close_button) ⇒ Boolean
Whether to show the close button in the toolbar.
-
#show_close_button? ⇒ Boolean
Whether to show the close button in the toolbar.
Constructor Details
#initialize ⇒ Gtk::Widget
Creates a new `HdySearchBar.
You will need to tell it about which widget is going to be your text entry using [methodSearchBar.connect_entry].
Instance Method Details
#connect_entry(entry) ⇒ nil
Sets the entry 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).
#handle_event(event) ⇒ Boolean
Handles key press events.
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 [methodSearchBar.connect_entry], this function will return immediately with a warning.
Showing the search bar on key presses
static gboolean
on_key_press_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
HdySearchBar *bar = HDY_SEARCH_BAR (user_data);
return hdy_search_bar_handle_event (self, event);
}
static void
create_toplevel (void)
{
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
GtkWindow *search_bar = hdy_search_bar_new ();
// Add more widgets to the window...
g_signal_connect (window,
"key-press-event",
G_CALLBACK (on_key_press_event),
search_bar);
}
#search_mode ⇒ Boolean
Gets whether the search mode is on.
#search_mode=(search_mode) ⇒ nil
Switches the search mode on or off.
#search_mode_enabled=(search_mode_enabled) ⇒ Boolean
Whether the search mode is on and the search bar shown.
#search_mode_enabled? ⇒ Boolean
Whether the search mode is on and the search bar shown.
#show_close_button ⇒ Boolean
Gets whether the close button is shown.
#show_close_button=(show_close_button) ⇒ Boolean
Whether to show the close button in the toolbar.
#show_close_button? ⇒ Boolean
Whether to show the close button in the toolbar.