2008-09-17 08:56:00 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2008 Sakari Bergen <sakari.bergen@beatwaves.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/messagedialog.h>
|
|
|
|
#include <gtkmm/stock.h>
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/export_format_specification.h"
|
|
|
|
#include "ardour/export_profile_manager.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2017-07-16 21:48:18 -04:00
|
|
|
#include "export_format_selector.h"
|
|
|
|
#include "export_format_dialog.h"
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
ExportFormatSelector::ExportFormatSelector () :
|
|
|
|
edit_button (Gtk::Stock::EDIT),
|
|
|
|
remove_button (Gtk::Stock::REMOVE),
|
|
|
|
new_button (Gtk::Stock::NEW)
|
|
|
|
{
|
|
|
|
pack_start (format_combo, true, true, 0);
|
|
|
|
pack_start (edit_button, false, false, 3);
|
|
|
|
pack_start (remove_button, false, false, 3);
|
|
|
|
pack_start (new_button, false, false, 3);
|
|
|
|
|
|
|
|
edit_button.signal_clicked().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &ExportFormatSelector::open_edit_dialog), false)));
|
2013-06-19 12:52:06 -04:00
|
|
|
remove_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatSelector::remove_format), true));
|
2008-09-17 08:56:00 -04:00
|
|
|
new_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatSelector::add_new_format));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Format combo */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
format_list = Gtk::ListStore::create (format_cols);
|
2011-03-13 12:22:24 -04:00
|
|
|
format_list->set_sort_column (format_cols.label, Gtk::SORT_ASCENDING);
|
2008-09-17 08:56:00 -04:00
|
|
|
format_combo.set_model (format_list);
|
|
|
|
format_combo.pack_start (format_cols.label);
|
|
|
|
format_combo.set_active (0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
format_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatSelector::update_format_combo));
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormatSelector::~ExportFormatSelector ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFormatSelector::set_state (ARDOUR::ExportProfileManager::FormatStatePtr const state_, ARDOUR::Session * session_)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
SessionHandlePtr::set_session (session_);
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
state = state_;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
update_format_list ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFormatSelector::update_format_list ()
|
|
|
|
{
|
|
|
|
FormatPtr format_to_select = state->format;
|
|
|
|
format_list->clear();
|
|
|
|
|
|
|
|
if (state->list->empty()) {
|
|
|
|
edit_button.set_sensitive (false);
|
|
|
|
remove_button.set_sensitive (false);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
edit_button.set_sensitive (true);
|
|
|
|
remove_button.set_sensitive (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Gtk::ListStore::iterator tree_it;
|
|
|
|
|
|
|
|
for (FormatList::const_iterator it = state->list->begin(); it != state->list->end(); ++it) {
|
|
|
|
tree_it = format_list->append();
|
|
|
|
tree_it->set_value (format_cols.format, *it);
|
|
|
|
tree_it->set_value (format_cols.label, (*it)->description());
|
|
|
|
}
|
|
|
|
|
2012-05-07 21:49:35 -04:00
|
|
|
if (format_combo.get_active_row_number() == -1 && format_combo.get_model()->children().size() > 0) {
|
2008-09-17 08:56:00 -04:00
|
|
|
format_combo.set_active (0);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
select_format (format_to_select);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFormatSelector::select_format (FormatPtr f)
|
|
|
|
{
|
|
|
|
Gtk::TreeModel::Children::iterator it;
|
|
|
|
for (it = format_list->children().begin(); it != format_list->children().end(); ++it) {
|
|
|
|
if (it->get_value (format_cols.format) == f) {
|
|
|
|
format_combo.set_active (it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFormatSelector::add_new_format ()
|
|
|
|
{
|
|
|
|
FormatPtr new_format = state->format = NewFormat (state->format);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
if (open_edit_dialog (true) != Gtk::RESPONSE_APPLY) {
|
2013-06-19 12:52:06 -04:00
|
|
|
remove_format(false);
|
2008-09-17 08:56:00 -04:00
|
|
|
if (state->list->empty()) {
|
|
|
|
state->format.reset ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-19 12:52:06 -04:00
|
|
|
ExportFormatSelector::remove_format (bool called_from_button)
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2013-06-19 12:52:06 -04:00
|
|
|
if (called_from_button) {
|
|
|
|
Gtk::MessageDialog dialog (_("Do you really want to remove the format?"),
|
|
|
|
false,
|
|
|
|
Gtk::MESSAGE_QUESTION,
|
|
|
|
Gtk::BUTTONS_YES_NO);
|
|
|
|
|
|
|
|
if (Gtk::RESPONSE_YES != dialog.run ()) {
|
|
|
|
/* User has selected "no" or closed the dialog, better
|
|
|
|
* abort
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
FormatPtr remove;
|
|
|
|
Gtk::TreeModel::iterator it = format_combo.get_active();
|
|
|
|
remove = it->get_value (format_cols.format);
|
2013-06-19 12:52:06 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
FormatRemoved (remove);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ExportFormatSelector::open_edit_dialog (bool new_dialog)
|
|
|
|
{
|
|
|
|
ExportFormatDialog dialog (state->format, new_dialog);
|
2009-12-17 13:24:23 -05:00
|
|
|
dialog.set_session (_session);
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::ResponseType response = (Gtk::ResponseType) dialog.run();
|
|
|
|
if (response == Gtk::RESPONSE_APPLY) {
|
|
|
|
update_format_description ();
|
|
|
|
FormatEdited (state->format);
|
|
|
|
CriticalSelectionChanged();
|
2018-11-21 17:21:13 -05:00
|
|
|
} else {
|
|
|
|
FormatReverted (state->format);
|
|
|
|
CriticalSelectionChanged();
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFormatSelector::update_format_combo ()
|
|
|
|
{
|
|
|
|
Gtk::TreeModel::iterator it = format_combo.get_active();
|
|
|
|
if (format_list->iter_is_valid (it)) {
|
|
|
|
state->format = it->get_value(format_cols.format);
|
|
|
|
} else if (!format_list->children().empty()) {
|
|
|
|
format_combo.set_active (0);
|
|
|
|
} else {
|
|
|
|
edit_button.set_sensitive (false);
|
|
|
|
remove_button.set_sensitive (false);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFormatSelector::update_format_description ()
|
|
|
|
{
|
|
|
|
format_combo.get_active()->set_value(format_cols.label, state->format->description());
|
|
|
|
}
|