Ardour  9.0-pre0-380-gbbdb6b0e63
action_model.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Johannes Mueller <github@johannes-mueller.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #include <string>
20 
21 #include <gtkmm/treestore.h>
22 #include <gtkmm/treemodelcolumn.h>
23 
24 #include "gtkmm2ext/visibility.h"
25 
26 namespace Gtk
27 {
28 class ComboBox;
29 }
30 
31 /*
32  The singleton ActionModel provides a Gtk::Treestore of all actions known to
33  ardour.
34 
35  To be used for example by surface control editors to implement action bindings.
36 */
37 
38 namespace ActionManager {
39 
41 {
42 public:
43  static const ActionModel& instance ();
44 
45  const Glib::RefPtr<Gtk::TreeStore> model () const { return _model; }
46 
47  const Gtk::TreeModelColumn<std::string>& name () const { return _columns.name; }
48  const Gtk::TreeModelColumn<std::string>& path () const { return _columns.path; }
49 
51  Columns() {
52  add (name);
53  add (path);
54  }
57  };
58 
59  const Columns& columns() const { return _columns; }
60 
61  void build_action_combo (Gtk::ComboBox& cb, std::string const& current_action) const;
63  const std::vector<std::pair<std::string,std::string> >& actions,
64  const std::string& current_action) const;
65 
66 private:
68 
69  bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found) const;
70 
72  Glib::RefPtr<Gtk::TreeStore> _model;
73 };
74 
75 }
static const ActionModel & instance()
const Glib::RefPtr< Gtk::TreeStore > model() const
Definition: action_model.h:45
Glib::RefPtr< Gtk::TreeStore > _model
Definition: action_model.h:72
const Columns & columns() const
Definition: action_model.h:59
bool find_action_in_model(const Gtk::TreeModel::iterator &iter, std::string const &action_path, Gtk::TreeModel::iterator *found) const
void build_custom_action_combo(Gtk::ComboBox &cb, const std::vector< std::pair< std::string, std::string > > &actions, const std::string &current_action) const
void build_action_combo(Gtk::ComboBox &cb, std::string const &current_action) const
const Gtk::TreeModelColumn< std::string > & name() const
Definition: action_model.h:47
const Gtk::TreeModelColumn< std::string > & path() const
Definition: action_model.h:48
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBGTKMM2EXT_API
void add(const Gtk::StockItem &item)
Definition: ardour_ui.h:187
Gtk::TreeModelColumn< std::string > name
Definition: action_model.h:55
Gtk::TreeModelColumn< std::string > path
Definition: action_model.h:56