table.set_spacings (6);
TransportMasterManager::instance().CurrentChanged.connect (current_connection, invalidator (*this), boost::bind (&TransportMastersWidget::current_changed, this, _1, _2), gui_context());
+ TransportMasterManager::instance().Added.connect (add_connection, invalidator (*this), boost::bind (&TransportMastersWidget::rebuild, this), gui_context());
+ TransportMasterManager::instance().Removed.connect (remove_connection, invalidator (*this), boost::bind (&TransportMastersWidget::rebuild, this), gui_context());
rebuild ();
}
void
TransportMastersWidget::add_master ()
{
- if (!TransportMasterManager::instance().add (LTC, "new ltc")) {
- rebuild ();
+ AddTransportMasterDialog d;
+
+ d.present ();
+ string name;
+
+ while (name.empty()) {
+
+ int r = d.run ();
+
+ switch (r) {
+ case RESPONSE_ACCEPT:
+ name = d.get_name();
+ break;
+ default:
+ return;
+ }
+ }
+
+ d.hide ();
+
+ if (TransportMasterManager::instance().add (d.get_type(), name)) {
+ MessageDialog msg (_("New transport master not added - check error log for details"));
+ msg.run ();
}
}
uint32_t n = 1;
- cerr << "There are " << masters.size() << endl;
-
Gtk::RadioButtonGroup use_button_group;
for (TransportMasterManager::TransportMasters::const_iterator m = masters.begin(); m != masters.end(); ++m, ++n) {
Row* r = new Row (*this);
rows.push_back (r);
- cerr << "Rows now holds " << rows.size() << endl;
-
r->tm = *m;
r->label.set_text ((*m)->name());
r->type.set_text (enum_2_string ((*m)->type()));
table.show_all ();
- // r->label_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
r->label_box.signal_button_press_event().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::name_press));
r->port_combo.signal_changed().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::port_choice_changed));
r->use_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::use_button_toggled));
return false;
}
+bool
+TransportMastersWidget::idle_remove (TransportMastersWidget::Row* row)
+{
+ TransportMasterManager::instance().remove (row->tm->name());
+ return false;
+}
+
void
TransportMastersWidget::Row::remove_clicked ()
{
+ /* have to do this via an idle callback, because it will destroy the
+ widget from which this callback was initiated.
+ */
+ Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (parent, &TransportMastersWidget::idle_remove), this));
}
void
}
void
- TransportMastersWidget::update (samplepos_t /* audible */)
+TransportMastersWidget::update (samplepos_t /* audible */)
{
samplepos_t now = AudioEngine::instance()->sample_time ();
ArdourWindow::set_session (s);
w.set_session (s);
}
+
+TransportMastersWidget::AddTransportMasterDialog::AddTransportMasterDialog ()
+ : ArdourDialog (_("Add Transport Master"), true, false)
+ , name_label (_("Name"))
+ , type_label (_("Type"))
+{
+ name_hbox.set_spacing (6);
+ name_hbox.pack_start (name_label, false, false);
+ name_hbox.pack_start (name_entry, true, true);
+
+ type_hbox.set_spacing (6);
+ type_hbox.pack_start (type_label, false, false);
+ type_hbox.pack_start (type_combo, true, true);
+
+ vector<string> s;
+
+ s.push_back (X_("MTC"));
+ s.push_back (X_("LTC"));
+ s.push_back (X_("MIDI Clock"));
+
+ set_popdown_strings (type_combo, s);
+ type_combo.set_active_text (X_("LTC"));
+
+ get_vbox()->pack_start (name_hbox, false, false);
+ get_vbox()->pack_start (type_hbox, false, false);
+
+ add_button (_("Cancel"), RESPONSE_CANCEL);
+ add_button (_("Add"), RESPONSE_ACCEPT);
+
+ name_entry.show ();
+ type_combo.show ();
+ name_label.show ();
+ type_label.show ();
+ name_hbox.show ();
+ type_hbox.show ();
+
+ name_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
+}
+
+string
+TransportMastersWidget::AddTransportMasterDialog::get_name () const
+{
+ return name_entry.get_text ();
+}
+
+SyncSource
+TransportMastersWidget::AddTransportMasterDialog::get_type() const
+{
+ string t = type_combo.get_active_text ();
+
+ if (t == X_("MTC")) {
+ return MTC;
+ } else if (t == X_("MIDI Clock")) {
+ return MIDIClock;
+ }
+
+ return LTC;
+}