2 Copyright (C) 2012 Paul Davis
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.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_gtk_key_editor_h__
21 #define __ardour_gtk_key_editor_h__
25 #include <gtkmm/buttonbox.h>
26 #include <gtkmm/notebook.h>
27 #include <gtkmm/scrolledwindow.h>
28 #include <gtkmm/treeview.h>
29 #include <gtkmm/treestore.h>
30 #include "gtkmm2ext/searchbar.h"
32 #include "ardour_window.h"
38 class KeyEditor : public ArdourWindow
43 void add_tab (std::string const &name, Gtkmm2ext::Bindings&);
44 void remove_tab (std::string const &name);
46 static sigc::signal<void> UpdateBindings;
49 _refresh_connection.disconnect ();
53 class Tab : public Gtk::VBox
56 Tab (KeyEditor&, std::string const &name, Gtkmm2ext::Bindings*);
60 void bind (GdkEventKey* release_event, guint pressed_key);
61 void action_selected ();
62 void sort_column_changed ();
64 bool visible_func(const Gtk::TreeModel::const_iterator& iter) const;
66 struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord {
74 Gtk::TreeModelColumn<std::string> name;
75 Gtk::TreeModelColumn<std::string> binding;
76 Gtk::TreeModelColumn<std::string> path;
77 Gtk::TreeModelColumn<bool> bindable;
78 Gtk::TreeModelColumn<Glib::RefPtr<Gtk::Action> > action;
82 /* give KeyEditor full access to these. This is just a helper
83 class with no special semantics
88 Gtkmm2ext::Bindings* bindings;
89 Gtk::ScrolledWindow scroller;
91 Glib::RefPtr<Gtk::TreeStore> data_model;
92 Glib::RefPtr<Gtk::TreeModelFilter> filter;
93 Glib::RefPtr<Gtk::TreeModelSort> sorted_filter;
94 KeyEditorColumns columns;
98 bool key_press_event (GdkEventKey*);
99 bool key_release_event (GdkEventKey*);
100 Gtk::TreeModel::iterator find_action_path (Gtk::TreeModel::const_iterator begin, Gtk::TreeModel::const_iterator end, const std::string& path) const;
106 Gtk::Notebook notebook;
107 Gtk::Button unbind_button;
108 Gtk::HButtonBox unbind_box;
110 Gtk::Button reset_button;
111 Gtk::Label reset_label;
112 Gtkmm2ext::SearchBar filter_entry;
113 std::string filter_string;
114 Gtk::Button print_button;
115 Gtk::Label print_label;
117 typedef std::vector<Tab*> Tabs;
125 void page_change (GtkNotebookPage*, guint);
127 unsigned int sort_column;
128 Gtk::SortType sort_type;
129 void toggle_sort_type ();
130 void search_string_updated (const std::string&);
133 sigc::connection _refresh_connection;
136 #endif /* __ardour_gtk_key_editor_h__ */