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.
22 #include <sigc++/bind.h>
23 #include <gtkmm/settings.h>
25 #include <pbd/error.h>
26 #include <pbd/file_utils.h>
27 #include <pbd/textreceiver.h>
28 #include <pbd/failed_constructor.h>
29 #include <pbd/pthread_utils.h>
31 #include <jack/jack.h>
33 #include <ardour/version.h>
34 #include <ardour/ardour.h>
35 #include <ardour/audioengine.h>
36 #include <ardour/session_utils.h>
37 #include <ardour/filesystem_paths.h>
39 #include <gtkmm/main.h>
40 #include <gtkmm2ext/popup.h>
41 #include <gtkmm2ext/utils.h>
43 #include "../svn_revision.h"
46 #include "ardour_ui.h"
53 using namespace ARDOUR_COMMAND_LINE;
54 using namespace ARDOUR;
58 TextReceiver text_receiver ("ardour");
60 extern int curvetest (string);
62 static ARDOUR_UI *ui = 0;
63 static const char* localedir = LOCALEDIR;
68 MessageDialog win (_("Ardour could not connect to JACK."),
71 (Gtk::ButtonsType)(Gtk::BUTTONS_NONE));
72 win.set_secondary_text(_("There are several possible reasons:\n\
74 1) JACK is not running.\n\
75 2) JACK is running as another user, perhaps root.\n\
76 3) There is already another client called \"ardour\".\n\
78 Please consider the possibilities, and perhaps (re)start JACK."));
80 win.add_button (Stock::QUIT, RESPONSE_CLOSE);
81 win.set_default_response (RESPONSE_CLOSE);
84 win.set_position (Gtk::WIN_POS_CENTER);
90 /* we just don't care about the result, but we want to block */
98 #include <mach-o/dyld.h>
99 #include <sys/param.h>
103 fixup_bundle_environment ()
105 if (!getenv ("ARDOUR_BUNDLED")) {
109 char execpath[MAXPATHLEN+1];
110 uint32_t pathsz = sizeof (execpath);
112 _NSGetExecutablePath (execpath, &pathsz);
114 Glib::ustring exec_path (execpath);
115 Glib::ustring dir_path = Glib::path_get_dirname (exec_path);
117 const char *cstr = getenv ("PATH");
119 /* ensure that we find any bundled executables (e.g. JACK) */
126 setenv ("PATH", path.c_str(), 1);
129 path += "/../Resources";
131 path += "/../Resources/Surfaces";
133 path += "/../Resources/Panners";
135 setenv ("ARDOUR_MODULE_PATH", path.c_str(), 1);
138 path += "/../Resources/icons:";
140 path += "/../Resources/pixmaps:";
142 path += "/../Resources/share:";
144 path += "/../Resources";
146 setenv ("ARDOUR_PATH", path.c_str(), 1);
147 setenv ("ARDOUR_CONFIG_PATH", path.c_str(), 1);
148 setenv ("ARDOUR_DATA_PATH", path.c_str(), 1);
150 cstr = getenv ("LADSPA_PATH");
156 path += "/../Plugins";
158 setenv ("LADSPA_PATH", path.c_str(), 1);
160 cstr = getenv ("VAMP_PATH");
166 path += "/../Frameworks";
168 setenv ("VAMP_PATH", path.c_str(), 1);
170 cstr = getenv ("ARDOUR_CONTROL_SURFACE_PATH");
176 path += "/../Surfaces";
178 setenv ("ARDOUR_CONTROL_SURFACE_PATH", path.c_str(), 1);
180 cstr = getenv ("LV2_PATH");
186 path += "/../Plugins";
188 setenv ("LV2_PATH", path.c_str(), 1);
191 path += "/../Frameworks/clearlooks";
193 setenv ("GTK_PATH", path.c_str(), 1);
196 path += "/../Resources/locale";
198 localedir = strdup (path.c_str());
200 /* write a pango.rc file and tell pango to use it. we'd love
201 to put this into the Ardour.app bundle and leave it there,
202 but the user may not have write permission. so ...
204 we also have to make sure that the user ardour directory
208 sys::path pangopath = user_config_directory();
209 pangopath /= "pango.rc";
210 path = pangopath.to_string();
212 std::ofstream pangorc (path.c_str());
214 error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
216 pangorc << "[Pango]\nModuleFiles=";
218 pangopath = dir_path;
220 pangopath /= 'Resources';
221 pangopath /= 'pango.modules';
223 pangorc << pangopath.to_string() << endl;
226 setenv ("PANGO_RC_FILE", path.c_str(), 1);
229 // gettext charset aliases
231 setenv ("CHARSETALIASDIR", path.c_str(), 1);
236 path += "/../Resources/fonts.conf";
238 setenv ("FONTCONFIG_FILE", path.c_str(), 1);
240 // GDK Pixbuf loader module file
243 path += "/../Resources/gdk-pixbuf.loaders";
245 setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1);
247 if (getenv ("ARDOUR_WITH_JACK")) {
251 path += "/../Frameworks";
253 setenv ("JACK_DRIVER_DIR", path.c_str(), 1);
260 /* this is called from the entry point of a wine-compiled
261 executable that is linked against gtk2_ardour built
265 int ardour_main (int argc, char *argv[])
267 int main (int argc, char *argv[])
270 vector<Glib::ustring> null_file_list;
273 fixup_bundle_environment ();
279 (void) bindtextdomain (PACKAGE, localedir);
280 /* our i18n translations are all in UTF-8, so make sure
281 that even if the user locale doesn't specify UTF-8,
282 we use that when handling them.
284 (void) bind_textdomain_codeset (PACKAGE,"UTF-8");
285 (void) textdomain (PACKAGE);
287 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
289 // catch error message system signals ();
291 text_receiver.listen_to (error);
292 text_receiver.listen_to (info);
293 text_receiver.listen_to (fatal);
294 text_receiver.listen_to (warning);
296 if (parse_opts (argc, argv)) {
300 if (curvetest_file) {
301 return curvetest (curvetest_file);
304 cout << _("Ardour/GTK ")
306 << _("\n (built using ")
307 << ardour_svn_revision
309 << _(" and GCC version ") << __VERSION__
319 cerr << _("Copyright (C) 1999-2008 Paul Davis") << endl
320 << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
322 << _("Ardour comes with ABSOLUTELY NO WARRANTY") << endl
323 << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl
324 << _("This is free software, and you are welcome to redistribute it ") << endl
325 << _("under certain conditions; see the source for copying conditions.")
329 /* some GUI objects need this */
334 ui = new ARDOUR_UI (&argc, &argv);
335 } catch (failed_constructor& err) {
336 error << _("could not create ARDOUR GUI") << endmsg;
340 ui->run (text_receiver);
344 pthread_cancel_all ();
348 } // end of extern C block