diff --git a/libs/gtkmm2ext/gtkmm2ext/string_completion.h b/libs/gtkmm2ext/gtkmm2ext/string_completion.h index 2e8a81c4c5..93d93ab53a 100644 --- a/libs/gtkmm2ext/gtkmm2ext/string_completion.h +++ b/libs/gtkmm2ext/gtkmm2ext/string_completion.h @@ -38,11 +38,13 @@ class LIBGTKMM2EXT_API StringCompletion : public Gtk::EntryCompletion void delete_string (Glib::ustring str); void insert_vector (std::vector strVector, bool norepeat = true); + void set_match_anywhere (); + static Glib::RefPtr create(); static Glib::RefPtr create (std::vector strVector, bool norepeat = true); protected: - Glib::RefPtr m_refCompletionModel; + Glib::RefPtr m_refCompletionModel; class CompletionRecord : public Gtk::TreeModel::ColumnRecord { @@ -57,6 +59,8 @@ class LIBGTKMM2EXT_API StringCompletion : public Gtk::EntryCompletion CompletionRecord m_completionRecord; bool _delete_string (const Gtk::TreeModel::iterator &iter, const Glib::ustring &str); bool _string_exists (const Glib::ustring &str); + bool match_anywhere (Glib::ustring const & str, Gtk::TreeModel::const_iterator const & iter); + void init(); }; diff --git a/libs/gtkmm2ext/string_completion.cc b/libs/gtkmm2ext/string_completion.cc index 78ffc841dc..c43be57598 100644 --- a/libs/gtkmm2ext/string_completion.cc +++ b/libs/gtkmm2ext/string_completion.cc @@ -105,3 +105,16 @@ StringCompletion::insert_vector (std::vector strVector, bool nore this->add_string (s, norepeat); } } + +bool +StringCompletion::match_anywhere (Glib::ustring const & str, Gtk::TreeModel::const_iterator const & iter) +{ + Glib::ustring r = Gtk::TreeModel::Row (*iter)[m_completionRecord.col_text]; + return r.find (str) != Glib::ustring::npos; +} + +void +StringCompletion::set_match_anywhere () +{ + set_match_func (sigc::mem_fun (this, &StringCompletion::match_anywhere)); +}