summaryrefslogtreecommitdiff
path: root/libs/surfaces/us2400/gui.cc
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/us2400/gui.cc
parentb141d17274c5d778fc8847e6129b37105be858ae (diff)
Use ActionModel API in the Control Surfaces that can make use of it
Diffstat (limited to 'libs/surfaces/us2400/gui.cc')
-rw-r--r--libs/surfaces/us2400/gui.cc117
1 files changed, 4 insertions, 113 deletions
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);