2009-06-28 20:57:27 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Paul Davis
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-06-28 20:38:58 -04:00
|
|
|
#include <gtkmm/menu.h>
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/route_group.h"
|
|
|
|
#include "route_group_menu.h"
|
|
|
|
#include "route_group_dialog.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace ARDOUR;
|
2010-02-18 08:59:49 -05:00
|
|
|
using namespace PBD;
|
2009-06-28 20:38:58 -04:00
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
RouteGroupMenu::RouteGroupMenu (Session* s, PropertyList* plist)
|
2009-12-17 13:24:23 -05:00
|
|
|
: SessionHandlePtr (s)
|
2010-02-18 08:59:49 -05:00
|
|
|
, _default_properties (plist)
|
2010-01-12 20:40:07 -05:00
|
|
|
, _inhibit_group_selected (false)
|
|
|
|
, _selected_route_group (0)
|
2009-06-28 20:38:58 -04:00
|
|
|
{
|
|
|
|
rebuild (0);
|
|
|
|
}
|
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
RouteGroupMenu::~RouteGroupMenu()
|
|
|
|
{
|
|
|
|
delete _default_properties;
|
|
|
|
}
|
|
|
|
|
2009-06-28 20:38:58 -04:00
|
|
|
void
|
|
|
|
RouteGroupMenu::rebuild (RouteGroup* curr)
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 20:40:07 -05:00
|
|
|
_selected_route_group = curr;
|
|
|
|
|
|
|
|
_inhibit_group_selected = true;
|
|
|
|
|
2009-06-28 20:38:58 -04:00
|
|
|
items().clear ();
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items().push_back (MenuElem (_("New group..."), sigc::mem_fun (*this, &RouteGroupMenu::new_group)));
|
2009-06-28 20:38:58 -04:00
|
|
|
items().push_back (SeparatorElem ());
|
|
|
|
|
|
|
|
RadioMenuItem::Group group;
|
2009-12-11 18:29:48 -05:00
|
|
|
items().push_back (RadioMenuElem (group, _("No group"), sigc::bind (sigc::mem_fun (*this, &RouteGroupMenu::set_group), (RouteGroup *) 0)));
|
2009-06-28 20:38:58 -04:00
|
|
|
|
|
|
|
if (curr == 0) {
|
|
|
|
static_cast<RadioMenuItem*> (&items().back())->set_active ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session) {
|
|
|
|
_session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &RouteGroupMenu::add_item), curr, &group));
|
|
|
|
}
|
2010-01-12 20:40:07 -05:00
|
|
|
|
|
|
|
_inhibit_group_selected = false;
|
2009-06-28 20:38:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteGroupMenu::add_item (RouteGroup* rg, RouteGroup* curr, RadioMenuItem::Group* group)
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
items().push_back (RadioMenuElem (*group, rg->name(), sigc::bind (sigc::mem_fun(*this, &RouteGroupMenu::set_group), rg)));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-28 20:38:58 -04:00
|
|
|
if (rg == curr) {
|
|
|
|
static_cast<RadioMenuItem*> (&items().back())->set_active ();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-06-28 20:38:58 -04:00
|
|
|
}
|
|
|
|
|
2011-01-05 20:07:10 -05:00
|
|
|
/** Called when a group is selected from the menu.
|
|
|
|
* @param Group, or 0 for none.
|
|
|
|
*/
|
2009-06-28 20:38:58 -04:00
|
|
|
void
|
|
|
|
RouteGroupMenu::set_group (RouteGroup* g)
|
|
|
|
{
|
2010-01-12 20:40:07 -05:00
|
|
|
if (g == _selected_route_group) {
|
|
|
|
/* cut off the signal_toggled that GTK emits for an option that is being un-selected
|
|
|
|
when a new option is being selected instead
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_inhibit_group_selected) {
|
|
|
|
GroupSelected (g);
|
|
|
|
}
|
|
|
|
|
|
|
|
_selected_route_group = g;
|
2009-06-28 20:38:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteGroupMenu::new_group ()
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
RouteGroup* g = new RouteGroup (*_session, "");
|
2010-08-25 13:31:33 -04:00
|
|
|
g->apply_changes (*_default_properties);
|
2009-06-28 20:38:58 -04:00
|
|
|
|
2011-01-07 21:35:46 -05:00
|
|
|
RouteGroupDialog d (g, true);
|
2009-06-28 20:38:58 -04:00
|
|
|
|
2011-01-07 21:35:46 -05:00
|
|
|
if (d.do_run ()) {
|
|
|
|
delete g;
|
|
|
|
} else {
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->add_route_group (g);
|
2009-06-28 20:38:58 -04:00
|
|
|
set_group (g);
|
|
|
|
}
|
|
|
|
}
|