Ardour  9.0-rc2-184-gc50547f0a6
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 <ytkmm/action.h>
26 #include <ytkmm/buttonbox.h>
27 #include <ytkmm/notebook.h>
28 #include <ytkmm/scrolledwindow.h>
29 #include <ytkmm/treemodelfilter.h>
30 #include <ytkmm/treestore.h>
31 #include <ytkmm/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  static void print ();
56 
57 private:
58  class Tab : public Gtk::VBox
59  {
60  public:
61  Tab (KeyEditor&, std::string const &name, Gtkmm2ext::Bindings*);
62 
63  uint32_t populate ();
64  void unbind ();
65  void bind (GdkEventKey* release_event, guint pressed_key);
66  void action_selected ();
68  void tab_mapped ();
70 
73  add (name);
74  add (binding);
75  add (path);
76  add (bindable);
77  add (action);
78  }
84  };
85 
87  /* give KeyEditor full access to these. This is just a helper
88  * class with no special semantics
89  */
90 
92  std::string name;
96  Glib::RefPtr<Gtk::TreeStore> data_model;
97  Glib::RefPtr<Gtk::TreeModelFilter> filter;
98  Glib::RefPtr<Gtk::TreeModelSort> sorted_filter;
100  guint last_keyval;
101 
102  protected:
106  };
107 
108  friend class Tab;
109 
118  std::string filter_string;
121 
122  typedef std::vector<Tab*> Tabs;
123 
126 
127  void unbind ();
128  void reset ();
129  void refresh ();
130  void page_change (GtkNotebookPage*, guint);
131 
132  unsigned int sort_column;
135  void search_string_updated (const std::string&);
136 
137  sigc::connection _refresh_connection;
138 };
139 
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:98
bool key_press_event(GdkEventKey *)
Tab(KeyEditor &, std::string const &name, Gtkmm2ext::Bindings *)
void sort_column_changed()
Gtkmm2ext::Bindings * bindings
Definition: keyeditor.h:93
KeyEditorColumns columns
Definition: keyeditor.h:99
KeyEditor & owner
Definition: keyeditor.h:91
Gtk::TreeView view
Definition: keyeditor.h:95
Glib::RefPtr< Gtk::TreeStore > data_model
Definition: keyeditor.h:96
void action_selected()
void bind(GdkEventKey *release_event, guint pressed_key)
bool key_release_event(GdkEventKey *)
std::string name
Definition: keyeditor.h:92
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:97
Gtk::VBox vpacker
Definition: keyeditor.h:86
Gtk::ScrolledWindow scroller
Definition: keyeditor.h:94
guint last_keyval
Definition: keyeditor.h:100
void disconnect()
Definition: keyeditor.h:51
void search_string_updated(const std::string &)
Gtk::Button unbind_button
Definition: keyeditor.h:112
Gtk::Button reset_button
Definition: keyeditor.h:115
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:110
void page_change(GtkNotebookPage *, guint)
Gtk::HBox reset_box
Definition: keyeditor.h:114
Gtk::SortType sort_type
Definition: keyeditor.h:133
Gtk::Button print_button
Definition: keyeditor.h:119
Tab * current_tab()
void refresh()
void remove_tab(std::string const &name)
void reset()
sigc::connection _refresh_connection
Definition: keyeditor.h:137
unsigned int sort_column
Definition: keyeditor.h:132
Tabs tabs
Definition: keyeditor.h:124
void toggle_sort_type()
Gtk::HButtonBox unbind_box
Definition: keyeditor.h:113
Gtk::Label reset_label
Definition: keyeditor.h:116
static void print()
ArdourWidgets::SearchBar filter_entry
Definition: keyeditor.h:117
Gtk::Notebook notebook
Definition: keyeditor.h:111
Gtk::Label print_label
Definition: keyeditor.h:120
std::string filter_string
Definition: keyeditor.h:118
std::vector< Tab * > Tabs
Definition: keyeditor.h:122
GtkImageIconNameData name
Definition: gtkimage.h:6
struct _GtkNotebookPage GtkNotebookPage
Definition: gtknotebook.h:58
DebugBits Bindings
Gtk::TreeModelColumn< std::string > binding
Definition: keyeditor.h:80
Gtk::TreeModelColumn< std::string > name
Definition: keyeditor.h:79
Gtk::TreeModelColumn< Glib::RefPtr< Gtk::Action > > action
Definition: keyeditor.h:83
Gtk::TreeModelColumn< bool > bindable
Definition: keyeditor.h:82
Gtk::TreeModelColumn< std::string > path
Definition: keyeditor.h:81