From c2deeaa96e71700115ab964dedca2a5e2f4d74d2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 5 Apr 2015 14:02:47 -0400 Subject: show dialog when audioengine becomes silent --- gtk2_ardour/ardour_ui.cc | 40 ++++++++++++++++++++++++++++++++++++++++ gtk2_ardour/ardour_ui.h | 1 + 2 files changed, 41 insertions(+) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 66a5efdb2c..0a4ba97c09 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -523,6 +523,7 @@ ARDOUR_UI::post_engine () AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context()); AudioEngine::instance()->BufferSizeChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context()); AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false)); + AudioEngine::instance()->BecameSilent.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::audioengine_became_silent, this), gui_context()); _tooltips.enable(); @@ -4695,3 +4696,42 @@ ARDOUR_UI::set_flat_buttons () { CairoWidget::set_flat_buttons( config()->get_flat_buttons() ); } + +void +ARDOUR_UI::audioengine_became_silent () +{ + MessageDialog msg (string_compose (_("This is a free/demo copy of %1. It has just switched to silent mode.\n\n" + "You can reset things to get another few minutes of working time,\n" + "or you can save your work and quit, or do nothing at all.\n\n" + "To avoid this behaviour, please consider paying for a copy of %1\n\n" + "or better yet becoming a subscriber. You can pay whatever you want,\n" + "and subscriptions start at US$1 per month."), + PROGRAM_NAME), + true, + Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_NONE, + true); + + msg.add_button (_("Do nothing"), Gtk::RESPONSE_CANCEL); + msg.add_button (_("Save and quit"), Gtk::RESPONSE_NO); + msg.add_button (_("Give me more time"), Gtk::RESPONSE_YES); + + int r = msg.run (); + + switch (r) { + case Gtk::RESPONSE_YES: + AudioEngine::instance()->reset_silence_countdown (); + break; + + case Gtk::RESPONSE_NO: + /* save and quit */ + save_state_canfail (""); + exit (0); + break; + + case Gtk::RESPONSE_CANCEL: + default: + /* don't reset, save session and exit */ + break; + } +} diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 81edbc3df2..e80761cf32 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -787,6 +787,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void check_announcements (); int do_audio_midi_setup (uint32_t); + void audioengine_became_silent (); }; #endif /* __ardour_gui_h__ */ -- cgit v1.2.3