Show ranges in more sensible order in export dialog.
authorColin Fletcher <colin.m.fletcher@googlemail.com>
Sun, 16 Jun 2013 17:50:23 +0000 (18:50 +0100)
committerColin Fletcher <colin.m.fletcher@googlemail.com>
Mon, 7 Oct 2013 09:48:48 +0000 (10:48 +0100)
Show ranges in order in which they appear on the timeline in export dialog,
but always show the session range first.

gtk2_ardour/export_timespan_selector.cc
gtk2_ardour/export_timespan_selector.h

index f239ab194ba2533f10e3bd00bd0b106f114aefa0..53b7dc9fe02287078d6121e04a15f0e95fee32c4 100644 (file)
@@ -105,6 +105,9 @@ ExportTimespanSelector::ExportTimespanSelector (ARDOUR::Session * session, Profi
        /* Range view */
 
        range_list = Gtk::ListStore::create (range_cols);
+       // order by location start times
+       range_list->set_sort_column(range_cols.location, Gtk::SORT_ASCENDING);
+       range_list->set_sort_func(range_cols.location, sigc::mem_fun(*this, &ExportTimespanSelector::location_sorter));
        range_view.set_model (range_list);
        range_view.set_headers_visible (true);
 }
@@ -114,6 +117,22 @@ ExportTimespanSelector::~ExportTimespanSelector ()
 
 }
 
+int
+ExportTimespanSelector::location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b)
+{
+       Location *l1 = (*a)[range_cols.location];
+       Location *l2 = (*b)[range_cols.location];
+       const Location *ls = _session->locations()->session_range_location();
+
+       // always sort session range first
+       if (l1 == ls)
+               return -1;
+       if (l2 == ls)
+               return +1;
+
+       return l1->start() - l2->start();
+}
+
 void
 ExportTimespanSelector::add_range_to_selection (ARDOUR::Location const * loc)
 {
index 2118a57b836f23353203524b41acdc4f25f7374e..31932c738b00fe211e1822ac2c3936d4c9870aa4 100644 (file)
@@ -84,6 +84,7 @@ class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
        void update_range_name (std::string const & path, std::string const & new_text);
 
        void set_selection_state_of_all_timespans (bool);
+       int location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b);
 
        /*** GUI components ***/