From 7658183a84791166747c698aca9c88ad2cfe5986 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 26 Jun 2014 00:46:59 +0200 Subject: accept text-entry-change w/o enter and add filter_text option --- gtk2_ardour/option_editor.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gtk2_ardour/option_editor.cc') diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index f163ec8f3d..39817e464f 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -16,6 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include @@ -146,6 +147,8 @@ EntryOption::EntryOption (string const & i, string const & n, sigc::slot _label = manage (left_aligned_label (n + ":")); _entry = manage (new Entry); _entry->signal_activate().connect (sigc::mem_fun (*this, &EntryOption::activated)); + _entry->signal_focus_out_event().connect (sigc::mem_fun (*this, &EntryOption::focus_out)); + _entry->signal_insert_text().connect (sigc::mem_fun (*this, &EntryOption::filter_text)); } void @@ -160,12 +163,37 @@ EntryOption::set_state_from_config () _entry->set_text (_get ()); } +void +EntryOption::set_sensitive (bool s) +{ + _entry->set_sensitive (s); +} + +void +EntryOption::filter_text (const Glib::ustring&, int*) +{ + std::string text = _entry->get_text (); + for (size_t i = 0; i < _invalid.length(); ++i) { + text.erase (std::remove(text.begin(), text.end(), _invalid.at(i)), text.end()); + } + if (text != _entry->get_text ()) { + _entry->set_text (text); + } +} + void EntryOption::activated () { _set (_entry->get_text ()); } +bool +EntryOption::focus_out (GdkEventFocus*) +{ + _set (_entry->get_text ()); + return true; +} + /** Construct a BoolComboOption. * @param i id * @param n User-visible name. -- cgit v1.2.3