2 Copyright (C) 2001-2007 Paul Davis
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.
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.
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.
23 #include <sigc++/bind.h>
24 #include <gtkmm/settings.h>
26 #include <pbd/error.h>
27 #include <pbd/file_utils.h>
28 #include <pbd/textreceiver.h>
29 #include <pbd/failed_constructor.h>
30 #include <pbd/pthread_utils.h>
32 #include <jack/jack.h>
34 #include <ardour/version.h>
35 #include <ardour/ardour.h>
36 #include <ardour/audioengine.h>
37 #include <ardour/session_utils.h>
38 #include <ardour/filesystem_paths.h>
40 #include <gtkmm/main.h>
41 #include <gtkmm2ext/popup.h>
42 #include <gtkmm2ext/utils.h>
44 #include "../svn_revision.h"
47 #include "ardour_ui.h"
54 using namespace ARDOUR_COMMAND_LINE;
55 using namespace ARDOUR;
59 TextReceiver text_receiver ("ardour");
61 extern int curvetest (string);
63 static ARDOUR_UI *ui = 0;
64 static const char* localedir = LOCALEDIR;
69 MessageDialog win (_("Ardour could not connect to JACK."),
72 (Gtk::ButtonsType)(Gtk::BUTTONS_NONE));
73 win.set_secondary_text(_("There are several possible reasons:\n\
75 1) JACK is not running.\n\
76 2) JACK is running as another user, perhaps root.\n\
77 3) There is already another client called \"ardour\".\n\
79 Please consider the possibilities, and perhaps (re)start JACK."));
81 win.add_button (Stock::QUIT, RESPONSE_CLOSE);
82 win.set_default_response (RESPONSE_CLOSE);
85 win.set_position (Gtk::WIN_POS_CENTER);
91 /* we just don't care about the result, but we want to block */
99 #include <mach-o/dyld.h>
100 #include <sys/param.h>
104 fixup_bundle_environment ()
106 if (!getenv ("ARDOUR_BUNDLED")) {
110 char execpath[MAXPATHLEN+1];
111 uint32_t pathsz = sizeof (execpath);
113 _NSGetExecutablePath (execpath, &pathsz);
115 Glib::ustring exec_path (execpath);
116 Glib::ustring dir_path = Glib::path_get_dirname (exec_path);
118 const char *cstr = getenv ("PATH");
120 /* ensure that we find any bundled executables (e.g. JACK) */
127 setenv ("PATH", path.c_str(), 1);
130 path += "/../Resources";
132 path += "/../Resources/Surfaces";
134 path += "/../Resources/Panners";
136 setenv ("ARDOUR_MODULE_PATH", path.c_str(), 1);
139 path += "/../Resources/icons:";
141 path += "/../Resources/pixmaps:";
143 path += "/../Resources/share:";
145 path += "/../Resources";
147 setenv ("ARDOUR_PATH", path.c_str(), 1);
148 setenv ("ARDOUR_CONFIG_PATH", path.c_str(), 1);
149 setenv ("ARDOUR_DATA_PATH", path.c_str(), 1);
151 cstr = getenv ("LADSPA_PATH");
157 path += "/../Plugins";
159 setenv ("LADSPA_PATH", path.c_str(), 1);
161 cstr = getenv ("VAMP_PATH");
167 path += "/../Frameworks";
169 setenv ("VAMP_PATH", path.c_str(), 1);
171 cstr = getenv ("ARDOUR_CONTROL_SURFACE_PATH");
177 path += "/../Surfaces";
179 setenv ("ARDOUR_CONTROL_SURFACE_PATH", path.c_str(), 1);
181 cstr = getenv ("LV2_PATH");
187 path += "/../Plugins";
189 setenv ("LV2_PATH", path.c_str(), 1);
192 path += "/../Frameworks/clearlooks";
194 setenv ("GTK_PATH", path.c_str(), 1);
197 path += "/../Resources/locale";
199 localedir = strdup (path.c_str());
201 /* write a pango.rc file and tell pango to use it. we'd love
202 to put this into the Ardour.app bundle and leave it there,
203 but the user may not have write permission. so ...
205 we also have to make sure that the user ardour directory
210 sys::create_directories (user_config_directory ());
212 catch (const sys::filesystem_error& ex) {
213 error << _("Could not create user configuration directory") << endmsg;
216 sys::path pangopath = user_config_directory();
217 pangopath /= "pango.rc";
218 path = pangopath.to_string();
220 std::ofstream pangorc (path.c_str());
222 error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
225 pangorc << "[Pango]\nModuleFiles=";
227 pangopath = dir_path;
229 pangopath /= "Resources";
230 pangopath /= "pango.modules";
232 pangorc << pangopath.to_string() << endl;
236 setenv ("PANGO_RC_FILE", path.c_str(), 1);
239 // gettext charset aliases
241 setenv ("CHARSETALIASDIR", path.c_str(), 1);
246 path += "/../Resources/fonts.conf";
248 setenv ("FONTCONFIG_FILE", path.c_str(), 1);
250 // GDK Pixbuf loader module file
253 path += "/../Resources/gdk-pixbuf.loaders";
255 setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1);
256 cerr << "Set GDK_PIXBUF_MODULE_FILE to " << path << endl;
258 if (getenv ("ARDOUR_WITH_JACK")) {
262 path += "/../Frameworks";
264 setenv ("JACK_DRIVER_DIR", path.c_str(), 1);
271 sigpipe_handler (int sig)
273 cerr << _("SIGPIPE received - JACK has probably died") << endl;
277 /* this is called from the entry point of a wine-compiled
278 executable that is linked against gtk2_ardour built
282 int ardour_main (int argc, char *argv[])
284 int main (int argc, char *argv[])
287 vector<Glib::ustring> null_file_list;
289 cerr << "here we go\n";
292 fixup_bundle_environment ();
294 cerr << "just did it\n";
299 (void) bindtextdomain (PACKAGE, localedir);
300 /* our i18n translations are all in UTF-8, so make sure
301 that even if the user locale doesn't specify UTF-8,
302 we use that when handling them.
304 (void) bind_textdomain_codeset (PACKAGE,"UTF-8");
305 (void) textdomain (PACKAGE);
307 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
309 // catch error message system signals ();
311 text_receiver.listen_to (error);
312 text_receiver.listen_to (info);
313 text_receiver.listen_to (fatal);
314 text_receiver.listen_to (warning);
316 if (parse_opts (argc, argv)) {
320 if (curvetest_file) {
321 return curvetest (curvetest_file);
324 cout << _("Ardour/GTK ")
326 << _("\n (built using ")
327 << ardour_svn_revision
329 << _(" and GCC version ") << __VERSION__
339 cerr << _("Copyright (C) 1999-2008 Paul Davis") << endl
340 << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
342 << _("Ardour comes with ABSOLUTELY NO WARRANTY") << endl
343 << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl
344 << _("This is free software, and you are welcome to redistribute it ") << endl
345 << _("under certain conditions; see the source for copying conditions.")
349 /* some GUI objects need this */
353 if (::signal (SIGPIPE, sigpipe_handler)) {
354 cerr << _("Cannot install SIGPIPE error handler") << endl;
358 ui = new ARDOUR_UI (&argc, &argv);
359 } catch (failed_constructor& err) {
360 error << _("could not create ARDOUR GUI") << endmsg;
364 ui->run (text_receiver);
368 pthread_cancel_all ();
372 } // end of extern C block