X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fgtkmm2ext%2Fgtk_ui.cc;h=35517e9604de825f14e4cac1c425df5a017b7140;hb=723ab60b39aed9a9190e047fc5803c1f4e1adac3;hp=442a5a22deeb2677d2bd130b453391506267b298;hpb=685fa95e729e5d510b28b4c715da062e9db580d9;p=ardour.git diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 442a5a22de..35517e9604 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 1999-2005 Paul Barton-Davis + 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 @@ -33,11 +33,13 @@ #include #include +#include #include #include #include #include #include +#include #include "i18n.h" @@ -47,46 +49,55 @@ using namespace Glib; using namespace PBD; using std::map; -pthread_t UI::gui_thread; UI *UI::theGtkUI = 0; +BaseUI::RequestType Gtkmm2ext::NullMessage = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::ErrorMessage = BaseUI::new_request_type(); -BaseUI::RequestType Gtkmm2ext::Quit = 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 /* instantiate the template */ +#include "pbd/abstract_ui.cc" /* instantiate the template */ - -UI::UI (string namestr, int *argc, char ***argv) - : AbstractUI (namestr, true) +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; - gui_thread = pthread_self (); } else { fatal << "duplicate UI requested" << endmsg; /* NOTREACHED */ } - /* add the pipe to the select/poll loop that GDK does */ + /* 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_event_loop_for_thread (this); - gdk_input_add (signal_pipe[0], - GDK_INPUT_READ, - UI::signal_pipe_callback, - this); + /* attach our request source to the default main context */ - errors = new TextViewer (850,100); - errors->text().set_editable (false); + request_channel.ios()->attach (MainContext::get_default()); + + 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(namestr); @@ -96,10 +107,13 @@ UI::UI (string namestr, int *argc, char ***argv) errors->dismiss_button().set_name ("ErrorLogCloseButton"); errors->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), (Window *) errors)); - - register_thread (pthread_self(), X_("GUI")); + errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); //load_rcfile (rcfile); + + /* instantiate the Application singleton */ + + Application::instance(); } UI::~UI () @@ -110,26 +124,40 @@ UI::~UI () bool UI::caller_is_ui_thread () { - return pthread_equal (gui_thread, pthread_self()); + 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