remove using namespace sigc everywhere to ensure clarity over which bind/mem_fun...
[ardour.git] / gtk2_ardour / ardour_dialog.cc
index 9a5a64a2f2e9cf7293aec996bf20cdee74c24915..cafb356d60d4e16378dcb0ffb5c75cb49985e2b0 100644 (file)
 */
 
 #include <iostream>
+#include <sigc++/bind.h>
 
-#include <gtkmmext/doi.h>
+#include <gtkmm2ext/doi.h>
 
 #include "ardour_dialog.h"
 #include "keyboard.h"
 #include "ardour_ui.h"
+#include "splash.h"
+#include "public_editor.h"
+#include "utils.h"
 
+using namespace std;
+using namespace Gtk;
+using namespace Gtkmm2ext;
 
-ArdourDialog::ArdourDialog (string name)
-       : Gtk::Window (GTK_WINDOW_TOPLEVEL),
-         KeyboardTarget (*this, name)
-{
-       session = 0;
-       kbd_input = false;
-       running = false;
-       _run_status = 0;
-       _within_hiding = false;
-       hide_on_stop = true;
-}
-
-ArdourDialog::~ArdourDialog ()
-{
-}
+sigc::signal<void> ArdourDialog::CloseAllDialogs;
 
-gint
-ArdourDialog::enter_notify_event_impl (GdkEventCrossing *ev)
+ArdourDialog::ArdourDialog (string title, bool modal, bool use_seperator)
+       : Dialog (title, modal, use_seperator)
 {
-       if (ev->detail != GDK_NOTIFY_INFERIOR) {
-               Keyboard::the_keyboard().set_current_dialog (this);
-       }
-       return FALSE;
+       init ();
 }
 
-gint
-ArdourDialog::leave_notify_event_impl (GdkEventCrossing *ev)
+ArdourDialog::ArdourDialog (Gtk::Window& parent, string title, bool modal, bool use_seperator)
+       : Dialog (title, parent, modal, use_seperator)
 {
-       if (ev->detail != GDK_NOTIFY_INFERIOR) {
-               Keyboard::the_keyboard().set_current_dialog (0);
-       }
-       return FALSE;
+       init ();
+       set_position (Gtk::WIN_POS_CENTER_ON_PARENT);
 }
 
-gint
-ArdourDialog::unmap_event_impl (GdkEventAny *ev)
-{
-       _within_hiding = true;
-        Hiding (); /* EMIT_SIGNAL */
-       _within_hiding = false;
-       return Gtk::Window::unmap_event_impl (ev);
-}
-
-void
-ArdourDialog::wm_close()
-{
-       stop (-1);
-       ARDOUR_UI::instance()->allow_focus(false);
-}
-
-void
-ArdourDialog::wm_doi ()
-{
-       if (!hide_on_stop) {
-               Hiding (); /* EMIT_SIGNAL */
-       }
-       stop (-1);
-       delete_when_idle (this);
-}
-
-gint
-ArdourDialog::wm_close_event (GdkEventAny* ev)
-{
-       wm_close ();
-       return TRUE;
-}
-
-gint
-ArdourDialog::wm_doi_event (GdkEventAny* ev)
+ArdourDialog::~ArdourDialog ()
 {
-       wm_doi ();
-       return TRUE;
 }
 
-gint
-ArdourDialog::wm_doi_event_stop (GdkEventAny* ev)
+bool
+ArdourDialog::on_enter_notify_event (GdkEventCrossing *ev)
 {
-       stop (-1);
-       return TRUE;
+       Keyboard::the_keyboard().enter_window (ev, this);
+       return false;
 }
 
-void
-ArdourDialog::set_hide_on_stop (bool yn)
+bool
+ArdourDialog::on_leave_notify_event (GdkEventCrossing *ev)
 {
-       hide_on_stop = yn;
+       Keyboard::the_keyboard().leave_window (ev, this);
+       return false;
 }
 
 void
-ArdourDialog::close ()
+ArdourDialog::on_unmap ()
 {
-       hide_all ();
-
-       if (kbd_input) {
-               ARDOUR_UI::instance()->allow_focus (false);
-       }
+       Keyboard::the_keyboard().leave_window (0, this);
+       Dialog::on_unmap ();
 }
 
 void
-ArdourDialog::stop (int rr)
+ArdourDialog::on_show ()
 {
-       _run_status = rr;
+       // never allow the splash screen to obscure any dialog
 
-       if (hide_on_stop) {
-               Hiding (); /* EMIT_SIGNAL */
-               hide_all ();
+       Splash* spl = Splash::instance();
 
-               if (kbd_input) {
-                       ARDOUR_UI::instance()->allow_focus (false);
-               }
+       if (spl) {
+               spl->pop_back ();
        }
 
-       if (running) {
-               Gtk::Main::quit ();
-               running = false;
-       }
+       Dialog::on_show ();
 }
 
 void
-ArdourDialog::run ()
+ArdourDialog::init ()
 {
-       show_all ();
-
-       if (kbd_input) {
-               ARDOUR_UI::instance()->allow_focus (true);
-       }
-
-       running = true;
-       Gtk::Main::run ();
-}
-
-void
-ArdourDialog::set_keyboard_input (bool yn)
-{
-       kbd_input = yn;
+       session = 0;
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
+       set_border_width (10);
+       CloseAllDialogs.connect (sigc::bind (sigc::mem_fun (*this, &ArdourDialog::response), RESPONSE_CANCEL));
 }
 
-int
-ArdourDialog::run_status ()
+bool
+ArdourDialog::on_key_press_event (GdkEventKey* key)
 {
-       return _run_status;
+       return Gtk::Dialog::on_key_press_event (key);
 }