In export format dialog, show preview of generated part of description. Fix to #0004941
[ardour.git] / gtk2_ardour / export_format_dialog.cc
index 68c3f3c41f900b877c68da8bf39523820d7c440b..d93eb23a2a20efdef2787c31c47c360b1f642c71 100644 (file)
@@ -36,6 +36,7 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
   applying_changes_from_engine (0),
 
   name_label (_("Label: "), Gtk::ALIGN_LEFT),
+  name_generated_part ("", Gtk::ALIGN_LEFT),
 
   normalize_checkbox (_("Normalize to:")),
   normalize_adjustment (0.00, -90.00, 0.00, 0.1, 0.2),
@@ -72,16 +73,22 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
 
        /* Pack containers in dialog */
 
-       get_vbox()->pack_start (name_hbox, false, false, 0);
        get_vbox()->pack_start (silence_table, false, false, 6);
        get_vbox()->pack_start (format_table, false, false, 6);
        get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
        get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
+       get_vbox()->pack_start (name_hbox, false, false, 6);
 
        /* Name, new and remove */
 
        name_hbox.pack_start (name_label, false, false, 0);
-       name_hbox.pack_start (name_entry, true, true, 0);
+       name_hbox.pack_start (name_entry, false, false, 0);
+       name_hbox.pack_start (name_generated_part, true, true, 0);
+       name_entry.set_width_chars(20);
+       update_description();
+       manager.DescriptionChanged.connect(
+               *this, invalidator (*this),
+               boost::bind (&ExportFormatDialog::update_description, this), gui_context());
 
        /* Normalize */
 
@@ -131,7 +138,7 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
        close_button->set_sensitive (false);
        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());
+       manager.CompleteChanged.connect (*this, invalidator (*this), boost::bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
 
        with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
        with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
@@ -336,7 +343,7 @@ ExportFormatDialog::init_format_table ()
                row[compatibility_cols.label] = (*it)->name();
 
                WeakCompatPtr ptr (*it);
-               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
        }
 
        compatibility_view.append_column_editable ("", compatibility_cols.selected);
@@ -364,8 +371,8 @@ ExportFormatDialog::init_format_table ()
                row[quality_cols.label] = (*it)->name();
 
                WeakQualityPtr ptr (*it);
-               (*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());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
        }
 
        quality_view.append_column ("", quality_cols.label);
@@ -386,19 +393,19 @@ ExportFormatDialog::init_format_table ()
                row[format_cols.label] = (*it)->name();
 
                WeakFormatPtr ptr (*it);
-               (*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());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::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 (*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());
+               if ((hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it))) {
+                       hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
+                       hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
 
-                       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());
+                       hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
+                       hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
                }
        }
 
@@ -420,8 +427,8 @@ ExportFormatDialog::init_format_table ()
                row[sample_rate_cols.label] = (*it)->name();
 
                WeakSampleRatePtr ptr (*it);
-               (*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());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
        }
 
        sample_rate_view.append_column ("", sample_rate_cols.label);
@@ -710,6 +717,16 @@ ExportFormatDialog::update_with_toc ()
        manager.select_with_toc (with_toc.get_active());
 }
 
+void
+ExportFormatDialog::update_description()
+{
+       std::string text;
+       if (format->is_complete()) {
+               text = ": " + format->description(false);
+       }
+       name_generated_part.set_text(text);
+}
+
 void
 ExportFormatDialog::update_name ()
 {
@@ -832,13 +849,13 @@ ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
        boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
        boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
 
-       if (linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr)) {
+       if ((linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr))) {
                show_linear_enconding_options (linear_ptr);
-       } else if (ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr)) {
+       } else if ((ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr))) {
                show_ogg_enconding_options (ogg_ptr);
-       } else if (flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr)) {
+       } else if ((flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr))) {
                show_flac_enconding_options (flac_ptr);
-       } else if (bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr)) {
+       } else if ((bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr))) {
                show_bwf_enconding_options (bwf_ptr);
        } else {
                std::cout << "Unrecognized format!" << std::endl;