13
0

Adds sorting the toe keyeditor

This commit is contained in:
Mathias Buhr 2016-02-28 00:53:39 +01:00 committed by Robin Gareus
parent ba31e9c83a
commit 0a8b99fe6c
2 changed files with 33 additions and 1 deletions

View File

@ -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);
@ -330,6 +339,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 ()
{

View File

@ -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__ */