3466a989868768226b025fa5d33b104e09cf4ec1
[ardour.git] / gtk2_ardour / ardour_ui2.cc
1 /*
2     Copyright (C) 1999 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23
24 #include <fcntl.h>
25 #include <signal.h>
26 #include <unistd.h>
27 #include <cerrno>
28 #include <iostream>
29 #include <cmath>
30
31 #include <sigc++/bind.h>
32 #include "pbd/error.h"
33 #include "pbd/basename.h"
34 #include "pbd/fastlog.h"
35
36 #include "gtkmm2ext/cairocell.h"
37 #include "gtkmm2ext/utils.h"
38 #include "gtkmm2ext/click_box.h"
39 #include "gtkmm2ext/window_title.h"
40
41 #include "ardour/profile.h"
42 #include "ardour/session.h"
43 #include "ardour/types.h"
44
45 #include "ardour_ui.h"
46 #include "keyboard.h"
47 #include "public_editor.h"
48 #include "audio_clock.h"
49 #include "actions.h"
50 #include "main_clock.h"
51 #include "utils.h"
52 #include "theme_manager.h"
53 #include "midi_tracer.h"
54 #include "shuttle_control.h"
55 #include "global_port_matrix.h"
56 #include "location_ui.h"
57 #include "rc_option_editor.h"
58 #include "time_info_box.h"
59
60 #include "i18n.h"
61
62 using namespace std;
63 using namespace ARDOUR;
64 using namespace PBD;
65 using namespace Gtkmm2ext;
66 using namespace Gtk;
67 using namespace Glib;
68 using namespace ARDOUR_UI_UTILS;
69
70
71 bool
72 ARDOUR_UI::tabs_button_event (GdkEventButton* ev)
73 {
74         std::vector<Widget*> children = _tabs.get_children();
75
76         for (std::vector<Widget*>::iterator w = children.begin(); w != children.end(); ++w) {
77
78                 Gtk::Widget* close_button = reinterpret_cast<Gtk::Widget*> ((*w)->get_data ("close-button"));
79
80                 if (close_button) {
81
82                         Gtk::Allocation alloc (close_button->get_allocation());
83                         int dx, dy;
84
85                         /* Allocation origin uses toplevel window coordinates;
86                          * event origin uses _tabs-centric coordinate space, so
87                          * translate before computing if event is inside the
88                          * close button.
89                          */
90
91                         close_button->get_toplevel()->translate_coordinates (_tabs, alloc.get_x(), alloc.get_y(), dx, dy);
92
93                         if (ev->x >= dx &&
94                             ev->y >= dy &&
95                             ev->x < dx + alloc.get_width() &&
96                             ev->y < dy + alloc.get_height()) {
97                                 if (close_button->event ((GdkEvent*) ev)) {
98                                         return true;
99                                 }
100                         }
101                 }
102         }
103
104         return false;
105 }
106
107 void
108 ARDOUR_UI::tabs_page_removed (Gtk::Widget*, guint)
109 {
110         if (_tabs.get_n_pages() == 1) {
111                 _tabs.set_show_tabs (false);
112         } else {
113                 _tabs.set_show_tabs (true);
114         }
115 }
116
117 void
118 ARDOUR_UI::tabs_page_added (Gtk::Widget*, guint)
119 {
120         if (_tabs.get_n_pages() == 1) {
121                 _tabs.set_show_tabs (false);
122         } else {
123                 _tabs.set_show_tabs (true);
124         }
125 }
126
127 void
128 ARDOUR_UI::tabs_switch (GtkNotebookPage*, guint page_number)
129 {
130 }
131
132 void
133 ARDOUR_UI::setup_tooltips ()
134 {
135         set_tip (roll_button, _("Play from playhead"));
136         set_tip (stop_button, _("Stop playback"));
137         set_tip (rec_button, _("Toggle record"));
138         set_tip (play_selection_button, _("Play range/selection"));
139         set_tip (goto_start_button, _("Go to start of session"));
140         set_tip (goto_end_button, _("Go to end of session"));
141         set_tip (auto_loop_button, _("Play loop range"));
142         set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels"));
143         set_tip (auto_return_button, _("Return to last playback start when stopped"));
144         set_tip (follow_edits_button, _("Playhead follows range selections and edits"));
145         set_tip (auto_input_button, _("Be sensible about input monitoring"));
146         set_tip (click_button, _("Enable/Disable audio click"));
147         set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
148         set_tip (auditioning_alert_button, _("When active, auditioning is taking place.\nClick to stop the audition"));
149         set_tip (feedback_alert_button, _("When active, there is a feedback loop."));
150         set_tip (primary_clock, _("<b>Primary Clock</b> right-click to set display mode. Click to edit, click+drag a digit or mouse-over+scroll wheel to modify.\nText edits: right-to-left overwrite <tt>Esc</tt>: cancel; <tt>Enter</tt>: confirm; postfix the edit with '+' or '-' to enter delta times.\n"));
151         set_tip (secondary_clock, _("<b>Secondary Clock</b> right-click to set display mode. Click to edit, click+drag a digit or mouse-over+scroll wheel to modify.\nText edits: right-to-left overwrite <tt>Esc</tt>: cancel; <tt>Enter</tt>: confirm; postfix the edit with '+' or '-' to enter delta times.\n"));
152         set_tip (editor_meter_peak_display, _("Reset All Peak Indicators"));
153         set_tip (error_alert_button, _("Show Error Log and acknowledge warnings"));
154
155         synchronize_sync_source_and_video_pullup ();
156
157         editor->setup_tooltips ();
158 }
159
160 bool
161 ARDOUR_UI::status_bar_button_press (GdkEventButton* ev)
162 {
163         bool handled = false;
164
165         switch (ev->button) {
166         case 1:
167                 status_bar_label.set_text ("");
168                 handled = true;
169                 break;
170         default:
171                 break;
172         }
173
174         return handled;
175 }
176
177 void
178 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
179 {
180         string text;
181
182         UI::display_message (prefix, prefix_len, ptag, mtag, msg);
183
184         ArdourLogLevel ll = LogLevelNone;
185
186         if (strcmp (prefix, _("[ERROR]: ")) == 0) {
187                 text = "<span color=\"red\" weight=\"bold\">";
188                 ll = LogLevelError;
189         } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
190                 text = "<span color=\"yellow\" weight=\"bold\">";
191                 ll = LogLevelWarning;
192         } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
193                 text = "<span color=\"green\" weight=\"bold\">";
194                 ll = LogLevelInfo;
195         } else {
196                 text = "<span color=\"white\" weight=\"bold\">???";
197         }
198
199         _log_not_acknowledged = std::max(_log_not_acknowledged, ll);
200
201 #ifdef TOP_MENUBAR
202         text += prefix;
203         text += "</span>";
204         text += msg;
205
206         status_bar_label.set_markup (text);
207 #endif
208 }
209
210 XMLNode*
211 ARDOUR_UI::tearoff_settings (const char* name) const
212 {
213         XMLNode* ui_node = Config->extra_xml(X_("UI"));
214
215         if (ui_node) {
216                 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
217                 if (tearoff_node) {
218                         XMLNode* mnode = tearoff_node->child (name);
219                         return mnode;
220                 }
221         }
222
223         return 0;
224 }
225
226 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
227
228 void
229 ARDOUR_UI::setup_transport ()
230 {
231         RefPtr<Action> act;
232
233         transport_hbox.set_border_width (PX_SCALE(3));
234         transport_hbox.set_spacing (PX_SCALE(3));
235
236         transport_base.set_name ("TransportBase");
237         transport_base.add (transport_hbox);
238
239         transport_frame.set_shadow_type (SHADOW_OUT);
240         transport_frame.set_name ("BaseFrame");
241         transport_frame.add (transport_base);
242
243         auto_return_button.set_text(_("Auto Return"));
244
245         follow_edits_button.set_text(_("Follow Edits"));
246
247 //      auto_input_button.set_text (_("Auto Input"));
248
249         click_button.set_icon (ArdourIcon::TransportMetronom);
250
251         act = ActionManager::get_action ("Transport", "ToggleClick");
252         click_button.set_related_action (act);
253         click_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::click_button_clicked), false);
254
255         auto_return_button.set_name ("transport option button");
256         follow_edits_button.set_name ("transport option button");
257         auto_input_button.set_name ("transport option button");
258
259         /* these have to provide a clear indication of active state */
260
261         click_button.set_name ("transport button");
262         sync_button.set_name ("transport active option button");
263
264         stop_button.set_active (true);
265
266         goto_start_button.set_icon (ArdourIcon::TransportStart);
267         goto_end_button.set_icon (ArdourIcon::TransportEnd);
268         roll_button.set_icon (ArdourIcon::TransportPlay);
269         stop_button.set_icon (ArdourIcon::TransportStop);
270         play_selection_button.set_icon (ArdourIcon::TransportRange);
271         auto_loop_button.set_icon (ArdourIcon::TransportLoop);
272         rec_button.set_icon (ArdourIcon::RecButton);
273         midi_panic_button.set_icon (ArdourIcon::TransportPanic);
274
275         act = ActionManager::get_action (X_("Transport"), X_("Stop"));
276         stop_button.set_related_action (act);
277         act = ActionManager::get_action (X_("Transport"), X_("Roll"));
278         roll_button.set_related_action (act);
279         act = ActionManager::get_action (X_("Transport"), X_("Record"));
280         rec_button.set_related_action (act);
281         act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
282         goto_start_button.set_related_action (act);
283         act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
284         goto_end_button.set_related_action (act);
285         act = ActionManager::get_action (X_("Transport"), X_("Loop"));
286         auto_loop_button.set_related_action (act);
287         act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
288         play_selection_button.set_related_action (act);
289         act = ActionManager::get_action (X_("MIDI"), X_("panic"));
290         midi_panic_button.set_related_action (act);
291         act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
292         sync_button.set_related_action (act);
293
294         /* clocks, etc. */
295
296         ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
297         ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
298
299         primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
300         secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
301         big_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
302
303         act = ActionManager::get_action ("Transport", "ToggleAutoReturn");
304         auto_return_button.set_related_action (act);
305         act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
306         follow_edits_button.set_related_action (act);
307         act = ActionManager::get_action ("Transport", "ToggleAutoInput");
308         auto_input_button.set_related_action (act);
309
310         /* alerts */
311
312         /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
313
314         solo_alert_button.set_name ("rude solo");
315         act = ActionManager::get_action (X_("Main"), X_("cancel-solo"));
316         solo_alert_button.set_related_action (act);
317         auditioning_alert_button.set_name ("rude audition");
318         auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false);
319         feedback_alert_button.set_name ("feedback alert");
320         feedback_alert_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::feedback_alert_press), false);
321         error_alert_button.set_name ("error alert");
322         error_alert_button.signal_button_release_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::error_alert_press), false);
323         act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
324         error_alert_button.set_related_action(act);
325         error_alert_button.set_fallthrough_to_parent(true);
326
327         alert_box.set_homogeneous (true);
328         alert_box.set_spacing (PX_SCALE(2));
329         alert_box.pack_start (solo_alert_button, true, true);
330         alert_box.pack_start (auditioning_alert_button, true, true);
331         alert_box.pack_start (feedback_alert_button, true, true);
332
333         /* all transport buttons should be the same size vertically and
334          * horizontally
335          */
336
337         Glib::RefPtr<SizeGroup> transport_button_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
338         transport_button_size_group->add_widget (goto_start_button);
339         transport_button_size_group->add_widget (goto_end_button);
340         transport_button_size_group->add_widget (auto_loop_button);
341         transport_button_size_group->add_widget (rec_button);
342         transport_button_size_group->add_widget (play_selection_button);
343         transport_button_size_group->add_widget (roll_button);
344         transport_button_size_group->add_widget (stop_button);
345
346         /* the icon for this has an odd aspect ratio, so fatten up the button */
347         midi_panic_button.set_size_request (PX_SCALE(25), -1);
348         goto_start_button.set_size_request (PX_SCALE(28), PX_SCALE(44));
349         click_button.set_size_request (PX_SCALE(32), PX_SCALE(44));
350
351
352         HBox* tbox1 = manage (new HBox);
353         HBox* tbox2 = manage (new HBox);
354         HBox* tbox = manage (new HBox);
355
356         VBox* vbox1 = manage (new VBox);
357         VBox* vbox2 = manage (new VBox);
358
359         Alignment* a1 = manage (new Alignment);
360         Alignment* a2 = manage (new Alignment);
361
362         tbox1->set_spacing (PX_SCALE(2));
363         tbox2->set_spacing (PX_SCALE(2));
364         tbox->set_spacing (PX_SCALE(2));
365
366         if (!Profile->get_trx()) {
367                 tbox1->pack_start (midi_panic_button, true, true, 5);
368                 tbox1->pack_start (click_button, true, true, 5);
369         }
370
371         tbox1->pack_start (goto_start_button, true, true);
372         tbox1->pack_start (goto_end_button, true, true);
373         tbox1->pack_start (auto_loop_button, true, true);
374
375         if (!Profile->get_trx()) {
376                 tbox2->pack_start (play_selection_button, true, true);
377         }
378         tbox2->pack_start (roll_button, true, true);
379         tbox2->pack_start (stop_button, true, true);
380         tbox2->pack_start (rec_button, true, true, 5);
381
382         vbox1->pack_start (*tbox1, true, true);
383         vbox2->pack_start (*tbox2, true, true);
384
385         a1->add (*vbox1);
386         a1->set (0.5, 0.5, 0.0, 1.0);
387         a2->add (*vbox2);
388         a2->set (0.5, 0.5, 0.0, 1.0);
389
390         tbox->pack_start (*a1, false, false);
391         tbox->pack_start (*a2, false, false);
392
393         HBox* clock_box = manage (new HBox);
394
395         clock_box->pack_start (*primary_clock, false, false);
396         if (!ARDOUR::Profile->get_small_screen() && !ARDOUR::Profile->get_trx()) {
397                 clock_box->pack_start (*secondary_clock, false, false);
398         }
399         clock_box->set_spacing (PX_SCALE(3));
400
401         shuttle_box = manage (new ShuttleControl);
402         shuttle_box->show ();
403
404         VBox* transport_vbox = manage (new VBox);
405         transport_vbox->set_name ("TransportBase");
406         transport_vbox->set_border_width (0);
407         transport_vbox->set_spacing (PX_SCALE(3));
408         transport_vbox->pack_start (*tbox, true, true, 0);
409
410         if (!Profile->get_trx()) {
411                 transport_vbox->pack_start (*shuttle_box, false, false, 0);
412         }
413
414         time_info_box = manage (new TimeInfoBox);
415
416         transport_hbox.pack_start (*transport_vbox, false, true);
417
418         /* transport related toggle controls */
419
420         VBox* auto_box = manage (new VBox);
421         auto_box->set_homogeneous (true);
422         auto_box->set_spacing (PX_SCALE(2));
423         auto_box->pack_start (sync_button, true, true);
424         if (!ARDOUR::Profile->get_trx()) {
425                 auto_box->pack_start (follow_edits_button, true, true);
426                 auto_box->pack_start (auto_return_button, true, true);
427         }
428
429         if (!ARDOUR::Profile->get_trx()) {
430                 transport_hbox.pack_start (*auto_box, false, false);
431         }
432         transport_hbox.pack_start (*clock_box, true, true);
433
434         if (ARDOUR::Profile->get_trx()) {
435                 transport_hbox.pack_start (*auto_box, false, false);
436         }
437
438         if (!ARDOUR::Profile->get_trx()) {
439                 transport_hbox.pack_start (*time_info_box, false, false);
440         }
441
442         if (!ARDOUR::Profile->get_trx()) {
443                 transport_hbox.pack_start (alert_box, false, false);
444                 transport_hbox.pack_start (meter_box, false, false);
445                 transport_hbox.pack_start (editor_meter_peak_display, false, false);
446         }
447
448         if (Profile->get_sae()) {
449                 Image* img = manage (new Image ((::get_icon (X_("sae")))));
450                 transport_hbox.pack_end (*img, false, false);
451         }
452
453         /* desensitize */
454
455         set_transport_sensitivity (false);
456 }
457 #undef PX_SCALE
458
459 void
460 ARDOUR_UI::soloing_changed (bool onoff)
461 {
462         if (solo_alert_button.get_active() != onoff) {
463                 solo_alert_button.set_active (onoff);
464         }
465 }
466
467 void
468 ARDOUR_UI::_auditioning_changed (bool onoff)
469 {
470         auditioning_alert_button.set_active (onoff);
471         set_transport_sensitivity (!onoff);
472 }
473
474 void
475 ARDOUR_UI::auditioning_changed (bool onoff)
476 {
477         UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::_auditioning_changed, this, onoff));
478 }
479
480 bool
481 ARDOUR_UI::audition_alert_press (GdkEventButton*)
482 {
483         if (_session) {
484                 _session->cancel_audition();
485         }
486         return true;
487 }
488
489 bool
490 ARDOUR_UI::feedback_alert_press (GdkEventButton *)
491 {
492         return true;
493 }
494
495 bool
496 ARDOUR_UI::error_alert_press (GdkEventButton* ev)
497 {
498         bool do_toggle = true;
499         if (ev->button == 1) {
500                 if (_log_not_acknowledged == LogLevelError) {
501                         // just acknowledge the error, don't hide the log if it's already visible
502                         RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
503                         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
504                         if (tact && tact->get_active()) {
505                                 do_toggle = false;
506                         }
507                 }
508                 _log_not_acknowledged = LogLevelNone;
509                 error_blink (false); // immediate acknowledge
510         }
511         // maybe fall through to to button toggle
512         return !do_toggle;
513 }
514
515 void
516 ARDOUR_UI::solo_blink (bool onoff)
517 {
518         if (_session == 0) {
519                 return;
520         }
521
522         if (_session->soloing() || _session->listening()) {
523                 if (onoff) {
524                         solo_alert_button.set_active (true);
525                 } else {
526                         solo_alert_button.set_active (false);
527                 }
528         } else {
529                 solo_alert_button.set_active (false);
530         }
531 }
532
533 void
534 ARDOUR_UI::sync_blink (bool onoff)
535 {
536         if (_session == 0 || !_session->config.get_external_sync()) {
537                 /* internal sync */
538                 sync_button.set_active (false);
539                 return;
540         }
541
542         if (!_session->transport_locked()) {
543                 /* not locked, so blink on and off according to the onoff argument */
544
545                 if (onoff) {
546                         sync_button.set_active (true);
547                 } else {
548                         sync_button.set_active (false);
549                 }
550         } else {
551                 /* locked */
552                 sync_button.set_active (true);
553         }
554 }
555
556 void
557 ARDOUR_UI::audition_blink (bool onoff)
558 {
559         if (_session == 0) {
560                 return;
561         }
562
563         if (_session->is_auditioning()) {
564                 if (onoff) {
565                         auditioning_alert_button.set_active (true);
566                 } else {
567                         auditioning_alert_button.set_active (false);
568                 }
569         } else {
570                 auditioning_alert_button.set_active (false);
571         }
572 }
573
574 void
575 ARDOUR_UI::feedback_blink (bool onoff)
576 {
577         if (_feedback_exists) {
578                 if (onoff) {
579                         feedback_alert_button.set_active (true);
580                 } else {
581                         feedback_alert_button.set_active (false);
582                 }
583         } else {
584                 feedback_alert_button.set_active (false);
585         }
586 }
587
588 void
589 ARDOUR_UI::error_blink (bool onoff)
590 {
591         switch (_log_not_acknowledged) {
592                 case LogLevelError:
593                         // blink
594                         if (onoff) {
595                                 error_alert_button.set_custom_led_color(0xff0000ff); // bright red
596                         } else {
597                                 error_alert_button.set_custom_led_color(0x880000ff); // dark red
598                         }
599                         break;
600                 case LogLevelWarning:
601                         error_alert_button.set_custom_led_color(0xccaa00ff); // yellow
602                         break;
603                 case LogLevelInfo:
604                         error_alert_button.set_custom_led_color(0x88cc00ff); // lime green
605                         break;
606                 default:
607                         error_alert_button.set_custom_led_color(0x333333ff); // gray
608                         break;
609         }
610 }
611
612
613
614 void
615 ARDOUR_UI::set_transport_sensitivity (bool yn)
616 {
617         ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
618         shuttle_box->set_sensitive (yn);
619 }
620
621 void
622 ARDOUR_UI::editor_realized ()
623 {
624         boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
625         Config->map_parameters (pc);
626
627         UIConfiguration::instance().reset_dpi ();
628 }
629
630 void
631 ARDOUR_UI::maximise_editing_space ()
632 {
633         if (editor) {
634                 editor->maximise_editing_space ();
635         }
636 }
637
638 void
639 ARDOUR_UI::restore_editing_space ()
640 {
641         if (editor) {
642                 editor->restore_editing_space ();
643         }
644 }
645
646 void
647 ARDOUR_UI::show_ui_prefs ()
648 {
649         if (rc_option_editor) {
650                 show_tabbable (rc_option_editor);
651                 rc_option_editor->set_current_page (_("GUI"));
652         }
653 }
654
655 bool
656 ARDOUR_UI::click_button_clicked (GdkEventButton* ev)
657 {
658         if (ev->button != 3) {
659                 /* this handler is just for button-3 clicks */
660                 return false;
661         }
662
663         show_tabbable (rc_option_editor);
664         rc_option_editor->set_current_page (_("Misc"));
665         return true;
666 }
667
668 void
669 ARDOUR_UI::toggle_follow_edits ()
670 {
671         RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
672         assert (act);
673
674         RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
675         assert (tact);
676
677         UIConfiguration::instance().set_follow_edits (tact->get_active ());
678 }
679
680 void
681 ARDOUR_UI::update_title ()
682 {
683         if (_session) {
684                 bool dirty = _session->dirty();
685
686                 string session_name;
687
688                 if (_session->snap_name() != _session->name()) {
689                         session_name = _session->snap_name();
690                 } else {
691                         session_name = _session->name();
692                 }
693
694                 if (dirty) {
695                         session_name = "*" + session_name;
696                 }
697
698                 WindowTitle title (session_name);
699                 title += Glib::get_application_name();
700                 _main_window.set_title (title.get_string());
701         } else {
702                 WindowTitle title (Glib::get_application_name());
703                 _main_window.set_title (title.get_string());
704         }
705
706 }
707