map::clear() calls erase. Cleans up cpp check warning 'iterator used after element...
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / searchbar.h
1 #pragma once
2
3 #include <gtkmm/entry.h>
4 #include <string>
5
6 #include "gtkmm2ext/visibility.h"
7
8 namespace Gtkmm2ext {
9
10 class LIBGTKMM2EXT_API SearchBar : public Gtk::Entry
11 {
12 public:
13         SearchBar(
14                 const std::string& placeholder_text = "Search...",
15                 bool icon_click_resets = true);
16
17         // resets the searchbar to the initial state
18         void reset ();
19         // emitted when the filter has been updated
20         sigc::signal<void, const std::string&> signal_search_string_updated () { return sig_search_string_updated; }
21 protected:
22         bool focus_in_event (GdkEventFocus*);
23         bool focus_out_event (GdkEventFocus*);
24
25         bool key_press_event (GdkEventKey*);
26         void icon_clicked_event (Gtk::EntryIconPosition, const GdkEventButton*);
27
28         const std::string placeholder_text;
29         sigc::signal<void, const std::string&> sig_search_string_updated;
30 private:
31         void search_string_changed () const;
32
33         Glib::RefPtr<Gdk::Pixbuf> icon;
34         bool icon_click_resets;
35 };
36
37 }