X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fexport_file_notebook.cc;h=a3af969740bb3a5535762b164b6c07aa36d8e8a3;hb=4ecb48b055c9cc2d3eaa36ec9a1ff48291257bd9;hp=ef0c56f55cb39b7f5356aaec50743b87ba09e3a0;hpb=da8eec7a8311295ee91308eca9fae2146385c512;p=ardour.git diff --git a/gtk2_ardour/export_file_notebook.cc b/gtk2_ardour/export_file_notebook.cc index ef0c56f55c..a3af969740 100644 --- a/gtk2_ardour/export_file_notebook.cc +++ b/gtk2_ardour/export_file_notebook.cc @@ -24,9 +24,11 @@ #include "gui_thread.h" #include "utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; +using namespace PBD; ExportFileNotebook::ExportFileNotebook () : page_counter (1) @@ -34,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); @@ -85,17 +87,52 @@ ExportFileNotebook::sync_with_manager () } set_current_page (0); + update_soundcloud_upload (); CriticalSelectionChanged (); } -std::string -ExportFileNotebook::get_nth_format_name (uint32_t n) +void +ExportFileNotebook::update_soundcloud_upload () +{ + 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 (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); +} + +void +ExportFileNotebook::FilePage::analysis_changed () +{ + format_state->format->set_analyse (analysis_button.get_active ()); + profile_manager->save_format_to_disk (format_state->format); +} + +void +ExportFileNotebook::FilePage::update_analysis_button () +{ + analysis_button.set_active (format_state->format->analyse()); +} + +void +ExportFileNotebook::update_example_filenames () { + int i = 0; FilePage * page; - if ((page = dynamic_cast (get_nth_page (n - 1)))) { - return page->get_format_name(); + while ((page = dynamic_cast (get_nth_page (i++)))) { + page->update_example_filename(); } - return ""; } void @@ -155,6 +192,7 @@ ExportFileNotebook::handle_page_change (GtkNotebookPage*, uint32_t page) } else { last_visible_page = page; } + update_soundcloud_upload (); } ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, ExportFileNotebook * parent, uint32_t number, @@ -166,6 +204,8 @@ 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")), + analysis_button (_("Analyze Exported Audio")), tab_number (number) { set_border_width (12); @@ -175,6 +215,12 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, pack_start (filename_label, false, false, 0); pack_start (filename_align, false, false, 0); + Gtk::HBox *hbox = Gtk::manage (new Gtk::HBox()); + hbox->set_spacing (6); + hbox->pack_start (soundcloud_upload_button, false, false, 0); + hbox->pack_start (analysis_button, false, false, 0); + pack_start (*hbox, false, false, 0); + format_align.add (format_selector); format_align.set_padding (6, 12, 18, 0); @@ -191,7 +237,9 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, /* Set states */ format_selector.set_state (format_state, s); - filename_selector.set_state (filename_state, s); + filename_selector.set_state (filename_state, s); + analysis_button.set_active (format_state->format->analyse()); + soundcloud_upload_button.set_active (format_state->format->soundcloud_upload()); /* Signals */ @@ -203,9 +251,14 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, format_selector.FormatRemoved.connect (sigc::mem_fun (*profile_manager, &ExportProfileManager::remove_format_profile)); format_selector.NewFormat.connect (sigc::mem_fun (*profile_manager, &ExportProfileManager::get_new_format)); - format_selector.CriticalSelectionChanged.connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::update_tab_label)); - filename_selector.CriticalSelectionChanged.connect (CriticalSelectionChanged.make_slot()); + format_selector.CriticalSelectionChanged.connect ( + sigc::mem_fun (*this, &ExportFileNotebook::FilePage::critical_selection_changed)); + 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)); + soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::soundcloud_upload_changed)); + analysis_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::analysis_changed)); /* Tab widget */ tab_close_button.add (*Gtk::manage (new Gtk::Image (::get_icon("close")))); @@ -216,6 +269,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, tab_widget.pack_end (tab_close_alignment, false, false, 0); tab_widget.show_all_children (); update_tab_label (); + update_example_filename(); /* Done */ @@ -238,7 +292,25 @@ 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 +ExportFileNotebook::FilePage::soundcloud_upload_changed () +{ + profile_manager->save_format_to_disk (format_state->format); +} + +void +ExportFileNotebook::FilePage::update_soundcloud_upload_button () +{ + soundcloud_upload_button.set_active (format_state->format->soundcloud_upload()); } void @@ -250,6 +322,40 @@ 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 +ExportFileNotebook::FilePage::update_example_filename() +{ + if (profile_manager) { + if (profile_manager->get_timespans().size() > 1 + || profile_manager->get_timespans().front()->timespans->size() > 1) { + filename_selector.require_timespan (true); + } else { + filename_selector.require_timespan (false); + } + + std::string example; + if (format_state->format) { + example = profile_manager->get_sample_filename_for_format ( + filename_state->filename, format_state->format); + } + + if (example != "") { + filename_selector.set_example_filename(Glib::path_get_basename (example)); + } else { + filename_selector.set_example_filename(""); + } + } +} + +void +ExportFileNotebook::FilePage::critical_selection_changed () +{ + update_tab_label(); + update_example_filename(); + update_analysis_button(); + update_soundcloud_upload_button(); CriticalSelectionChanged(); }