pulling trunk
[ardour.git] / gtk2_ardour / sfdb_ui.cc
index 4e6d6fb875b4075f819530481f46c12d5fa15fcd..947f470ac8f342144a17892bd764520362f0234c 100644 (file)
@@ -25,7 +25,7 @@
 #include <gtkmm/box.h>
 #include <gtkmm/stock.h>
 
-#include <pbd/basename.h>
+#include <pbd/convert.h>
 
 #include <gtkmm2ext/utils.h>
 
@@ -44,8 +44,6 @@
 using namespace ARDOUR;
 using namespace std;
 
-string length2string (const int32_t frames, const float sample_rate);
-
 SoundFileBox::SoundFileBox ()
        :
        _session(0),
@@ -129,7 +127,7 @@ SoundFileBox::setup_labels (string filename)
        }
 
        length.set_alignment (0.0f, 0.0f);
-       length.set_text (string_compose("Length: %1", length2string(sf_info.length, sf_info.samplerate)));
+       length.set_text (string_compose("Length: %1", PBD::length2string(sf_info.length, sf_info.samplerate)));
 
        format.set_alignment (0.0f, 0.0f);
        format.set_text (sf_info.format_name);
@@ -207,7 +205,7 @@ SoundFileBox::play_btn_clicked ()
                }
 
                string result;
-               _session->region_name (result, PBD::basename(srclist[0]->name()), false);
+               _session->region_name (result, Glib::path_get_basename(srclist[0]->name()), false);
                AudioRegion* a_region = new AudioRegion(srclist, 0, srclist[0]->length(), result, 0, Region::DefaultFlags, false);
                region_cache[path] = a_region;
        }
@@ -234,7 +232,9 @@ SoundFileBox::add_field_clicked ()
     ArdourPrompter prompter (true);
     string name;
 
-    prompter.set_prompt (_("Name for field"));
+    prompter.set_prompt (_("Name for Field"));
+    prompter.add_button (Gtk::Stock::ADD, Gtk::RESPONSE_ACCEPT);
+    prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
 
     switch (prompter.run ()) {
                case Gtk::RESPONSE_ACCEPT:
@@ -286,7 +286,7 @@ SoundFileBox::field_selected ()
        }
 }
 
-SoundFileBrowser::SoundFileBrowser (string title)
+SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s)
        : ArdourDialog (title, false),
          chooser (Gtk::FILE_CHOOSER_ACTION_OPEN)
 {
@@ -295,6 +295,8 @@ SoundFileBrowser::SoundFileBrowser (string title)
        chooser.set_select_multiple (true);
 
        chooser.signal_update_preview().connect(mem_fun(*this, &SoundFileBrowser::update_preview));
+
+       set_session (s);
 }
 
 void
@@ -309,9 +311,9 @@ SoundFileBrowser::update_preview ()
        chooser.set_preview_widget_active(preview.setup_labels(chooser.get_filename()));
 }
 
-SoundFileChooser::SoundFileChooser (string title)
+SoundFileChooser::SoundFileChooser (string title, ARDOUR::Session* s)
        :
-       SoundFileBrowser(title)
+       SoundFileBrowser(title, s)
 {
        add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
        add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
@@ -327,12 +329,12 @@ static const char *import_mode_strings[] = {
 
 vector<string> SoundFileOmega::mode_strings;
 
-SoundFileOmega::SoundFileOmega (string title)
-       : SoundFileBrowser (title),
+SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s)
+       : SoundFileBrowser (title, s),
          split_check (_("Split Channels"))
 {
        if (mode_strings.empty()) {
-               mode_strings = internationalize (import_mode_strings);
+               mode_strings = PBD::internationalize (import_mode_strings);
        }
 
        ARDOUR_UI::instance()->tooltips().set_tip(split_check,