Ardour  9.0-pre0-582-g084a23a80d
keyeditor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2016 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
4  * Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #pragma once
22 
23 #include <string>
24 
25 #include <gtkmm/action.h>
26 #include <gtkmm/buttonbox.h>
27 #include <gtkmm/notebook.h>
28 #include <gtkmm/scrolledwindow.h>
29 #include <gtkmm/treemodelfilter.h>
30 #include <gtkmm/treestore.h>
31 #include <gtkmm/treeview.h>
32 
33 #include "widgets/searchbar.h"
34 
35 #include "ardour_window.h"
36 
37 namespace Gtkmm2ext {
38  class Bindings;
39 }
40 
41 class KeyEditor : public ArdourWindow
42 {
43 public:
45 
46  void add_tab (std::string const &name, Gtkmm2ext::Bindings&);
47  void remove_tab (std::string const &name);
48 
49  static sigc::signal<void> UpdateBindings;
50 
51  void disconnect () {
52  _refresh_connection.disconnect ();
53  }
54 
55 private:
56  class Tab : public Gtk::VBox
57  {
58  public:
59  Tab (KeyEditor&, std::string const &name, Gtkmm2ext::Bindings*);
60 
61  uint32_t populate ();
62  void unbind ();
63  void bind (GdkEventKey* release_event, guint pressed_key);
64  void action_selected ();
66  void tab_mapped ();
68 
71  add (name);
72  add (binding);
73  add (path);
74  add (bindable);
75  add (action);
76  }
82  };
83 
85  /* give KeyEditor full access to these. This is just a helper
86  * class with no special semantics
87  */
88 
90  std::string name;
94  Glib::RefPtr<Gtk::TreeStore> data_model;
95  Glib::RefPtr<Gtk::TreeModelFilter> filter;
96  Glib::RefPtr<Gtk::TreeModelSort> sorted_filter;
98  guint last_keyval;
99 
100  protected:
104  };
105 
106  friend class Tab;
107 
116  std::string filter_string;
119 
120  typedef std::vector<Tab*> Tabs;
121 
124 
125  void unbind ();
126  void reset ();
127  void refresh ();
128  void page_change (GtkNotebookPage*, guint);
129 
130  unsigned int sort_column;
133  void search_string_updated (const std::string&);
134  void print () const;
135 
136  sigc::connection _refresh_connection;
137 };
138 
void add(TreeModelColumnBase &column)
void path(Glib::ustring &path, Glib::ustring &path_reversed)
Compute a widget's path of the form "GtkWindow.MyLabel".
uint32_t populate()
Glib::RefPtr< Gtk::TreeModelSort > sorted_filter
Definition: keyeditor.h:96
bool key_press_event(GdkEventKey *)
Tab(KeyEditor &, std::string const &name, Gtkmm2ext::Bindings *)
void sort_column_changed()
Gtkmm2ext::Bindings * bindings
Definition: keyeditor.h:91
KeyEditorColumns columns
Definition: keyeditor.h:97
KeyEditor & owner
Definition: keyeditor.h:89
Gtk::TreeView view
Definition: keyeditor.h:93
Glib::RefPtr< Gtk::TreeStore > data_model
Definition: keyeditor.h:94
void action_selected()
void bind(GdkEventKey *release_event, guint pressed_key)
bool key_release_event(GdkEventKey *)
std::string name
Definition: keyeditor.h:90
bool visible_func(const Gtk::TreeModel::const_iterator &iter) const
Gtk::TreeModel::iterator find_action_path(Gtk::TreeModel::const_iterator begin, Gtk::TreeModel::const_iterator end, const std::string &path) const
Glib::RefPtr< Gtk::TreeModelFilter > filter
Definition: keyeditor.h:95
Gtk::VBox vpacker
Definition: keyeditor.h:84
Gtk::ScrolledWindow scroller
Definition: keyeditor.h:92
guint last_keyval
Definition: keyeditor.h:98
void disconnect()
Definition: keyeditor.h:51
void search_string_updated(const std::string &)
Gtk::Button unbind_button
Definition: keyeditor.h:110
Gtk::Button reset_button
Definition: keyeditor.h:113
void unbind()
static sigc::signal< void > UpdateBindings
Definition: keyeditor.h:49
void add_tab(std::string const &name, Gtkmm2ext::Bindings &)
Gtk::VBox vpacker
Definition: keyeditor.h:108
void page_change(GtkNotebookPage *, guint)
Gtk::HBox reset_box
Definition: keyeditor.h:112
Gtk::SortType sort_type
Definition: keyeditor.h:131
Gtk::Button print_button
Definition: keyeditor.h:117
Tab * current_tab()
void refresh()
void remove_tab(std::string const &name)
void reset()
sigc::connection _refresh_connection
Definition: keyeditor.h:136
unsigned int sort_column
Definition: keyeditor.h:130
Tabs tabs
Definition: keyeditor.h:122
void toggle_sort_type()
Gtk::HButtonBox unbind_box
Definition: keyeditor.h:111
Gtk::Label reset_label
Definition: keyeditor.h:114
void print() const
ArdourWidgets::SearchBar filter_entry
Definition: keyeditor.h:115
Gtk::Notebook notebook
Definition: keyeditor.h:109
Gtk::Label print_label
Definition: keyeditor.h:118
std::string filter_string
Definition: keyeditor.h:116
std::vector< Tab * > Tabs
Definition: keyeditor.h:120
GtkImageIconNameData name
Definition: gtkimage.h:6
struct _GtkNotebookPage GtkNotebookPage
Definition: gtknotebook.h:58
DebugBits Bindings
Gtk::TreeModelColumn< std::string > binding
Definition: keyeditor.h:78
Gtk::TreeModelColumn< std::string > name
Definition: keyeditor.h:77
Gtk::TreeModelColumn< Glib::RefPtr< Gtk::Action > > action
Definition: keyeditor.h:81
Gtk::TreeModelColumn< bool > bindable
Definition: keyeditor.h:80
Gtk::TreeModelColumn< std::string > path
Definition: keyeditor.h:79