/* Copyright (C) 1999-2005 Paul Barton-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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id$ */ #include #include #include #include #include #include #include #include #include "pbd/error.h" #include "pbd/touchable.h" #include "pbd/failed_constructor.h" #include "pbd/pthread_utils.h" #include "pbd/replace_all.h" #include "gtkmm2ext/application.h" #include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/textviewer.h" #include "gtkmm2ext/popup.h" #include "gtkmm2ext/utils.h" #include "gtkmm2ext/window_title.h" #include "gtkmm2ext/actions.h" #include "gtkmm2ext/activatable.h" #include "gtkmm2ext/actions.h" #include "gtkmm2ext/gui_thread.h" #include "i18n.h" using namespace Gtkmm2ext; using namespace Gtk; using namespace Glib; using namespace PBD; using std::map; UI* UI::theGtkUI = 0; float UI::ui_scale = 1.0; BaseUI::RequestType Gtkmm2ext::NullMessage = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::ErrorMessage = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::TouchDisplay = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::StateChange = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::SetTip = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::AddIdle = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::AddTimeout = BaseUI::new_request_type(); #include "pbd/abstract_ui.cc" /* instantiate the template */ template class AbstractUI; UI::UI (string application_name, string thread_name, int *argc, char ***argv) : AbstractUI (thread_name) , _receiver (*this) , errors (0) { theMain = new Main (argc, argv); pthread_set_name ("gui"); _active = false; if (!theGtkUI) { theGtkUI = this; } else { fatal << "duplicate UI requested" << endmsg; abort(); /* NOTREACHED */ } /* the GUI event loop runs in the main thread of the app, which is assumed to have called this. */ run_loop_thread = Threads::Thread::self(); /* store "this" as the UI-for-thread of this thread, same argument as for previous line. */ set_event_loop_for_thread (this); /* we will be receiving requests */ EventLoop::register_request_buffer_factory ("gui", request_buffer_factory); /* attach our request source to the default main context */ attach_request_source (); errors = new TextViewer (800,600); errors->text().set_editable (false); errors->text().set_name ("ErrorText"); errors->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("/Editor/toggle-log-window"))); Glib::set_application_name (application_name); WindowTitle title(Glib::get_application_name()); title += _("Log"); errors->set_title (title.get_string()); errors->dismiss_button().set_name ("ErrorLogCloseButton"); errors->signal_delete_event().connect (sigc::bind (sigc::ptr_fun (just_hide_it), (Window *) errors)); errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); //load_rcfile (rcfile); /* instantiate the Application singleton */ Application::instance(); } UI::~UI () { _receiver.hangup (); delete (errors); } bool UI::caller_is_ui_thread () { return Threads::Thread::self() == run_loop_thread; } int UI::load_rcfile (string path, bool themechange) { /* Yes, pointers to Glib::RefPtr. If these are not kept around, * a segfault somewhere deep in the wonderfully robust glib will result. * This does not occur if wiget.get_style is used instead of rc.get_style below, * except that doesn't actually work... */ static Glib::RefPtr