fix track controls height allocation to be font sensitive; fix core dump related...
[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     $Id$
19 */
20
21 #include <getopt.h>
22 #include <iostream>
23 #include <cstdlib>
24
25 #include "opts.h"
26
27 #include "i18n.h"
28
29 using namespace std;
30
31 string GTK_ARDOUR::session_name = "";
32 string GTK_ARDOUR::jack_client_name = "ardour";
33 bool  GTK_ARDOUR::show_key_actions = false;
34 bool GTK_ARDOUR::no_splash = true;
35 bool GTK_ARDOUR::just_version = false;
36 bool GTK_ARDOUR::use_vst = true;
37 bool GTK_ARDOUR::new_session = false;
38 char* GTK_ARDOUR::curvetest_file = 0;
39 bool GTK_ARDOUR::try_hw_optimization = false;
40 bool GTK_ARDOUR::use_gtk_theme = false;
41
42 using namespace GTK_ARDOUR;
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              << _("  -N, --new session-name           Create a new session from the command line\n")                       
54              << _("  -o, --use-hw-optimizations        Try to use h/w specific optimizations\n")
55 #ifdef VST_SUPPORT
56              << _("  -V, --novst                      Do not use VST support\n")
57 #endif
58              << _("  [session-name]                   Name of session to load\n")
59              << _("  -C, --curvetest filename         Curve algorithm debugger\n")
60              << _("  -g, --gtktheme                   Allow GTK to load a theme\n")
61                 ;
62         return 1;
63
64 }
65
66 int
67 GTK_ARDOUR::parse_opts (int argc, char *argv[])
68
69 {
70         const char *optstring = "U:hbvVnoc:C:N:g";
71         const char *execname = strrchr (argv[0], '/');
72
73         if (execname == 0) {
74                 execname = argv[0];
75         } else {
76                 execname++;
77         }
78
79         const struct option longopts[] = {
80                 { "version", 0, 0, 'v' },
81                 { "help", 0, 0, 'h' },
82                 { "bindings", 0, 0, 'b' },
83                 { "show-splash", 0, 0, 'n' },
84                 { "name", 1, 0, 'c' },
85                 { "novst", 0, 0, 'V' },
86                 { "new", 1, 0, 'N' },
87                 { "use-hw-optimizations", 0, 0, 'o' },
88                 { "curvetest", 1, 0, 'C' },
89                 { "gtktheme", 0, 0, 'g' },
90                 { 0, 0, 0, 0 }
91         };
92
93         int option_index = 0;
94         int c = 0;
95
96         while (1) {
97                 c = getopt_long (argc, argv, optstring, longopts, &option_index);
98
99                 if (c == -1) {
100                         break;
101                 }
102
103                 switch (c) {
104                 case 0:
105                         break;
106                 
107                 case 'v':
108                         just_version = true;
109                         break;
110
111                 case 'h':
112                         print_help (execname);
113                         exit (0);
114                         break;
115                 case 'b':
116                         show_key_actions = true;
117                         break;
118
119                 case 'g':
120                         use_gtk_theme = true;
121                         break;
122
123                 case 'n':
124                         no_splash = false;
125                         break;
126
127                 case 'N':
128                         new_session = true;
129                         session_name = optarg;
130                         break;
131
132                 case 'o':
133                         try_hw_optimization = true;
134                         break;
135
136                 case 'V':
137 #ifdef VST_SUPPORT
138                         use_vst = false;
139 #endif /* VST_SUPPORT */
140                         break;
141
142                 case 'c':
143                         jack_client_name = optarg;
144                         break;
145
146                 case 'C':
147                         curvetest_file = optarg;
148                         break;
149
150                 default:
151                         break;
152                 }
153         }
154
155         if (optind < argc) {
156                 session_name = argv[optind++];
157         }
158
159         return 0;
160 }
161