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>
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.
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.
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.
21 #ifndef __ardour_gtk_key_editor_h__
22 #define __ardour_gtk_key_editor_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>
33 #include "widgets/searchbar.h"
35 #include "ardour_window.h"
41 class KeyEditor : public ArdourWindow
46 void add_tab (std::string const &name, Gtkmm2ext::Bindings&);
47 void remove_tab (std::string const &name);
49 static sigc::signal<void> UpdateBindings;
52 _refresh_connection.disconnect ();
56 class Tab : public Gtk::VBox
59 Tab (KeyEditor&, std::string const &name, Gtkmm2ext::Bindings*);
63 void bind (GdkEventKey* release_event, guint pressed_key);
64 void action_selected ();
65 void sort_column_changed ();
67 bool visible_func(const Gtk::TreeModel::const_iterator& iter) const;
69 struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord {
77 Gtk::TreeModelColumn<std::string> name;
78 Gtk::TreeModelColumn<std::string> binding;
79 Gtk::TreeModelColumn<std::string> path;
80 Gtk::TreeModelColumn<bool> bindable;
81 Gtk::TreeModelColumn<Glib::RefPtr<Gtk::Action> > action;
85 /* give KeyEditor full access to these. This is just a helper
86 * class with no special semantics
91 Gtkmm2ext::Bindings* bindings;
92 Gtk::ScrolledWindow scroller;
94 Glib::RefPtr<Gtk::TreeStore> data_model;
95 Glib::RefPtr<Gtk::TreeModelFilter> filter;
96 Glib::RefPtr<Gtk::TreeModelSort> sorted_filter;
97 KeyEditorColumns columns;
101 bool key_press_event (GdkEventKey*);
102 bool key_release_event (GdkEventKey*);
103 Gtk::TreeModel::iterator find_action_path (Gtk::TreeModel::const_iterator begin, Gtk::TreeModel::const_iterator end, const std::string& path) const;
109 Gtk::Notebook notebook;
110 Gtk::Button unbind_button;
111 Gtk::HButtonBox unbind_box;
113 Gtk::Button reset_button;
114 Gtk::Label reset_label;
115 ArdourWidgets::SearchBar filter_entry;
116 std::string filter_string;
117 Gtk::Button print_button;
118 Gtk::Label print_label;
120 typedef std::vector<Tab*> Tabs;
128 void page_change (GtkNotebookPage*, guint);
130 unsigned int sort_column;
131 Gtk::SortType sort_type;
132 void toggle_sort_type ();
133 void search_string_updated (const std::string&);
136 sigc::connection _refresh_connection;
139 #endif /* __ardour_gtk_key_editor_h__ */