X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui.cc;h=524d16e017c002e8191ba0ec0959a74028b54f28;hb=5e7d9d30e28e8022661497244ccd43a1f5a836c6;hp=5a91bc6dfcae11805718e1cc06977fce1a1b7d6b;hpb=c7a766866e684680477031c7325289c7153a04aa;p=ardour.git diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 5a91bc6dfc..524d16e017 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -28,6 +28,8 @@ #include #include +#include + #ifndef PLATFORM_WINDOWS #include #endif @@ -55,6 +57,8 @@ #include "pbd/file_utils.h" #include "pbd/localtime_r.h" #include "pbd/pthread_utils.h" +#include "pbd/replace_all.h" +#include "pbd/xml++.h" #include "gtkmm2ext/application.h" #include "gtkmm2ext/bindings.h" @@ -181,10 +185,40 @@ ask_about_configuration_copy (string const & old_dir, string const & new_dir, in return (msg.run() == Gtk::RESPONSE_YES); } -ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) +static void +libxml_generic_error_func (void* /* parsing_context*/, + const char* msg, + ...) +{ + va_list ap; + char buf[2048]; + + va_start (ap, msg); + vsnprintf (buf, sizeof (buf), msg, ap); + error << buf << endmsg; + va_end (ap); +} + +static void +libxml_structured_error_func (void* /* parsing_context*/, + xmlErrorPtr err) +{ + string msg = err->message; + + replace_all (msg, "\n", ""); + + error << X_("XML error: ") << msg << " in " << err->file << " at line " << err->line; + if (err->int2) { + error << ':' << err->int2; + } + error << endmsg; +} + + +ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir, UIConfiguration* uic) : Gtkmm2ext::UI (PROGRAM_NAME, argcp, argvp) - , ui_config (new UIConfiguration) + , ui_config (uic->post_gui_init ()) , session_loaded (false) , gui_object_state (new GUIObjectState) , primary_clock (new MainClock (X_("primary"), X_("transport"), true )) @@ -214,6 +248,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) , error_alert_button ( ArdourButton::just_led_default_elements ) , editor_meter(0) , editor_meter_peak_display() + , session_selector_window (0) , open_session_selector (0) , _numpad_locate_happening (false) , _session_is_new (false) @@ -258,6 +293,11 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) theArdourUI = this; } + /* stop libxml from spewing to stdout/stderr */ + + xmlSetGenericErrorFunc (this, libxml_generic_error_func); + xmlSetStructuredErrorFunc (this, libxml_structured_error_func); + ui_config->ParameterChanged.connect (sigc::mem_fun (*this, &ARDOUR_UI::parameter_changed)); boost::function pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1)); ui_config->map_parameters (pc); @@ -434,8 +474,12 @@ ARDOUR_UI::engine_running () first_time_engine_run = false; } + if (_session) { + _session->reset_xrun_count (); + } update_disk_space (); update_cpu_load (); + update_xrun_count (); update_sample_rate (AudioEngine::instance()->sample_rate()); update_timecode_format (); } @@ -799,13 +843,16 @@ ARDOUR_UI::starting () if ((nsm_url = g_getenv ("NSM_URL")) != 0) { nsm = new NSM_Client; if (!nsm->init (nsm_url)) { - /* TODO this needs fixing! + /* the ardour executable may have different names: + * * waf's obj.target for distro versions: eg ardour4, ardourvst4 * Ardour4, Mixbus3 for bundled versions + full path on OSX & windows * argv[0] does not apply since we need the wrapper-script (not the binary itself) - * No idea how to address all these. + * + * The wrapper startup script should set the environment variable 'ARDOUR_SELF' */ - nsm->announce (PROGRAM_NAME, ":dirty:", "ardour4"); + const char *process_name = g_getenv ("ARDOUR_SELF"); + nsm->announce (PROGRAM_NAME, ":dirty:", process_name ? process_name : "ardour4"); unsigned int i = 0; // wait for announce reply from nsm server @@ -1179,6 +1226,7 @@ void ARDOUR_UI::every_second () { update_cpu_load (); + update_xrun_count (); update_buffer_load (); update_disk_space (); update_timecode_format (); @@ -1339,6 +1387,29 @@ ARDOUR_UI::update_format () format_label.set_markup (s.str ()); } +void +ARDOUR_UI::update_xrun_count () +{ + char buf[64]; + + /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets + should also be changed. + */ + + if (_session) { + const unsigned int x = _session->get_xrun_count (); + if (x > 9999) { + snprintf (buf, sizeof (buf), _("X: >10K"), X_("red")); + } else { + snprintf (buf, sizeof (buf), _("X: %u"), x > 0 ? X_("red") : X_("green"), x); + } + } else { + snprintf (buf, sizeof (buf), _("X: ?"), X_("yellow")); + } + xrun_label.set_markup (buf); + set_tip (xrun_label, _("Audio dropouts. Shift+click to reset")); +} + void ARDOUR_UI::update_cpu_load () { @@ -2072,7 +2143,6 @@ ARDOUR_UI::get_smart_mode() const void ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode) { - if (!_session) { return; } @@ -2398,14 +2468,6 @@ ARDOUR_UI::save_session_as () return; } - ArdourDialog progress_dialog(_("Save As"), true); - Gtk::Label label; - Gtk::ProgressBar progress_bar; - - progress_dialog.get_vbox()->pack_start (label); - progress_dialog.get_vbox()->pack_start (progress_bar); - label.show (); - progress_bar.show (); Session::SaveAs sa; @@ -2414,25 +2476,50 @@ ARDOUR_UI::save_session_as () sa.switch_to = save_as_dialog->switch_to(); sa.copy_media = save_as_dialog->copy_media(); sa.copy_external = save_as_dialog->copy_external(); + sa.include_media = save_as_dialog->include_media (); - /* this signal will be emitted from within this, the calling thread, - * after every file is copied. It provides information on percentage - * complete (in terms of total data to copy), the number of files - * copied so far, and the total number to copy. - */ - - ScopedConnection c; - - sa.Progress.connect_same_thread (c, boost::bind (&ARDOUR_UI::save_as_progress_update, this, _1, _2, _3, &label, &progress_bar)); + /* Only bother with a progress dialog if we're going to copy + media into the save-as target. Without that choice, this + will be very fast because we're only talking about a few kB's to + perhaps a couple of MB's of data. + */ - progress_dialog.show_all (); - progress_dialog.present (); + ArdourDialog progress_dialog (_("Save As"), true); + + if (sa.include_media && sa.copy_media) { + + Gtk::Label label; + Gtk::ProgressBar progress_bar; + + progress_dialog.get_vbox()->pack_start (label); + progress_dialog.get_vbox()->pack_start (progress_bar); + label.show (); + progress_bar.show (); + + /* this signal will be emitted from within this, the calling thread, + * after every file is copied. It provides information on percentage + * complete (in terms of total data to copy), the number of files + * copied so far, and the total number to copy. + */ + + ScopedConnection c; + + sa.Progress.connect_same_thread (c, boost::bind (&ARDOUR_UI::save_as_progress_update, this, _1, _2, _3, &label, &progress_bar)); + + progress_dialog.show_all (); + progress_dialog.present (); + } if (_session->save_as (sa)) { /* ERROR MESSAGE */ MessageDialog msg (string_compose (_("Save As failed: %1"), sa.failure_message)); msg.run (); } + + if (!sa.include_media) { + unload_session (false); + load_session (sa.final_session_folder_name, sa.new_name); + } } /** Ask the user for the name of a new snapshot and then take it. @@ -3122,6 +3209,9 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, msg.set_position (Gtk::WIN_POS_CENTER); pop_back_splash (msg); msg.present (); + + dump_errors (cerr); + (void) msg.run (); msg.hide (); @@ -4817,3 +4907,9 @@ ARDOUR_UI::audioengine_became_silent () break; } } + +void +ARDOUR_UI::hide_application () +{ + Application::instance ()-> hide (); +}