Unconditionally save instant.xml on session-close
[ardour.git] / gtk2_ardour / io_selector.h
1 /*
2  * Copyright (C) 2005-2006 Doug McLain <doug@nostar.net>
3  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2005-2011 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2007-2010 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2007-2011 David Robillard <d@drobilla.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __gtkardour_io_selector_h__
24 #define __gtkardour_io_selector_h__
25
26 #include "port_matrix.h"
27 #include "ardour_window.h"
28
29 class IOSelector : public PortMatrix
30 {
31 public:
32         IOSelector (Gtk::Window*, ARDOUR::Session *, boost::shared_ptr<ARDOUR::IO>);
33
34         void set_state (ARDOUR::BundleChannel c[2], bool);
35         PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
36
37         std::string disassociation_verb () const;
38         std::string channel_noun () const;
39
40         ARDOUR::Session* session() const { return _session; }
41
42         uint32_t n_io_ports () const;
43         boost::shared_ptr<ARDOUR::IO> const io () { return _io; }
44         void setup_ports (int);
45         bool list_is_global (int) const;
46
47         bool find_inputs_for_io_outputs () const {
48                 return _find_inputs_for_io_outputs;
49         }
50
51         int ours () const {
52                 return _ours;
53         }
54
55         int other () const {
56                 return _other;
57         }
58
59 private:
60
61         void setup_type ();
62         void io_changed ();
63         void io_changed_proxy ();
64
65         int _other;
66         int _ours;
67         boost::shared_ptr<ARDOUR::IO> _io;
68         boost::shared_ptr<PortGroup> _port_group;
69         bool _find_inputs_for_io_outputs;
70         PBD::ScopedConnection _io_connection;
71 };
72
73 class IOSelectorWindow : public ArdourWindow
74 {
75   public:
76         IOSelectorWindow (ARDOUR::Session *, boost::shared_ptr<ARDOUR::IO>, bool can_cancel = false);
77
78         IOSelector& selector() { return _selector; }
79
80   protected:
81         void on_map ();
82         void on_show ();
83
84   private:
85         IOSelector _selector;
86
87         void io_name_changed (void *src);
88         bool wm_delete (GdkEventAny*);
89 };
90
91 #endif /* __gtkardour_io_selector_h__ */