From 5b7bcec529c0b44cacf61298a0df5e7903e111d9 Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Sat, 20 Apr 2019 14:08:36 +0200 Subject: Use ActionModel API in the Control Surfaces that can make use of it --- libs/surfaces/us2400/gui.cc | 117 ++------------------------------------------ 1 file changed, 4 insertions(+), 113 deletions(-) (limited to 'libs/surfaces/us2400/gui.cc') 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(); @@ -356,116 +357,6 @@ US2400ProtocolGUI::make_action_renderer (Glib::RefPtr model, Gtk::Tre return renderer; } -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 paths; - vector labels; - vector tooltips; - vector keys; - vector > actions; - - typedef std::map NodeMap; - NodeMap nodes; - NodeMap::iterator r; - - ActionManager::get_all_actions (paths, labels, tooltips, keys, actions); - - vector::iterator k; - vector::iterator p; - vector::iterator t; - vector::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 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 () { @@ -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); -- cgit v1.2.3