#include <cerrno>
#include <fstream>
+#include <stdarg.h>
+
#ifndef PLATFORM_WINDOWS
#include <sys/resource.h>
#endif
#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"
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 ))
, 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)
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<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
ui_config->map_parameters (pc);
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 ();
}
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
ARDOUR_UI::every_second ()
{
update_cpu_load ();
+ update_xrun_count ();
update_buffer_load ();
update_disk_space ();
update_timecode_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: <span foreground=\"%s\">>10K</span>"), X_("red"));
+ } else {
+ snprintf (buf, sizeof (buf), _("X: <span foreground=\"%s\">%u</span>"), x > 0 ? X_("red") : X_("green"), x);
+ }
+ } else {
+ snprintf (buf, sizeof (buf), _("X: <span foreground=\"%s\">?</span>"), X_("yellow"));
+ }
+ xrun_label.set_markup (buf);
+ set_tip (xrun_label, _("Audio dropouts. Shift+click to reset"));
+}
+
void
ARDOUR_UI::update_cpu_load ()
{
void
ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode)
{
-
if (!_session) {
return;
}
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;
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.
msg.set_position (Gtk::WIN_POS_CENTER);
pop_back_splash (msg);
msg.present ();
+
+ dump_errors (cerr);
+
(void) msg.run ();
msg.hide ();
break;
}
}
+
+void
+ARDOUR_UI::hide_application ()
+{
+ Application::instance ()-> hide ();
+}