ARDOUR_UI::starting ()
{
Application* app = Application::instance ();
- char *nsm_url;
+ const char *nsm_url;
bool brand_new_user = ArdourStartup::required ();
app->ShouldQuit.connect (sigc::mem_fun (*this, &ARDOUR_UI::queue_finish));
app->ready ();
- nsm_url = getenv ("NSM_URL");
+ /* we need to create this early because it may need to set the
+ * audio backend end up.
+ */
+
+ try {
+ audio_midi_setup.get (true);
+ } catch (...) {
+ return -1;
+ }
- if (nsm_url) {
+ if ((nsm_url = g_getenv ("NSM_URL")) != 0) {
nsm = new NSM_Client;
if (!nsm->init (nsm_url)) {
nsm->announce (PROGRAM_NAME, ":dirty:", "ardour3");
for ( i = 0; i < 5000; ++i) {
nsm->check ();
usleep (i);
- if (nsm->is_active())
+ if (nsm->is_active()) {
break;
+ }
+ }
+ if (i == 5000) {
+ error << _("NSM server did not announce itself") << endmsg;
+ return -1;
}
// wait for open command from nsm server
for ( i = 0; i < 5000; ++i) {
nsm->check ();
usleep (1000);
- if (nsm->client_id ())
+ if (nsm->client_id ()) {
break;
+ }
+ }
+
+ if (i == 5000) {
+ error << _("NSM: no client ID provided") << endmsg;
+ return -1;
}
if (_session && nsm) {
_session->set_nsm_state( nsm->is_active() );
+ } else {
+ error << _("NSM: no session created") << endmsg;
+ return -1;
}
// nsm requires these actions disabled
}
}
- }
- else {
+ } else {
delete nsm;
nsm = 0;
+ error << _("NSM: initialization failed") << endmsg;
+ return -1;
}
} else {
}
}
- /* we need to create this early because it may need to set the
- * audio backend end up.
- */
-
- try {
- audio_midi_setup.get (true);
- } catch (...) {
- return -1;
- }
-
/* go get a session */
const bool new_session_required = (ARDOUR_COMMAND_LINE::new_session || brand_new_user);
display_cleanup_results (rep, _("deleted file"), true);
}
+void
+ARDOUR_UI::setup_order_hint ()
+{
+ uint32_t order_hint = 0;
+
+ /*
+ we want the new routes to have their order keys set starting from
+ the highest order key in the selection + 1 (if available).
+ */
+ if (add_route_dialog->get_transient_for () == mixer->get_toplevel()) {
+ for (RouteUISelection::iterator s = mixer->selection().routes.begin(); s != mixer->selection().routes.end(); ++s) {
+ if ((*s)->route()->order_key() > order_hint) {
+ order_hint = (*s)->route()->order_key();
+ }
+ }
+
+ if (!mixer->selection().routes.empty()) {
+ order_hint++;
+ }
+
+ } else {
+ for (TrackSelection::iterator s = editor->get_selection().tracks.begin(); s != editor->get_selection().tracks.end(); ++s) {
+ RouteTimeAxisView* tav = dynamic_cast<RouteTimeAxisView*> (*s);
+ if (tav->route()->order_key() > order_hint) {
+ order_hint = tav->route()->order_key();
+ }
+ }
+
+ if (!editor->get_selection().tracks.empty()) {
+ order_hint++;
+ }
+ }
+
+ _session->set_order_hint (order_hint);
+
+ /* create a gap in the existing route order keys to accomodate new routes.*/
+
+ boost::shared_ptr <RouteList> rd = _session->get_routes();
+ for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) {
+ boost::shared_ptr<Route> rt (*ri);
+
+ if (rt->is_monitor()) {
+ continue;
+ }
+
+ if (rt->order_key () >= order_hint) {
+ rt->set_order_key (rt->order_key () + add_route_dialog->count());
+ }
+ }
+}
+
void
ARDOUR_UI::add_route (Gtk::Window* float_window)
{
}
if (float_window) {
+ add_route_dialog->unset_transient_for ();
add_route_dialog->set_transient_for (*float_window);
}
return;
}
+ setup_order_hint();
+
PBD::ScopedConnection idle_connection;
if (count > 8) {