Use lwrcase_dirname for desktop file names and substitutions.
[ardour.git] / gtk2_ardour / export_file_notebook.cc
index c9cd747d75ccc5b5ed2b796d27553c9f7c0b27a7..2469e4f6ccc530e36e960da31a1904d899fa300d 100644 (file)
 
 #include "ardour/export_format_specification.h"
 
-#include "pbd/filesystem.h"
-
 #include "gui_thread.h"
 #include "utils.h"
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
 using namespace PBD;
 
 ExportFileNotebook::ExportFileNotebook () :
@@ -37,7 +36,7 @@ ExportFileNotebook::ExportFileNotebook () :
        /* Last page */
 
        new_file_button.set_image (*Gtk::manage (new Gtk::Image (::get_icon("add"))));
-       new_file_button.set_label (_(" Click here to add another format"));
+       new_file_button.set_label (_("Add another format"));
        new_file_button.set_alignment (0, 0.5);
        new_file_button.set_relief (Gtk::RELIEF_NONE);
 
@@ -88,27 +87,41 @@ ExportFileNotebook::sync_with_manager ()
        }
 
        set_current_page (0);
+       update_soundcloud_upload ();
        CriticalSelectionChanged ();
 }
 
 void
-ExportFileNotebook::update_example_filenames()
+ExportFileNotebook::update_soundcloud_upload ()
 {
-       int i = 0;
-       FilePage * page;
-       while ((page = dynamic_cast<FilePage *> (get_nth_page (i++)))) {
-               page->update_example_filename();
+       int i;
+       bool show_credentials_entry = false;
+       ExportProfileManager::FormatStateList const & formats = profile_manager->get_formats ();
+       ExportProfileManager::FormatStateList::const_iterator format_it;
+
+       for (i = 0, format_it = formats.begin(); format_it != formats.end(); ++i, ++format_it) {
+               FilePage * page;
+               if ((page = dynamic_cast<FilePage *> (get_nth_page (i)))) {
+                       bool this_soundcloud_upload = page->get_soundcloud_upload ();
+                       (*format_it)->format->set_soundcloud_upload (this_soundcloud_upload);
+                       if (this_soundcloud_upload) {
+                               show_credentials_entry  = true;
+                       }
+               }
        }
+
+       soundcloud_export_selector->set_visible (show_credentials_entry);
+
 }
 
-std::string
-ExportFileNotebook::get_nth_format_name (uint32_t n)
+void
+ExportFileNotebook::update_example_filenames ()
 {
+       int i = 0;
        FilePage * page;
-       if ((page = dynamic_cast<FilePage *> (get_nth_page (n - 1)))) {
-               return page->get_format_name();
+       while ((page = dynamic_cast<FilePage *> (get_nth_page (i++)))) {
+               page->update_example_filename();
        }
-       return "";
 }
 
 void
@@ -179,6 +192,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
 
   format_label (_("Format"), Gtk::ALIGN_LEFT),
   filename_label (_("Location"), Gtk::ALIGN_LEFT),
+  soundcloud_upload_button (_("Upload to Soundcloud")),
   tab_number (number)
 {
        set_border_width (12);
@@ -187,6 +201,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
        pack_start (format_align, false, false, 0);
        pack_start (filename_label, false, false, 0);
        pack_start (filename_align, false, false, 0);
+       pack_start (soundcloud_upload_button, false, false, 0);
 
        format_align.add (format_selector);
        format_align.set_padding (6, 12, 18, 0);
@@ -221,6 +236,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
        filename_selector.CriticalSelectionChanged.connect (
                sigc::mem_fun (*this, &ExportFileNotebook::FilePage::critical_selection_changed));
 
+       soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*parent, &ExportFileNotebook::update_soundcloud_upload));
        /* Tab widget */
 
        tab_close_button.add (*Gtk::manage (new Gtk::Image (::get_icon("close"))));
@@ -254,7 +270,13 @@ ExportFileNotebook::FilePage::get_format_name () const
        if (format_state && format_state->format) {
                return format_state->format->name();
        }
-       return "No format!";
+       return _("No format!");
+}
+
+bool
+ExportFileNotebook::FilePage::get_soundcloud_upload () const
+{
+       return soundcloud_upload_button.get_active ();
 }
 
 void
@@ -266,7 +288,7 @@ ExportFileNotebook::FilePage::save_format_to_manager (FormatPtr format)
 void
 ExportFileNotebook::FilePage::update_tab_label ()
 {
-       tab_label.set_text (string_compose ("Format %1: %2", tab_number, get_format_name()));
+       tab_label.set_text (string_compose (_("Format %1: %2"), tab_number, get_format_name()));
 }
 
 void
@@ -279,10 +301,9 @@ ExportFileNotebook::FilePage::update_example_filename()
                        example = profile_manager->get_sample_filename_for_format (
                                filename_state->filename, format_state->format);
                }
-               
+
                if (example != "") {
-                       sys::path path(example);
-                       filename_selector.set_example_filename(path.leaf());
+                       filename_selector.set_example_filename(Glib::path_get_basename (example));
                } else {
                        filename_selector.set_example_filename("");
                }