summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2019-04-20 14:08:36 +0200
committerJohannes Mueller <github@johannes-mueller.org>2019-04-20 15:25:32 +0200
commit5b7bcec529c0b44cacf61298a0df5e7903e111d9 (patch)
tree6641ada41ecff828d7944fe453b841693ce5d095 /libs/surfaces
parentb141d17274c5d778fc8847e6129b37105be858ae (diff)
Use ActionModel API in the Control Surfaces that can make use of it
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/cc121/gui.cc126
-rw-r--r--libs/surfaces/cc121/gui.h15
-rw-r--r--libs/surfaces/faderport/gui.cc142
-rw-r--r--libs/surfaces/faderport/gui.h16
-rw-r--r--libs/surfaces/faderport8/gui.cc113
-rw-r--r--libs/surfaces/faderport8/gui.h16
-rw-r--r--libs/surfaces/mackie/gui.cc126
-rw-r--r--libs/surfaces/mackie/gui.h19
-rw-r--r--libs/surfaces/us2400/gui.cc117
-rw-r--r--libs/surfaces/us2400/gui.h18
10 files changed, 78 insertions, 630 deletions
diff --git a/libs/surfaces/cc121/gui.cc b/libs/surfaces/cc121/gui.cc
index 8d2ff08c95..c532298e48 100644
--- a/libs/surfaces/cc121/gui.cc
+++ b/libs/surfaces/cc121/gui.cc
@@ -27,6 +27,7 @@
#include "pbd/file_utils.h"
#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/action_model.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/gui_thread.h"
@@ -84,6 +85,7 @@ CC121GUI::CC121GUI (CC121& p)
, table (2, 5)
, action_table (5, 4)
, ignore_active_change (false)
+ , action_model (ActionManager::ActionModel::instance ())
{
set_border_width (12);
@@ -127,8 +129,6 @@ CC121GUI::CC121GUI (CC121& p)
table.attach (output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
row++;
- build_available_action_menu ();
-
build_user_action_combo (function1_combo, CC121::ButtonState(0), CC121::Function1);
build_user_action_combo (function2_combo, CC121::ButtonState(0), CC121::Function2);
build_user_action_combo (function3_combo, CC121::ButtonState(0), CC121::Function3);
@@ -365,106 +365,10 @@ CC121GUI::update_port_combos ()
}
void
-CC121GUI::build_available_action_menu ()
-{
- /* build a model of all available actions (needs to be tree structured
- * more)
- */
-
- available_action_model = TreeStore::create (action_columns);
-
- vector<string> paths;
- vector<string> labels;
- vector<string> tooltips;
- vector<string> keys;
- vector<Glib::RefPtr<Gtk::Action> > actions;
-
- ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
-
- typedef std::map<string,TreeIter> NodeMap;
- NodeMap nodes;
- NodeMap::iterator r;
-
-
- vector<string>::iterator k;
- vector<string>::iterator p;
- vector<string>::iterator t;
- vector<string>::iterator l;
-
- available_action_model->clear ();
-
- TreeIter rowp;
- TreeModel::Row parent;
-
- /* Disabled item (row 0) */
-
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("Disabled");
-
- for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
-
- TreeModel::Row row;
- vector<string> parts;
-
- parts.clear ();
-
- split (*p, parts, '/');
-
- if (parts.empty()) {
- continue;
- }
-
- //kinda kludgy way to avoid displaying menu items as mappable
- if (parts[0] == _("Main Menu") )
- continue;
- if (parts[0] == _("JACK") )
- continue;
- if (parts[0] == _("redirectmenu") )
- continue;
- if (parts[0] == _("RegionList") )
- continue;
- if (parts[0] == _("ProcessorMenu") )
- continue;
-
- if ((r = nodes.find (parts[0])) == nodes.end()) {
-
- /* top level is missing */
-
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- nodes[parts[0]] = rowp;
- parent = *(rowp);
- parent[action_columns.name] = parts[0];
-
- row = *(available_action_model->append (parent.children()));
-
- } else {
-
- row = *(available_action_model->append ((*r->second)->children()));
-
- }
-
- /* add this action */
-
- if (l->empty ()) {
- row[action_columns.name] = *t;
- action_map[*t] = *p;
- } else {
- row[action_columns.name] = *l;
- action_map[*l] = *p;
- }
-
- row[action_columns.path] = *p;
- }
-}
-
-void
CC121GUI::action_changed (Gtk::ComboBox* cb, CC121::ButtonID id, CC121::ButtonState bs)
{
TreeModel::const_iterator row = cb->get_active ();
- string action_path = (*row)[action_columns.path];
+ string action_path = (*row)[action_model.path()];
/* release binding */
fp.set_action (id, action_path, false, bs);
@@ -473,7 +377,7 @@ CC121GUI::action_changed (Gtk::ComboBox* cb, CC121::ButtonID id, CC121::ButtonSt
void
CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const & actions, CC121::ButtonID id, CC121::ButtonState bs)
{
- Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
+ Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_model.columns()));
TreeIter rowp;
TreeModel::Row row;
string current_action = fp.get_action (id, false, bs); /* lookup release action */
@@ -483,8 +387,8 @@ CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > co
rowp = model->append();
row = *(rowp);
- row[action_columns.name] = _("Disabled");
- row[action_columns.path] = string();
+ row[action_model.name()] = _("Disabled");
+ row[action_model.path()] = string();
if (current_action.empty()) {
active_row = 0;
@@ -493,15 +397,15 @@ CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > co
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
rowp = model->append();
row = *(rowp);
- row[action_columns.name] = i->first;
- row[action_columns.path] = i->second;
+ row[action_model.name()] = i->first;
+ row[action_model.path()] = i->second;
if (current_action == i->second) {
active_row = n+1;
}
}
cb.set_model (model);
- cb.pack_start (action_columns.name);
+ cb.pack_start (action_model.name());
if (active_row >= 0) {
cb.set_active (active_row);
@@ -528,7 +432,7 @@ bool
CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
{
TreeModel::Row row = *iter;
- string path = row[action_columns.path];
+ string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
@@ -541,8 +445,8 @@ CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string con
void
CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC121::ButtonID id)
{
- cb.set_model (available_action_model);
- cb.pack_start (action_columns.name);
+ cb.set_model (action_model.model());
+ cb.pack_start (action_model.name());
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs));
/* set the active "row" to the right value for the current button binding */
@@ -554,11 +458,11 @@ CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC1
return;
}
- TreeModel::iterator iter = available_action_model->children().end();
+ TreeModel::iterator iter = action_model.model()->children().end();
- available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &CC121GUI::find_action_in_model), current_action, &iter));
+ action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &CC121GUI::find_action_in_model), current_action, &iter));
- if (iter != available_action_model->children().end()) {
+ if (iter != action_model.model()->children().end()) {
cb.set_active (iter);
} else {
cb.set_active (0);
diff --git a/libs/surfaces/cc121/gui.h b/libs/surfaces/cc121/gui.h
index 107a81ed32..41371ea026 100644
--- a/libs/surfaces/cc121/gui.h
+++ b/libs/surfaces/cc121/gui.h
@@ -37,6 +37,10 @@ namespace Gtk {
#include "cc121.h"
+namespace ActionManager {
+ class ActionModel;
+}
+
namespace ArdourSurface {
class CC121GUI : public Gtk::VBox
@@ -87,16 +91,8 @@ private:
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
void active_port_changed (Gtk::ComboBox*,bool for_input);
- struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
- ActionColumns() {
- add (name);
- add (path);
- }
- Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<std::string> path;
- };
+ const ActionManager::ActionModel& action_model;
- ActionColumns action_columns;
Glib::RefPtr<Gtk::TreeStore> available_action_model;
std::map<std::string,std::string> action_map; // map from action names to paths
@@ -104,7 +100,6 @@ private:
void build_user_action_combo (Gtk::ComboBox&, CC121::ButtonState, CC121::ButtonID);
void build_foot_action_combo (Gtk::ComboBox&, CC121::ButtonState);
- void build_available_action_menu ();
void action_changed (Gtk::ComboBox*, CC121::ButtonID, CC121::ButtonState);
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
diff --git a/libs/surfaces/faderport/gui.cc b/libs/surfaces/faderport/gui.cc
index 5040b925cb..279bd16087 100644
--- a/libs/surfaces/faderport/gui.cc
+++ b/libs/surfaces/faderport/gui.cc
@@ -26,6 +26,7 @@
#include "pbd/unwind.h"
#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/action_model.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/gui_thread.h"
@@ -83,6 +84,7 @@ FPGUI::FPGUI (FaderPort& p)
, table (2, 5)
, action_table (5, 4)
, ignore_active_change (false)
+ , action_model (ActionManager::ActionModel::instance ())
{
set_border_width (12);
@@ -137,8 +139,6 @@ FPGUI::FPGUI (FaderPort& p)
build_trns_action_combo (trns_combo[1], FaderPort::ShiftDown);
build_trns_action_combo (trns_combo[2], FaderPort::LongPress);
- build_available_action_menu ();
-
build_foot_action_combo (foot_combo[0], FaderPort::ButtonState(0));
build_foot_action_combo (foot_combo[1], FaderPort::ShiftDown);
build_foot_action_combo (foot_combo[2], FaderPort::LongPress);
@@ -346,122 +346,10 @@ FPGUI::update_port_combos ()
}
void
-FPGUI::build_available_action_menu ()
-{
- /* build a model of all available actions (needs to be tree structured
- * more)
- */
-
- available_action_model = TreeStore::create (action_columns);
-
- vector<string> paths;
- vector<string> labels;
- vector<string> tooltips;
- vector<string> keys;
- vector<Glib::RefPtr<Gtk::Action> > actions;
-
- ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
-
- typedef std::map<string,TreeIter> NodeMap;
- NodeMap nodes;
- NodeMap::iterator r;
-
-
- vector<string>::iterator k;
- vector<string>::iterator p;
- vector<string>::iterator t;
- vector<string>::iterator l;
-
- available_action_model->clear ();
-
- TreeIter rowp;
- TreeModel::Row parent;
-
- /* Disabled item (row 0) */
-
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("Disabled");
-
- /* Key aliasing */
-
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("Shift");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("Control");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("Option");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("CmdAlt");
-
-
- for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
-
- TreeModel::Row row;
- vector<string> parts;
-
- parts.clear ();
-
- split (*p, parts, '/');
-
- if (parts.empty()) {
- continue;
- }
-
- //kinda kludgy way to avoid displaying menu items as mappable
- if (parts[0] == _("Main Menu") )
- continue;
- if (parts[0] == _("JACK") )
- continue;
- if (parts[0] == _("redirectmenu") )
- continue;
- if (parts[0] == _("RegionList") )
- continue;
- if (parts[0] == _("ProcessorMenu") )
- continue;
-
- if ((r = nodes.find (parts[0])) == nodes.end()) {
-
- /* top level is missing */
-
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- nodes[parts[0]] = rowp;
- parent = *(rowp);
- parent[action_columns.name] = parts[0];
-
- row = *(available_action_model->append (parent.children()));
-
- } else {
-
- row = *(available_action_model->append ((*r->second)->children()));
-
- }
-
- /* add this action */
-
- if (l->empty ()) {
- row[action_columns.name] = *t;
- action_map[*t] = *p;
- } else {
- row[action_columns.name] = *l;
- action_map[*l] = *p;
- }
-
- row[action_columns.path] = *p;
- }
-}
-
-void
FPGUI::action_changed (Gtk::ComboBox* cb, FaderPort::ButtonID id, FaderPort::ButtonState bs)
{
TreeModel::const_iterator row = cb->get_active ();
- string action_path = (*row)[action_columns.path];
+ string action_path = (*row)[action_model.path()];
/* release binding */
fp.set_action (id, action_path, false, bs);
@@ -470,7 +358,7 @@ FPGUI::action_changed (Gtk::ComboBox* cb, FaderPort::ButtonID id, FaderPort::But
void
FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const & actions, FaderPort::ButtonID id, FaderPort::ButtonState bs)
{
- Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
+ Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_model.columns()));
TreeIter rowp;
TreeModel::Row row;
string current_action = fp.get_action (id, false, bs); /* lookup release action */
@@ -480,8 +368,8 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const
rowp = model->append();
row = *(rowp);
- row[action_columns.name] = _("Disabled");
- row[action_columns.path] = string();
+ row[action_model.name()] = _("Disabled");
+ row[action_model.path()] = string();
if (current_action.empty()) {
active_row = 0;
@@ -490,15 +378,15 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
rowp = model->append();
row = *(rowp);
- row[action_columns.name] = i->first;
- row[action_columns.path] = i->second;
+ row[action_model.name()] = i->first;
+ row[action_model.path()] = i->second;
if (current_action == i->second) {
active_row = n+1;
}
}
cb.set_model (model);
- cb.pack_start (action_columns.name);
+ cb.pack_start (action_model.name());
if (active_row >= 0) {
cb.set_active (active_row);
@@ -576,7 +464,7 @@ bool
FPGUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
{
TreeModel::Row row = *iter;
- string path = row[action_columns.path];
+ string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
@@ -592,8 +480,8 @@ FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
#ifndef MIXBUS
bs = FaderPort::ButtonState (bs|FaderPort::UserDown);
#endif
- cb.set_model (available_action_model);
- cb.pack_start (action_columns.name);
+ cb.set_model (action_model.model());
+ cb.pack_start (action_model.name());
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs));
/* set the active "row" to the right value for the current button binding */
@@ -605,11 +493,11 @@ FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
return;
}
- TreeModel::iterator iter = available_action_model->children().end();
+ TreeModel::iterator iter = action_model.model()->children().end();
- available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter));
+ action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter));
- if (iter != available_action_model->children().end()) {
+ if (iter != action_model.model()->children().end()) {
cb.set_active (iter);
} else {
cb.set_active (0);
diff --git a/libs/surfaces/faderport/gui.h b/libs/surfaces/faderport/gui.h
index 2a7a782910..60ad81d75f 100644
--- a/libs/surfaces/faderport/gui.h
+++ b/libs/surfaces/faderport/gui.h
@@ -36,6 +36,10 @@ namespace Gtk {
#include "faderport.h"
+namespace ActionManager {
+ class ActionModel;
+}
+
namespace ArdourSurface {
class FPGUI : public Gtk::VBox
@@ -83,17 +87,8 @@ private:
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
void active_port_changed (Gtk::ComboBox*,bool for_input);
- struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
- ActionColumns() {
- add (name);
- add (path);
- }
- Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<std::string> path;
- };
+ const ActionManager::ActionModel& action_model;
- ActionColumns action_columns;
- Glib::RefPtr<Gtk::TreeStore> available_action_model;
std::map<std::string,std::string> action_map; // map from action names to paths
void build_action_combo (Gtk::ComboBox& cb, std::vector<std::pair<std::string,std::string> > const & actions, FaderPort::ButtonID, FaderPort::ButtonState);
@@ -103,7 +98,6 @@ private:
void build_user_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
void build_foot_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
- void build_available_action_menu ();
void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState);
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
diff --git a/libs/surfaces/faderport8/gui.cc b/libs/surfaces/faderport8/gui.cc
index 6eb4fabfb8..a4b0b9b172 100644
--- a/libs/surfaces/faderport8/gui.cc
+++ b/libs/surfaces/faderport8/gui.cc
@@ -27,6 +27,7 @@
#include "pbd/file_utils.h"
#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/action_model.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/gui_thread.h"
@@ -85,6 +86,7 @@ FP8GUI::FP8GUI (FaderPort8& p)
, ignore_active_change (false)
, two_line_text_cb (_("Two Line Trackname"))
, auto_pluginui_cb (_("Auto Show/Hide Plugin GUIs"))
+ , action_model (ActionManager::ActionModel::instance ())
{
set_border_width (12);
@@ -148,7 +150,6 @@ FP8GUI::FP8GUI (FaderPort8& p)
pack_start (hpacker, false, false);
/* actions */
- build_available_action_menu ();
int action_row = 0;
int action_col = 0;
@@ -340,107 +341,11 @@ FP8GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input)
-void
-FP8GUI::build_available_action_menu ()
-{
- /* build a model of all available actions (needs to be tree structured
- * more)
- */
-
- available_action_model = TreeStore::create (action_columns);
-
- vector<string> paths;
- vector<string> labels;
- vector<string> tooltips;
- vector<string> keys;
- vector<Glib::RefPtr<Gtk::Action> > actions;
-
- ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
-
- typedef std::map<string,TreeIter> NodeMap;
- NodeMap nodes;
- NodeMap::iterator r;
-
-
- vector<string>::iterator k;
- vector<string>::iterator p;
- vector<string>::iterator t;
- vector<string>::iterator l;
-
- available_action_model->clear ();
-
- TreeIter rowp;
- TreeModel::Row parent;
-
- /* Disabled item (row 0) */
-
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[action_columns.name] = _("Disabled");
-
- for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
-
- TreeModel::Row row;
- vector<string> parts;
-
- parts.clear ();
-
- split (*p, parts, '/');
-
- if (parts.empty()) {
- continue;
- }
-
- //kinda kludgy way to avoid displaying menu items as mappable
- if (parts[0] == _("Main Menu") )
- continue;
- if (parts[0] == _("JACK") )
- continue;
- if (parts[0] == _("redirectmenu") )
- continue;
- if (parts[0] == _("RegionList") )
- continue;
- if (parts[0] == _("ProcessorMenu") )
- continue;
-
- if ((r = nodes.find (parts[0])) == nodes.end()) {
-
- /* top level is missing */
-
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- nodes[parts[0]] = rowp;
- parent = *(rowp);
- parent[action_columns.name] = parts[0];
-
- row = *(available_action_model->append (parent.children()));
-
- } else {
-
- row = *(available_action_model->append ((*r->second)->children()));
-
- }
-
- /* add this action */
-
- if (l->empty ()) {
- row[action_columns.name] = *t;
- action_map[*t] = *p;
- } else {
- row[action_columns.name] = *l;
- action_map[*l] = *p;
- }
-
- row[action_columns.path] = *p;
- }
-}
-
bool
FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const& action_path, TreeModel::iterator* found)
{
TreeModel::Row row = *iter;
- string path = row[action_columns.path];
+ string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
@@ -453,8 +358,8 @@ FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const
void
FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
{
- cb.set_model (available_action_model);
- cb.pack_start (action_columns.name);
+ cb.set_model (action_model.model());
+ cb.pack_start (action_model.name());
/* set the active "row" to the right value for the current button binding */
string current_action = fp.get_button_action (id, false); /* lookup release action */
@@ -462,11 +367,11 @@ FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
if (current_action.empty()) {
cb.set_active (0); /* "disabled" */
} else {
- TreeModel::iterator iter = available_action_model->children().end();
+ TreeModel::iterator iter = action_model.model()->children().end();
- available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FP8GUI::find_action_in_model), current_action, &iter));
+ action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FP8GUI::find_action_in_model), current_action, &iter));
- if (iter != available_action_model->children().end()) {
+ if (iter != action_model.model()->children().end()) {
cb.set_active (iter);
} else {
cb.set_active (0);
@@ -480,7 +385,7 @@ void
FP8GUI::action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id)
{
TreeModel::const_iterator row = cb->get_active ();
- string action_path = (*row)[action_columns.path];
+ string action_path = (*row)[action_model.path()];
fp.set_button_action (id, false, action_path);
}
diff --git a/libs/surfaces/faderport8/gui.h b/libs/surfaces/faderport8/gui.h
index 5e9dfd6489..8b8eacd2d7 100644
--- a/libs/surfaces/faderport8/gui.h
+++ b/libs/surfaces/faderport8/gui.h
@@ -37,6 +37,10 @@ namespace Gtk {
#include "faderport8.h"
+namespace ActionManager {
+ class ActionModel;
+}
+
namespace ArdourSurface { namespace FP_NAMESPACE {
class FP8GUI : public Gtk::VBox
@@ -88,21 +92,11 @@ private:
void auto_pluginui_toggled ();
/* user actions */
- void build_available_action_menu ();
void build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id);
void action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id);
- struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
- ActionColumns() {
- add (name);
- add (path);
- }
- Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<std::string> path;
- };
+ const ActionManager::ActionModel& action_model;
- ActionColumns action_columns;
- Glib::RefPtr<Gtk::TreeStore> available_action_model;
std::map<std::string,std::string> action_map; // map from action names to paths
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc
index 613bfb8567..8b9eb26b03 100644
--- a/libs/surfaces/mackie/gui.cc
+++ b/libs/surfaces/mackie/gui.cc
@@ -34,6 +34,7 @@
#include "pbd/stacktrace.h"
#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/action_model.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/utils.h"
@@ -88,6 +89,7 @@ MackieControlProtocol::build_gui ()
MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
: _cp (p)
, table (2, 9)
+ , action_model (ActionManager::ActionModel::instance ())
, touch_sensitivity_adjustment (0, 0, 9, 1, 4)
, touch_sensitivity_scale (touch_sensitivity_adjustment)
, recalibrate_fader_button (_("Recalibrate Faders"))
@@ -239,7 +241,6 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
function_key_scroller.add (function_key_editor);
append_page (*fkey_packer, _("Function Keys"));
- build_available_action_menu ();
build_function_key_editor ();
refresh_function_key_editor ();
fkey_packer->show_all();
@@ -442,117 +443,6 @@ MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, G
}
void
-MackieControlProtocolGUI::build_available_action_menu ()
-{
- /* build a model of all available actions (needs to be tree structured
- * more)
- */
-
- available_action_model = TreeStore::create (available_action_columns);
-
- vector<string> paths;
- vector<string> labels;
- vector<string> tooltips;
- vector<string> keys;
- vector<Glib::RefPtr<Gtk::Action> > actions;
-
- typedef std::map<string,TreeIter> NodeMap;
- NodeMap nodes;
- NodeMap::iterator r;
-
- ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
-
- vector<string>::iterator k;
- vector<string>::iterator p;
- vector<string>::iterator t;
- vector<string>::iterator l;
-
- available_action_model->clear ();
-
- /* Because there are button bindings built in that are not
- in the key binding map, there needs to be a way to undo
- a profile edit.
- */
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Remove Binding");
-
- /* Key aliasing */
-
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Shift");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Control");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Option");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("CmdAlt");
-
- for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
-
- TreeModel::Row row;
- vector<string> parts;
-
- parts.clear ();
-
- split (*p, parts, '/');
-
- if (parts.empty()) {
- continue;
- }
-
- //kinda kludgy way to avoid displaying menu items as mappable
- if (parts[0] == _("Main Menu") )
- continue;
- if (parts[0] == _("JACK") )
- continue;
- if (parts[0] == _("redirectmenu") )
- continue;
- if (parts[0] == _("RegionList") )
- continue;
- if (parts[0] == _("ProcessorMenu") )
- continue;
-
- if ((r = nodes.find (parts[0])) == nodes.end()) {
-
- /* top level is missing */
-
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- nodes[parts[0]] = rowp;
- parent = *(rowp);
- parent[available_action_columns.name] = parts[0];
-
- row = *(available_action_model->append (parent.children()));
-
- } else {
-
- row = *(available_action_model->append ((*r->second)->children()));
-
- }
-
- /* add this action */
-
- if (l->empty ()) {
- row[available_action_columns.name] = *t;
- action_map[*t] = *p;
- } else {
- row[available_action_columns.name] = *l;
- action_map[*l] = *p;
- }
-
- row[available_action_columns.path] = *p;
- }
-}
-
-void
MackieControlProtocolGUI::build_function_key_editor ()
{
function_key_editor.append_column (_("Key"), function_key_columns.name);
@@ -560,32 +450,32 @@ MackieControlProtocolGUI::build_function_key_editor ()
TreeViewColumn* col;
CellRendererCombo* renderer;
- renderer = make_action_renderer (available_action_model, function_key_columns.plain);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.plain);
col = manage (new TreeViewColumn (_("Plain"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.plain);
function_key_editor.append_column (*col);
- renderer = make_action_renderer (available_action_model, function_key_columns.shift);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.shift);
col = manage (new TreeViewColumn (_("Shift"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.shift);
function_key_editor.append_column (*col);
- renderer = make_action_renderer (available_action_model, function_key_columns.control);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.control);
col = manage (new TreeViewColumn (_("Control"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.control);
function_key_editor.append_column (*col);
- renderer = make_action_renderer (available_action_model, function_key_columns.option);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.option);
col = manage (new TreeViewColumn (_("Option"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.option);
function_key_editor.append_column (*col);
- renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.cmdalt);
col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
function_key_editor.append_column (*col);
- renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.shiftcontrol);
col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
function_key_editor.append_column (*col);
diff --git a/libs/surfaces/mackie/gui.h b/libs/surfaces/mackie/gui.h
index 0f91a32e12..f40676630d 100644
--- a/libs/surfaces/mackie/gui.h
+++ b/libs/surfaces/mackie/gui.h
@@ -35,6 +35,10 @@ namespace Gtk {
#include "pbd/i18n.h"
+namespace ActionManager {
+ class ActionModel;
+}
+
namespace ArdourSurface {
class MackieControlProtocol;
@@ -67,15 +71,6 @@ class MackieControlProtocolGUI : public Gtk::Notebook
Gtk::TreeModelColumn<std::string> full_name;
};
- struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
- AvailableActionColumns() {
- add (name);
- add (path);
- }
- Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<std::string> path;
- };
-
struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
FunctionKeyColumns() {
add (name);
@@ -97,18 +92,17 @@ class MackieControlProtocolGUI : public Gtk::Notebook
Gtk::TreeModelColumn<std::string> shiftcontrol;
};
- AvailableActionColumns available_action_columns;
FunctionKeyColumns function_key_columns;
MidiPortColumns midi_port_columns;
Gtk::ScrolledWindow function_key_scroller;
Gtk::TreeView function_key_editor;
Glib::RefPtr<Gtk::ListStore> function_key_model;
- Glib::RefPtr<Gtk::TreeStore> available_action_model;
+
+ const ActionManager::ActionModel& action_model;
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
- void build_available_action_menu ();
void refresh_function_key_editor ();
void build_function_key_editor ();
void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
@@ -157,4 +151,3 @@ class MackieControlProtocolGUI : public Gtk::Notebook
};
}
-
diff --git a/libs/surfaces/us2400/gui.cc b/libs/surfaces/us2400/gui.cc
index 9f6543875b..7766b87d41 100644
--- a/libs/surfaces/us2400/gui.cc
+++ b/libs/surfaces/us2400/gui.cc
@@ -35,6 +35,7 @@
#include "pbd/stacktrace.h"
#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/action_model.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/utils.h"
@@ -89,6 +90,7 @@ US2400Protocol::build_gui ()
US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p)
: _cp (p)
, table (2, 9)
+ , action_model (ActionManager::ActionModel::instance ())
, _device_dependent_widget (0)
, _ignore_profile_changed (false)
, ignore_active_change (false)
@@ -155,7 +157,6 @@ US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p)
function_key_scroller.add (function_key_editor);
append_page (*fkey_packer, _("Function Keys"));
- build_available_action_menu ();
build_function_key_editor ();
refresh_function_key_editor ();
fkey_packer->show_all();
@@ -357,116 +358,6 @@ US2400ProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::Tre
}
void
-US2400ProtocolGUI::build_available_action_menu ()
-{
- /* build a model of all available actions (needs to be tree structured
- * more)
- */
-
- available_action_model = TreeStore::create (available_action_columns);
-
- vector<string> paths;
- vector<string> labels;
- vector<string> tooltips;
- vector<string> keys;
- vector<Glib::RefPtr<Gtk::Action> > actions;
-
- typedef std::map<string,TreeIter> NodeMap;
- NodeMap nodes;
- NodeMap::iterator r;
-
- ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
-
- vector<string>::iterator k;
- vector<string>::iterator p;
- vector<string>::iterator t;
- vector<string>::iterator l;
-
- available_action_model->clear ();
-
- /* Because there are button bindings built in that are not
- * in the key binding map, there needs to be a way to undo
- * a profile edit. */
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Remove Binding");
-
- /* Key aliasing */
-
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Shift");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Control");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("Option");
- rowp = available_action_model->append();
- parent = *(rowp);
- parent[available_action_columns.name] = _("CmdAlt");
-
- for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
-
- TreeModel::Row row;
- vector<string> parts;
-
- parts.clear ();
-
- split (*p, parts, '/');
-
- if (parts.empty()) {
- continue;
- }
-
- /* kinda kludgy way to avoid displaying menu items as mappable */
- if (parts[0] == _("Main Menu"))
- continue;
- if (parts[0] == _("JACK"))
- continue;
- if (parts[0] == _("redirectmenu"))
- continue;
- if (parts[0] == _("RegionList"))
- continue;
- if (parts[0] == _("ProcessorMenu"))
- continue;
-
- if ((r = nodes.find (parts[0])) == nodes.end()) {
-
- /* top level is missing */
-
- TreeIter rowp;
- TreeModel::Row parent;
- rowp = available_action_model->append();
- nodes[parts[0]] = rowp;
- parent = *(rowp);
- parent[available_action_columns.name] = parts[0];
-
- row = *(available_action_model->append (parent.children()));
-
- } else {
-
- row = *(available_action_model->append ((*r->second)->children()));
-
- }
-
- /* add this action */
-
- if (l->empty ()) {
- row[available_action_columns.name] = *t;
- action_map[*t] = *p;
- } else {
- row[available_action_columns.name] = *l;
- action_map[*l] = *p;
- }
-
- row[available_action_columns.path] = (*p);
- }
-}
-
-void
US2400ProtocolGUI::build_function_key_editor ()
{
function_key_editor.append_column (_("Key"), function_key_columns.name);
@@ -474,12 +365,12 @@ US2400ProtocolGUI::build_function_key_editor ()
TreeViewColumn* col;
CellRendererCombo* renderer;
- renderer = make_action_renderer (available_action_model, function_key_columns.plain);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.plain);
col = manage (new TreeViewColumn (_("Plain"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.plain);
function_key_editor.append_column (*col);
- renderer = make_action_renderer (available_action_model, function_key_columns.shift);
+ renderer = make_action_renderer (action_model.model(), function_key_columns.shift);
col = manage (new TreeViewColumn (_("Shift"), *renderer));
col->add_attribute (renderer->property_text(), function_key_columns.shift);
function_key_editor.append_column (*col);
diff --git a/libs/surfaces/us2400/gui.h b/libs/surfaces/us2400/gui.h
index 7e0342bb85..ea3ba0e8e2 100644
--- a/libs/surfaces/us2400/gui.h
+++ b/libs/surfaces/us2400/gui.h
@@ -35,6 +35,10 @@ namespace Gtk {
#include "pbd/i18n.h"
+namespace ActionManager {
+ class ActionModel;
+}
+
namespace ArdourSurface {
class US2400Protocol;
@@ -66,15 +70,6 @@ class US2400ProtocolGUI : public Gtk::Notebook
Gtk::TreeModelColumn<std::string> full_name;
};
- struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
- AvailableActionColumns() {
- add (name);
- add (path);
- }
- Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<std::string> path;
- };
-
struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
FunctionKeyColumns() {
add (name);
@@ -96,7 +91,6 @@ class US2400ProtocolGUI : public Gtk::Notebook
Gtk::TreeModelColumn<std::string> shiftcontrol;
};
- AvailableActionColumns available_action_columns;
FunctionKeyColumns function_key_columns;
MidiPortColumns midi_port_columns;
@@ -107,7 +101,8 @@ class US2400ProtocolGUI : public Gtk::Notebook
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
- void build_available_action_menu ();
+ const ActionManager::ActionModel& action_model;
+
void refresh_function_key_editor ();
void build_function_key_editor ();
void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
@@ -139,4 +134,3 @@ class US2400ProtocolGUI : public Gtk::Notebook
};
}
-