NOOP, remove trailing tabs/whitespace.
[ardour.git] / gtk2_ardour / export_filename_selector.cc
index 2912ce75e63801a9ebfd07b04394de7310dabb21..831b75ef02650baeadc895e619131629157816c3 100644 (file)
 
 */
 
-#include "export_filename_selector.h"
+#include <gtkmm/messagedialog.h>
 
-#include "ardour/export_handler.h"
-#include "ardour/session.h"
-#include "ardour/session_directory.h"
+#include "export_filename_selector.h"
 
 #include "i18n.h"
 
 using namespace ARDOUR;
 
 ExportFilenameSelector::ExportFilenameSelector () :
-       include_label (_("Include in Filename(s):"), Gtk::ALIGN_LEFT),
+       include_label ("", Gtk::ALIGN_LEFT),
 
        label_label (_("Label:"), Gtk::ALIGN_LEFT),
        session_checkbox (_("Session Name")),
        revision_checkbox (_("Revision:")),
 
        path_label (_("Folder:"), Gtk::ALIGN_LEFT),
-       browse_button (_("Browse"))
+       browse_button (_("Browse")),
+
+       example_filename_label ("", Gtk::ALIGN_LEFT)
 {
+       include_label.set_markup (_("<i>Build filename(s) from these components:</i>"));
+
+       pack_start (path_hbox, false, false, 12);
        pack_start (include_label, false, false, 6);
        pack_start (include_hbox, false, false, 0);
-       pack_start (path_hbox, false, false, 12);
+       pack_start (example_filename_label, false, false, 12);
 
        include_hbox.pack_start (label_label, false, false, 3);
        include_hbox.pack_start (label_entry, false, false, 3);
@@ -93,6 +96,7 @@ ExportFilenameSelector::ExportFilenameSelector () :
 
        label_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::update_label));
        path_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::update_folder));
+       path_entry.signal_activate().connect (sigc::mem_fun (*this, &ExportFilenameSelector::check_folder), false);
 
        session_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_session_selection));
 
@@ -201,6 +205,16 @@ ExportFilenameSelector::set_state (ARDOUR::ExportProfileManager::FilenameStatePt
 
 }
 
+void
+ExportFilenameSelector::set_example_filename (std::string filename)
+{
+       if (filename == "") {
+               example_filename_label.set_markup (_("<small><i>Sorry, no example filename can be shown at the moment</i></small>"));
+       } else {
+               example_filename_label.set_markup (string_compose(_("<small><i>Current (approximate) filename: \"%1\"</i></small>"), filename));
+       }
+}
+
 void
 ExportFilenameSelector::update_label ()
 {
@@ -225,6 +239,23 @@ ExportFilenameSelector::update_folder ()
        CriticalSelectionChanged();
 }
 
+void
+ExportFilenameSelector::check_folder ()
+{
+       if (!filename) {
+               return;
+       }
+
+       if (!Glib::file_test (path_entry.get_text(), Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
+               Gtk::MessageDialog msg (string_compose (_("%1: this is only the directory/folder name, not the filename.\n\
+The filename will be chosen from the information just above the folder selector."), path_entry.get_text()));
+               msg.run ();
+               path_entry.set_text (Glib::path_get_dirname (path_entry.get_text()));
+               filename->set_folder (path_entry.get_text());
+               CriticalSelectionChanged();
+       }
+}
+
 void
 ExportFilenameSelector::change_date_format ()
 {
@@ -295,14 +326,25 @@ ExportFilenameSelector::open_browse_dialog ()
        dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
        dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
 
-       int result = dialog.run();
+       while (true) {
+               int result = dialog.run();
+
+               if (result == Gtk::RESPONSE_OK) {
+                       std::string filename = dialog.get_filename();
 
-       if (result == Gtk::RESPONSE_OK) {
-               std::string filename = dialog.get_filename();
+                       if (!Glib::file_test (filename, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
+                               Gtk::MessageDialog msg (string_compose (_("%1: this is only the directory/folder name, not the filename.\n\
+The filename will be chosen from the information just above the folder selector."), filename));
+                               msg.run ();
+                               continue;
+                       }
 
-               if (filename.length()) {
-                       path_entry.set_text (filename);
+                       if (filename.length()) {
+                               path_entry.set_text (filename);
+                               break;
+                       }
                }
+               break;
        }
 
        CriticalSelectionChanged();