summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Buhr <napcode@apparatus.de>2016-02-28 00:53:39 +0100
committerRobin Gareus <robin@gareus.org>2016-03-05 16:27:48 +0100
commit0a8b99fe6cd840c0daa71ec0ef48f4e958f2f356 (patch)
tree238a8559541a5e299e5f273713a1380f454e87dd
parentba31e9c83afe642aa2d940e981388fedc8e7aac4 (diff)
Adds sorting the toe keyeditor
-rw-r--r--gtk2_ardour/keyeditor.cc28
-rw-r--r--gtk2_ardour/keyeditor.h6
2 files changed, 33 insertions, 1 deletions
diff --git a/gtk2_ardour/keyeditor.cc b/gtk2_ardour/keyeditor.cc
index d8d1f2d592..ba360e9de7 100644
--- a/gtk2_ardour/keyeditor.cc
+++ b/gtk2_ardour/keyeditor.cc
@@ -55,7 +55,8 @@ KeyEditor::KeyEditor ()
: ArdourWindow (_("Key Bindings"))
, unbind_button (_("Remove shortcut"))
, unbind_box (BUTTONBOX_END)
-
+ , sort_column(0)
+ , sort_type(Gtk::SORT_ASCENDING)
{
last_keyval = 0;
@@ -150,6 +151,7 @@ KeyEditor::Tab::Tab (KeyEditor& ke, string const & str, Bindings* b)
view.append_column (_("Action"), columns.name);
view.append_column (_("Shortcut"), columns.binding);
view.set_headers_visible (true);
+ view.set_headers_clickable (true);
view.get_selection()->set_mode (SELECTION_SINGLE);
view.set_reorderable (false);
view.set_size_request (500,300);
@@ -159,6 +161,13 @@ KeyEditor::Tab::Tab (KeyEditor& ke, string const & str, Bindings* b)
view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &Tab::action_selected));
+ view.get_column(0)->set_sort_column (columns.name);
+ view.get_column(1)->set_sort_column (columns.binding);
+ model->set_sort_column (owner.sort_column, owner.sort_type);
+ model->signal_sort_column_changed().connect (sigc::mem_fun (*this, &Tab::sort_column_changed));
+
+ signal_map().connect (sigc::mem_fun (*this, &Tab::tab_mapped));
+
scroller.add (view);
scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -331,6 +340,23 @@ KeyEditor::Tab::populate ()
}
void
+KeyEditor::Tab::sort_column_changed ()
+{
+ int column;
+ SortType type;
+ if (model->get_sort_column_id (column, type)) {
+ owner.sort_column = column;
+ owner.sort_type = type;
+ }
+}
+
+void
+KeyEditor::Tab::tab_mapped ()
+{
+ model->set_sort_column (owner.sort_column, owner.sort_type);
+}
+
+void
KeyEditor::reset ()
{
Keyboard::the_keyboard().reset_bindings ();
diff --git a/gtk2_ardour/keyeditor.h b/gtk2_ardour/keyeditor.h
index 9ded5d33be..b04b973009 100644
--- a/gtk2_ardour/keyeditor.h
+++ b/gtk2_ardour/keyeditor.h
@@ -55,6 +55,8 @@ class KeyEditor : public ArdourWindow
void unbind ();
void bind (GdkEventKey* release_event, guint pressed_key);
void action_selected ();
+ void sort_column_changed ();
+ void tab_mapped ();
struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord {
KeyEditorColumns () {
@@ -104,6 +106,10 @@ class KeyEditor : public ArdourWindow
void unbind ();
void reset ();
void page_change (GtkNotebookPage*, guint);
+
+ unsigned int sort_column;
+ Gtk::SortType sort_type;
+ void toggle_sort_type ();
};
#endif /* __ardour_gtk_key_editor_h__ */