X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Fmain.cc;h=cebef59f26c5995f7f18ccc2b945b819f68c0045;hb=082461f108b0778327dec9d92704c15622ac3a86;hp=284192ede24933fce2e26e3434d3e0b75c94e06f;hpb=6ee23029a338951705c589be6c61ab52099758b6;p=ardour.git diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 284192ede2..cebef59f26 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2007 Paul Davis + Copyright (C) 2001-2012 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -141,35 +141,14 @@ fixup_bundle_environment (int, char* []) _NSGetExecutablePath (execpath, &pathsz); - std::string dir_path = Glib::path_get_dirname (execpath); std::string path; - const char *cstr = getenv ("PATH"); + std::string exec_dir = Glib::path_get_dirname (execpath); + std::string bundle_dir; + std::string userconfigdir = user_config_directory(); - /* ensure that we find any bundled executables (e.g. JACK), - and find them before any instances of the same name - elsewhere in PATH - */ - - path = dir_path; - - /* JACK is often in /usr/local/bin and since Info.plist refuses to - set PATH, we have to force this in order to discover a running - instance of JACK ... - */ - - path += ':'; - path += "/usr/local/bin"; - - if (cstr) { - path += ':'; - path += cstr; - } - setenv ("PATH", path.c_str(), 1); - - export_search_path (dir_path, "ARDOUR_DLL_PATH", "/../lib"); + bundle_dir = Glib::path_get_dirname (exec_dir); - path += dir_path; - path += "/../Resources"; + export_search_path (bundle_dir, "ARDOUR_DLL_PATH", "/lib"); /* inside an OS X .app bundle, there is no difference between DATA and CONFIG locations, since OS X doesn't @@ -177,16 +156,13 @@ fixup_bundle_environment (int, char* []) machine-independent shared data. */ - export_search_path (dir_path, "ARDOUR_DATA_PATH", "/../Resources"); - export_search_path (dir_path, "ARDOUR_CONFIG_PATH", "/../Resources"); - export_search_path (dir_path, "ARDOUR_INSTANT_XML_PATH", "/../Resources"); - - export_search_path (dir_path, "LADSPA_PATH", "/../Plugins"); - export_search_path (dir_path, "VAMP_PATH", "/../Frameworks"); - - path = dir_path; - path += "/../lib/clearlooks"; - setenv ("GTK_PATH", path.c_str(), 1); + export_search_path (bundle_dir, "ARDOUR_DATA_PATH", "/Resources"); + export_search_path (bundle_dir, "ARDOUR_CONFIG_PATH", "/Resources"); + export_search_path (bundle_dir, "ARDOUR_INSTANT_XML_PATH", "/Resources"); + export_search_path (bundle_dir, "LADSPA_PATH", "/Plugins"); + export_search_path (bundle_dir, "VAMP_PATH", "/lib"); + export_search_path (bundle_dir, "SUIL_MODULE_DIR", "/lib"); + export_search_path (bundle_dir, "GTK_PATH", "/lib/clearlooks"); /* unset GTK_RC_FILES so that we only load the RC files that we define */ @@ -194,12 +170,7 @@ fixup_bundle_environment (int, char* []) unsetenv ("GTK_RC_FILES"); if (!ARDOUR::translations_are_disabled ()) { - - path = dir_path; - path += "/../Resources/locale"; - - localedir = strdup (path.c_str()); - setenv ("GTK_LOCALEDIR", localedir, 1); + export_search_path (bundle_dir, "GTK_LOCALEDIR", "/Resources/locale"); } /* write a pango.rc file and tell pango to use it. we'd love @@ -210,62 +181,28 @@ fixup_bundle_environment (int, char* []) actually exists ... */ - try { - sys::create_directories (user_config_directory ()); - } - catch (const sys::filesystem_error& ex) { - error << _("Could not create user configuration directory") << endmsg; - } - - sys::path pangopath = user_config_directory(); - pangopath /= "pango.rc"; - path = pangopath.to_string(); - - std::ofstream pangorc (path.c_str()); - if (!pangorc) { - error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg; - return; + if (g_mkdir_with_parents (userconfigdir.c_str(), 0755) < 0) { + error << string_compose (_("cannot create user ardour folder %1 (%2)"), userconfigdir, strerror (errno)) + << endmsg; } else { - pangorc << "[Pango]\nModuleFiles="; - - pangopath = dir_path; - pangopath /= ".."; - pangopath /= "Resources"; - pangopath /= "pango.modules"; - - pangorc << pangopath.to_string() << endl; - - pangorc.close (); - - setenv ("PANGO_RC_FILE", path.c_str(), 1); - } - - // gettext charset aliases - - setenv ("CHARSETALIASDIR", path.c_str(), 1); - - // font config - - path = dir_path; - path += "/../Resources/fonts.conf"; - - setenv ("FONTCONFIG_FILE", path.c_str(), 1); - - // GDK Pixbuf loader module file - - path = dir_path; - path += "/../Resources/gdk-pixbuf.loaders"; - - setenv ("GDK_PIXBUF_MODULE_FILE", path.c_str(), 1); - - if (getenv ("ARDOUR_WITH_JACK")) { - // JACK driver dir - - path = dir_path; - path += "/../Frameworks"; - - setenv ("JACK_DRIVER_DIR", path.c_str(), 1); + + path = Glib::build_filename (userconfigdir, "pango.rc"); + std::ofstream pangorc (path.c_str()); + if (!pangorc) { + error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg; + } else { + pangorc << "[Pango]\nModuleFiles=" + << Glib::build_filename (bundle_dir, "Resources/pango.modules") + << endl; + pangorc.close (); + + setenv ("PANGO_RC_FILE", path.c_str(), 1); + } } + + setenv ("CHARSETALIASDIR", bundle_dir.c_str(), 1); + setenv ("FONTCONFIG_FILE", Glib::build_filename (bundle_dir, "Resources/fonts.conf").c_str(), 1); + setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (bundle_dir, "Resources/gdk-pixbuf.loaders").c_str(), 1); } #else @@ -283,9 +220,9 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) EnvironmentalProtectionAgency::set_global_epa (new EnvironmentalProtectionAgency (true, "PREBUNDLE_ENV")); - Glib::ustring dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0])); - Glib::ustring path; - Glib::ustring userconfigdir = user_config_directory().to_string(); + std::string path; + std::string dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0])); + std::string userconfigdir = user_config_directory(); /* note that this function is POSIX/Linux specific, so using / as a dir separator in this context is just fine. @@ -295,13 +232,11 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) export_search_path (dir_path, "ARDOUR_CONFIG_PATH", "/etc"); export_search_path (dir_path, "ARDOUR_INSTANT_XML_PATH", "/share"); export_search_path (dir_path, "ARDOUR_DATA_PATH", "/share"); - - export_search_path (dir_path, "LADSPA_PATH", "/../plugins"); + export_search_path (dir_path, "LADSPA_PATH", "/plugins"); export_search_path (dir_path, "VAMP_PATH", "/lib"); + export_search_path (dir_path, "SUIL_MODULE_DIR", "/lib"); - path = dir_path; - path += "/lib/clearlooks"; - setenv ("GTK_PATH", path.c_str(), 1); + export_search_path (dir_path, "GTK_PATH", "/lib/clearlooks"); /* unset GTK_RC_FILES so that we only load the RC files that we define */ @@ -309,11 +244,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) unsetenv ("GTK_RC_FILES"); if (!ARDOUR::translations_are_disabled ()) { - path = dir_path; - path += "/share/locale"; - - localedir = strdup (path.c_str()); - setenv ("GTK_LOCALEDIR", localedir, 1); + export_search_path (dir_path, "GTK_LOCALEDIR", "/share/locale"); } /* Tell fontconfig where to find fonts.conf. Use the system version @@ -328,8 +259,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) path = Glib::build_filename (dir_path, "etc/fonts/fonts.conf"); setenv ("FONTCONFIG_FILE", path.c_str(), 1); - path = Glib::build_filename (dir_path, "etc/fonts"); - setenv ("FONTCONFIG_PATH", "/etc/fonts", 1); + export_search_path (dir_path, "FONTCONFIG_PATH", "/etc/fonts"); } /* write a pango.rc file and tell pango to use it. we'd love @@ -343,32 +273,33 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) if (g_mkdir_with_parents (userconfigdir.c_str(), 0755) < 0) { error << string_compose (_("cannot create user ardour folder %1 (%2)"), userconfigdir, strerror (errno)) << endmsg; - return; - } - - Glib::ustring mpath; - - path = Glib::build_filename (userconfigdir, "pango.rc"); - - std::ofstream pangorc (path.c_str()); - if (!pangorc) { - error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg; } else { - mpath = Glib::build_filename (userconfigdir, "pango.modules"); - pangorc << "[Pango]\nModuleFiles="; - pangorc << mpath << endl; - pangorc.close (); + path = Glib::build_filename (userconfigdir, "pango.rc"); + std::ofstream pangorc (path.c_str()); + if (!pangorc) { + error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg; + } else { + pangorc << "[Pango]\nModuleFiles=" + << Glib::build_filename (userconfigdir, "pango.modules") + << endl; + pangorc.close (); + } + + setenv ("PANGO_RC_FILE", path.c_str(), 1); + + /* similar for GDK pixbuf loaders, but there's no RC file required + to specify where it lives. + */ + + setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders").c_str(), 1); } - - setenv ("PANGO_RC_FILE", path.c_str(), 1); - /* similar for GDK pixbuf loaders, but there's no RC file required - to specify where it lives. - */ - - mpath = Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders"); - setenv ("GDK_PIXBUF_MODULE_FILE", mpath.c_str(), 1); + /* this doesn't do much but setting it should prevent various parts of the GTK/GNU stack + from looking outside the bundle to find the charset.alias file. + */ + setenv ("CHARSETALIASDIR", dir_path.c_str(), 1); + } #endif @@ -421,10 +352,6 @@ sigpipe_handler (int /*signal*/) } } -#ifdef HAVE_LV2 -void close_external_ui_windows(); -#endif - #ifdef WINDOWS_VST_SUPPORT extern int windows_vst_gui_init (int* argc, char** argv[]); @@ -501,7 +428,7 @@ int main (int argc, char *argv[]) if (no_splash) { cerr << _("Copyright (C) 1999-2012 Paul Davis") << endl - << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl + << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker, Robin Gareus") << endl << endl << string_compose (_("%1 comes with ABSOLUTELY NO WARRANTY"), PROGRAM_NAME) << endl << _("not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") << endl @@ -532,9 +459,6 @@ int main (int argc, char *argv[]) ARDOUR::cleanup (); pthread_cancel_all (); -#ifdef HAVE_LV2 - close_external_ui_windows(); -#endif return 0; } #ifdef WINDOWS_VST_SUPPORT