fix prev. commit
[ardour.git] / gtk2_ardour / main.cc
index abdfa35877a8e461b925664e20f252b2d408bf74..441b2dc92956485cb0ab410040dffc51aca45760 100644 (file)
@@ -99,6 +99,28 @@ gui_jack_error ()
        win.run ();
 }
 
+#ifndef NDEBUG
+static void ardour_g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) {
+       switch (log_level) {
+               case G_LOG_FLAG_FATAL:
+               case G_LOG_LEVEL_CRITICAL:
+                       fatal << "g_log: " << message << endmsg;
+                       break;
+               case G_LOG_LEVEL_ERROR:
+                       error << "g_log: " << message << endmsg;
+                       break;
+               case G_LOG_LEVEL_WARNING:
+                       warning << "g_log: " << message << endmsg;
+                       break;
+               case G_LOG_LEVEL_MESSAGE:
+               case G_LOG_LEVEL_INFO:
+               default:
+                       info << "g_log: " << message << endmsg;
+                       break;
+       }
+}
+#endif
+
 static gboolean
 tell_about_backend_death (void* /* ignored */)
 {
@@ -345,13 +367,26 @@ int main (int argc, char *argv[])
        }
 #endif
 
+       UIConfiguration* ui_config = new UIConfiguration;
+
+       if (ui_config->pre_gui_init ()) {
+               error << _("Could not complete pre-GUI initialization") << endmsg;
+               exit (1);
+       }
+       
        try {
-               ui = new ARDOUR_UI (&argc, &argv, localedir.c_str());
+               ui = new ARDOUR_UI (&argc, &argv, localedir.c_str(), ui_config);
        } catch (failed_constructor& err) {
                error << string_compose (_("could not create %1 GUI"), PROGRAM_NAME) << endmsg;
                exit (1);
        }
 
+#ifndef NDEBUG
+       g_log_set_handler (NULL,
+                       GLogLevelFlags (G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL |  G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_RECURSION),
+                       &ardour_g_log, NULL);
+#endif
+
        ui->run (text_receiver);
        Gtkmm2ext::Application::instance()->cleanup();
        delete ui;