Adds sorting the toe keyeditor
authorMathias Buhr <napcode@apparatus.de>
Sat, 27 Feb 2016 23:53:39 +0000 (00:53 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 5 Mar 2016 15:27:48 +0000 (16:27 +0100)
gtk2_ardour/keyeditor.cc
gtk2_ardour/keyeditor.h

index d8d1f2d59263d75f2b01bbfea492da5d55b1a701..ba360e9de7885804de4453ecb4448526dc16c99f 100644 (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 ()
 {
index 9ded5d33bebae5a6c0c6ce3ae424604333b12389..b04b9730091b2399b4129c2dfbe46bc79fb0998e 100644 (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__ */