improvements (?) for window visibility during session loading - time to test on linux

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2476 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-09-24 15:41:23 +00:00
parent 47e8a7ac4a
commit 2e765255e9
11 changed files with 129 additions and 45 deletions

View file

@ -34,6 +34,7 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/compose.h> #include <pbd/compose.h>
#include <pbd/misc.h>
#include <pbd/pathscanner.h> #include <pbd/pathscanner.h>
#include <pbd/failed_constructor.h> #include <pbd/failed_constructor.h>
#include <pbd/enumwriter.h> #include <pbd/enumwriter.h>
@ -191,6 +192,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
have_disk_speed_dialog_displayed = false; have_disk_speed_dialog_displayed = false;
_will_create_new_session_automatically = false; _will_create_new_session_automatically = false;
session_loaded = false; session_loaded = false;
loading_dialog = 0;
last_speed_displayed = -1.0f; last_speed_displayed = -1.0f;
keybindings_path = ARDOUR::find_config_file ("ardour.bindings"); keybindings_path = ARDOUR::find_config_file ("ardour.bindings");
@ -1958,7 +1960,16 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
{ {
string session_name; string session_name;
string session_path; string session_path;
string template_name;
if (!loading_dialog) {
loading_dialog = new MessageDialog (*new_session_dialog,
_("Starting audio engine"),
false,
Gtk::MESSAGE_INFO,
Gtk::BUTTONS_NONE);
}
int response = Gtk::RESPONSE_NONE; int response = Gtk::RESPONSE_NONE;
new_session_dialog->set_modal(true); new_session_dialog->set_modal(true);
@ -2002,6 +2013,9 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
have_engine = true; have_engine = true;
} }
loading_dialog->show_all ();
flush_pending ();
create_engine (); create_engine ();
/* now handle possible affirmative responses */ /* now handle possible affirmative responses */
@ -2031,14 +2045,16 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
/* OK == OPEN button */ /* OK == OPEN button */
session_name = new_session_dialog->session_name(); session_name = new_session_dialog->session_name();
if (new_session_dialog->get_current_page() == 1) { if (session_name.empty()) {
response = Gtk::RESPONSE_NONE;
if (session_name.empty()) { continue;
response = Gtk::RESPONSE_NONE; }
continue;
}
switch (new_session_dialog->get_current_page()) {
case 1: /* recent session selector */
case 2: /* audio engine control */
if (session_name[0] == '/' || if (session_name[0] == '/' ||
(session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') || (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
(session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) { (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
@ -2047,13 +2063,9 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
session_path = new_session_dialog->session_folder(); session_path = new_session_dialog->session_folder();
load_session (session_path, session_name); load_session (session_path, session_name);
} }
break;
} else {
if (session_name.empty()) { case 0: /* nominally the "new" session creator, but could be in use for an old session */
response = Gtk::RESPONSE_NONE;
continue;
}
if (new_session_dialog->get_current_page() == 0 && ARDOUR_COMMAND_LINE::session_name.empty()) { if (new_session_dialog->get_current_page() == 0 && ARDOUR_COMMAND_LINE::session_name.empty()) {
should_be_new = true; should_be_new = true;
@ -2079,7 +2091,12 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
session_path = Glib::build_filename (session_path, session_name); session_path = Glib::build_filename (session_path, session_name);
if (should_be_new && Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { if (!should_be_new) {
load_session (session_path, session_name);
continue; /* leaves while() loop because response != NONE */
} else if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path); Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
@ -2096,6 +2113,9 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
switch (msg.run()) { switch (msg.run()) {
case RESPONSE_YES: case RESPONSE_YES:
new_session_dialog->hide ();
goto_editor_window ();
flush_pending ();
load_session (session_path, session_name); load_session (session_path, session_name);
goto done; goto done;
break; break;
@ -2104,14 +2124,18 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
new_session_dialog->reset (); new_session_dialog->reset ();
continue; continue;
} }
} }
_session_is_new = true; _session_is_new = true;
std::string template_name = new_session_dialog->session_template_name();
if (new_session_dialog->use_session_template()) { if (new_session_dialog->use_session_template()) {
template_name = new_session_dialog->session_template_name();
new_session_dialog->hide ();
goto_editor_window ();
flush_pending ();
load_session (session_path, session_name, &template_name); load_session (session_path, session_name, &template_name);
} else { } else {
@ -2168,6 +2192,10 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
nphysout = (uint32_t) new_session_dialog->output_limit_count(); nphysout = (uint32_t) new_session_dialog->output_limit_count();
} }
new_session_dialog->hide ();
goto_editor_window ();
flush_pending ();
if (build_session (session_path, if (build_session (session_path,
session_name, session_name,
cchns, cchns,
@ -2183,6 +2211,10 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
continue; continue;
} }
} }
break;
default:
break;
} }
} }
@ -2190,19 +2222,20 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
done: done:
show(); show();
new_session_dialog->get_window()->set_cursor(); loading_dialog->hide ();
new_session_dialog->hide(); new_session_dialog->hide();
return true; return true;
} }
void void
ARDOUR_UI::close_session() ARDOUR_UI::close_session ()
{ {
if (!check_audioengine()) { if (!check_audioengine()) {
return; return;
} }
unload_session(); unload_session (true);
get_session_parameters ("", true, false); get_session_parameters ("", true, false);
} }
@ -2210,19 +2243,22 @@ int
ARDOUR_UI::load_session (const string & path, const string & snap_name, string* mix_template) ARDOUR_UI::load_session (const string & path, const string & snap_name, string* mix_template)
{ {
Session *new_session; Session *new_session;
int x; int unload_status;
int retval = -1;
session_loaded = false; session_loaded = false;
if (!check_audioengine()) { if (!check_audioengine()) {
return -1; return -1;
} }
x = unload_session (); unload_status = unload_session ();
if (x < 0) { if (unload_status < 0) {
return -1; goto out;
} else if (x > 0) { } else if (unload_status > 0) {
return 0; retval = 0;
goto out;
} }
/* if it already exists, we must have write access */ /* if it already exists, we must have write access */
@ -2231,17 +2267,23 @@ ARDOUR_UI::load_session (const string & path, const string & snap_name, string*
MessageDialog msg (*editor, _("You do not have write access to this session.\n" MessageDialog msg (*editor, _("You do not have write access to this session.\n"
"This prevents the session from being loaded.")); "This prevents the session from being loaded."));
msg.run (); msg.run ();
return -1; goto out;
} }
if (loading_dialog) {
loading_dialog->set_markup (_("Please wait while Ardour loads your session"));
flush_pending ();
}
disable_screen_updates ();
try { try {
new_session = new Session (*engine, path, snap_name, mix_template); new_session = new Session (*engine, path, snap_name, mix_template);
} }
catch (...) { catch (...) {
error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg; error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg;
return -1; goto out;
} }
connect_to_session (new_session); connect_to_session (new_session);
@ -2257,7 +2299,12 @@ ARDOUR_UI::load_session (const string & path, const string & snap_name, string*
} }
editor->edit_cursor_position (true); editor->edit_cursor_position (true);
return 0; enable_screen_updates ();
flush_pending ();
retval = 0;
out:
return retval;
} }
int int

View file

@ -133,7 +133,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
bool get_session_parameters (Glib::ustring path, bool have_engine = false, bool should_be_new = false); bool get_session_parameters (Glib::ustring path, bool have_engine = false, bool should_be_new = false);
gint cmdline_new_session (string path); gint cmdline_new_session (string path);
int unload_session (); int unload_session (bool hide_stuff = false);
void close_session(); void close_session();
int save_state_canfail (string state_name = ""); int save_state_canfail (string state_name = "");
@ -736,6 +736,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg); Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg);
Gtk::Label status_bar_label; Gtk::Label status_bar_label;
Gtk::ToggleButton error_log_button; Gtk::ToggleButton error_log_button;
Gtk::MessageDialog* loading_dialog;
}; };
#endif /* __ardour_gui_h__ */ #endif /* __ardour_gui_h__ */

View file

@ -163,7 +163,7 @@ ARDOUR_UI::connect_to_session (Session *s)
} }
int int
ARDOUR_UI::unload_session () ARDOUR_UI::unload_session (bool hide_stuff)
{ {
if (session && session->dirty()) { if (session && session->dirty()) {
switch (ask_about_saving_session (_("close"))) { switch (ask_about_saving_session (_("close"))) {
@ -175,7 +175,12 @@ ARDOUR_UI::unload_session ()
break; break;
} }
} }
editor->hide ();
if (hide_stuff) {
editor->hide ();
mixer->hide ();
}
second_connection.disconnect (); second_connection.disconnect ();
point_one_second_connection.disconnect (); point_one_second_connection.disconnect ();
point_oh_five_second_connection.disconnect (); point_oh_five_second_connection.disconnect ();

View file

@ -99,6 +99,7 @@ Editor::external_audio_dialog ()
case RESPONSE_OK: case RESPONSE_OK:
sfbrowser->hide (); sfbrowser->hide ();
break; break;
default: default:
// cancel from the browser - we are done // cancel from the browser - we are done
sfbrowser->hide (); sfbrowser->hide ();

View file

@ -526,8 +526,6 @@ SoundFileBrowser::update_preview ()
void void
SoundFileBrowser::found_list_view_selected () SoundFileBrowser::found_list_view_selected ()
{ {
cerr << "file selected\n";
if (!reset_options ()) { if (!reset_options ()) {
set_response_sensitive (RESPONSE_OK, false); set_response_sensitive (RESPONSE_OK, false);
} else { } else {
@ -625,8 +623,6 @@ SoundFileOmega::reset_options ()
abort (); abort ();
} }
cerr << "got " << paths.size() << " paths at depth = " << reset_depth << endl;
if (paths.empty()) { if (paths.empty()) {
channel_combo.set_sensitive (false); channel_combo.set_sensitive (false);
@ -1139,8 +1135,6 @@ SoundFileOmega::file_selection_changed ()
return; return;
} }
cerr << "file selection changed\n";
if (!reset_options ()) { if (!reset_options ()) {
set_response_sensitive (RESPONSE_OK, false); set_response_sensitive (RESPONSE_OK, false);
} else { } else {

View file

@ -479,6 +479,7 @@ carbon_menu_item_connect (GtkWidget *menu_item,
/* /*
* carbon event handler * carbon event handler
*/ */
static int eventcnt = 0;
static OSStatus static OSStatus
menu_event_handler_func (EventHandlerCallRef event_handler_call_ref, menu_event_handler_func (EventHandlerCallRef event_handler_call_ref,

View file

@ -117,7 +117,6 @@ void
Auditioner::audition_region (boost::shared_ptr<Region> region) Auditioner::audition_region (boost::shared_ptr<Region> region)
{ {
if (g_atomic_int_get (&_active)) { if (g_atomic_int_get (&_active)) {
cerr << "re-audition while still active!\n";
/* don't go via session for this, because we are going /* don't go via session for this, because we are going
to remain active. to remain active.
*/ */
@ -177,6 +176,7 @@ Auditioner::play_audition (nframes_t nframes)
} }
need_butler = _diskstream->commit (this_nframes); need_butler = _diskstream->commit (this_nframes);
current_frame += this_nframes; current_frame += this_nframes;
if (current_frame >= length) { if (current_frame >= length) {

View file

@ -29,6 +29,7 @@ dmalloc.cc
error.cc error.cc
fpu.cc fpu.cc
id.cc id.cc
misc.c
mountpoint.cc mountpoint.cc
path.cc path.cc
pathscanner.cc pathscanner.cc

21
libs/pbd/misc.c Normal file
View file

@ -0,0 +1,21 @@
#include <pbd/misc.h>
#ifdef GTKOSX
#include <AppKit/AppKit.h>
#endif
void
disable_screen_updates ()
{
#ifdef GTKOSX
NSDisableScreenUpdates ();
#endif
}
void
enable_screen_updates ()
{
#ifdef GTKOSX
NSEnableScreenUpdates();
#endif
}

View file

@ -141,8 +141,6 @@ mountpoint (string path)
} }
} }
free(mntbufp);
return best; return best;
} }
#endif // HAVE_GETMNTENT #endif // HAVE_GETMNTENT

15
libs/pbd/pbd/misc.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef __pbd_misc_h__
#define __pbd_misc_h__
#ifdef __cplusplus
extern "C" {
#endif
void disable_screen_updates ();
void enable_screen_updates ();
#ifdef __cplusplus
}
#endif
#endif /* __pbd_misc_h__ */