2008-09-29 13:01:52 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2008 Paul Davis
|
|
|
|
Author: Sakari Bergen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "export_file_notebook.h"
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/export_format_specification.h"
|
2008-09-29 13:01:52 -04:00
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "gui_thread.h"
|
2008-09-29 13:01:52 -04:00
|
|
|
#include "utils.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-09-29 13:01:52 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2012-01-29 15:55:44 -05:00
|
|
|
using namespace PBD;
|
2008-09-29 13:01:52 -04:00
|
|
|
|
|
|
|
ExportFileNotebook::ExportFileNotebook () :
|
|
|
|
page_counter (1)
|
|
|
|
{
|
|
|
|
/* Last page */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-03 08:39:50 -04:00
|
|
|
new_file_button.set_image (*Gtk::manage (new Gtk::Image (::get_icon("add"))));
|
2012-06-20 09:01:14 -04:00
|
|
|
new_file_button.set_label (_("Add another format"));
|
2008-09-29 13:01:52 -04:00
|
|
|
new_file_button.set_alignment (0, 0.5);
|
|
|
|
new_file_button.set_relief (Gtk::RELIEF_NONE);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
new_file_hbox.pack_start (new_file_button, true, true);
|
|
|
|
append_page (new_file_dummy, new_file_hbox);
|
|
|
|
set_tab_label_packing (new_file_dummy, true, true, Gtk::PACK_START);
|
|
|
|
new_file_hbox.show_all_children ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
page_change_connection = signal_switch_page().connect (sigc::mem_fun (*this, &ExportFileNotebook::handle_page_change));
|
|
|
|
new_file_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFileNotebook::add_new_file_page));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::set_session_and_manager (ARDOUR::Session * s, boost::shared_ptr<ARDOUR::ExportProfileManager> manager)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
SessionHandlePtr::set_session (s);
|
2008-09-29 13:01:52 -04:00
|
|
|
profile_manager = manager;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
sync_with_manager ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::sync_with_manager ()
|
|
|
|
{
|
|
|
|
/* Clear pages from notebook
|
|
|
|
The page switch handling has to be disabled during removing all pages due to a gtk bug
|
|
|
|
*/
|
|
|
|
|
|
|
|
page_change_connection.block();
|
|
|
|
while (get_n_pages() > 1) {
|
|
|
|
remove_page (0);
|
|
|
|
}
|
|
|
|
page_change_connection.block(false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
page_counter = 1;
|
|
|
|
last_visible_page = 0;
|
|
|
|
|
|
|
|
/* File notebook */
|
|
|
|
|
|
|
|
ExportProfileManager::FormatStateList const & formats = profile_manager->get_formats ();
|
|
|
|
ExportProfileManager::FormatStateList::const_iterator format_it;
|
|
|
|
ExportProfileManager::FilenameStateList const & filenames = profile_manager->get_filenames ();
|
|
|
|
ExportProfileManager::FilenameStateList::const_iterator filename_it;
|
|
|
|
for (format_it = formats.begin(), filename_it = filenames.begin();
|
|
|
|
format_it != formats.end() && filename_it != filenames.end();
|
|
|
|
++format_it, ++filename_it) {
|
|
|
|
add_file_page (*format_it, *filename_it);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
set_current_page (0);
|
2014-05-23 13:14:37 -04:00
|
|
|
update_soundcloud_upload ();
|
2008-09-29 13:01:52 -04:00
|
|
|
CriticalSelectionChanged ();
|
|
|
|
}
|
|
|
|
|
2014-05-23 13:14:37 -04:00
|
|
|
void
|
2014-05-27 06:23:47 -04:00
|
|
|
ExportFileNotebook::update_soundcloud_upload ()
|
2014-05-23 13:14:37 -04:00
|
|
|
{
|
|
|
|
int i;
|
2014-05-31 09:47:11 -04:00
|
|
|
bool show_credentials_entry = false;
|
2014-05-23 13:14:37 -04:00
|
|
|
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)))) {
|
2014-05-31 09:47:11 -04:00
|
|
|
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;
|
|
|
|
}
|
2014-05-23 13:14:37 -04:00
|
|
|
}
|
|
|
|
}
|
2014-05-31 09:47:11 -04:00
|
|
|
soundcloud_export_selector->set_visible (show_credentials_entry);
|
2016-02-10 15:28:43 -05:00
|
|
|
}
|
2014-05-31 09:47:11 -04:00
|
|
|
|
2016-02-10 15:28:43 -05:00
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::analysis_changed ()
|
|
|
|
{
|
|
|
|
format_state->format->set_analyse (analysis_button.get_active ());
|
2016-09-17 06:28:34 -04:00
|
|
|
profile_manager->save_format_to_disk (format_state->format);
|
2014-05-23 13:14:37 -04:00
|
|
|
}
|
|
|
|
|
2016-09-10 18:39:08 -04:00
|
|
|
void
|
2016-09-14 06:00:29 -04:00
|
|
|
ExportFileNotebook::FilePage::update_analysis_button ()
|
2016-09-10 18:39:08 -04:00
|
|
|
{
|
2016-09-14 06:00:29 -04:00
|
|
|
analysis_button.set_active (format_state->format->analyse());
|
2016-09-10 18:39:08 -04:00
|
|
|
}
|
|
|
|
|
2012-01-29 15:55:44 -05:00
|
|
|
void
|
2014-05-27 06:23:47 -04:00
|
|
|
ExportFileNotebook::update_example_filenames ()
|
2012-01-29 15:55:44 -05:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
FilePage * page;
|
|
|
|
while ((page = dynamic_cast<FilePage *> (get_nth_page (i++)))) {
|
|
|
|
page->update_example_filename();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
void
|
|
|
|
ExportFileNotebook::add_new_file_page ()
|
|
|
|
{
|
|
|
|
FilePage * page;
|
|
|
|
if ((page = dynamic_cast<FilePage *> (get_nth_page (get_current_page())))) {
|
|
|
|
add_file_page (profile_manager->duplicate_format_state (page->get_format_state()),
|
|
|
|
profile_manager->duplicate_filename_state (page->get_filename_state()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::add_file_page (ARDOUR::ExportProfileManager::FormatStatePtr format_state, ARDOUR::ExportProfileManager::FilenameStatePtr filename_state)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
FilePage * page = Gtk::manage (new FilePage (_session, profile_manager, this, page_counter, format_state, filename_state));
|
2008-09-29 13:01:52 -04:00
|
|
|
page->CriticalSelectionChanged.connect (CriticalSelectionChanged.make_slot());
|
|
|
|
insert_page (*page, page->get_tab_widget(), get_n_pages() - 1);
|
|
|
|
|
|
|
|
update_remove_file_page_sensitivity ();
|
|
|
|
show_all_children();
|
|
|
|
++page_counter;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
CriticalSelectionChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::remove_file_page (FilePage * page)
|
|
|
|
{
|
|
|
|
profile_manager->remove_format_state (page->get_format_state());
|
|
|
|
profile_manager->remove_filename_state (page->get_filename_state());
|
|
|
|
|
|
|
|
remove_page (*page);
|
|
|
|
update_remove_file_page_sensitivity ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
CriticalSelectionChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::update_remove_file_page_sensitivity ()
|
|
|
|
{
|
|
|
|
FilePage * page;
|
|
|
|
if ((page = dynamic_cast<FilePage *> (get_nth_page (0)))) {
|
|
|
|
if (get_n_pages() > 2) {
|
|
|
|
page->set_remove_sensitive (true);
|
|
|
|
} else {
|
|
|
|
page->set_remove_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::handle_page_change (GtkNotebookPage*, uint32_t page)
|
|
|
|
{
|
|
|
|
if (page + 1 == (uint32_t) get_n_pages()) {
|
|
|
|
set_current_page (last_visible_page);
|
|
|
|
} else {
|
|
|
|
last_visible_page = page;
|
|
|
|
}
|
2016-02-10 15:28:43 -05:00
|
|
|
update_soundcloud_upload ();
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, ExportFileNotebook * parent, uint32_t number,
|
|
|
|
ExportProfileManager::FormatStatePtr format_state,
|
|
|
|
ExportProfileManager::FilenameStatePtr filename_state) :
|
2017-07-01 12:42:24 -04:00
|
|
|
format_state (format_state),
|
|
|
|
filename_state (filename_state),
|
|
|
|
profile_manager (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)
|
2008-09-29 13:01:52 -04:00
|
|
|
{
|
|
|
|
set_border_width (12);
|
|
|
|
|
|
|
|
pack_start (format_label, false, false, 0);
|
|
|
|
pack_start (format_align, false, false, 0);
|
|
|
|
pack_start (filename_label, false, false, 0);
|
|
|
|
pack_start (filename_align, false, false, 0);
|
2016-02-10 15:28:43 -05:00
|
|
|
|
|
|
|
Gtk::HBox *hbox = Gtk::manage (new Gtk::HBox());
|
|
|
|
hbox->set_spacing (6);
|
2017-03-18 10:05:54 -04:00
|
|
|
#ifndef NDEBUG // SoundCloud upload is currently b0rked, needs debugging
|
2016-02-10 15:28:43 -05:00
|
|
|
hbox->pack_start (soundcloud_upload_button, false, false, 0);
|
2017-03-18 10:05:54 -04:00
|
|
|
#endif
|
2016-02-10 15:28:43 -05:00
|
|
|
hbox->pack_start (analysis_button, false, false, 0);
|
|
|
|
pack_start (*hbox, false, false, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
format_align.add (format_selector);
|
|
|
|
format_align.set_padding (6, 12, 18, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
filename_align.add (filename_selector);
|
|
|
|
filename_align.set_padding (0, 12, 18, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
Pango::AttrList bold;
|
|
|
|
Pango::Attribute b = Pango::Attribute::create_attr_weight (Pango::WEIGHT_BOLD);
|
|
|
|
bold.insert (b);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
format_label.set_attributes (bold);
|
|
|
|
filename_label.set_attributes (bold);
|
|
|
|
tab_label.set_attributes (bold);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
/* Set states */
|
|
|
|
format_selector.set_state (format_state, s);
|
2016-02-10 15:28:43 -05:00
|
|
|
filename_selector.set_state (filename_state, s);
|
|
|
|
analysis_button.set_active (format_state->format->analyse());
|
2016-09-14 06:00:29 -04:00
|
|
|
soundcloud_upload_button.set_active (format_state->format->soundcloud_upload());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
/* Signals */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
tab_close_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*parent, &ExportFileNotebook::remove_file_page), this));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
profile_manager->FormatListChanged.connect (format_connection, invalidator (*this), boost::bind (&ExportFormatSelector::update_format_list, &format_selector), gui_context());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
format_selector.FormatEdited.connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::save_format_to_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));
|
2018-11-21 17:21:13 -05:00
|
|
|
format_selector.FormatReverted.connect (sigc::mem_fun (*profile_manager, &ExportProfileManager::revert_format_profile));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-01-29 15:55:44 -05:00
|
|
|
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));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-23 13:14:37 -04:00
|
|
|
soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*parent, &ExportFileNotebook::update_soundcloud_upload));
|
2016-09-14 06:00:29 -04:00
|
|
|
soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::soundcloud_upload_changed));
|
2016-02-10 15:28:43 -05:00
|
|
|
analysis_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::analysis_changed));
|
2008-09-29 13:01:52 -04:00
|
|
|
/* Tab widget */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
tab_close_button.add (*Gtk::manage (new Gtk::Image (::get_icon("close"))));
|
|
|
|
tab_close_alignment.add (tab_close_button);
|
|
|
|
tab_close_alignment.set (0.5, 0.5, 0, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
tab_widget.pack_start (tab_label, false, false, 3);
|
|
|
|
tab_widget.pack_end (tab_close_alignment, false, false, 0);
|
|
|
|
tab_widget.show_all_children ();
|
|
|
|
update_tab_label ();
|
2012-01-29 15:55:44 -05:00
|
|
|
update_example_filename();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
/* Done */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
show_all_children ();
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFileNotebook::FilePage::~FilePage ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::set_remove_sensitive (bool value)
|
|
|
|
{
|
|
|
|
tab_close_button.set_sensitive (value);
|
|
|
|
}
|
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string
|
2008-09-29 13:01:52 -04:00
|
|
|
ExportFileNotebook::FilePage::get_format_name () const
|
|
|
|
{
|
|
|
|
if (format_state && format_state->format) {
|
|
|
|
return format_state->format->name();
|
|
|
|
}
|
2012-07-17 09:11:15 -04:00
|
|
|
return _("No format!");
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
|
2014-05-23 13:14:37 -04:00
|
|
|
bool
|
|
|
|
ExportFileNotebook::FilePage::get_soundcloud_upload () const
|
|
|
|
{
|
2017-03-18 10:05:54 -04:00
|
|
|
#ifdef NDEBUG // SoundCloud upload is currently b0rked, needs debugging
|
|
|
|
return false;
|
|
|
|
#endif
|
2014-05-23 13:14:37 -04:00
|
|
|
return soundcloud_upload_button.get_active ();
|
|
|
|
}
|
|
|
|
|
2016-09-14 06:00:29 -04:00
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::soundcloud_upload_changed ()
|
|
|
|
{
|
2016-09-17 06:28:34 -04:00
|
|
|
profile_manager->save_format_to_disk (format_state->format);
|
2016-09-14 06:00:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::update_soundcloud_upload_button ()
|
|
|
|
{
|
|
|
|
soundcloud_upload_button.set_active (format_state->format->soundcloud_upload());
|
|
|
|
}
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::save_format_to_manager (FormatPtr format)
|
|
|
|
{
|
|
|
|
profile_manager->save_format_to_disk (format);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::update_tab_label ()
|
|
|
|
{
|
2012-07-17 09:11:15 -04:00
|
|
|
tab_label.set_text (string_compose (_("Format %1: %2"), tab_number, get_format_name()));
|
2012-01-29 15:55:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::update_example_filename()
|
|
|
|
{
|
|
|
|
if (profile_manager) {
|
2016-02-11 14:53:32 -05:00
|
|
|
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);
|
|
|
|
}
|
2012-02-26 15:48:51 -05:00
|
|
|
|
|
|
|
std::string example;
|
|
|
|
if (format_state->format) {
|
|
|
|
example = profile_manager->get_sample_filename_for_format (
|
|
|
|
filename_state->filename, format_state->format);
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-01-29 15:55:44 -05:00
|
|
|
if (example != "") {
|
2012-06-23 01:08:53 -04:00
|
|
|
filename_selector.set_example_filename(Glib::path_get_basename (example));
|
2012-01-29 15:55:44 -05:00
|
|
|
} else {
|
|
|
|
filename_selector.set_example_filename("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFileNotebook::FilePage::critical_selection_changed ()
|
|
|
|
{
|
|
|
|
update_tab_label();
|
|
|
|
update_example_filename();
|
2016-09-14 06:00:29 -04:00
|
|
|
update_analysis_button();
|
|
|
|
update_soundcloud_upload_button();
|
2008-09-29 13:01:52 -04:00
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|