add session save signal and hook-up videotimeline
[ardour.git] / gtk2_ardour / ardour_dialog.cc
index 3af944d85ccafb3c8e17375d4aab6b90464f3d3a..c0e17087818cf9d98498a85f4390d66792a2641c 100644 (file)
 */
 
 #include <iostream>
+#include <sigc++/bind.h>
 
 #include <gtkmm2ext/doi.h>
 
 #include "ardour_dialog.h"
 #include "keyboard.h"
-#include "ardour_ui.h"
+#include "splash.h"
 
+using namespace std;
+using namespace Gtk;
+using namespace Gtkmm2ext;
 
-ArdourDialog::ArdourDialog (string name)
-       : Dialog (name), 
-         KeyboardTarget (*this, name)
+sigc::signal<void> ArdourDialog::CloseAllDialogs;
+
+ArdourDialog::ArdourDialog (string title, bool modal, bool use_seperator)
+       : Dialog (title, modal, use_seperator)
+{
+       init ();
+}
+
+ArdourDialog::ArdourDialog (Gtk::Window& parent, string title, bool modal, bool use_seperator)
+       : Dialog (title, parent, modal, use_seperator)
 {
-       session = 0;
-       kbd_input = false;
-       running = false;
-       _run_status = 0;
-       _within_hiding = false;
-       hide_on_stop = true;
+       init ();
+       set_position (Gtk::WIN_POS_CENTER_ON_PARENT);
 }
 
 ArdourDialog::~ArdourDialog ()
@@ -45,96 +52,44 @@ ArdourDialog::~ArdourDialog ()
 bool
 ArdourDialog::on_enter_notify_event (GdkEventCrossing *ev)
 {
-       if (ev->detail != GDK_NOTIFY_INFERIOR) {
-               Keyboard::the_keyboard().set_current_dialog (this);
-       }
-       return FALSE;
+       Keyboard::the_keyboard().enter_window (ev, this);
+       return Dialog::on_enter_notify_event (ev);
 }
 
 bool
 ArdourDialog::on_leave_notify_event (GdkEventCrossing *ev)
 {
-       if (ev->detail != GDK_NOTIFY_INFERIOR) {
-               Keyboard::the_keyboard().set_current_dialog (0);
-       }
-       return FALSE;
+       Keyboard::the_keyboard().leave_window (ev, this);
+       return Dialog::on_leave_notify_event (ev);
 }
 
 void
 ArdourDialog::on_unmap ()
 {
-       _within_hiding = true;
-       Hiding (); /* EMIT_SIGNAL */
-       _within_hiding = false;
+       Keyboard::the_keyboard().leave_window (0, this);
        Dialog::on_unmap ();
 }
 
 void
-ArdourDialog::set_hide_on_stop (bool yn)
-{
-       hide_on_stop = yn;
-}
-
-void
-ArdourDialog::stop (int rr)
-{
-       if (hide_on_stop) {
-               Hiding (); /* EMIT_SIGNAL */
-               hide_all ();
-
-               if (kbd_input) {
-                       ARDOUR_UI::instance()->allow_focus (false);
-               }
-       }
-
-       if (running) {
-               if (rr == 0) {
-                       response (GTK_RESPONSE_ACCEPT);
-               } else {
-                       response (GTK_RESPONSE_CANCEL);
-               }
-               running = false;
-       }
-}
-
-void
-ArdourDialog::run ()
+ArdourDialog::on_show ()
 {
-       show_all ();
+       // never allow the splash screen to obscure any dialog
 
-       if (kbd_input) {
-               ARDOUR_UI::instance()->allow_focus (true);
-       }
+       Splash* spl = Splash::instance();
 
-       running = true;
-       switch (Dialog::run ()) {
-       case GTK_RESPONSE_ACCEPT:
-               _run_status = 0;
-               break;
-               
-       case GTK_RESPONSE_DELETE_EVENT:
-               _run_status = -1;
-               break;
-
-       default:
-               _run_status = -1;
+       if (spl) {
+               spl->pop_back_for (*this);
        }
 
-       hide_all ();
-
-       if (kbd_input) {
-               ARDOUR_UI::instance()->allow_focus (false);
-       }
+       Dialog::on_show ();
 }
 
 void
-ArdourDialog::set_keyboard_input (bool yn)
-{
-       kbd_input = yn;
-}
-
-int
-ArdourDialog::run_status ()
+ArdourDialog::init ()
 {
-       return _run_status;
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
+       set_border_width (10);
+       CloseAllDialogs.connect (
+               sigc::bind (sigc::mem_fun (*this, &ArdourDialog::response),
+                           RESPONSE_CANCEL));
 }