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>
25 #include <glibmm/ustring.h>
27 #include <pbd/error.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>
38 #include <gtkmm/main.h>
39 #include <gtkmm2ext/popup.h>
40 #include <gtkmm2ext/utils.h>
42 #include "svn_revision.h"
44 #include "ardour_ui.h"
51 using namespace ARDOUR_COMMAND_LINE;
52 using namespace ARDOUR;
56 TextReceiver text_receiver ("ardour");
58 extern int curvetest (string);
60 static ARDOUR_UI *ui = 0;
61 static const char* localedir = LOCALEDIR;
65 #include <mach-o/dyld.h>
66 #include <sys/param.h>
70 fixup_bundle_environment ()
72 if (!getenv ("ARDOUR_BUNDLED")) {
76 char execpath[MAXPATHLEN+1];
77 uint32_t pathsz = sizeof (execpath);
79 _NSGetExecutablePath (execpath, &pathsz);
81 Glib::ustring exec_path (execpath);
82 Glib::ustring dir_path = Glib::path_get_dirname (exec_path);
84 const char *cstr = getenv ("PATH");
86 /* ensure that we find any bundled executables (e.g. JACK) */
93 setenv ("PATH", path.c_str(), 1);
96 path += "/../Resources";
98 path += "/../Resources/Surfaces";
100 path += "/../Resources/Panners";
102 setenv ("ARDOUR_MODULE_PATH", path.c_str(), 1);
105 path += "/../Resources/icons:";
107 path += "/../Resources/pixmaps:";
109 path += "/../Resources/share:";
111 path += "/../Resources";
113 setenv ("ARDOUR_PATH", path.c_str(), 1);
114 setenv ("ARDOUR_CONFIG_PATH", path.c_str(), 1);
115 setenv ("ARDOUR_DATA_PATH", path.c_str(), 1);
117 cstr = getenv ("LADSPA_PATH");
123 path += "/../Plugins";
125 setenv ("LADSPA_PATH", path.c_str(), 1);
127 cstr = getenv ("VAMP_PATH");
133 path += "/../Frameworks";
135 setenv ("VAMP_PATH", path.c_str(), 1);
137 cstr = getenv ("ARDOUR_CONTROL_SURFACE_PATH");
143 path += "/../Surfaces";
145 setenv ("ARDOUR_CONTROL_SURFACE_PATH", path.c_str(), 1);
147 cstr = getenv ("LV2_PATH");
153 path += "/../Plugins";
155 setenv ("LV2_PATH", path.c_str(), 1);
158 path += "/../Frameworks/clearlooks";
160 setenv ("GTK_PATH", path.c_str(), 1);
163 path += "/../Resources/locale";
165 localedir = strdup (path.c_str());
167 /* write a pango.rc file and tell pango to use it. we'd love
168 to put this into the Ardour.app bundle and leave it there,
169 but the user may not have write permission. so ...
171 we also have to make sure that the user ardour directory
175 if (g_mkdir_with_parents (ARDOUR::get_user_ardour_path().c_str(), 0755) < 0) {
176 error << string_compose (_("cannot create user ardour folder %1 (%2)"), ARDOUR::get_user_ardour_path(), strerror (errno))
180 path = Glib::build_filename (ARDOUR::get_user_ardour_path(), "pango.rc");
182 std::ofstream pangorc (path.c_str());
184 error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
186 pangorc << "[Pango]\nModuleFiles=";
187 Glib::ustring mpath = dir_path;
188 mpath += "/../Resources/pango.modules";
189 pangorc << mpath << endl;
192 setenv ("PANGO_RC_FILE", path.c_str(), 1);
196 // gettext charset aliases
198 setenv ("CHARSETALIASDIR", path.c_str(), 1);
203 path += "/../Resources/fonts.conf";
205 setenv ("FONTCONFIG_FILE", path.c_str(), 1);
207 // GDK Pixbuf loader module file
210 path += "/../Resources/gdk-pixbuf.loaders";
212 setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1);
213 cerr << "Set GDK_PIXBUF_MODULE_FILE to " << path << endl;
215 if (getenv ("ARDOUR_WITH_JACK")) {
219 path += "/../Frameworks";
221 setenv ("JACK_DRIVER_DIR", path.c_str(), 1);
228 sigpipe_handler (int sig)
230 cerr << _("SIGPIPE received - JACK has probably died") << endl;
234 /* this is called from the entry point of a wine-compiled
235 executable that is linked against gtk2_ardour built
239 int ardour_main (int argc, char *argv[])
241 int main (int argc, char* argv[])
244 vector<Glib::ustring> null_file_list;
246 cerr << "here we go\n";
249 fixup_bundle_environment ();
251 cerr << "just did it\n";
256 (void) bindtextdomain (PACKAGE, localedir);
257 /* our i18n translations are all in UTF-8, so make sure
258 that even if the user locale doesn't specify UTF-8,
259 we use that when handling them.
261 (void) bind_textdomain_codeset (PACKAGE,"UTF-8");
262 (void) textdomain (PACKAGE);
264 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
266 // catch error message system signals ();
268 text_receiver.listen_to (error);
269 text_receiver.listen_to (info);
270 text_receiver.listen_to (fatal);
271 text_receiver.listen_to (warning);
273 if (parse_opts (argc, argv)) {
277 if (curvetest_file) {
278 return curvetest (curvetest_file);
281 cout << _("Ardour/GTK ")
283 << _("\n (built using ")
284 << ardour_svn_revision
286 << _(" and GCC version ") << __VERSION__
296 cerr << _("Copyright (C) 1999-2008 Paul Davis") << endl
297 << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
299 << _("Ardour comes with ABSOLUTELY NO WARRANTY") << endl
300 << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl
301 << _("This is free software, and you are welcome to redistribute it ") << endl
302 << _("under certain conditions; see the source for copying conditions.")
306 /* some GUI objects need this */
310 if (::signal (SIGPIPE, sigpipe_handler)) {
311 cerr << _("Cannot install SIGPIPE error handler") << endl;
315 ui = new ARDOUR_UI (&argc, &argv);
316 } catch (failed_constructor& err) {
317 error << _("could not create ARDOUR GUI") << endmsg;
321 ui->run (text_receiver);
325 pthread_cancel_all ();
329 } // end of extern C block