#include <gtkmm/menu.h>
#include <gtkmm/menushell.h>
#include <gtkmm/treeview.h>
+
+#include "pbd/strsplit.h"
#include "pbd/xml++.h"
+
+#include "context_menu_helper.h"
#include "visibility_group.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
return false;
}
- menu()->popup (1, ev->time);
- return true;
-}
-
-Gtk::Menu*
-VisibilityGroup::menu ()
-{
using namespace Gtk::Menu_Helpers;
- Gtk::Menu* m = Gtk::manage (new Gtk::Menu);
+ Gtk::Menu* m = ARDOUR_UI_UTILS::shared_popup_menu ();
MenuList& items = m->items ();
for (vector<Member>::iterator i = _members.begin(); i != _members.end(); ++i) {
j->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &VisibilityGroup::toggle), i));
}
- return m;
+ m->popup (1, ev->time);
+ return true;
}
+
/** @return true if the member should be visible, even taking into account any override functor */
bool
VisibilityGroup::should_actually_be_visible (Member const & m) const
update ();
}
+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
{