moron
[ardour.git] / gtk2_ardour / main.cc
index 6c868978b1e5bb7252ec119230b93545b36886c6..9147941242aa38be76d0499f5a9be2ee0d4d33e8 100644 (file)
@@ -21,6 +21,7 @@
 #include <signal.h>
 #include <cerrno>
 #include <fstream>
+#include <vector>
 
 #include <sigc++/bind.h>
 #include <gtkmm/settings.h>
@@ -74,9 +75,9 @@ void
 gui_jack_error ()
 {
        MessageDialog win (string_compose (_("%1 could not connect to JACK."), PROGRAM_NAME),
-                    false,
-                    Gtk::MESSAGE_INFO,
-                    (Gtk::ButtonsType)(Gtk::BUTTONS_NONE));
+                          false,
+                          Gtk::MESSAGE_INFO,
+                          Gtk::BUTTONS_NONE);
 win.set_secondary_text(_("There are several possible reasons:\n\
 \n\
 1) JACK is not running.\n\
@@ -289,6 +290,10 @@ fixup_bundle_environment (int, char* [])
 void
 fixup_bundle_environment (int /*argc*/, char* argv[])
 {
+       /* THIS IS FOR LINUX - its just about the only place where its
+        * acceptable to build paths directly using '/'.
+        */
+
        if (!getenv ("ARDOUR_BUNDLED")) {
                return;
        }
@@ -359,6 +364,22 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
                setenv ("GTK_LOCALEDIR", localedir, 1);
        }
 
+       /* Tell fontconfig where to find fonts.conf. Use the system version
+          if it exists, otherwise use the stuff we included in t
+       */
+
+       if (Glib::file_test ("/etc/fonts/fonts.conf", Glib::FILE_TEST_EXISTS)) {
+               setenv ("FONTCONFIG_FILE", "/etc/fonts/fonts.conf", 1);
+               setenv ("FONTCONFIG_PATH", "/etc/fonts", 1);
+       } else {
+               /* use the one included in the bundle */
+               
+               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);
+       }
+
        /* write a pango.rc file and tell pango to use it. we'd love
           to put this into the Ardour.app bundle and leave it there,
           but the user may not have write permission. so ...
@@ -370,32 +391,32 @@ 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;
-       } else {
-
-               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 ();
-               }
-
-               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.
-               */
+               return;
+       } 
 
-               mpath = Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders");
-               setenv ("GDK_PIXBUF_MODULE_FILE", mpath.c_str(), 1);
+       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 ();
        }
+       
+       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);
 }
 
 #endif
@@ -405,7 +426,7 @@ tell_about_jack_death (void* /* ignored */)
 {
        if (AudioEngine::instance()->processed_frames() == 0) {
                /* died during startup */
-               MessageDialog msg (_("JACK exited"), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK);
+               MessageDialog msg (_("JACK exited"), false);
                msg.set_position (Gtk::WIN_POS_CENTER);
                msg.set_secondary_text (string_compose (_(
 "JACK exited unexpectedly, and without notifying %1.\n\
@@ -421,7 +442,7 @@ Click OK to exit %1."), PROGRAM_NAME));
 
                /* engine has already run, so this is a mid-session JACK death */
 
-               MessageDialog* msg = manage (new MessageDialog (_("JACK exited"), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_NONE));
+               MessageDialog* msg = manage (new MessageDialog (_("JACK exited"), false));
                msg->set_secondary_text (string_compose (_(
 "JACK exited unexpectedly, and without notifying %1.\n\
 \n\
@@ -452,9 +473,9 @@ sigpipe_handler (int /*signal*/)
 void close_external_ui_windows();
 #endif
 
-#ifdef VST_SUPPORT
+#ifdef WINDOWS_VST_SUPPORT
 
-extern int gui_init (int* argc, char** argv[]);
+extern int windows_vst_gui_init (int* argc, char** argv[]);
 
 /* this is called from the entry point of a wine-compiled
    executable that is linked against gtk2_ardour built
@@ -474,11 +495,11 @@ int main (int argc, char *argv[])
 
        gtk_set_locale ();
 
-#ifdef VST_SUPPORT
+#ifdef WINDOWS_VST_SUPPORT
        /* this does some magic that is needed to make GTK and Wine's own
           X11 client interact properly.
        */
-       gui_init (&argc, &argv);
+       windows_vst_gui_init (&argc, &argv);
 #endif
 
        (void) bindtextdomain (PACKAGE, localedir);
@@ -527,7 +548,7 @@ int main (int argc, char *argv[])
        }
 
        if (no_splash) {
-               cerr << _("Copyright (C) 1999-2011 Paul Davis") << endl
+               cerr << _("Copyright (C) 1999-2012 Paul Davis") << endl
                     << _("Some portions Copyright (C) Steve Harris, Ari Johnson, Brett Viren, Joel Baker") << endl
                     << endl
                     << string_compose (_("%1 comes with ABSOLUTELY NO WARRANTY"), PROGRAM_NAME) << endl
@@ -564,7 +585,7 @@ int main (int argc, char *argv[])
 #endif
        return 0;
 }
-#ifdef VST_SUPPORT
+#ifdef WINDOWS_VST_SUPPORT
 } // end of extern C block
 #endif