X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvisibility_group.cc;h=d0ef1dd63510a0c36b9253a4421ab724410b2d06;hb=1f6c54a2f053caa8afec70f2acffdb7f7d73f09f;hp=a7098f57d6b4b766d7e9edf8599f7bdb6a5037e2;hpb=83d47f57c087e4a9e1dcd3155adfcbb6fd691af1;p=ardour.git diff --git a/gtk2_ardour/visibility_group.cc b/gtk2_ardour/visibility_group.cc index a7098f57d6..d0ef1dd635 100644 --- a/gtk2_ardour/visibility_group.cc +++ b/gtk2_ardour/visibility_group.cc @@ -21,10 +21,13 @@ #include #include #include + +#include "pbd/strsplit.h" #include "pbd/xml++.h" + #include "visibility_group.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; @@ -54,7 +57,7 @@ VisibilityGroup::add (Gtk::Widget* widget, string const & id, string const & nam m.name = name; m.visible = visible; m.override = override; - + _members.push_back (m); } @@ -161,12 +164,58 @@ VisibilityGroup::set_state (string v) } v = v.substr (comma + 1); - + } while (1); update (); } +string +VisibilityGroup::remove_element (std::string const& from, std::string const& element) +{ + std::vector s; + std::string ret; + + split (from, s, ','); + for (std::vector::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 s; + std::string ret; + + split (from, s, ','); + + for (std::vector::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 { @@ -195,11 +244,11 @@ VisibilityGroup::update_list_view () if (!_model) { return; } - + _ignore_list_view_change = true; _model->clear (); - + for (vector::iterator i = _members.begin(); i != _members.end(); ++i) { Gtk::TreeModel::iterator j = _model->append (); Gtk::TreeModel::Row row = *j; @@ -220,8 +269,8 @@ VisibilityGroup::list_view () Gtk::TreeView* v = Gtk::manage (new Gtk::TreeView (_model)); v->set_headers_visible (false); - v->append_column (_(""), _model_columns._visible); - v->append_column (_(""), _model_columns._name); + v->append_column ("", _model_columns._visible); + v->append_column ("", _model_columns._name); Gtk::CellRendererToggle* visible_cell = dynamic_cast (v->get_column_cell_renderer (0)); visible_cell->property_activatable() = true; @@ -235,7 +284,7 @@ VisibilityGroup::list_view_visible_changed (string const & path) if (_ignore_list_view_change) { return; } - + Gtk::TreeModel::iterator i = _model->get_iter (path); if (!i) { return;