enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / tranzport / state.cc
1 /*
2  *   Copyright (C) 2006 Paul Davis
3  *   Copyright (C) 2007 Michael Taht
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *   GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  */
20
21 #include <iostream>
22 #include <algorithm>
23 #include <cmath>
24
25 #define __STDC_FORMAT_MACROS
26 #include <inttypes.h>
27 #include <float.h>
28 #include <sys/time.h>
29 #include <errno.h>
30 #include "ardour/route.h"
31 #include "ardour/audio_track.h"
32 #include "ardour/session.h"
33 #include "ardour/location.h"
34 #include "ardour/dB.h"
35
36 using namespace ARDOUR;
37 using namespace std;
38 using namespace sigc;
39 using namespace PBD;
40
41 #include "pbd/i18n.h"
42
43 #include "pbd/abstract_ui.cc"
44
45 #include "tranzport_control_protocol.h"
46
47
48 // FIXME: How to handle multiple tranzports in a system?
49
50 XMLNode&
51 TranzportControlProtocol::get_state ()
52 {
53         return ControlProtocol::get_state();
54 }
55
56 int
57 TranzportControlProtocol::set_state (const XMLNode& node)
58 {
59         cout << "TranzportControlProtocol::set_state: active " << _active << endl;
60         int retval = 0;
61
62 // I think I want to make these strings rather than numbers
63 #if 0
64         // fetch current display mode
65         if ( node.property( X_("display_mode") ) != 0 )
66         {
67                 string display = node.property( X_("display_mode") )->value();
68                 try
69                 {
70                         set_active( true );
71                         int32_t new_display = atoi( display.c_str() );
72                         if ( display_mode != new_display ) display_mode = (DisplayMode)new_display;
73                 }
74                 catch ( exception & e )
75                 {
76                         cout << "exception in TranzportControlProtocol::set_state: " << e.what() << endl;
77                         return -1;
78                 }
79         }
80
81         if ( node.property( X_("wheel_mode") ) != 0 )
82         {
83                 string wheel = node.property( X_("wheel_mode") )->value();
84                 try
85                 {
86                         int32_t new_wheel = atoi( wheel.c_str() );
87                         if ( wheel_mode != new_wheel ) wheel_mode = (WheelMode) new_wheel;
88                 }
89                 catch ( exception & e )
90                 {
91                         cout << "exception in TranzportControlProtocol::set_state: " << e.what() << endl;
92                         return -1;
93                 }
94         }
95
96         // fetch current bling mode
97         if ( node.property( X_("bling") ) != 0 )
98         {
99                 string bling = node.property( X_("bling_mode") )->value();
100                 try
101                 {
102                         int32_t new_bling = atoi( bling.c_str() );
103                         if ( bling_mode != new_bling ) bling_mode = (BlingMode) new_bling;
104                 }
105                 catch ( exception & e )
106                 {
107                         cout << "exception in TranzportControlProtocol::set_state: " << e.what() << endl;
108                         return -1;
109                 }
110         }
111 #endif
112
113         return retval;
114
115 }
116
117 // These are intended for the day we have more options for tranzport modes
118 // And perhaps we could load up sessions this way, too
119
120 int
121 TranzportControlProtocol::save (char *name)
122 {
123         // Presently unimplemented
124         return 0;
125 }
126
127 int
128 TranzportControlProtocol::load (char *name)
129 {
130         // Presently unimplemented
131         return 0;
132 }
133
134 int
135 TranzportControlProtocol::save_config (char *name)
136 {
137         // Presently unimplemented
138         return 0;
139 }
140
141 int
142 TranzportControlProtocol::load_config (char *name)
143 {
144         // Presently unimplemented
145         return 0;
146 }