2008-09-17 08:56:00 -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_filename_selector.h"
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/export_handler.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/session_directory.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
|
|
|
ExportFilenameSelector::ExportFilenameSelector () :
|
2009-12-17 13:24:23 -05:00
|
|
|
include_label (_("Include in Filename(s):"), 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"))
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
|
|
|
pack_start (include_label, false, false, 6);
|
|
|
|
pack_start (include_hbox, false, false, 0);
|
|
|
|
pack_start (path_hbox, false, false, 12);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
include_hbox.pack_start (label_label, false, false, 3);
|
|
|
|
include_hbox.pack_start (label_entry, false, false, 3);
|
|
|
|
include_hbox.pack_start (session_checkbox, false, false, 3);
|
|
|
|
include_hbox.pack_start (date_format_combo, false, false, 3);
|
|
|
|
include_hbox.pack_start (time_format_combo, false, false, 3);
|
|
|
|
include_hbox.pack_start (revision_checkbox, false, false, 3);
|
|
|
|
include_hbox.pack_start (revision_spinbutton, false, false, 3);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-02-15 20:08:25 -05:00
|
|
|
label_entry.set_activates_default ();
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
path_hbox.pack_start (path_label, false, false, 3);
|
|
|
|
path_hbox.pack_start (path_entry, true, true, 3);
|
|
|
|
path_hbox.pack_start (browse_button, false, false, 3);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-02-15 20:08:25 -05:00
|
|
|
path_entry.set_activates_default ();
|
|
|
|
|
2008-10-11 11:35:36 -04:00
|
|
|
date_format_combo.set_name ("PaddedButton");
|
|
|
|
time_format_combo.set_name ("PaddedButton");
|
2008-10-11 10:07:50 -04:00
|
|
|
browse_button.set_name ("PaddedButton");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
label_sizegroup = Gtk::SizeGroup::create (Gtk::SIZE_GROUP_HORIZONTAL);
|
|
|
|
label_sizegroup->add_widget (label_label);
|
|
|
|
label_sizegroup->add_widget (path_label);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Date */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
date_format_list = Gtk::ListStore::create (date_format_cols);
|
|
|
|
date_format_combo.set_model (date_format_list);
|
|
|
|
date_format_combo.pack_start (date_format_cols.label);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
date_format_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_date_format));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Time */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
time_format_list = Gtk::ListStore::create (time_format_cols);
|
|
|
|
time_format_combo.set_model (time_format_list);
|
|
|
|
time_format_combo.pack_start (time_format_cols.label);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
time_format_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_time_format));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Revision */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
revision_spinbutton.set_digits (0);
|
|
|
|
revision_spinbutton.set_increments (1, 10);
|
|
|
|
revision_spinbutton.set_range (1, 1000);
|
|
|
|
revision_spinbutton.set_sensitive (false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Signals */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
label_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::update_label));
|
|
|
|
path_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::update_folder));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
session_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_session_selection));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
revision_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_revision_selection));
|
|
|
|
revision_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_revision_value));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
browse_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFilenameSelector::open_browse_dialog));
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ExportFilenameSelector::~ExportFilenameSelector ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::load_state ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
label_entry.set_text (filename->include_label ? filename->get_label() : "");
|
|
|
|
session_checkbox.set_active (filename->include_session);
|
|
|
|
revision_checkbox.set_active (filename->include_revision);
|
|
|
|
revision_spinbutton.set_value (filename->get_revision());
|
|
|
|
path_entry.set_text (filename->get_folder());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::TreeModel::Children::iterator it;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
for (it = date_format_list->children().begin(); it != date_format_list->children().end(); ++it) {
|
|
|
|
if (it->get_value (date_format_cols.format) == filename->get_date_format()) {
|
|
|
|
date_format_combo.set_active (it);
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
for (it = time_format_list->children().begin(); it != time_format_list->children().end(); ++it) {
|
|
|
|
if (it->get_value (time_format_cols.format) == filename->get_time_format()) {
|
|
|
|
time_format_combo.set_active (it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::set_state (ARDOUR::ExportProfileManager::FilenameStatePtr state_, ARDOUR::Session * session_)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
SessionHandlePtr::set_session (session_);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
filename = state_->filename;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Fill combo boxes */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::TreeModel::iterator iter;
|
|
|
|
Gtk::TreeModel::Row row;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Dates */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
date_format_list->clear();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = date_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[date_format_cols.format] = ExportFilename::D_None;
|
|
|
|
row[date_format_cols.label] = filename->get_date_format_str (ExportFilename::D_None);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = date_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[date_format_cols.format] = ExportFilename::D_ISO;
|
|
|
|
row[date_format_cols.label] = filename->get_date_format_str (ExportFilename::D_ISO);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = date_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[date_format_cols.format] = ExportFilename::D_ISOShortY;
|
|
|
|
row[date_format_cols.label] = filename->get_date_format_str (ExportFilename::D_ISOShortY);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = date_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[date_format_cols.format] = ExportFilename::D_BE;
|
|
|
|
row[date_format_cols.label] = filename->get_date_format_str (ExportFilename::D_BE);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = date_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[date_format_cols.format] = ExportFilename::D_BEShortY;
|
|
|
|
row[date_format_cols.label] = filename->get_date_format_str (ExportFilename::D_BEShortY);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Times */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
time_format_list->clear();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = time_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[time_format_cols.format] = ExportFilename::T_None;
|
|
|
|
row[time_format_cols.label] = filename->get_time_format_str (ExportFilename::T_None);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = time_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[time_format_cols.format] = ExportFilename::T_NoDelim;
|
|
|
|
row[time_format_cols.label] = filename->get_time_format_str (ExportFilename::T_NoDelim);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = time_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[time_format_cols.format] = ExportFilename::T_Delim;
|
|
|
|
row[time_format_cols.label] = filename->get_time_format_str (ExportFilename::T_Delim);
|
|
|
|
|
|
|
|
/* Load state */
|
|
|
|
|
|
|
|
load_state();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::update_label ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
filename->set_label (label_entry.get_text());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
filename->include_label = !label_entry.get_text().empty();
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::update_folder ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
filename->set_folder (path_entry.get_text());
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::change_date_format ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
DateFormat format = date_format_combo.get_active()->get_value (date_format_cols.format);
|
|
|
|
filename->set_date_format (format);
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::change_time_format ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
TimeFormat format = time_format_combo.get_active()->get_value (time_format_cols.format);
|
|
|
|
filename->set_time_format (format);
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::change_session_selection ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
filename->include_session = session_checkbox.get_active();
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::change_revision_selection ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
bool selected = revision_checkbox.get_active();
|
|
|
|
filename->include_revision = selected;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
revision_spinbutton.set_sensitive (selected);
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::change_revision_value ()
|
|
|
|
{
|
|
|
|
if (!filename) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
filename->set_revision ((uint32_t) revision_spinbutton.get_value_as_int());
|
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportFilenameSelector::open_browse_dialog ()
|
|
|
|
{
|
|
|
|
Gtk::FileChooserDialog dialog(_("Choose export folder"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
|
|
|
//dialog.set_transient_for(*this);
|
|
|
|
dialog.set_filename (path_entry.get_text());
|
|
|
|
|
|
|
|
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
|
|
|
dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
|
|
|
|
|
|
|
int result = dialog.run();
|
|
|
|
|
|
|
|
if (result == Gtk::RESPONSE_OK) {
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string filename = dialog.get_filename();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
if (filename.length()) {
|
|
|
|
path_entry.set_text (filename);
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|