2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2005-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2015 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <iostream>
|
2008-12-12 09:43:24 -05:00
|
|
|
#include <sigc++/bind.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/doi.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "ardour_dialog.h"
|
2013-05-02 21:13:36 -04:00
|
|
|
#include "ardour_ui.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "keyboard.h"
|
2008-02-02 12:22:04 -05:00
|
|
|
#include "splash.h"
|
2021-07-21 23:45:18 -04:00
|
|
|
#include "ui_config.h"
|
2013-05-07 22:09:16 -04:00
|
|
|
#include "window_manager.h"
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2008-12-12 09:43:24 -05:00
|
|
|
using namespace Gtk;
|
2009-12-04 17:51:32 -05:00
|
|
|
using namespace Gtkmm2ext;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2022-05-08 11:55:00 -04:00
|
|
|
ArdourDialog::ArdourDialog (const string& title, bool modal, bool use_seperator)
|
|
|
|
: Dialog (title, modal, use_seperator)
|
|
|
|
, _sensitive (true)
|
|
|
|
, proxy (nullptr)
|
|
|
|
, _splash_pushed (false)
|
2022-12-12 12:15:55 -05:00
|
|
|
, allow_idle (true)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-09-17 04:44:51 -04:00
|
|
|
init ();
|
2015-10-15 12:06:49 -04:00
|
|
|
set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2022-05-08 11:55:00 -04:00
|
|
|
ArdourDialog::ArdourDialog (Gtk::Window& parent, const string& title, bool modal, bool use_seperator)
|
|
|
|
: Dialog (title, parent, modal, use_seperator)
|
|
|
|
, _sensitive (true)
|
|
|
|
, proxy (nullptr)
|
|
|
|
, _splash_pushed (false)
|
2022-12-12 12:15:55 -05:00
|
|
|
, allow_idle (true)
|
2007-10-11 18:07:47 -04:00
|
|
|
{
|
2008-09-17 04:44:51 -04:00
|
|
|
init ();
|
2007-10-11 18:07:47 -04:00
|
|
|
set_position (Gtk::WIN_POS_CENTER_ON_PARENT);
|
2023-06-10 15:36:31 -04:00
|
|
|
set_transient_for (parent);
|
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
ArdourDialog::~ArdourDialog ()
|
2017-04-01 10:40:07 -04:00
|
|
|
{
|
|
|
|
pop_splash ();
|
2022-05-08 11:55:00 -04:00
|
|
|
Keyboard::the_keyboard ().focus_out_window (nullptr, this);
|
|
|
|
WM::Manager::instance ().remove (proxy);
|
2018-11-29 08:25:22 -05:00
|
|
|
proxy->explicit_delete ();
|
2022-12-12 12:20:02 -05:00
|
|
|
}
|
|
|
|
|
2022-12-12 12:15:55 -05:00
|
|
|
void
|
|
|
|
ArdourDialog::disallow_idle ()
|
|
|
|
{
|
|
|
|
allow_idle = false;
|
2017-04-01 10:40:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ArdourDialog::on_response (int response_id)
|
|
|
|
{
|
|
|
|
pop_splash ();
|
|
|
|
hide ();
|
2022-12-12 12:15:55 -05:00
|
|
|
if (allow_idle) {
|
|
|
|
ARDOUR::GUIIdle ();
|
|
|
|
}
|
2017-04-01 10:40:07 -04:00
|
|
|
Gtk::Dialog::on_response (response_id);
|
|
|
|
}
|
|
|
|
|
2017-07-03 08:03:10 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-04-01 10:40:07 -04:00
|
|
|
void
|
|
|
|
ArdourDialog::pop_splash ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-04-01 09:50:48 -04:00
|
|
|
if (_splash_pushed) {
|
2022-05-08 11:55:00 -04:00
|
|
|
Splash* spl = Splash::exists () ? Splash::instance () : nullptr;
|
2017-04-01 09:50:48 -04:00
|
|
|
|
|
|
|
if (spl) {
|
2021-06-23 06:52:16 -04:00
|
|
|
spl->pop_front_for (*this);
|
2017-04-01 09:50:48 -04:00
|
|
|
}
|
2017-04-01 10:40:07 -04:00
|
|
|
_splash_pushed = false;
|
2017-04-01 09:50:48 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2013-05-06 10:55:40 -04:00
|
|
|
bool
|
2022-05-08 11:55:00 -04:00
|
|
|
ArdourDialog::on_focus_in_event (GdkEventFocus* ev)
|
2013-05-06 10:55:40 -04:00
|
|
|
{
|
2022-05-08 11:55:00 -04:00
|
|
|
Keyboard::the_keyboard ().focus_in_window (ev, this);
|
2015-04-01 11:41:49 -04:00
|
|
|
return Dialog::on_focus_in_event (ev);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-09-26 10:33:53 -04:00
|
|
|
bool
|
2022-05-08 11:55:00 -04:00
|
|
|
ArdourDialog::on_focus_out_event (GdkEventFocus* ev)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2022-05-08 11:55:00 -04:00
|
|
|
if (!get_modal ()) {
|
|
|
|
Keyboard::the_keyboard ().focus_out_window (ev, this);
|
2015-04-01 11:41:49 -04:00
|
|
|
}
|
|
|
|
return Dialog::on_focus_out_event (ev);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-09-26 10:33:53 -04:00
|
|
|
void
|
|
|
|
ArdourDialog::on_unmap ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2022-05-08 11:55:00 -04:00
|
|
|
Keyboard::the_keyboard ().leave_window (nullptr, this);
|
2021-06-25 13:50:36 -04:00
|
|
|
pop_splash ();
|
2005-09-26 10:33:53 -04:00
|
|
|
Dialog::on_unmap ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2008-02-02 12:22:04 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
ArdourDialog::on_show ()
|
|
|
|
{
|
2013-04-30 13:50:15 -04:00
|
|
|
Dialog::on_show ();
|
|
|
|
|
2008-02-02 12:22:04 -05:00
|
|
|
// never allow the splash screen to obscure any dialog
|
|
|
|
|
2022-05-08 11:55:00 -04:00
|
|
|
if (Splash::exists ()) {
|
|
|
|
Splash* spl = Splash::instance ();
|
2008-02-02 12:22:04 -05:00
|
|
|
|
2021-06-25 13:50:36 -04:00
|
|
|
spl->pop_back_for (*this);
|
|
|
|
_splash_pushed = true;
|
2008-02-02 12:22:04 -05:00
|
|
|
}
|
2020-01-24 17:54:51 -05:00
|
|
|
|
|
|
|
_sensitive = true;
|
2008-02-02 12:22:04 -05:00
|
|
|
}
|
2008-09-17 04:44:51 -04:00
|
|
|
|
2013-05-05 16:10:54 -04:00
|
|
|
bool
|
|
|
|
ArdourDialog::on_delete_event (GdkEventAny*)
|
|
|
|
{
|
|
|
|
hide ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2008-12-12 09:43:24 -05:00
|
|
|
ArdourDialog::init ()
|
2008-09-17 04:44:51 -04:00
|
|
|
{
|
|
|
|
set_border_width (10);
|
2015-04-01 11:41:49 -04:00
|
|
|
add_events (Gdk::FOCUS_CHANGE_MASK);
|
2021-07-21 23:45:18 -04:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2013-05-07 18:09:12 -04:00
|
|
|
set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG);
|
2021-07-21 23:45:18 -04:00
|
|
|
#else
|
2022-05-08 11:55:00 -04:00
|
|
|
if (UIConfiguration::instance ().get_all_floating_windows_are_dialogs () || get_modal ()) {
|
2021-07-21 23:45:18 -04:00
|
|
|
set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG);
|
|
|
|
} else {
|
|
|
|
set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-07 18:09:12 -04:00
|
|
|
|
2022-05-08 11:55:00 -04:00
|
|
|
Gtk::Window* parent = WM::Manager::instance ().transient_parent ();
|
2013-05-07 18:09:12 -04:00
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
set_transient_for (*parent);
|
|
|
|
}
|
|
|
|
|
2017-07-03 08:03:10 -04:00
|
|
|
ARDOUR_UI::CloseAllDialogs.connect (sigc::mem_fun (*this, &ArdourDialog::close_self)); /* send a RESPONSE_CANCEL to self */
|
2013-05-07 22:09:16 -04:00
|
|
|
|
2022-05-08 11:55:00 -04:00
|
|
|
proxy = new WM::ProxyTemporary (get_title (), this);
|
|
|
|
WM::Manager::instance ().register_window (proxy);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2020-01-24 17:54:51 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
ArdourDialog::set_ui_sensitive (bool yn)
|
|
|
|
{
|
|
|
|
_sensitive = yn;
|
|
|
|
}
|