diff options
author | Robin Gareus <robin@gareus.org> | 2014-06-26 00:46:59 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-06-26 19:13:15 +0200 |
commit | 7658183a84791166747c698aca9c88ad2cfe5986 (patch) | |
tree | 2f47a0d28757058d95d5d06d8f9e5fe0fe9602a5 /gtk2_ardour/option_editor.cc | |
parent | b90d7a01fad8ab1289106d2a862fde3b6b4fab8b (diff) |
accept text-entry-change w/o enter and add filter_text option
Diffstat (limited to 'gtk2_ardour/option_editor.cc')
-rw-r--r-- | gtk2_ardour/option_editor.cc | 28 |
1 files changed, 28 insertions, 0 deletions
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 <algorithm> #include <gtkmm/box.h> #include <gtkmm/alignment.h> @@ -146,6 +147,8 @@ EntryOption::EntryOption (string const & i, string const & n, sigc::slot<string> _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 @@ -161,11 +164,36 @@ EntryOption::set_state_from_config () } 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. |