From e61c4b692b0401fd4f73c6ee70020f1a391fb019 Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Sun, 19 May 2019 16:43:48 +0200 Subject: [PATCH] Use ActionModel also in ContourDesign surface --- .../contourdesign/button_config_widget.cc | 119 +----------------- .../contourdesign/button_config_widget.h | 5 +- 2 files changed, 6 insertions(+), 118 deletions(-) diff --git a/libs/surfaces/contourdesign/button_config_widget.cc b/libs/surfaces/contourdesign/button_config_widget.cc index 17fadc7c9f..a2b3e5687a 100644 --- a/libs/surfaces/contourdesign/button_config_widget.cc +++ b/libs/surfaces/contourdesign/button_config_widget.cc @@ -24,6 +24,7 @@ #include "gtkmm2ext/bindings.h" #include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/actions.h" +#include "gtkmm2ext/action_model.h" #include "pbd/i18n.h" #include "pbd/strsplit.h" @@ -35,38 +36,12 @@ using namespace std; using namespace Gtk; using namespace ArdourSurface; -class ActionModel -{ -public: - static const ActionModel& instance (); - - const Glib::RefPtr model () const { return _available_action_model; } - - const TreeModelColumn& name () const { return _action_columns.name; } - const TreeModelColumn& path () const { return _action_columns.path; } - -private: - ActionModel (); - struct ActionColumns : public TreeModel::ColumnRecord { - ActionColumns() { - add (name); - add (path); - } - TreeModelColumn name; - TreeModelColumn path; - }; - - const ActionColumns _action_columns; - Glib::RefPtr _available_action_model; -}; - - ButtonConfigWidget::ButtonConfigWidget () : HBox () , _choice_jump (_("Jump: ")) , _choice_action (_("Other action: ")) , _jump_distance (JumpDistance ()) - , _action_model (ActionModel::instance ()) + , _action_model (ActionManager::ActionModel::instance ()) { RadioButtonGroup cbg = _choice_jump.get_group (); _choice_action.set_group (cbg); @@ -180,93 +155,3 @@ ButtonConfigWidget::update_config () { Changed (); /* emit signal */ } - - - -const ActionModel& -ActionModel::instance () -{ - static ActionModel am; - return am; -} - -ActionModel::ActionModel () -{ - _available_action_model = TreeStore::create (_action_columns); - _available_action_model->clear (); - - typedef std::map NodeMap; - NodeMap nodes; - NodeMap::iterator r; - - TreeIter rowp; - TreeModel::Row parent; - - rowp = _available_action_model->append (); - parent = *(rowp); - parent[_action_columns.name] = _("Disabled"); - - vector paths; - vector labels; - vector tooltips; - vector keys; - vector > actions; - - ActionManager::get_all_actions (paths, labels, tooltips, keys, actions); - - vector::iterator k; - vector::iterator p; - vector::iterator t; - vector::iterator l; - - 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] == _("Editor_menus") ) - 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; - } else { - row[_action_columns.name] = *l; - } - - row[_action_columns.path] = *p; - } -} diff --git a/libs/surfaces/contourdesign/button_config_widget.h b/libs/surfaces/contourdesign/button_config_widget.h index c1f8f52b78..02c49ff0cf 100644 --- a/libs/surfaces/contourdesign/button_config_widget.h +++ b/libs/surfaces/contourdesign/button_config_widget.h @@ -29,7 +29,10 @@ #include "contourdesign.h" #include "jump_distance_widget.h" +namespace ActionManager +{ class ActionModel; +} namespace ArdourSurface { @@ -59,7 +62,7 @@ private: JumpDistanceWidget _jump_distance; Gtk::ComboBox _action_cb; - const ActionModel& _action_model; + const ActionManager::ActionModel& _action_model; }; }