32 #include <glib/gstdio.h>
34 #include <fontconfig/fontconfig.h>
50 static std::string ret;
52 LPITEMIDLIST pidl = 0;
55 if (S_OK == SHGetSpecialFolderLocation (0, CSIDL_WINDOWS, &pidl))
57 if (SHGetPathFromIDListA (pidl, path)) {
65 else if (
char *env_path = getenv (
"windir"))
67 strcpy (path, env_path);
84 gchar* pExeRoot = g_win32_get_package_installation_directory_of_module (0);
87 pExeRoot = g_build_filename(
"C:\\",
"Program Files", PROGRAM_NAME, 0);
94 strcpy(tmp, pExeRoot);
95 if (0 != (p = strrchr (tmp, G_DIR_SEPARATOR))) {
98 if (0 != (p = g_build_filename(tmp, 0))) {
115 bool conversion_needed =
false;
116 bool succeeded =
false;
118 fstream file_to_fix (fd = g_fopen(str_file_to_fix.c_str(),
"r+b"));
120 if (file_to_fix.is_open()) {
121 vector<std::string> lines;
124 file_to_fix.seekg (0, std::ios::beg);
125 file_to_fix.seekp (0, std::ios::beg);
128 while (!file_to_fix.eof() && file_to_fix.getline (buf,
sizeof(buf))) {
131 if (!conversion_needed && (std::string::npos != line.find(
"$(")))
132 conversion_needed =
true;
133 lines.push_back(line);
136 if (conversion_needed) {
138 std::string::size_type token_begin, token_end;
139 vector<string>::iterator i;
141 for (i = lines.begin(); i != lines.end(); ++i) {
142 if (string::npos != (token_begin = i->find(
"$("))) {
143 if (string::npos != (token_end = i->find(
")", token_begin))) {
144 std::string str_replace_with;
145 std::string str_to_replace = i->substr(token_begin, ((token_end+1)-token_begin));
147 if (0 == str_to_replace.compare(
"$(CWD)")) {
149 if (getcwd(buf,
sizeof(buf))) {
150 if (buf[strlen(buf)-1] == G_DIR_SEPARATOR)
151 buf[strlen(buf)-1] =
'\0';
152 str_replace_with = buf;
155 i->erase(token_begin, ((token_end+1)-token_begin));
156 i->insert(token_begin, str_replace_with);
160 }
else if (0 == str_to_replace.compare(
"$(WINDRIVE)")){
165 i->erase(token_begin, ((token_end+1)-token_begin));
166 i->insert(token_begin, str_replace_with);
167 }
else if (0 == str_to_replace.compare(
"$(LOCALCACHEDIR)")){
172 i->erase(token_begin, ((token_end+1)-token_begin));
173 i->insert(token_begin, str_replace_with);
176 std::string envvar_name = str_to_replace.substr(2, str_to_replace.length()-3);
178 if (
const char *envvar_value = getenv(envvar_name.c_str())) {
179 strcpy(buf, envvar_value);
180 if (buf[strlen(buf)-1] == G_DIR_SEPARATOR)
181 buf[strlen(buf)-1] =
'\0';
182 str_replace_with = buf;
185 i->erase(token_begin, ((token_end+1)-token_begin));
186 i->insert(token_begin, str_replace_with);
189 cerr <<
_(
"ERROR: unknown environment variable") << endl;
197 file_to_fix.clear ();
198 file_to_fix.seekg (0, std::ios::beg);
200 chsize(fileno (fd), 0);
202 for (i = lines.begin(); i != lines.end(); ++i) {
205 file_to_fix << (*i).c_str() << endl;
222 cerr <<
_(
"ERROR: Could not open config file '") << str_file_to_fix <<
"'" << endl;
231 string fonts_conf_file;
236 if (!fonts_conf_file.empty()) {
237 fonts_conf_file +=
"\\";
238 fonts_conf_file += PROGRAM_NAME;
239 fonts_conf_file += FONTS_CONF_LOCATION;
243 Glib::setenv (
"FONTCONFIG_FILE", fonts_conf_file,
true);
246 cerr <<
_(
"ERROR: processing error for 'fonts.conf' file") << endl;
248 cerr <<
_(
"ERROR: Malformed module folder (fonts.conf)") << endl;
255 string pango_modules_file;
257 #if defined(DEBUG) || defined(RDC_BUILD)
261 if (!pango_modules_file.empty()) {
262 pango_modules_file +=
"\\";
263 pango_modules_file += PROGRAM_NAME;
264 pango_modules_file += PANGO_CONF_LOCATION;
267 Glib::ustring pango_modules_path = Glib::locale_to_utf8(
"C:\\Program Files\\Mixbus3\\etc\\ΔΗΜΗΤΡΗΣ\\pango.modules");
270 Glib::ustring pango_modules_path = pango_modules_file;
272 pango_modules_path.resize (pango_modules_path.size()-14);
276 Glib::ustring pango_modules_path = pango_modules_file;
277 pango_modules_path.resize (pango_modules_path.size()-14);
281 Glib::setenv (
"PANGO_MODULE_PATH", Glib::filename_from_utf8(pango_modules_path),
true);
284 cerr <<
_(
"ERROR: processing error for 'pango.modules' file") << endl;
286 cerr <<
_(
"ERROR: Malformed module folder (pango.modules)") << endl;
293 string gdk_pixbuf_loaders_file;
295 #if defined(DEBUG) || defined(RDC_BUILD)
299 if (!gdk_pixbuf_loaders_file.empty()) {
300 gdk_pixbuf_loaders_file +=
"\\";
301 gdk_pixbuf_loaders_file += PROGRAM_NAME;
302 gdk_pixbuf_loaders_file += PIXBUFLOADERS_CONF_LOCATION;
307 Glib::setenv (
"GDK_PIXBUF_MODULE_FILE", Glib::filename_from_utf8(gdk_pixbuf_loaders_file),
true);
310 cerr <<
_(
"ERROR: processing error for 'gdk-pixbuf.loaders' file") << endl;
312 cerr <<
_(
"ERROR: Malformed module folder (gdk-pixbuf.loaders)") << endl;
319 string clearlooks_la_file;
321 #if defined(DEBUG) || defined(RDC_BUILD)
325 if (!clearlooks_la_file.empty()) {
326 clearlooks_la_file +=
"\\";
327 clearlooks_la_file += PROGRAM_NAME;
328 clearlooks_la_file += CLEARLOOKS_CONF_LOCATION;
334 Glib::setenv (
"GTK_THEME_ENGINE_FILE", Glib::filename_from_utf8(clearlooks_la_file).c_str(),
true);
337 cerr <<
_(
"ERROR: processing error for 'clearlooks.la' file") << endl;
339 cerr <<
_(
"ERROR: Malformed module folder (clearlooks.la)") << endl;
346 std::string exec_path = argv[0];
347 std::string dir_path = Glib::path_get_dirname (exec_path);
351 g_chdir (dir_path.c_str());
356 dir_path = Glib::path_get_dirname (dir_path);
363 path +=
"\\lib\\ardour3\\surfaces;";
365 path +=
"\\lib\\ardour3\\panners;";
367 path +=
"\\lib\\ardour3\\backends;";
370 Glib::setenv (
"ARDOUR_DLL_PATH", path,
true);
375 path += PROGRAM_NAME;
377 Glib::setenv (
"ARDOUR_DATA_PATH", path,
true);
386 Glib::setenv (
"ARDOUR_CONFIG_PATH", path,
true);
391 path = Glib::path_get_dirname (path);
392 path += G_SEARCHPATH_SEPARATOR;
393 path += windows_search_path().to_string();
395 path += windows_search_path().to_string();
396 path +=
"\\pixmaps;";
398 path += G_SEARCHPATH_SEPARATOR;
401 Glib::setenv (
"ARDOUR_PATH", path,
true);
406 Glib::setenv (
"ARDOUR_INSTANT_XML_PATH", path,
true);
411 Glib::setenv (
"LADSPA_PATH", path,
true);
419 cstr = getenv (
"VAMP_PATH");
422 path += G_SEARCHPATH_SEPARATOR;
427 path += PROGRAM_NAME;
428 path +=
"\\bin\\vamp";
429 path += G_SEARCHPATH_SEPARATOR;
430 path +=
"%ProgramFiles%\\Vamp Plugins";
431 Glib::setenv (
"VAMP_PATH", path,
true);
435 cstr = getenv (
"ARDOUR_CONTROL_SURFACE_PATH");
438 path += G_SEARCHPATH_SEPARATOR;
443 Glib::setenv (
"ARDOUR_CONTROL_SURFACE_PATH", path,
true);
448 path = windows_search_path().to_string();
450 Glib::setenv (
"GTK_LOCALEDIR", path,
true);
458 cstr = getenv (
"GTK_PATH");
461 path += G_SEARCHPATH_SEPARATOR;
466 path +=
"\\.gtk-2.0";
467 Glib::setenv (
"GTK_PATH", path,
true);
471 Glib::unsetenv (
"GTK_RC_FILES");
477 if (NULL == getenv(
"HOME")) {
478 Glib::setenv (
"HOME", Glib::locale_from_utf8(g_get_home_dir()),
true);
484 #ifdef DLL_PIXBUF_LOADERS
487 #ifdef DLL_PANGO_MODULES
495 std::string ardour_mono_file;
498 cerr <<
_(
"Cannot find ArdourMono TrueType font") << endl;
501 FcConfig *config = FcInitLoadConfigAndFonts();
502 FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(ardour_mono_file.c_str()));
504 if (ret == FcFalse) {
505 cerr <<
_(
"Cannot load ArdourMono TrueType font.") << endl;
508 ret = FcConfigSetCurrent(config);
510 if (ret == FcFalse) {
511 cerr <<
_(
"Failed to set fontconfig configuration.") << endl;
std::string get_windows_drive_volume_letter()
LIBARDOUR_API PBD::Searchpath ladspa_search_path()
const string get_module_folder()
LIBPBD_API Transmitter error
LIBARDOUR_API bool translations_are_enabled()
bool find_file(const Searchpath &search_path, const string &filename, std::string &result)
void fixup_clearlooks_config()
bool fixup_config_file(Glib::ustring str_file_to_fix)
LIBARDOUR_API std::string user_config_directory(int version=-1)
LIBARDOUR_API PBD::Searchpath control_protocol_search_path()
static const char * localedir
LIBARDOUR_API std::string ardour_dll_directory()
LIBARDOUR_API PBD::Searchpath ardour_config_search_path()
LIBARDOUR_API std::string user_cache_directory()
LIBPBD_TEMPLATE_MEMBER_API const std::string to_string() const
void fixup_fonts_config()
LIBARDOUR_API PBD::Searchpath ardour_data_search_path()
void fixup_bundle_environment(int argc, char *argv[], string &localedir)
void fixup_pixbuf_loaders_config()
void fixup_pango_config()