improvements (?) for window visibility during session loading - time to test on linux
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 24 Sep 2007 15:41:23 +0000 (15:41 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 24 Sep 2007 15:41:23 +0000 (15:41 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2476 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_dialogs.cc
gtk2_ardour/editor_audio_import.cc
gtk2_ardour/sfdb_ui.cc
gtk2_ardour/sync-menu.c
libs/ardour/auditioner.cc
libs/pbd/SConscript
libs/pbd/misc.c [new file with mode: 0644]
libs/pbd/mountpoint.cc
libs/pbd/pbd/misc.h [new file with mode: 0644]

index 9c612eb220f36eafb339c5d3dd20ba662f38d562..93cc753807f6745852ecfccee35cde8f0859a461 100644 (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,7 +1960,16 @@ 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;
 
        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;
                }
 
+               loading_dialog->show_all ();
+               flush_pending ();
+               
                create_engine ();
 
                /* now handle possible affirmative responses */
@@ -2031,14 +2045,16 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
                        /* OK == OPEN button */
 
                        session_name = new_session_dialog->session_name();
-                       
-                       if (new_session_dialog->get_current_page() == 1) {
-                               
-                               if (session_name.empty()) {
-                                       response = Gtk::RESPONSE_NONE;
-                                       continue;
-                               } 
+               
+                       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);
                                }
-                       
-                       } else {
+                               break;
 
-                               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;
@@ -2104,14 +2124,18 @@ ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_e
                                                new_session_dialog->reset ();
                                                continue;
                                        }
-                               }
+                               } 
 
                                _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,19 +2222,20 @@ 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;
 }
 
 void
-ARDOUR_UI::close_session()
+ARDOUR_UI::close_session ()
 {
        if (!check_audioengine()) {
                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
index 507c25315581d2cfc011b335ca9c89e0678803bc..1811a4db5ac84c67546e0b5d021c235e94538690 100644 (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__ */
index fcd75154b4380f594f988866e0340870aad9d836..b5fa7e23962c598de441146248b3d5e8b768840c 100644 (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;
                }
        }
-       editor->hide ();
+
+       if (hide_stuff) {
+               editor->hide ();
+               mixer->hide ();
+       }
+
        second_connection.disconnect ();
        point_one_second_connection.disconnect ();
        point_oh_five_second_connection.disconnect ();
index 0633b5ccaf23a26fd34b137deb916c3ff3c15047..863c162c43cea3b0a38c37ed2167cc40ceac36ae 100644 (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 ();
index 5767cf12d1c737229348923dde949d7a9fe36353..1ba31404ed71b105b81fdadbc86c7f3073a07d50 100644 (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 {
index 1f06939ff55bd45a0b44466e208b4b08f6d3131c..c471c7f90bb05105d584274850701fdbb808124e 100644 (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, 
index c1fef40151caffd3520013e2a974c25be6fa95ae..63f8850c0921cca21c4754e217efebe1f9aed138 100644 (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) {
index a0065f09bd50c855c51d33d75f5f6063e2dca554..9e09d5513e7ffa8cd142e213cacd07a7cd5eca61 100644 (file)
@@ -29,6 +29,7 @@ dmalloc.cc
 error.cc
 fpu.cc
 id.cc
+misc.c
 mountpoint.cc
 path.cc
 pathscanner.cc
diff --git a/libs/pbd/misc.c b/libs/pbd/misc.c
new file mode 100644 (file)
index 0000000..797be5d
--- /dev/null
@@ -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
+}
index c1bcb375f3a67f84d1a4d4cc8febb827f6a84de7..054aff07de91f6827842b42e3ce8f75a47af4079 100644 (file)
@@ -141,8 +141,6 @@ mountpoint (string path)
                }
        }
 
-       free(mntbufp);
-       
        return best;
 }
 #endif // HAVE_GETMNTENT
diff --git a/libs/pbd/pbd/misc.h b/libs/pbd/pbd/misc.h
new file mode 100644 (file)
index 0000000..306c006
--- /dev/null
@@ -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__ */