basic startup changes to enable the engine control stuff to work; a little ARDOUR_SAE...
[ardour.git] / gtk2_ardour / main.cc
1 /*
2     Copyright (C) 2001-2007 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 <cstdlib>
21
22 #include <sigc++/bind.h>
23 #include <gtkmm/settings.h>
24
25 #include <pbd/error.h>
26 #include <pbd/textreceiver.h>
27 #include <pbd/failed_constructor.h>
28 #include <pbd/pthread_utils.h>
29
30 #include <jack/jack.h>
31
32 #include <ardour/version.h>
33 #include <ardour/ardour.h>
34 #include <ardour/audioengine.h>
35
36 #include <gtkmm/main.h>
37 #include <gtkmm2ext/popup.h>
38 #include <gtkmm2ext/utils.h>
39
40 #include "svn_revision.h"
41 #include "version.h"
42 #include "ardour_ui.h"
43 #include "opts.h"
44 #include "enums.h"
45
46 #include "i18n.h"
47
48 using namespace Gtk;
49 using namespace ARDOUR_COMMAND_LINE;
50 using namespace ARDOUR;
51 using namespace PBD;
52 using namespace sigc;
53
54 TextReceiver text_receiver ("ardour");
55
56 extern int curvetest (string);
57
58 static ARDOUR_UI  *ui = 0;
59
60 gint
61 show_ui_callback (void *arg)
62 {
63         ARDOUR_UI * ui = (ARDOUR_UI *) arg;
64
65         ui->hide_splash();
66         
67         return FALSE;
68 }
69
70 #ifdef VST_SUPPORT
71 /* this is called from the entry point of a wine-compiled
72    executable that is linked against gtk2_ardour built
73    as a shared library.
74 */
75 extern "C" {
76 int ardour_main (int argc, char *argv[])
77 #else
78 int main (int argc, char *argv[])
79 #endif
80
81 {
82         vector<Glib::ustring> null_file_list;
83
84         Glib::thread_init();
85         gtk_set_locale ();
86
87         (void) bindtextdomain (PACKAGE, LOCALEDIR);
88         /* our i18n translations are all in UTF-8, so make sure
89            that even if the user locale doesn't specify UTF-8,
90            we use that when handling them.
91         */
92         (void) bind_textdomain_codeset (PACKAGE,"UTF-8");
93         (void) textdomain (PACKAGE);
94
95         pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
96
97         // catch error message system signals ();
98
99         text_receiver.listen_to (error);
100         text_receiver.listen_to (info);
101         text_receiver.listen_to (fatal);
102         text_receiver.listen_to (warning);
103
104         if (parse_opts (argc, argv)) {
105                 exit (1);
106         }
107
108         if (curvetest_file) {
109                 return curvetest (curvetest_file);
110         }
111         
112         cout << _("Ardour/GTK ") 
113              << VERSIONSTRING
114              << _("\n   (built using ")
115              << ardour_svn_revision
116 #ifdef __GNUC__
117              << _(" and GCC version ") << __VERSION__ 
118 #endif
119              << ')'
120              << endl;
121         
122         if (just_version) {
123                 exit (0);
124         }
125
126         if (no_splash) {
127                 cerr << _("Copyright (C) 1999-2007 Paul Davis") << endl
128                      << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
129                      << endl
130                      << _("Ardour comes with ABSOLUTELY NO WARRANTY") << endl
131                      << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl
132                      << _("This is free software, and you are welcome to redistribute it ") << endl
133                      << _("under certain conditions; see the source for copying conditions.")
134                      << endl;
135         }
136
137         /* some GUI objects need this */
138
139         PBD::ID::init ();
140
141         try { 
142                 ui = new ARDOUR_UI (&argc, &argv);
143         } catch (failed_constructor& err) {
144                 error << _("could not create ARDOUR GUI") << endmsg;
145                 exit (1);
146         }
147
148         if (!no_splash) {
149                 ui->show_splash ();
150                 if (session_name.length()) {  
151                         g_timeout_add (4000, show_ui_callback, ui);
152                 }
153         }
154
155         if (!keybindings_path.empty()) {
156                 ui->set_keybindings_path (keybindings_path);
157         }
158
159         ui->run (text_receiver);
160         ui = 0;
161
162         ARDOUR::cleanup ();
163         pthread_cancel_all ();
164         return 0;
165 }
166 #ifdef VST_SUPPORT
167 } // end of extern C block
168 #endif
169