enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / export_timespan_selector.cc
index f239ab194ba2533f10e3bd00bd0b106f114aefa0..ad9470af32c6e0ce2d6591b17cd2e774ec9a7f69 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "export_timespan_selector.h"
 
-#include "ardour_ui.h"
-
 #include "ardour/location.h"
 #include "ardour/types.h"
 #include "ardour/session.h"
@@ -34,7 +32,7 @@
 #include <sstream>
 #include <iomanip>
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace Glib;
 using namespace ARDOUR;
@@ -50,15 +48,15 @@ ExportTimespanSelector::ExportTimespanSelector (ARDOUR::Session * session, Profi
        option_hbox.pack_start (time_format_label, false, false, 0);
        option_hbox.pack_start (time_format_combo, false, false, 6);
 
-       Gtk::Button* b = manage (new Gtk::Button (_("Select All")));
+       Gtk::Button* b = Gtk::manage (new Gtk::Button (_("Select All")));
        b->signal_clicked().connect (
                sigc::bind (
                        sigc::mem_fun (*this, &ExportTimespanSelector::set_selection_state_of_all_timespans), true
                        )
                );
        option_hbox.pack_start (*b, false, false, 6);
-       
-       b = manage (new Gtk::Button (_("Deselect All")));
+
+       b = Gtk::manage (new Gtk::Button (_("Deselect All")));
        b->signal_clicked().connect (
                sigc::bind (
                        sigc::mem_fun (*this, &ExportTimespanSelector::set_selection_state_of_all_timespans), false
@@ -80,7 +78,6 @@ ExportTimespanSelector::ExportTimespanSelector (ARDOUR::Session * session, Profi
 
        time_format_list = Gtk::ListStore::create (time_format_cols);
        time_format_combo.set_model (time_format_list);
-       time_format_combo.set_name ("PaddedButton");
 
        iter = time_format_list->append();
        row = *iter;
@@ -105,6 +102,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 +114,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)
 {
@@ -305,7 +321,7 @@ ExportTimespanSelector::ms_str (framecnt_t frames) const
        mins = (int) floor (left / (_session->frame_rate() * 60.0f));
        left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f);
        secs = (int) floor (left / (float) _session->frame_rate());
-       left -= (framecnt_t) floor (secs * _session->frame_rate());
+       left -= (framecnt_t) floor ((double)(secs * _session->frame_rate()));
        sec_promilles = (int) (left * 1000 / (float) _session->frame_rate() + 0.5);
 
        oss << std::setfill('0') << std::right <<