per-kbd-layout keybindings selection; initial pass at link-region-and-track-selection
[ardour.git] / gtk2_ardour / opts.cc
1 /*
2     Copyright (C) 2001 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 <getopt.h>
21 #include <iostream>
22 #include <cstdlib>
23
24 #include "opts.h"
25
26 #include "i18n.h"
27
28 using namespace std;
29
30 Glib::ustring ARDOUR_COMMAND_LINE::session_name = "";
31 string ARDOUR_COMMAND_LINE::jack_client_name = "ardour";
32 bool  ARDOUR_COMMAND_LINE::show_key_actions = false;
33 bool ARDOUR_COMMAND_LINE::no_splash = true;
34 bool ARDOUR_COMMAND_LINE::just_version = false;
35 bool ARDOUR_COMMAND_LINE::use_vst = true;
36 bool ARDOUR_COMMAND_LINE::new_session = false;
37 char* ARDOUR_COMMAND_LINE::curvetest_file = 0;
38 bool ARDOUR_COMMAND_LINE::try_hw_optimization = true;
39 Glib::ustring ARDOUR_COMMAND_LINE::keybindings_path = ""; /* empty means use builtin default */
40 Glib::ustring ARDOUR_COMMAND_LINE::menus_file = "ardour.menus";
41
42 using namespace ARDOUR_COMMAND_LINE;
43
44 int
45 print_help (const char *execname)
46 {
47         cout << _("Usage: ") << execname << "\n"
48              << _("  -v, --version                    Show version information\n")
49              << _("  -h, --help                       Print this message\n")
50              << _("  -b, --bindings                   Print all possible keyboard binding names\n")
51              << _("  -n, --show-splash                Show splash screen\n")
52              << _("  -c, --name  name                 Use a specific jack client name, default is ardour\n")
53              << _("  -m, --menus file                 Use \"file\" for Ardour menus\n")                       
54              << _("  -N, --new session-name           Create a new session from the command line\n")
55              << _("  -O, --no-hw-optimizations        Disable h/w specific optimizations\n")
56              << _("  -S, --sync                       Draw the gui synchronously \n")
57 #ifdef VST_SUPPORT
58              << _("  -V, --novst                      Do not use VST support\n")
59 #endif
60              << _("  [session-name]                   Name of session to load\n")
61              << _("  -C, --curvetest filename         Curve algorithm debugger\n")
62              << _("  -k, --keybindings filename       Name of key bindings to load (default is ~/.ardour2/ardour.bindings)\n")
63                 ;
64         return 1;
65
66 }
67
68 int
69 ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[])
70 {
71         const char *optstring = "U:hSbvVnOc:C:m:N:k:p:";
72         const char *execname = strrchr (argv[0], '/');
73
74         if (getenv ("ARDOUR_SAE")) {
75                 menus_file = "ardour-sae.menus";
76                 keybindings_path = "ardour-sae";
77         }
78
79         if (execname == 0) {
80                 execname = argv[0];
81         } else {
82                 execname++;
83         }
84
85         const struct option longopts[] = {
86                 { "version", 0, 0, 'v' },
87                 { "help", 0, 0, 'h' },
88                 { "bindings", 0, 0, 'b' },
89                 { "show-splash", 0, 0, 'n' },
90                 { "menus", 1, 0, 'm'} ,
91                 { "name", 1, 0, 'c' },
92                 { "novst", 0, 0, 'V' },
93                 { "new", 1, 0, 'N' },
94                 { "no-hw-optimizations", 0, 0, 'O' },
95                 { "sync", 0, 0, 'S' },
96                 { "curvetest", 1, 0, 'C' },
97                 { "sillyAppleUndocumentedFinderFeature", 1, 0, 'p' },
98                 { 0, 0, 0, 0 }
99         };
100
101         int option_index = 0;
102         int c = 0;
103
104         while (1) {
105                 c = getopt_long (argc, argv, optstring, longopts, &option_index);
106
107                 if (c == -1) {
108                         break;
109                 }
110
111                 switch (c) {
112                 case 0:
113                         break;
114                 
115                 case 'v':
116                         just_version = true;
117                         break;
118
119                 case 'h':
120                         print_help (execname);
121                         exit (0);
122                         break;
123
124                 case 'b':
125                         show_key_actions = true;
126                         break;
127
128                 case 'm':
129                         menus_file = optarg;
130                         break;
131
132                 case 'n':
133                         no_splash = false;
134                         break;
135
136                 case 'p':
137                         //undocumented OS X finder -psn_XXXXX argument
138                         break;
139                 
140                 case 'S':
141                         // just pass this through to gtk it will figure it out
142                         break;
143
144                 case 'N':
145                         new_session = true;
146                         session_name = optarg;
147                         break;
148
149                 case 'O':
150                         try_hw_optimization = false;
151                         break;
152
153                 case 'V':
154 #ifdef VST_SUPPORT
155                         use_vst = false;
156 #endif /* VST_SUPPORT */
157                         break;
158
159                 case 'c':
160                         jack_client_name = optarg;
161                         break;
162
163                 case 'C':
164                         curvetest_file = optarg;
165                         break;
166
167                 case 'k':
168                         keybindings_path = optarg;
169                         break;
170
171                 default:
172                         return print_help(execname);
173                 }
174         }
175
176         if (optind < argc) {
177                 if (new_session) {
178                         cerr << "Illogical combination: you can either create a new session, or a load an existing session but not both!" << endl;
179                         return print_help(execname);
180                 }
181                 session_name = argv[optind++];
182         }
183
184
185         return 0;
186 }
187