X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_dialog.cc;h=1c9da0112f1439bf4e50e737fab033607f0a52d2;hb=0e9dab6aabc2efddc957c7c71bc55354c16626ed;hp=cd7d0fbd55bbeacd1425db04f6342b6a1d32e6bb;hpb=e1b0f1bd0b03c071d2b5987e4ab75ef059e32111;p=ardour.git diff --git a/gtk2_ardour/ardour_dialog.cc b/gtk2_ardour/ardour_dialog.cc index cd7d0fbd55..1c9da0112f 100644 --- a/gtk2_ardour/ardour_dialog.cc +++ b/gtk2_ardour/ardour_dialog.cc @@ -26,14 +26,18 @@ #include "ardour_ui.h" #include "keyboard.h" #include "splash.h" +#include "utils.h" +#include "window_manager.h" using namespace std; using namespace Gtk; using namespace Gtkmm2ext; +using namespace ARDOUR_UI_UTILS; ArdourDialog::ArdourDialog (string title, bool modal, bool use_seperator) : Dialog (title, modal, use_seperator) - , _splash_pushed (false) + , proxy (0) + , _splash_pushed (false) { init (); set_position (Gtk::WIN_POS_MOUSE); @@ -41,7 +45,7 @@ ArdourDialog::ArdourDialog (string title, bool modal, bool use_seperator) ArdourDialog::ArdourDialog (Gtk::Window& parent, string title, bool modal, bool use_seperator) : Dialog (title, parent, modal, use_seperator) - , _splash_pushed (false) + , _splash_pushed (false) { init (); set_position (Gtk::WIN_POS_CENTER_ON_PARENT); @@ -49,27 +53,58 @@ ArdourDialog::ArdourDialog (Gtk::Window& parent, string title, bool modal, bool ArdourDialog::~ArdourDialog () { - if (_splash_pushed) { - Splash* spl = Splash::instance(); - - if (spl) { - spl->pop_front(); - } - } + pop_splash (); + Keyboard::the_keyboard().focus_out_window (0, this); + WM::Manager::instance().remove (proxy); +} + +void +ArdourDialog::on_response (int response_id) +{ + pop_splash (); + hide (); + ARDOUR::GUIIdle (); + Gtk::Dialog::on_response (response_id); +} + +void +ArdourDialog::close_self () +{ + /* Don't call Idle, don't pop splash. + * This is used at exit and session-close and invoked + * via close_all_dialogs. + */ + hide (); + Gtk::Dialog::on_response (RESPONSE_CANCEL); +} + +void +ArdourDialog::pop_splash () +{ + if (_splash_pushed) { + Splash* spl = Splash::instance(); + + if (spl) { + spl->pop_front(); + } + _splash_pushed = false; + } } bool -ArdourDialog::on_enter_notify_event (GdkEventCrossing *ev) +ArdourDialog::on_focus_in_event (GdkEventFocus *ev) { - Keyboard::the_keyboard().enter_window (ev, this); - return Dialog::on_enter_notify_event (ev); + Keyboard::the_keyboard().focus_in_window (ev, this); + return Dialog::on_focus_in_event (ev); } bool -ArdourDialog::on_leave_notify_event (GdkEventCrossing *ev) +ArdourDialog::on_focus_out_event (GdkEventFocus *ev) { - Keyboard::the_keyboard().leave_window (ev, this); - return Dialog::on_leave_notify_event (ev); + if (!get_modal()) { + Keyboard::the_keyboard().focus_out_window (ev, this); + } + return Dialog::on_focus_out_event (ev); } void @@ -90,14 +125,32 @@ ArdourDialog::on_show () if (spl && spl->is_visible()) { spl->pop_back_for (*this); - _splash_pushed = true; + _splash_pushed = true; } } +bool +ArdourDialog::on_delete_event (GdkEventAny*) +{ + hide (); + return false; +} + void ArdourDialog::init () { set_border_width (10); - // set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); - ARDOUR_UI::CloseAllDialogs.connect (sigc::bind (sigc::mem_fun (*this, &ArdourDialog::response), RESPONSE_CANCEL)); + add_events (Gdk::FOCUS_CHANGE_MASK); + set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); + + Gtk::Window* parent = WM::Manager::instance().transient_parent(); + + if (parent) { + set_transient_for (*parent); + } + + ARDOUR_UI::CloseAllDialogs.connect (sigc::mem_fun (*this, &ArdourDialog::close_self)); /* send a RESPONSE_CANCEL to self */ + + proxy = new WM::ProxyTemporary (get_title(), this); + WM::Manager::instance().register_window (proxy); }