Merge edit and mix groups to just being route groups. Add properties to route groups...
[ardour.git] / gtk2_ardour / group_tabs.cc
1 /*
2     Copyright (C) 2009 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <gtkmm/stock.h>
21 #include "ardour/session.h"
22 #include "ardour/route_group.h"
23 #include "route_group_dialog.h"
24 #include "group_tabs.h"
25 #include "i18n.h"
26
27 using namespace Gtk;
28 using namespace ARDOUR;
29
30 GroupTabs::GroupTabs ()
31         : _session (0),
32           _menu (0)
33 {
34
35 }
36
37 void
38 GroupTabs::set_session (Session* s)
39 {
40         _session = s;
41         s->RouteGroupChanged.connect (mem_fun (*this, &GroupTabs::set_dirty));
42 }
43
44
45 /** Handle a size request.
46  *  @param req GTK requisition
47  */
48 void
49 GroupTabs::on_size_request (Gtk::Requisition *req)
50 {
51         /* Use a dummy, small width and the actual height that we want */
52         req->width = 16;
53         req->height = 16;
54 }
55
56 bool
57 GroupTabs::on_button_press_event (GdkEventButton* ev)
58 {
59         using namespace Menu_Helpers;
60         
61         RouteGroup* g = click_to_route_group (ev);
62         
63         if (ev->button == 1 && g) {
64                 
65                 g->set_active (!g->is_active (), this);
66                 
67         } else if (ev->button == 3 && g) {
68
69                 if (!_menu) {
70                         _menu = new Menu;
71                         MenuList& items = _menu->items ();
72                         items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &GroupTabs::edit_group), g)));
73                         items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &GroupTabs::remove_group), g)));
74                 }
75
76                 _menu->popup (ev->button, ev->time);
77
78         }
79
80         return true;
81 }
82
83
84 void
85 GroupTabs::edit_group (RouteGroup* g)
86 {
87         RouteGroupDialog d (g, Gtk::Stock::APPLY);
88         d.do_run ();
89 }
90
91 void
92 GroupTabs::remove_group (RouteGroup *g)
93 {
94         _session->remove_route_group (*g);
95 }