fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / gtk2_ardour / transport_masters_dialog.cc
1 /*
2  * Copyright (C) 2018-2019 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2018-2019 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 #include <gtkmm/stock.h>
20
21 #include "pbd/enumwriter.h"
22 #include "pbd/i18n.h"
23
24 #include "temporal/time.h"
25
26 #include "ardour/audioengine.h"
27 #include "ardour/session.h"
28 #include "ardour/transport_master.h"
29 #include "ardour/transport_master_manager.h"
30
31 #include "widgets/tooltips.h"
32
33 #include "gtkmm2ext/utils.h"
34 #include "gtkmm2ext/gui_thread.h"
35
36 #include "ardour_ui.h"
37 #include "floating_text_entry.h"
38 #include "transport_masters_dialog.h"
39
40
41 using namespace std;
42 using namespace Gtk;
43 using namespace Gtkmm2ext;
44 using namespace ARDOUR;
45 using namespace PBD;
46 using namespace ArdourWidgets;
47
48 TransportMastersWidget::TransportMastersWidget ()
49         : table (4, 13)
50         , add_button (_("Add a new Transport Master"))
51 {
52         pack_start (table, PACK_EXPAND_WIDGET, 12);
53         pack_start (add_button, FALSE, FALSE);
54
55         add_button.signal_clicked ().connect (sigc::mem_fun (*this, &TransportMastersWidget::add_master));
56
57         col_title[0].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Use")));
58         col_title[1].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Name")));
59         col_title[2].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Type")));
60         col_title[3].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Format/\nBPM")));
61         col_title[4].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Current")));
62         col_title[5].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Last")));
63         col_title[6].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Timestamp")));
64         col_title[7].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Delta")));
65         col_title[8].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Collect")));
66         col_title[9].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Data Source")));
67         col_title[10].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Active\nCommands")));
68         col_title[11].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Clock\nSynced")));
69         col_title[12].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("29.97/\n30")));
70         col_title[13].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Remove")));
71
72         set_tooltip (col_title[12], _("<b>When enabled</b> the external timecode source is assumed to use 29.97 fps instead of 30000/1001.\n"
73                                       "SMPTE 12M-1999 specifies 29.97df as 30000/1001. The spec further mentions that "
74                                       "drop-sample timecode has an accumulated error of -86ms over a 24-hour period.\n"
75                                       "Drop-sample timecode would compensate exactly for a NTSC color frame rate of 30 * 0.9990 (ie 29.970000). "
76                                       "That is not the actual rate. However, some vendors use that rate - despite it being against the specs - "
77                                       "because the variant of using exactly 29.97 fps has zero timecode drift.\n"
78                              ));
79
80         set_tooltip (col_title[11], string_compose (_("<b>When enabled</b> the external timecode source is assumed to be sample-clock synced to the audio interface\n"
81                                                       "being used by %1."), PROGRAM_NAME));
82
83         table.set_spacings (6);
84
85         TransportMasterManager::instance().CurrentChanged.connect (current_connection, invalidator (*this), boost::bind (&TransportMastersWidget::current_changed, this, _1, _2), gui_context());
86         TransportMasterManager::instance().Added.connect (add_connection, invalidator (*this), boost::bind (&TransportMastersWidget::rebuild, this), gui_context());
87         TransportMasterManager::instance().Removed.connect (remove_connection, invalidator (*this), boost::bind (&TransportMastersWidget::rebuild, this), gui_context());
88
89         AudioEngine::instance()->Running.connect (engine_running_connection, invalidator (*this), boost::bind (&TransportMastersWidget::update_usability, this), gui_context());
90
91         rebuild ();
92 }
93
94 TransportMastersWidget::~TransportMastersWidget ()
95 {
96         for (vector<Row*>::iterator r = rows.begin(); r != rows.end(); ++r) {
97                 delete *r;
98         }
99 }
100
101 void
102 TransportMastersWidget::set_transport_master (boost::shared_ptr<TransportMaster> tm)
103 {
104         _session->request_sync_source (tm);
105 }
106
107 void
108 TransportMastersWidget::current_changed (boost::shared_ptr<TransportMaster> old_master, boost::shared_ptr<TransportMaster> new_master)
109 {
110         for (vector<Row*>::iterator r = rows.begin(); r != rows.end(); ++r) {
111                 if ((*r)->tm == new_master) {
112                         (*r)->use_button.set_active (true);
113                         break; /* there can only be one */
114                 }
115         }
116 }
117
118 void
119 TransportMastersWidget::add_master ()
120 {
121         AddTransportMasterDialog d;
122
123         d.present ();
124         string name;
125
126         while (name.empty()) {
127
128                 int r = d.run ();
129
130                 switch (r) {
131                 case RESPONSE_ACCEPT:
132                         name = d.get_name();
133                         break;
134                 default:
135                         return;
136                 }
137         }
138
139         d.hide ();
140
141         if (TransportMasterManager::instance().add (d.get_type(), name)) {
142                 MessageDialog msg (_("New transport master not added - check error log for details"));
143                 msg.run ();
144         }
145 }
146
147 void
148 TransportMastersWidget::clear ()
149 {
150         container_clear (table);
151
152         for (vector<Row*>::iterator r = rows.begin(); r != rows.end(); ++r) {
153                 delete *r;
154         }
155
156         rows.clear ();
157 }
158
159 void
160 TransportMastersWidget::rebuild ()
161 {
162         TransportMasterManager::TransportMasters const & masters (TransportMasterManager::instance().transport_masters());
163
164         clear ();
165         table.resize (masters.size()+1, 14);
166
167         for (size_t col = 0; col < sizeof (col_title) / sizeof (col_title[0]); ++col) {
168                 table.attach (col_title[col], col, col+1, 0, 1);
169         }
170
171         uint32_t n = 1;
172
173         Gtk::RadioButtonGroup use_button_group;
174
175         for (TransportMasterManager::TransportMasters::const_iterator m = masters.begin(); m != masters.end(); ++m, ++n) {
176
177                 Row* r = new Row (*this);
178                 rows.push_back (r);
179
180                 r->tm = *m;
181                 r->label.set_text ((*m)->name());
182                 r->type.set_text (enum_2_string  ((*m)->type()));
183
184                 r->use_button.set_group (use_button_group);
185
186                 if (TransportMasterManager::instance().current() == r->tm) {
187                         r->use_button.set_active (true);
188                 }
189
190                 int col = 0;
191
192                 r->label_box.add (r->label);
193
194                 table.attach (r->use_button, col, col+1, n, n+1); ++col;
195                 table.attach (r->label_box, col, col+1, n, n+1); ++col;
196                 table.attach (r->type, col, col+1, n, n+1); ++col;
197                 table.attach (r->format, col, col+1, n, n+1); ++col;
198                 table.attach (r->current, col, col+1, n, n+1); ++col;
199                 table.attach (r->last, col, col+1, n, n+1); ++col;
200                 table.attach (r->timestamp, col, col+1, n, n+1); ++col;
201                 table.attach (r->delta, col, col+1, n, n+1); ++col;
202                 table.attach (r->collect_button, col, col+1, n, n+1); ++col;
203                 table.attach (r->port_combo, col, col+1, n, n+1); ++col;
204                 table.attach (r->request_options, col, col+1, n, n+1); ++col;
205
206                 boost::shared_ptr<TimecodeTransportMaster> ttm (boost::dynamic_pointer_cast<TimecodeTransportMaster> (r->tm));
207
208                 if (ttm) {
209                         table.attach (r->sclock_synced_button, col, col+1, n, n+1); ++col;
210                         table.attach (r->fr2997_button, col, col+1, n, n+1); ++col;
211                         r->fr2997_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::fr2997_button_toggled));
212                 } else {
213                         col += 2;
214                 }
215
216                 if (r->tm->removeable()) {
217                         table.attach (r->remove_button, col, col+1, n, n+1); ++col;
218                 } else {
219                         col++;
220                 }
221
222                 table.show_all ();
223
224                 r->label_box.signal_button_press_event().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::name_press));
225                 r->port_combo.signal_changed().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::port_choice_changed));
226                 r->use_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::use_button_toggled));
227                 r->collect_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::collect_button_toggled));
228                 r->request_options.signal_button_press_event().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::request_option_press), false);
229                 r->remove_button.signal_clicked().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::remove_clicked));
230
231                 if (ttm) {
232                         r->sclock_synced_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::sync_button_toggled));
233                 }
234
235                 r->tm->PropertyChanged.connect (r->property_change_connection, invalidator (*this), boost::bind (&TransportMastersWidget::Row::prop_change, r, _1), gui_context());
236
237                 PropertyChange all_change;
238                 all_change.add (Properties::locked);
239                 all_change.add (Properties::collect);
240                 all_change.add (Properties::connected);
241
242                 if (ttm) {
243                         all_change.add (Properties::fr2997);
244                         all_change.add (Properties::sclock_synced);
245                 }
246
247                 r->prop_change (all_change);
248         }
249
250         update_usability ();
251 }
252
253 void
254 TransportMastersWidget::update_usability ()
255 {
256         for (vector<Row*>::iterator r= rows.begin(); r != rows.end(); ++r) {
257                 const bool usable = (*r)->tm->usable();
258                 (*r)->use_button.set_sensitive (usable);
259                 (*r)->collect_button.set_sensitive (usable);
260                 (*r)->request_options.set_sensitive (usable);
261         }
262 }
263
264 TransportMastersWidget::Row::Row (TransportMastersWidget& p)
265         : parent (p)
266         , request_option_menu (0)
267         , remove_button (X_("x"))
268         , name_editor (0)
269         , save_when (0)
270         , ignore_active_change (false)
271 {
272 }
273
274 TransportMastersWidget::Row::~Row ()
275 {
276         delete request_option_menu;
277 }
278
279 bool
280 TransportMastersWidget::Row::name_press (GdkEventButton* ev)
281 {
282         if (ev->type == GDK_2BUTTON_PRESS && ev->button == 1) {
283                 Gtk::Window* toplevel = dynamic_cast<Gtk::Window*> (label.get_toplevel());
284                 if (!toplevel) {
285                         return false;
286                 }
287                 name_editor = new FloatingTextEntry (toplevel, tm->name());
288                 name_editor->use_text.connect (sigc::mem_fun (*this, &TransportMastersWidget::Row::name_edited));
289                 name_editor->show ();
290                 return true;
291         }
292         return false;
293 }
294
295 bool
296 TransportMastersWidget::idle_remove (TransportMastersWidget::Row* row)
297 {
298         TransportMasterManager::instance().remove (row->tm->name());
299         return false;
300 }
301
302 void
303 TransportMastersWidget::Row::remove_clicked ()
304 {
305         /* have to do this via an idle callback, because it will destroy the
306            widget from which this callback was initiated.
307         */
308         Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (parent, &TransportMastersWidget::idle_remove), this));
309 }
310
311 void
312 TransportMastersWidget::Row::name_edited (string str, int ignored)
313 {
314         tm->set_name (str);
315         /* floating text entry deletes itself */
316         name_editor = 0;
317 }
318
319 void
320 TransportMastersWidget::Row::prop_change (PropertyChange what_changed)
321 {
322         if (what_changed.contains (Properties::locked)) {
323         }
324
325         if (what_changed.contains (Properties::fr2997)) {
326                 fr2997_button.set_active (boost::dynamic_pointer_cast<TimecodeTransportMaster> (tm)->fr2997());
327         }
328
329         if (what_changed.contains (Properties::sclock_synced)) {
330                 sclock_synced_button.set_active (boost::dynamic_pointer_cast<TimecodeTransportMaster> (tm)->sample_clock_synced());
331         }
332
333         if (what_changed.contains (Properties::collect)) {
334                 collect_button.set_active (tm->collect());
335         }
336
337         if (what_changed.contains (Properties::connected)) {
338                 populate_port_combo ();
339         }
340
341         if (what_changed.contains (Properties::name)) {
342                 label.set_text (tm->name());
343         }
344 }
345
346 void
347 TransportMastersWidget::Row::use_button_toggled ()
348 {
349         if (use_button.get_active()) {
350                 parent.set_transport_master (tm);
351         }
352 }
353
354 void
355 TransportMastersWidget::Row::fr2997_button_toggled ()
356 {
357         boost::dynamic_pointer_cast<TimecodeTransportMaster>(tm)->set_fr2997 (fr2997_button.get_active());
358 }
359
360 void
361 TransportMastersWidget::Row::collect_button_toggled ()
362 {
363         tm->set_collect (collect_button.get_active());
364 }
365
366 void
367 TransportMastersWidget::Row::sync_button_toggled ()
368 {
369         tm->set_sample_clock_synced (sclock_synced_button.get_active());
370 }
371
372 bool
373 TransportMastersWidget::Row::request_option_press (GdkEventButton* ev)
374 {
375         if (ev->button == 1) {
376                 if (!request_option_menu) {
377                         build_request_options ();
378                 }
379                 request_option_menu->popup (1, ev->time);
380                 return true;
381         }
382         return false;
383 }
384
385 void
386 TransportMastersWidget::Row::build_request_options ()
387 {
388         using namespace Gtk::Menu_Helpers;
389
390         request_option_menu = new Menu;
391
392         MenuList& items (request_option_menu->items());
393
394         items.push_back (CheckMenuElem (_("Accept speed-changing commands (start/stop)")));
395         Gtk::CheckMenuItem* i = dynamic_cast<Gtk::CheckMenuItem *> (&items.back ());
396         i->set_active (tm->request_mask() & TR_Speed);
397         items.push_back (CheckMenuElem (_("Accept locate commands")));
398         i = dynamic_cast<Gtk::CheckMenuItem *> (&items.back ());
399         i->set_active (tm->request_mask() & TR_Locate);
400 }
401
402 Glib::RefPtr<Gtk::ListStore>
403 TransportMastersWidget::Row::build_port_list (vector<string> const & ports)
404 {
405         Glib::RefPtr<Gtk::ListStore> store = ListStore::create (port_columns);
406         TreeModel::Row row;
407
408         row = *store->append ();
409         row[port_columns.full_name] = string();
410         row[port_columns.short_name] = _("Disconnected");
411
412         for (vector<string>::const_iterator p = ports.begin(); p != ports.end(); ++p) {
413
414                 if (AudioEngine::instance()->port_is_mine (*p)) {
415                         continue;
416                 }
417
418                 row = *store->append ();
419                 row[port_columns.full_name] = *p;
420
421                 std::string pn = ARDOUR::AudioEngine::instance()->get_pretty_name_by_name (*p);
422                 if (pn.empty ()) {
423                         pn = (*p).substr ((*p).find (':') + 1);
424                 }
425                 row[port_columns.short_name] = pn;
426         }
427
428         return store;
429 }
430
431 void
432 TransportMastersWidget::Row::populate_port_combo ()
433 {
434         if (!tm->port()) {
435                 port_combo.hide ();
436                 return;
437         } else {
438                 port_combo.show ();
439         }
440
441         vector<string> inputs;
442
443         if (tm->port()->type() == DataType::MIDI) {
444                 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput), inputs);
445         } else {
446                 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::AUDIO, ARDOUR::PortFlags (ARDOUR::IsOutput), inputs);
447         }
448
449         Glib::RefPtr<Gtk::ListStore> input = build_port_list (inputs);
450         bool input_found = false;
451         int n;
452
453         port_combo.set_model (input);
454
455         Gtk::TreeModel::Children children = input->children();
456         Gtk::TreeModel::Children::iterator i;
457         i = children.begin();
458         ++i; /* skip "Disconnected" */
459
460
461         for (n = 1;  i != children.end(); ++i, ++n) {
462                 string port_name = (*i)[port_columns.full_name];
463                 if (tm->port()->connected_to (port_name)) {
464                         port_combo.set_active (n);
465                         input_found = true;
466                         break;
467                 }
468         }
469
470         if (!input_found) {
471                 port_combo.set_active (0); /* disconnected */
472         }
473 }
474
475 void
476 TransportMastersWidget::Row::port_choice_changed ()
477 {
478         if (ignore_active_change) {
479                 return;
480         }
481
482         TreeModel::iterator active = port_combo.get_active ();
483         string new_port = (*active)[port_columns.full_name];
484
485         if (new_port.empty()) {
486                 tm->port()->disconnect_all ();
487                 return;
488         }
489
490         if (!tm->port()->connected_to (new_port)) {
491                 tm->port()->disconnect_all ();
492                 tm->port()->connect (new_port);
493         }
494 }
495
496 void
497 TransportMastersWidget::Row::update (Session* s, samplepos_t now)
498 {
499         using namespace Timecode;
500
501         samplepos_t pos;
502         double speed;
503         samplepos_t most_recent;
504         samplepos_t when;
505         stringstream ss;
506         Time t;
507         Time l;
508         boost::shared_ptr<TimecodeTransportMaster> ttm;
509         boost::shared_ptr<MIDIClock_TransportMaster> mtm;
510
511         if (!AudioEngine::instance()->running()) {
512                 return;
513         }
514
515         if (s) {
516
517                 if (tm->speed_and_position (speed, pos, most_recent, when, now)) {
518
519                         sample_to_timecode (pos, t, false, false, 25, false, AudioEngine::instance()->sample_rate(), 100, false, 0);
520                         sample_to_timecode (most_recent, l, false, false, 25, false, AudioEngine::instance()->sample_rate(), 100, false, 0);
521
522                         if ((ttm = boost::dynamic_pointer_cast<TimecodeTransportMaster> (tm))) {
523                                 format.set_text (timecode_format_name (ttm->apparent_timecode_format()));
524                                 last.set_text (Timecode::timecode_format_time (l));
525                         } else if ((mtm = boost::dynamic_pointer_cast<MIDIClock_TransportMaster> (tm))) {
526                                 char buf[8];
527                                 snprintf (buf, sizeof (buf), "%.1f", mtm->bpm());
528                                 format.set_text (buf);
529                                 last.set_text ("");
530                         } else {
531                                 format.set_text ("");
532                                 last.set_text ("");
533                         }
534                         current.set_text (Timecode::timecode_format_time (t));
535                         delta.set_markup (tm->delta_string ());
536
537                         char gap[32];
538                         const float seconds = (when - now) / (float) AudioEngine::instance()->sample_rate();
539                         if (abs (seconds) < 1.0) {
540                                 snprintf (gap, sizeof (gap), "%.3fs", seconds);
541                         } else if (abs (seconds) < 4.0) {
542                                 snprintf (gap, sizeof (gap), "%ds", (int) floor (seconds));
543                         } else {
544                                 snprintf (gap, sizeof (gap), "%s", _(">4s ago"));
545                         }
546                         timestamp.set_text (gap);
547                         save_when = when;
548
549                 } else {
550
551                         if (save_when) {
552                                 char gap[32];
553
554                                 const float seconds = (when - now) / (float) AudioEngine::instance()->sample_rate();
555                                 if (abs (seconds) < 1.0) {
556                                         snprintf (gap, sizeof (gap), "%.3fs", seconds);
557                                 } else if (abs (seconds) < 4.0) {
558                                         snprintf (gap, sizeof (gap), "%ds", (int) floor (seconds));
559                                 } else {
560                                         snprintf (gap, sizeof (gap), "%s", _(">4s ago"));
561                                 }
562                                 timestamp.set_text (gap);
563                                 save_when = when;
564                         }
565                         delta.set_text ("");
566                         current.set_text ("");
567                 }
568         }
569 }
570
571 void
572 TransportMastersWidget::update (samplepos_t /* audible */)
573 {
574         samplepos_t now = AudioEngine::instance()->sample_time ();
575
576         for (vector<Row*>::iterator r = rows.begin(); r != rows.end(); ++r) {
577                 (*r)->update (_session, now);
578         }
579 }
580
581 void
582 TransportMastersWidget::on_map ()
583 {
584         update_connection = ARDOUR_UI::Clock.connect (sigc::mem_fun (*this, &TransportMastersWidget::update));
585         Gtk::VBox::on_map ();
586 }
587
588 void
589 TransportMastersWidget::on_unmap ()
590 {
591         update_connection.disconnect ();
592         Gtk::VBox::on_unmap ();
593 }
594
595 TransportMastersWindow::TransportMastersWindow ()
596         : ArdourWindow (_("Transport Masters"))
597 {
598         add (w);
599         w.show ();
600 }
601
602 void
603 TransportMastersWindow::on_realize ()
604 {
605         ArdourWindow::on_realize ();
606         /* (try to) ensure that resizing is possible and the window can be moved (and closed) */
607         get_window()->set_decorations (Gdk::DECOR_BORDER | Gdk::DECOR_RESIZEH | Gdk::DECOR_TITLE | Gdk::DECOR_MENU);
608 }
609
610
611
612 void
613 TransportMastersWindow::set_session (ARDOUR::Session* s)
614 {
615         ArdourWindow::set_session (s);
616         w.set_session (s);
617 }
618
619 TransportMastersWidget::AddTransportMasterDialog::AddTransportMasterDialog ()
620         : ArdourDialog (_("Add Transport Master"), true, false)
621         , name_label (_("Name"))
622         , type_label (_("Type"))
623 {
624         name_hbox.set_spacing (6);
625         name_hbox.pack_start (name_label, false, false);
626         name_hbox.pack_start (name_entry, true, true);
627
628         type_hbox.set_spacing (6);
629         type_hbox.pack_start (type_label, false, false);
630         type_hbox.pack_start (type_combo, true, true);
631
632         vector<string> s;
633
634         s.push_back (X_("MTC"));
635         s.push_back (X_("LTC"));
636         s.push_back (X_("MIDI Clock"));
637
638         set_popdown_strings (type_combo, s);
639         type_combo.set_active_text (X_("LTC"));
640
641         get_vbox()->pack_start (name_hbox, false, false);
642         get_vbox()->pack_start (type_hbox, false, false);
643
644         add_button (_("Cancel"), RESPONSE_CANCEL);
645         add_button (_("Add"), RESPONSE_ACCEPT);
646
647         name_entry.show ();
648         type_combo.show ();
649         name_label.show ();
650         type_label.show ();
651         name_hbox.show ();
652         type_hbox.show ();
653
654         name_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
655 }
656
657 string
658 TransportMastersWidget::AddTransportMasterDialog::get_name () const
659 {
660         return name_entry.get_text ();
661 }
662
663 SyncSource
664 TransportMastersWidget::AddTransportMasterDialog::get_type() const
665 {
666         string t = type_combo.get_active_text ();
667
668         if (t == X_("MTC")) {
669                 return MTC;
670         } else if (t == X_("MIDI Clock")) {
671                 return MIDIClock;
672         }
673
674         return LTC;
675 }