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>
24 #include <glibmm/ustring.h>
26 #include <pbd/error.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>
37 #include <gtkmm/main.h>
38 #include <gtkmm2ext/popup.h>
39 #include <gtkmm2ext/utils.h>
41 #include "svn_revision.h"
43 #include "ardour_ui.h"
50 using namespace ARDOUR_COMMAND_LINE;
51 using namespace ARDOUR;
55 TextReceiver text_receiver ("ardour");
57 extern int curvetest (string);
59 static ARDOUR_UI *ui = 0;
60 static const char* localedir = LOCALEDIR;
64 #include <mach-o/dyld.h>
65 #include <sys/param.h>
69 fixup_bundle_environment ()
71 if (!getenv ("ARDOUR_BUNDLED")) {
75 char execpath[MAXPATHLEN+1];
76 uint32_t pathsz = sizeof (execpath);
78 _NSGetExecutablePath (execpath, &pathsz);
80 Glib::ustring exec_path (execpath);
81 Glib::ustring dir_path = Glib::path_get_dirname (exec_path);
83 const char *cstr = getenv ("PATH");
85 /* ensure that we find any bundled executables (e.g. JACK) */
92 setenv ("PATH", path.c_str(), 1);
95 path += "/../Resources";
97 path += "/../Resources/Surfaces";
99 path += "/../Resources/Panners";
101 setenv ("ARDOUR_MODULE_PATH", path.c_str(), 1);
104 path += "/../Resources/icons:";
106 path += "/../Resources/pixmaps:";
108 path += "/../Resources/share:";
110 path += "/../Resources";
112 setenv ("ARDOUR_PATH", path.c_str(), 1);
113 setenv ("ARDOUR_CONFIG_PATH", path.c_str(), 1);
114 setenv ("ARDOUR_DATA_PATH", path.c_str(), 1);
116 cstr = getenv ("LADSPA_PATH");
122 path += "/../Plugins";
124 setenv ("LADSPA_PATH", path.c_str(), 1);
126 cstr = getenv ("VAMP_PATH");
132 path += "/../Frameworks";
134 setenv ("VAMP_PATH", path.c_str(), 1);
136 cstr = getenv ("ARDOUR_CONTROL_SURFACE_PATH");
142 path += "/../Surfaces";
144 setenv ("ARDOUR_CONTROL_SURFACE_PATH", path.c_str(), 1);
146 cstr = getenv ("LV2_PATH");
152 path += "/../Plugins";
154 setenv ("LV2_PATH", path.c_str(), 1);
157 path += "/../Frameworks/clearlooks";
159 setenv ("GTK_PATH", path.c_str(), 1);
162 path += "/../Resources/locale";
164 localedir = strdup (path.c_str());
166 /* write a pango.rc file and tell pango to use it. we'd love
167 to put this into the Ardour.app bundle and leave it there,
168 but the user may not have write permission. so ...
171 path = Glib::build_filename (ARDOUR::get_user_ardour_path(), "pango.rc");
173 std::ofstream pangorc (path.c_str());
175 error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
177 pangorc << "[Pango]\nModuleFiles=";
178 Glib::ustring mpath = dir_path;
179 mpath += "/../Resources/pango.modules";
180 pangorc << mpath << endl;
183 setenv ("PANGO_RC_FILE", path.c_str(), 1);
186 // gettext charset aliases
188 setenv ("CHARSETALIASDIR", path.c_str(), 1);
193 path += "/../Resources/fonts.conf";
195 setenv ("FONTCONFIG_FILE", path.c_str(), 1);
197 // GDK Pixbuf loader module file
200 path += "/../Resources/gdk-pixbuf.loaders";
202 setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1);
204 if (getenv ("ARDOUR_WITH_JACK")) {
208 path += "/../Frameworks";
210 setenv ("JACK_DRIVER_DIR", path.c_str(), 1);
217 /* this is called from the entry point of a wine-compiled
218 executable that is linked against gtk2_ardour built
222 int ardour_main (int argc, char *argv[])
224 int main (int argc, char* argv[])
227 vector<Glib::ustring> null_file_list;
230 fixup_bundle_environment ();
236 (void) bindtextdomain (PACKAGE, localedir);
237 /* our i18n translations are all in UTF-8, so make sure
238 that even if the user locale doesn't specify UTF-8,
239 we use that when handling them.
241 (void) bind_textdomain_codeset (PACKAGE,"UTF-8");
242 (void) textdomain (PACKAGE);
244 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
246 // catch error message system signals ();
248 text_receiver.listen_to (error);
249 text_receiver.listen_to (info);
250 text_receiver.listen_to (fatal);
251 text_receiver.listen_to (warning);
253 if (parse_opts (argc, argv)) {
257 if (curvetest_file) {
258 return curvetest (curvetest_file);
261 cout << _("Ardour/GTK ")
263 << _("\n (built using ")
264 << ardour_svn_revision
266 << _(" and GCC version ") << __VERSION__
276 cerr << _("Copyright (C) 1999-2008 Paul Davis") << endl
277 << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
279 << _("Ardour comes with ABSOLUTELY NO WARRANTY") << endl
280 << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl
281 << _("This is free software, and you are welcome to redistribute it ") << endl
282 << _("under certain conditions; see the source for copying conditions.")
286 /* some GUI objects need this */
291 ui = new ARDOUR_UI (&argc, &argv);
292 } catch (failed_constructor& err) {
293 error << _("could not create ARDOUR GUI") << endmsg;
297 ui->run (text_receiver);
301 pthread_cancel_all ();
305 } // end of extern C block