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/compose.h>
#include <pbd/misc.h>
#include <pbd/pathscanner.h>
#include <pbd/failed_constructor.h>
#include <pbd/enumwriter.h>
@ -191,6 +192,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
have_disk_speed_dialog_displayed = false;
_will_create_new_session_automatically = false;
session_loaded = false;
loading_dialog = 0;
last_speed_displayed = -1.0f;
keybindings_path = ARDOUR::find_config_file ("ardour.bindings");
@ -1958,6 +1960,15 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
{
string session_name;
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;
@ -2002,6 +2013,9 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
have_engine = true;
}
loading_dialog->show_all ();
flush_pending ();
create_engine ();
/* now handle possible affirmative responses */
@ -2032,13 +2046,15 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
session_name = new_session_dialog->session_name();
if (new_session_dialog->get_current_page() == 1) {
if (session_name.empty()) {
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] == '/' ||
(session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
(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();
load_session (session_path, session_name);
}
break;
} else {
if (session_name.empty()) {
response = Gtk::RESPONSE_NONE;
continue;
}
case 0: /* nominally the "new" session creator, but could be in use for an old session */
if (new_session_dialog->get_current_page() == 0 && ARDOUR_COMMAND_LINE::session_name.empty()) {
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);
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);
@ -2096,6 +2113,9 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
switch (msg.run()) {
case RESPONSE_YES:
new_session_dialog->hide ();
goto_editor_window ();
flush_pending ();
load_session (session_path, session_name);
goto done;
break;
@ -2108,10 +2128,14 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
_session_is_new = true;
std::string template_name = new_session_dialog->session_template_name();
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);
} 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();
}
new_session_dialog->hide ();
goto_editor_window ();
flush_pending ();
if (build_session (session_path,
session_name,
cchns,
@ -2183,6 +2211,10 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
continue;
}
}
break;
default:
break;
}
}
@ -2190,7 +2222,7 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
done:
show();
new_session_dialog->get_window()->set_cursor();
loading_dialog->hide ();
new_session_dialog->hide();
return true;
}
@ -2202,7 +2234,8 @@ ARDOUR_UI::close_session()
return;
}
unload_session();
unload_session (true);
get_session_parameters ("", true, false);
}
@ -2210,19 +2243,22 @@ int
ARDOUR_UI::load_session (const string & path, const string & snap_name, string* mix_template)
{
Session *new_session;
int x;
int unload_status;
int retval = -1;
session_loaded = false;
if (!check_audioengine()) {
return -1;
}
x = unload_session ();
unload_status = unload_session ();
if (x < 0) {
return -1;
} else if (x > 0) {
return 0;
if (unload_status < 0) {
goto out;
} else if (unload_status > 0) {
retval = 0;
goto out;
}
/* 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"
"This prevents the session from being loaded."));
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 {
new_session = new Session (*engine, path, snap_name, mix_template);
}
catch (...) {
error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg;
return -1;
goto out;
}
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);
return 0;
enable_screen_updates ();
flush_pending ();
retval = 0;
out:
return retval;
}
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);
gint cmdline_new_session (string path);
int unload_session ();
int unload_session (bool hide_stuff = false);
void close_session();
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);
Gtk::Label status_bar_label;
Gtk::ToggleButton error_log_button;
Gtk::MessageDialog* loading_dialog;
};
#endif /* __ardour_gui_h__ */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -29,6 +29,7 @@ dmalloc.cc
error.cc
fpu.cc
id.cc
misc.c
mountpoint.cc
path.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;
}
#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__ */