diff options
Diffstat (limited to 'gtk2_ardour/visibility_group.cc')
-rw-r--r-- | gtk2_ardour/visibility_group.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gtk2_ardour/visibility_group.cc b/gtk2_ardour/visibility_group.cc index 46a941d0fc..9a59e613eb 100644 --- a/gtk2_ardour/visibility_group.cc +++ b/gtk2_ardour/visibility_group.cc @@ -21,7 +21,10 @@ #include <gtkmm/menu.h> #include <gtkmm/menushell.h> #include <gtkmm/treeview.h> + +#include "pbd/strsplit.h" #include "pbd/xml++.h" + #include "visibility_group.h" #include "i18n.h" @@ -168,6 +171,52 @@ VisibilityGroup::set_state (string v) } string +VisibilityGroup::remove_element (std::string const& from, std::string const& element) +{ + std::vector<string> s; + std::string ret; + + split (from, s, ','); + for (std::vector<string>::const_iterator i = s.begin(); i != s.end(); ++i) { + if ((*i) == element) { + continue; + } + if (!ret.empty()) { + ret += ','; + } + ret += *i; + } + + return ret; +} + +string +VisibilityGroup::add_element (std::string const& from, std::string const& element) +{ + std::vector<string> s; + std::string ret; + + split (from, s, ','); + + for (std::vector<string>::const_iterator i = s.begin(); i != s.end(); ++i) { + if ((*i) == element) { + /* already present, just return the original */ + return from; + } + } + + ret = from; + + if (!ret.empty()) { + ret += ','; + } + + ret += element; + + return ret; +} + +string VisibilityGroup::get_state_name () const { return _xml_property_name; |