X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fsfdb_ui.cc;h=e9000fa096eb455a12b65873b138d4048b9b7bcd;hb=af2ee3c8564c7d60cadb130b8c7ad1f4cddd2216;hp=423b15c1905dc8ad45507b46775e165b0f712e5a;hpb=f1571ab7edc65ec1fc507b05d7bbc397b3549007;p=ardour.git diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 423b15c190..e9000fa096 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -36,10 +36,10 @@ #include "pbd/gstdio_compat.h" #include -#include "pbd/convert.h" #include "pbd/tokenizer.h" #include "pbd/enumwriter.h" #include "pbd/pthread_utils.h" +#include "pbd/string_convert.h" #include "pbd/xml++.h" #include @@ -237,6 +237,9 @@ SoundFileBox::SoundFileBox (bool /*persistent*/) play_btn.signal_clicked().connect (sigc::mem_fun (*this, &SoundFileBox::audition)); stop_btn.signal_clicked().connect (sigc::mem_fun (*this, &SoundFileBox::stop_audition)); + update_autoplay (); + autoplay_btn.signal_toggled().connect(sigc::mem_fun (*this, &SoundFileBox::autoplay_toggled)); + stop_btn.set_sensitive (false); channels_value.set_alignment (0.0f, 0.5f); @@ -327,12 +330,12 @@ SoundFileBox::setup_labels (const string& filename) if (ms) { if (ms->is_type0()) { - channels_value.set_text (to_string(ms->channels().size(), std::dec)); + channels_value.set_text (to_string(ms->channels().size())); } else { if (ms->num_tracks() > 1) { - channels_value.set_text (to_string(ms->num_tracks(), std::dec) + _("(Tracks)")); + channels_value.set_text (to_string(ms->num_tracks()) + _("(Tracks)")); } else { - channels_value.set_text (to_string(ms->num_tracks(), std::dec)); + channels_value.set_text (to_string(ms->num_tracks())); } } length_clock.set (ms->length(ms->timeline_position())); @@ -392,7 +395,7 @@ SoundFileBox::setup_labels (const string& filename) n = n.substr (8); } format_text.set_text (n); - channels_value.set_text (to_string (sf_info.channels, std::dec)); + channels_value.set_text (to_string (sf_info.channels)); if (_session && sf_info.samplerate != _session->frame_rate()) { samplerate.set_markup (string_compose ("%1", _("Sample rate:"))); @@ -433,6 +436,22 @@ SoundFileBox::setup_labels (const string& filename) return true; } +void +SoundFileBox::update_autoplay () +{ + const bool config_autoplay = UIConfiguration::instance().get_autoplay_files(); + + if (autoplay_btn.get_active() != config_autoplay) { + autoplay_btn.set_active (config_autoplay); + } +} + +void +SoundFileBox::autoplay_toggled() +{ + UIConfiguration::instance().set_autoplay_files(autoplay_btn.get_active()); +} + bool SoundFileBox::autoplay() const { @@ -606,7 +625,6 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi , _status (0) , _done (false) , import_button (_("Import")) - , close_button (Stock::CLOSE) , gm (0) { @@ -782,14 +800,11 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi Gtk::HButtonBox* button_box = manage (new HButtonBox); button_box->set_layout (BUTTONBOX_END); - button_box->pack_start (close_button, false, false); - close_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &SoundFileBrowser::do_something), RESPONSE_CLOSE)); button_box->pack_start (import_button, false, false); import_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &SoundFileBrowser::do_something), RESPONSE_OK)); Gtkmm2ext::UI::instance()->set_tip (import_button, _("Press to import selected files")); - Gtkmm2ext::UI::instance()->set_tip (close_button, _("Press to close this window without importing any files")); vpacker.pack_end (*button_box, false, false); @@ -823,6 +838,12 @@ SoundFileBrowser::set_action_sensitive (bool yn) import_button.set_sensitive (yn); } +bool +SoundFileBrowser::get_action_sensitive () const +{ + return import_button.get_sensitive (); +} + void SoundFileBrowser::do_something (int action) { @@ -837,6 +858,22 @@ SoundFileBrowser::on_show () start_metering (); } +bool +SoundFileBrowser::on_key_press_event (GdkEventKey* ev) +{ + if (ev->keyval == GDK_Escape) { + do_something (RESPONSE_CLOSE); + return true; + } + if (ev->keyval == GDK_space && ev->type == GDK_KEY_PRESS) { + if (get_action_sensitive()) { + preview.audition(); + return true; + } + } + return ArdourWindow::on_key_press_event (ev); +} + void SoundFileBrowser::clear_selection () { @@ -847,7 +884,7 @@ SoundFileBrowser::clear_selection () void SoundFileBrowser::chooser_file_activated () { - preview.audition (); + do_something (RESPONSE_OK); } void