mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-11 07:56:27 +01:00
accept text-entry-change w/o enter and add filter_text option
This commit is contained in:
parent
18cedeec63
commit
4e86a22f8f
2 changed files with 34 additions and 1 deletions
|
|
@ -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
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -189,17 +189,22 @@ public:
|
|||
EntryOption (std::string const &, std::string const &, sigc::slot<std::string>, sigc::slot<bool, std::string>);
|
||||
void set_state_from_config ();
|
||||
void add_to_page (OptionEditorPage*);
|
||||
void set_sensitive (bool);
|
||||
void set_invalid_chars (std::string i) { _invalid = i; }
|
||||
|
||||
Gtk::Widget& tip_widget() { return *_entry; }
|
||||
Gtk::Widget& tip_widget() { return *_entry; }
|
||||
|
||||
private:
|
||||
|
||||
void activated ();
|
||||
bool focus_out (GdkEventFocus*);
|
||||
void filter_text (const Glib::ustring&, int*);
|
||||
|
||||
sigc::slot<std::string> _get; ///< slot to get the configuration variable's value
|
||||
sigc::slot<bool, std::string> _set; ///< slot to set the configuration variable's value
|
||||
Gtk::Label* _label; ///< UI label
|
||||
Gtk::Entry* _entry; ///< UI entry
|
||||
std::string _invalid;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue