remeber recent-session sort-column
authorRobin Gareus <robin@gareus.org>
Wed, 16 Sep 2015 16:59:04 +0000 (18:59 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 16 Sep 2015 16:59:04 +0000 (18:59 +0200)
gtk2_ardour/session_dialog.cc
gtk2_ardour/session_dialog.h
gtk2_ardour/ui_config_vars.h

index aca3f66fa92d8ec446cd12f960cf7b6c35dbd406..ad50ecf92d766ed763b97c1c653861c53c2c976c 100644 (file)
@@ -321,6 +321,8 @@ SessionDialog::setup_initial_choice_box ()
        recent_label.set_markup (string_compose ("<span weight=\"bold\" size=\"large\">%1</span>", _("Recent Sessions")));
        
        recent_session_model = TreeStore::create (recent_session_columns);
+       recent_session_model->signal_sort_column_changed().connect (sigc::mem_fun (*this, &SessionDialog::recent_session_sort_changed));
+
        
        recent_session_display.set_model (recent_session_model);
        recent_session_display.append_column (_("Session Name"), recent_session_columns.visible_name);
@@ -750,15 +752,30 @@ SessionDialog::redisplay_recent_sessions ()
        Gtk::TreeView::Column* pColumn;
        if ((pColumn = recent_session_display.get_column (0))) { // name
                pColumn->set_sort_column (recent_session_columns.visible_name);
-               pColumn->set_sort_indicator (true);
        }
        if ((pColumn = recent_session_display.get_column (3))) { // date
                pColumn->set_sort_column (recent_session_columns.time_modified); // unixtime
        }
 
+       const int32_t sort = ARDOUR_UI::config()->get_recent_session_sort();
+       recent_session_model->set_sort_column (abs (sort), sort < 0 ? Gtk::SORT_DESCENDING : Gtk::SORT_ASCENDING);
+
        return session_snapshot_count;
 }
 
+void
+SessionDialog::recent_session_sort_changed ()
+{
+       int column;
+       SortType order;
+       if (recent_session_model->get_sort_column_id (column, order)) {
+               int32_t sort = column * (order == Gtk::SORT_DESCENDING ? -1 : 1);
+               if (sort != ARDOUR_UI::config()->get_recent_session_sort()) {
+                       ARDOUR_UI::config()->set_recent_session_sort(sort);
+               }
+       }
+}
+
 void
 SessionDialog::recent_session_row_selected ()
 {
index e7c8738b5b9cba33b4d99d3f0fc5b53809870dcd..1a5d1a8386457dbad39bb7beb16659cf34fc199c 100644 (file)
@@ -135,6 +135,7 @@ class SessionDialog : public ArdourDialog {
        Gtk::FileChooserButton       existing_session_chooser;
        int redisplay_recent_sessions ();
        void recent_session_row_selected ();
+       void recent_session_sort_changed ();
        void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
 
        void existing_session_selected ();
index 04865674e746aa1f61a4d4c769f9dc24f97f2b4f..644265312c90d46a48078ff2ff1c8bdee31cce0c 100644 (file)
@@ -74,3 +74,4 @@ UI_CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false)
 UI_CONFIG_VARIABLE (bool, buggy_gradients, "buggy-gradients", false)
 UI_CONFIG_VARIABLE (bool, cairo_image_surface, "cairo-image-surface", false)
 UI_CONFIG_VARIABLE (uint64_t, waveform_cache_size, "waveform-cache-size", 100) /* units of megagbytes */
+UI_CONFIG_VARIABLE (int32_t, recent_session_sort, "recent-session-sort", 0)