Fix restore of track visibility from state files (#3245)
[ardour.git] / gtk2_ardour / export_format_dialog.cc
index ac3ec1be6ae2a549750b9815e03fc411e0bbd77d..cd34104d860deb9a05bd735c5be49246e3b53162 100644 (file)
 
 */
 
-#include "export_format_dialog.h"
-
 #include "ardour/session.h"
 #include "ardour/export_format_specification.h"
 
+#include "export_format_dialog.h"
+#include "gui_thread.h"
 #include "i18n.h"
 
 using namespace ARDOUR;
 
 ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
-  ArdourDialog (new_dialog ? _("New export format profile") : _("Edit export format profile")),
+  ArdourDialog (new_dialog ? _("New Export Format Profile") : _("Edit Export Format Profile")),
   format (format),
   manager (format),
   original_state (format->get_state()),
@@ -123,11 +123,11 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        /* Buttons */
 
        revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-       revert_button->signal_clicked().connect (mem_fun(*this, &ExportFormatDialog::revert));
+       revert_button->signal_clicked().connect (sigc::mem_fun(*this, &ExportFormatDialog::revert));
        close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
        close_button->set_sensitive (false);
-       close_button->signal_clicked().connect (mem_fun (*this, &ExportFormatDialog::end_dialog));
-       manager.CompleteChanged.connect (mem_fun (*close_button, &Gtk::Button::set_sensitive));
+       close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
+       manager.CompleteChanged.connect (*this, invalidator (*this), ui_bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
 
        /* Load state before hooking up the rest of the signals */
 
@@ -135,40 +135,40 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
 
        /* Name entry */
 
-       name_entry.signal_changed().connect (mem_fun (*this, &ExportFormatDialog::update_name));
+       name_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_name));
 
        /* Normalize, silence and src_quality signals */
 
-       trim_start_checkbox.signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
-       trim_end_checkbox.signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
+       trim_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
+       trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
 
-       normalize_checkbox.signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
-       normalize_spinbutton.signal_value_changed().connect (mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
 
-       silence_start_checkbox.signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
-       silence_start_clock.ValueChanged.connect (mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
+       silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
+       silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
 
-       silence_end_checkbox.signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
-       silence_end_clock.ValueChanged.connect (mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
+       silence_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
+       silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
 
-       src_quality_combo.signal_changed().connect (mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
+       src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
 
        /* Format table signals */
 
        Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(compatibility_view.get_column_cell_renderer (0));
-       toggle->signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
-       compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
+       toggle->signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
+       compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
 
-       quality_view.get_selection()->signal_changed().connect (mem_fun(*this, &ExportFormatDialog::update_quality_selection));
-       format_view.get_selection()->signal_changed().connect (mem_fun(*this, &ExportFormatDialog::update_format_selection));
-       sample_rate_view.get_selection()->signal_changed().connect (mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
+       quality_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_quality_selection));
+       format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_format_selection));
+       sample_rate_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
 
        /* Encoding option signals */
 
-       sample_format_view.get_selection()->signal_changed().connect (mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
-       dither_type_view.get_selection()->signal_changed().connect (mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
+       sample_format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
+       dither_type_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
 
-       tag_checkbox.signal_toggled().connect (mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
+       tag_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
 
        /* Finalize */
 
@@ -194,14 +194,14 @@ ExportFormatDialog::revert ()
 void
 ExportFormatDialog::set_session (ARDOUR::Session* s)
 {
-       session = s;
-       if (!session) {
-               return;
-       }
-
+       SessionHandlePtr::set_session (s);
        silence_start_clock.set_session (s);
        silence_end_clock.set_session (s);
 
+       if (!_session) {
+               return;
+       }
+
        update_clock (silence_start_clock, silence_start);
        update_clock (silence_end_clock, silence_end);
 
@@ -210,7 +210,7 @@ ExportFormatDialog::set_session (ARDOUR::Session* s)
        if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
                Gtk::ListStore::Children::iterator it;
                for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
-                       if ((nframes_t) (*it)->get_value (sample_rate_cols.ptr)->rate == session->nominal_frame_rate()) {
+                       if ((nframes_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_frame_rate()) {
                                sample_rate_view.get_selection()->select (it);
                                break;
                        }
@@ -319,7 +319,7 @@ ExportFormatDialog::init_format_table ()
                row[compatibility_cols.label] = (*it)->name();
 
                WeakCompatPtr ptr (*it);
-               (*it)->SelectChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_compatibility_selection), ptr));
+               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
        }
 
        compatibility_view.append_column_editable ("", compatibility_cols.selected);
@@ -347,8 +347,8 @@ ExportFormatDialog::init_format_table ()
                row[quality_cols.label] = (*it)->name();
 
                WeakQualityPtr ptr (*it);
-               (*it)->SelectChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_quality_selection), ptr));
-               (*it)->CompatibleChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_quality_compatibility), ptr));
+               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
        }
 
        quality_view.append_column ("", quality_cols.label);
@@ -369,19 +369,19 @@ ExportFormatDialog::init_format_table ()
                row[format_cols.label] = (*it)->name();
 
                WeakFormatPtr ptr (*it);
-               (*it)->SelectChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_format_selection), ptr));
-               (*it)->CompatibleChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_format_compatibility), ptr));
+               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
 
                /* Encoding options */
 
                boost::shared_ptr<HasSampleFormat> hsf;
 
                if (hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it)) {
-                       hsf->SampleFormatSelectChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::change_sample_format_selection));
-                       hsf->SampleFormatCompatibleChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::change_sample_format_compatibility));
+                       hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
+                       hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
 
-                       hsf->DitherTypeSelectChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::change_dither_type_selection));
-                       hsf->DitherTypeCompatibleChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::change_dither_type_compatibility));
+                       hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
+                       hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
                }
        }
 
@@ -401,10 +401,10 @@ ExportFormatDialog::init_format_table ()
                row[sample_rate_cols.ptr] = *it;
                row[sample_rate_cols.color] = "white";
                row[sample_rate_cols.label] = (*it)->name();
-
+               
                WeakSampleRatePtr ptr (*it);
-               (*it)->SelectChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_sample_rate_selection), ptr));
-               (*it)->CompatibleChanged.connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::change_sample_rate_compatibility), ptr));
+               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
        }
 
        sample_rate_view.append_column ("", sample_rate_cols.label);
@@ -586,8 +586,8 @@ ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr
 
        if (select) {
                ExportFormatManager::SampleRatePtr ptr = rate.lock();
-               if (ptr && session) {
-                       src_quality_combo.set_sensitive ((uint32_t) ptr->rate != session->frame_rate());
+               if (ptr && _session) {
+                       src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->frame_rate());
                }
        }
 }
@@ -728,7 +728,7 @@ void
 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
 {
        // TODO position
-       clock.set (session->convert_to_frames_at (0, time), true);
+       clock.set (_session->convert_to_frames_at (0, time), true);
 
        AudioClock::Mode mode(AudioClock::Timecode);
 
@@ -753,7 +753,7 @@ ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & ti
 void
 ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
 {
-       if (!session) {
+       if (!_session) {
                return;
        }
 
@@ -762,15 +762,15 @@ ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
        switch (clock.mode()) {
          case AudioClock::Timecode:
                time.type = AnyTime::Timecode;
-               session->timecode_time (frames, time.timecode);
+               _session->timecode_time (frames, time.timecode);
                break;
          case AudioClock::BBT:
                time.type = AnyTime::BBT;
-               session->bbt_time (frames, time.bbt);
+               _session->bbt_time (frames, time.bbt);
                break;
          case AudioClock::MinSec:
                time.type = AnyTime::Seconds;
-               time.seconds = (double) frames / session->frame_rate();
+               time.seconds = (double) frames / _session->frame_rate();
                break;
          case AudioClock::Frames:
                time.type = AnyTime::Frames;