From 2de80a5e90dca50c5c018afdca6b11ca80f25f7a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 10 Jul 2012 01:04:36 +0000 Subject: OS X-based fixes for splash screen mgmt git-svn-id: svn://localhost/ardour2/branches/3.0@13006 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 30 ++++++++--------- gtk2_ardour/splash.cc | 87 ++++++++++++++++++++++++++---------------------- gtk2_ardour/splash.h | 5 ++- 3 files changed, 64 insertions(+), 58 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 1b108100d9..c5d2bf5c11 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -2396,20 +2396,6 @@ ARDOUR_UI::idle_load (const std::string& path) } } -void -ARDOUR_UI::loading_message (const std::string& msg) -{ - if (ARDOUR_COMMAND_LINE::no_splash) { - return; - } - - if (!splash) { - show_splash (); - } - - splash->message (msg); -} - /** @param quit_on_cancel true if exit() should be called if the user clicks `cancel' in the new session dialog */ int ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, string load_template) @@ -2814,7 +2800,7 @@ ARDOUR_UI::launch_manual () void ARDOUR_UI::launch_reference () { - PBD::open_uri("http://ardour.org/refmanual"); + PBD::open_uri ("http://ardour.org/refmanual"); } void @@ -2832,6 +2818,20 @@ ARDOUR_UI::about_signal_response (int /*response*/) hide_about(); } +void +ARDOUR_UI::loading_message (const std::string& msg) +{ + if (ARDOUR_COMMAND_LINE::no_splash) { + return; + } + + if (!splash) { + show_splash (); + } + + splash->message (msg); +} + void ARDOUR_UI::show_splash () { diff --git a/gtk2_ardour/splash.cc b/gtk2_ardour/splash.cc index cd09be0574..78b5547ded 100644 --- a/gtk2_ardour/splash.cc +++ b/gtk2_ardour/splash.cc @@ -21,6 +21,7 @@ #include "pbd/failed_constructor.h" #include "pbd/file_utils.h" + #include "ardour/ardour.h" #include "ardour/filesystem_paths.h" @@ -44,6 +45,7 @@ Splash::Splash () std::string splash_file; if (!find_file_in_search_path (ardour_data_search_path(), "splash.png", splash_file)) { + cerr << "Cannot find splash screen image file\n"; throw failed_constructor(); } @@ -52,6 +54,7 @@ Splash::Splash () } catch (...) { + cerr << "Cannot construct splash screen image\n"; throw failed_constructor(); } @@ -77,6 +80,8 @@ Splash::Splash () set_default_size (pixbuf->get_width(), pixbuf->get_height()); the_splash = this; + expose_done = false; + ARDOUR::BootMessage.connect (msg_connection, invalidator (*this), boost::bind (&Splash::boot_message, this, _1), gui_context()); } @@ -85,40 +90,6 @@ Splash::~Splash () the_splash = 0; } -bool -Splash::wakeup_from_splash_sleep () -{ - splash_done_visible = true; - return false; -} - -bool -Splash::splash_mapped (GdkEventAny*) -{ - Glib::signal_idle().connect (sigc::mem_fun (this, &Splash::wakeup_from_splash_sleep)); - return false; -} - -void -Splash::display () -{ - bool was_mapped = is_mapped (); - - if (!was_mapped) { - signal_map_event().connect (sigc::mem_fun (this, &Splash::splash_mapped), false); - splash_done_visible = false; - } - - pop_front (); - present (); - - if (!was_mapped) { - while (!splash_done_visible) { - gtk_main_iteration (); - } - } -} - void Splash::pop_back_for (Gtk::Window& win) { @@ -141,10 +112,15 @@ Splash::on_realize () layout->set_font_description (get_style()->get_font()); } - bool -Splash::on_button_release_event (GdkEventButton*) +Splash::on_button_release_event (GdkEventButton* ev) { + RefPtr window = get_window(); + + if (!window || ev->window != window->gobj()) { + return false; + } + hide (); return true; } @@ -169,6 +145,8 @@ Splash::expose (GdkEventExpose* ev) Glib::RefPtr white = style->get_white_gc(); window->draw_layout (white, 10, pixbuf->get_height() - 30, layout); + + Glib::signal_idle().connect (sigc::mem_fun (this, &Splash::idle_after_expose)); return true; } @@ -179,6 +157,32 @@ Splash::boot_message (std::string msg) message (msg); } +bool +Splash::idle_after_expose () +{ + expose_done = true; + return false; +} + +void +Splash::display () +{ + bool was_mapped = is_mapped (); + + if (!was_mapped) { + expose_done = false; + } + + pop_front (); + present (); + + if (!was_mapped) { + while (!expose_done) { + gtk_main_iteration (); + } + } +} + void Splash::message (const string& msg) { @@ -190,9 +194,12 @@ Splash::message (const string& msg) Glib::RefPtr win = darea.get_window(); if (win) { - win->invalidate_rect (Gdk::Rectangle (0, darea.get_height() - 30, - darea.get_width(), 30), true); - win->process_updates (true); - gdk_flush (); + expose_done = false; + + win->invalidate_rect (Gdk::Rectangle (0, darea.get_height() - 30, darea.get_width(), 30), true); + + while (!expose_done) { + gtk_main_iteration (); + } } } diff --git a/gtk2_ardour/splash.h b/gtk2_ardour/splash.h index fcb211d81d..536d7f30f1 100644 --- a/gtk2_ardour/splash.h +++ b/gtk2_ardour/splash.h @@ -58,9 +58,8 @@ class Splash : public Gtk::Window void boot_message (std::string); PBD::ScopedConnection msg_connection; - bool splash_done_visible; - bool wakeup_from_splash_sleep (); - bool splash_mapped (GdkEventAny*); + bool expose_done; + bool idle_after_expose (); }; #endif /* __ardour_gtk_splash_h__ */ -- cgit v1.2.3