mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 20:26:30 +01:00
add API to query Gtk::ComboBoxText entries
..the overly complex C++ style variant. iterate twice.. hell yeah.
This commit is contained in:
parent
26ba494083
commit
4c2ea510e3
2 changed files with 43 additions and 0 deletions
|
|
@ -97,6 +97,15 @@ namespace Gtkmm2ext {
|
||||||
LIBGTKMM2EXT_API void set_popdown_strings (Gtk::ComboBoxText&,
|
LIBGTKMM2EXT_API void set_popdown_strings (Gtk::ComboBoxText&,
|
||||||
const std::vector<std::string>&);
|
const std::vector<std::string>&);
|
||||||
|
|
||||||
|
LIBGTKMM2EXT_API void get_popdown_strings (Gtk::ComboBoxText&,
|
||||||
|
std::vector<std::string>&);
|
||||||
|
|
||||||
|
LIBGTKMM2EXT_API bool contains_value (Gtk::ComboBoxText&,
|
||||||
|
const std::string);
|
||||||
|
|
||||||
|
LIBGTKMM2EXT_API bool set_active_text_if_present (Gtk::ComboBoxText&,
|
||||||
|
const std::string);
|
||||||
|
|
||||||
template<class T> /*LIBGTKMM2EXT_API*/ void deferred_delete (void *ptr) {
|
template<class T> /*LIBGTKMM2EXT_API*/ void deferred_delete (void *ptr) {
|
||||||
delete static_cast<T *> (ptr);
|
delete static_cast<T *> (ptr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <gtk/gtkpaned.h>
|
#include <gtk/gtkpaned.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
@ -306,6 +307,39 @@ Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Gtkmm2ext::get_popdown_strings (Gtk::ComboBoxText& cr, std::vector<std::string>& strings)
|
||||||
|
{
|
||||||
|
strings.clear ();
|
||||||
|
Glib::RefPtr<const Gtk::TreeModel> m = cr.get_model();
|
||||||
|
if (!m) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(Gtk::TreeModel::iterator i = m->children().begin(); i != m->children().end(); ++i) {
|
||||||
|
Glib::ustring txt;
|
||||||
|
(*i)->get_value(0, txt);
|
||||||
|
strings.push_back (txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Gtkmm2ext::contains_value (Gtk::ComboBoxText& cr, const std::string text)
|
||||||
|
{
|
||||||
|
std::vector<std::string> s;
|
||||||
|
get_popdown_strings (cr, s);
|
||||||
|
return (std::find (s.begin(), s.end(), text) != s.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Gtkmm2ext::set_active_text_if_present (Gtk::ComboBoxText& cr, const std::string text)
|
||||||
|
{
|
||||||
|
if (contains_value(cr, text)) {
|
||||||
|
cr.set_active_text (text);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
GdkWindow*
|
GdkWindow*
|
||||||
Gtkmm2ext::get_paned_handle (Gtk::Paned& paned)
|
Gtkmm2ext::get_paned_handle (Gtk::Paned& paned)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue