/* 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 #include #include #include #include #include #include #include #include #include #include "i18n.h" using namespace Gtkmm2ext; using namespace Gtk; using namespace Glib; using namespace PBD; using std::map; UI *UI::theGtkUI = 0; 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 */ UI::UI (string namestr, int *argc, char ***argv) : AbstractUI (namestr) { theMain = new Main (argc, argv); #ifndef GTK_NEW_TOOLTIP_API tips = new Tooltips; #endif _active = false; if (!theGtkUI) { theGtkUI = this; } else { fatal << "duplicate UI requested" << endmsg; /* NOTREACHED */ } /* the GUI event loop runs in the main thread of the app, which is assumed to have called this. */ run_loop_thread = Thread::self(); /* store "this" as the UI-for-thread of this thread, same argument as for previous line. */ set_ui_for_thread (this); /* attach our request source to the default main context */ request_channel.ios()->attach (MainContext::get_default()); errors = new TextViewer (800,600); errors->text().set_editable (false); errors->text().set_name ("ErrorText"); Glib::set_application_name(namestr); 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 (bind (sigc::ptr_fun (just_hide_it), (Window *) errors)); errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); //load_rcfile (rcfile); } UI::~UI () { } bool UI::caller_is_ui_thread () { return 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