13
0

Make Route Group dialog instant-apply. Disallow identically-named route group; fixes #3689.

git-svn-id: svn://localhost/ardour2/branches/3.0@8481 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-01-08 02:35:46 +00:00
parent 150d3fdfbf
commit af0030a6de
6 changed files with 111 additions and 62 deletions

View File

@ -399,17 +399,15 @@ AddRouteDialog::group_changed ()
plist.add (Properties::active, true); plist.add (Properties::active, true);
g->apply_changes (plist); g->apply_changes (plist);
RouteGroupDialog d (g, Gtk::Stock::NEW); RouteGroupDialog d (g, true);
int const r = d.do_run ();
if (r == Gtk::RESPONSE_OK) { if (d.do_run ()) {
delete g;
route_group_combo.set_active (2);
} else {
_session->add_route_group (g); _session->add_route_group (g);
add_route_group (g); add_route_group (g);
route_group_combo.set_active (3); route_group_combo.set_active (3);
} else {
delete g;
route_group_combo.set_active (2);
} }
} }
} }

View File

@ -173,7 +173,7 @@ GroupTabs::on_button_release_event (GdkEventButton* ev)
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
/* edit */ /* edit */
RouteGroupDialog d (_dragging->group, Gtk::Stock::APPLY); RouteGroupDialog d (_dragging->group, false);
d.do_run (); d.do_run ();
} else { } else {
@ -374,7 +374,6 @@ GroupTabs::new_from_soloed ()
} }
run_new_group_dialog (soloed); run_new_group_dialog (soloed);
} }
void void
@ -383,19 +382,15 @@ GroupTabs::run_new_group_dialog (RouteList const & rl)
RouteGroup* g = new RouteGroup (*_session, ""); RouteGroup* g = new RouteGroup (*_session, "");
g->apply_changes (default_properties ()); g->apply_changes (default_properties ());
RouteGroupDialog d (g, Gtk::Stock::NEW); RouteGroupDialog d (g, true);
int const r = d.do_run ();
switch (r) { if (d.do_run ()) {
case Gtk::RESPONSE_OK: delete g;
case Gtk::RESPONSE_ACCEPT: } else {
_session->add_route_group (g); _session->add_route_group (g);
for (RouteList::const_iterator i = rl.begin(); i != rl.end(); ++i) { for (RouteList::const_iterator i = rl.begin(); i != rl.end(); ++i) {
g->add (*i); g->add (*i);
} }
break;
default:
delete g;
} }
} }
@ -406,10 +401,9 @@ GroupTabs::create_and_add_group () const
g->apply_changes (default_properties ()); g->apply_changes (default_properties ());
RouteGroupDialog d (g, Gtk::Stock::NEW); RouteGroupDialog d (g, true);
int const r = d.do_run ();
if (r != Gtk::RESPONSE_OK) { if (d.do_run ()) {
delete g; delete g;
return 0; return 0;
} }
@ -421,7 +415,7 @@ GroupTabs::create_and_add_group () const
void void
GroupTabs::edit_group (RouteGroup* g) GroupTabs::edit_group (RouteGroup* g)
{ {
RouteGroupDialog d (g, Gtk::Stock::APPLY); RouteGroupDialog d (g, false);
d.do_run (); d.do_run ();
} }

View File

@ -19,7 +19,9 @@
#include <gtkmm/table.h> #include <gtkmm/table.h>
#include <gtkmm/stock.h> #include <gtkmm/stock.h>
#include <gtkmm/messagedialog.h>
#include "ardour/route_group.h" #include "ardour/route_group.h"
#include "ardour/session.h"
#include "route_group_dialog.h" #include "route_group_dialog.h"
#include "i18n.h" #include "i18n.h"
#include <iostream> #include <iostream>
@ -29,17 +31,18 @@ using namespace ARDOUR;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
RouteGroupDialog::RouteGroupDialog (RouteGroup* g, StockID const & s) RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
: ArdourDialog (_("Route Group")), : ArdourDialog (_("Route Group"))
_group (g), , _group (g)
_active (_("Active")), , _initial_name (g->name ())
_gain (_("Gain")), , _active (_("Active"))
_relative (_("Relative")), , _gain (_("Gain"))
_mute (_("Muting")), , _relative (_("Relative"))
_solo (_("Soloing")), , _mute (_("Muting"))
_rec_enable (_("Record enable")), , _solo (_("Soloing"))
_select (_("Selection")), , _rec_enable (_("Record enable"))
_edit (_("Editing")) , _select (_("Selection"))
, _edit (_("Editing"))
{ {
set_modal (true); set_modal (true);
set_skip_taskbar_hint (true); set_skip_taskbar_hint (true);
@ -84,6 +87,16 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, StockID const & s)
_select.set_active (_group->is_select()); _select.set_active (_group->is_select());
_edit.set_active (_group->is_edit()); _edit.set_active (_group->is_edit());
_name.signal_changed().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_gain.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_relative.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_mute.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_solo.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_rec_enable.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_select.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
_edit.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
gain_toggled (); gain_toggled ();
Table* table = manage (new Table (8, 3, false)); Table* table = manage (new Table (8, 3, false));
@ -114,36 +127,61 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, StockID const & s)
_gain.signal_toggled().connect(sigc::mem_fun (*this, &RouteGroupDialog::gain_toggled)); _gain.signal_toggled().connect(sigc::mem_fun (*this, &RouteGroupDialog::gain_toggled));
add_button (Stock::CANCEL, RESPONSE_CANCEL); if (creating_new) {
add_button (s, RESPONSE_OK); add_button (Stock::CANCEL, RESPONSE_CANCEL);
set_default_response (RESPONSE_OK); add_button (Stock::NEW, RESPONSE_OK);
set_default_response (RESPONSE_OK);
} else {
add_button (Stock::CLOSE, RESPONSE_CLOSE);
set_default_response (RESPONSE_CLOSE);
}
show_all_children (); show_all_children ();
} }
int /** @return true if the route group edit was cancelled, otherwise false */
bool
RouteGroupDialog::do_run () RouteGroupDialog::do_run ()
{ {
int const r = run (); while (1) {
int const r = run ();
if (r == Gtk::RESPONSE_OK || r == Gtk::RESPONSE_ACCEPT) { if (unique_name ()) {
return (r == Gtk::RESPONSE_CANCEL);
}
PropertyList plist; _group->set_name (_initial_name);
MessageDialog msg (
_("A route group of this name already exists. Please use a different name."),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true
);
plist.add (Properties::gain, _gain.get_active()); msg.run ();
plist.add (Properties::recenable, _rec_enable.get_active());
plist.add (Properties::mute, _mute.get_active());
plist.add (Properties::solo, _solo.get_active ());
plist.add (Properties::select, _select.get_active());
plist.add (Properties::edit, _edit.get_active());
plist.add (Properties::relative, _relative.get_active());
plist.add (Properties::active, _active.get_active());
plist.add (Properties::name, string (_name.get_text()));
_group->apply_changes (plist);
} }
return r; /* NOTREACHED */
return false;
}
void
RouteGroupDialog::update ()
{
PropertyList plist;
plist.add (Properties::gain, _gain.get_active());
plist.add (Properties::recenable, _rec_enable.get_active());
plist.add (Properties::mute, _mute.get_active());
plist.add (Properties::solo, _solo.get_active ());
plist.add (Properties::select, _select.get_active());
plist.add (Properties::edit, _edit.get_active());
plist.add (Properties::relative, _relative.get_active());
plist.add (Properties::active, _active.get_active());
plist.add (Properties::name, string (_name.get_text()));
_group->apply_changes (plist);
} }
void void
@ -152,3 +190,15 @@ RouteGroupDialog::gain_toggled ()
_relative.set_sensitive (_gain.get_active ()); _relative.set_sensitive (_gain.get_active ());
} }
/** @return true if the current group's name is unique accross the session */
bool
RouteGroupDialog::unique_name () const
{
list<RouteGroup*> route_groups = _group->session().route_groups ();
list<RouteGroup*>::iterator i = route_groups.begin ();
while (i != route_groups.end() && ((*i)->name() != _name.get_text() || *i == _group)) {
++i;
}
return (i == route_groups.end ());
}

View File

@ -29,12 +29,13 @@
class RouteGroupDialog : public ArdourDialog class RouteGroupDialog : public ArdourDialog
{ {
public: public:
RouteGroupDialog (ARDOUR::RouteGroup *, Gtk::StockID const &); RouteGroupDialog (ARDOUR::RouteGroup *, bool);
int do_run (); bool do_run ();
private: private:
ARDOUR::RouteGroup* _group; ARDOUR::RouteGroup* _group;
std::string _initial_name;
Gtk::Entry _name; Gtk::Entry _name;
Gtk::CheckButton _active; Gtk::CheckButton _active;
@ -45,8 +46,11 @@ private:
Gtk::CheckButton _rec_enable; Gtk::CheckButton _rec_enable;
Gtk::CheckButton _select; Gtk::CheckButton _select;
Gtk::CheckButton _edit; Gtk::CheckButton _edit;
Gtk::Button* _ok;
void gain_toggled (); void gain_toggled ();
void update ();
bool unique_name () const;
}; };

View File

@ -113,13 +113,12 @@ RouteGroupMenu::new_group ()
RouteGroup* g = new RouteGroup (*_session, ""); RouteGroup* g = new RouteGroup (*_session, "");
g->apply_changes (*_default_properties); g->apply_changes (*_default_properties);
RouteGroupDialog d (g, Gtk::Stock::NEW); RouteGroupDialog d (g, true);
int const r = d.do_run ();
if (r == Gtk::RESPONSE_OK) { if (d.do_run ()) {
delete g;
} else {
_session->add_route_group (g); _session->add_route_group (g);
set_group (g); set_group (g);
} else {
delete g;
} }
} }

View File

@ -409,6 +409,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
} }
} }
std::list<RouteGroup*> const & route_groups () const {
return _route_groups;
}
/* fundamental operations. duh. */ /* fundamental operations. duh. */
std::list<boost::shared_ptr<AudioTrack> > new_audio_track ( std::list<boost::shared_ptr<AudioTrack> > new_audio_track (