13
0
livetrax/gtk2_ardour/export_format_selector.cc
David Robillard e0aaed6d65 *** NEW CODING POLICY ***
All #include statements that include a header that is a part of a library
bundled with ardour MUST use quotes, not angle brackets.

Do this:

#include "ardour/types.h"

NOT this:

#include <ardour/types.h>

Rationale:

This is best practice in general, to ensure we include the local version
and not the system version.  That quotes mean "local" (in some sense)
and angle brackets mean "system" (in some sense) is a ubiquitous
convention and IIRC right in the C spec somewhere.

More pragmatically, this is required by (my) waf (stuff) for dependencies
to work correctly.  That is:

!!! FAILURE TO DO THIS CAN RESULT IN BROKEN BUILDS !!!

Failure to comply is punishable by death by torture. :)

P.S. It's not that dramatic in all cases, but this (in combination with some
GCC flags specific to the include type) is the best way I have found to be
absolutely 100% positive the local ones are being used (and we definitely
want to be absolutely 100% positive on that one).


git-svn-id: svn://localhost/ardour2/branches/3.0@4655 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-02-25 18:26:51 +00:00

175 lines
4.7 KiB
C++

/*
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_format_selector.h"
#include "export_format_dialog.h"
#include "ardour/export_format_specification.h"
#include "ardour/export_profile_manager.h"
#include "ardour/session.h"
#include "i18n.h"
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);
format_combo.set_name ("PaddedButton");
edit_button.set_name ("PaddedButton");
remove_button.set_name ("PaddedButton");
new_button.set_name ("PaddedButton");
edit_button.signal_clicked().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &ExportFormatSelector::open_edit_dialog), false)));
remove_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatSelector::remove_format));
new_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatSelector::add_new_format));
/* Format combo */
format_list = Gtk::ListStore::create (format_cols);
format_combo.set_model (format_list);
format_combo.pack_start (format_cols.label);
format_combo.set_active (0);
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_)
{
session = session_;
state = state_;
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());
}
if (format_combo.get_active_row_number() == -1) {
format_combo.set_active (0);
}
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;
}
}
CriticalSelectionChanged();
}
void
ExportFormatSelector::add_new_format ()
{
FormatPtr new_format = state->format = NewFormat (state->format);
if (open_edit_dialog (true) != Gtk::RESPONSE_APPLY) {
remove_format();
if (state->list->empty()) {
state->format.reset ();
}
}
}
void
ExportFormatSelector::remove_format ()
{
FormatPtr remove;
Gtk::TreeModel::iterator it = format_combo.get_active();
remove = it->get_value (format_cols.format);
FormatRemoved (remove);
}
int
ExportFormatSelector::open_edit_dialog (bool new_dialog)
{
ExportFormatDialog dialog (state->format, new_dialog);
dialog.set_session (session);
Gtk::ResponseType response = (Gtk::ResponseType) dialog.run();
if (response == Gtk::RESPONSE_APPLY) {
update_format_description ();
FormatEdited (state->format);
CriticalSelectionChanged();
}
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);
}
CriticalSelectionChanged();
}
void
ExportFormatSelector::update_format_description ()
{
format_combo.get_active()->set_value(format_cols.label, state->format->description());
}