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 char* localedir = LOCALEDIR;
63 show_ui_callback (void *arg)
65 ARDOUR_UI * ui = (ARDOUR_UI *) arg;
74 #include <mach-o/dyld.h>
75 #include <sys/param.h>
79 fixup_bundle_environment ()
81 char execpath[MAXPATHLEN+1];
82 uint32_t pathsz = sizeof (execpath);
84 _NSGetExecutablePath (execpath, &pathsz);
86 cerr << "EXEC PATH = " << execpath << endl;
87 Glib::ustring exec_path (execpath);
88 Glib::ustring dir_path = Glib::path_get_dirname (exec_path);
92 path += "/../Resources";
94 path += "/../Resources/Surfaces";
96 path += "/../Resources/Panners";
98 setenv ("ARDOUR_MODULE_PATH", path.c_str(), 1);
99 cerr << "ARDOUR_MODULE_PATH = " << path << endl;
102 path += "/../Resources/icons:";
104 path += "/../Resources/pixmaps:";
106 path += "/../Resources/share:";
108 path += "/../Resources";
110 setenv ("ARDOUR_PATH", path.c_str(), 1);
111 setenv ("ARDOUR_CONFIG_PATH", path.c_str(), 1);
112 setenv ("ARDOUR_DATA_PATH", path.c_str(), 1);
114 cerr << "ARDOUR_PATH, DATA+CONFIG = " << path << endl;
117 path += "/../Frameworks/clearlooks";
119 setenv ("GTK_PATH", path.c_str(), 1);
122 path += "/../Resources/locale";
124 localedir = strdup (path.c_str());
126 /* write a pango.rc file and tell pango to use it */
129 path += "/../Resources/pango.rc";
131 std::ofstream pangorc (path.c_str());
133 error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
135 pangorc << "[Pango]\nModuleFiles=";
136 Glib::ustring mpath = dir_path;
137 mpath += "/../Resources/pango.modules";
138 pangorc << mpath << endl;
141 setenv ("PANGO_RC_FILE", path.c_str(), 1);
144 // gettext charset aliases
146 setenv ("CHARSETALIASDIR", path.c_str(), 1);
151 path += "/../Resources/fonts.conf";
153 setenv ("FONTCONFIG_FILE", path.c_str(), 1);
155 // GDK Pixbuf loader module file
158 path += "/../Resources/gdk-pixbuf.loaders";
160 setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1);
165 /* this is called from the entry point of a wine-compiled
166 executable that is linked against gtk2_ardour built
170 int ardour_main (int argc, char *argv[])
172 int main (int argc, char* argv[], char* envp[])
176 vector<Glib::ustring> null_file_list;
179 fixup_bundle_environment ();
182 for (int xx = 0; xx < argc; ++xx) {
183 cerr << "argv[" << xx << "] = " << argv[xx] << endl;
186 for (int xx = 0; envp && envp[xx]; ++xx) {
187 cerr << "envp[" << xx << "] = " << envp[xx] << endl;
193 (void) bindtextdomain (PACKAGE, localedir);
194 /* our i18n translations are all in UTF-8, so make sure
195 that even if the user locale doesn't specify UTF-8,
196 we use that when handling them.
198 (void) bind_textdomain_codeset (PACKAGE,"UTF-8");
199 (void) textdomain (PACKAGE);
201 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
203 // catch error message system signals ();
205 text_receiver.listen_to (error);
206 text_receiver.listen_to (info);
207 text_receiver.listen_to (fatal);
208 text_receiver.listen_to (warning);
210 if (parse_opts (argc, argv)) {
214 if (curvetest_file) {
215 return curvetest (curvetest_file);
218 cout << _("Ardour/GTK ")
220 << _("\n (built using ")
221 << ardour_svn_revision
223 << _(" and GCC version ") << __VERSION__
233 cerr << _("Copyright (C) 1999-2007 Paul Davis") << endl
234 << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
236 << _("Ardour comes with ABSOLUTELY NO WARRANTY") << endl
237 << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl
238 << _("This is free software, and you are welcome to redistribute it ") << endl
239 << _("under certain conditions; see the source for copying conditions.")
243 /* some GUI objects need this */
248 ui = new ARDOUR_UI (&argc, &argv);
249 } catch (failed_constructor& err) {
250 error << _("could not create ARDOUR GUI") << endmsg;
256 if (session_name.length()) {
257 g_timeout_add (4000, show_ui_callback, ui);
261 if (!keybindings_path.empty()) {
262 ui->set_keybindings_path (keybindings_path);
265 ui->run (text_receiver);
269 pthread_cancel_all ();
273 } // end of extern C block