move window visibility buttons to have less impact on minimum width
[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 "mixer_ui.h"
52 #include "utils.h"
53 #include "theme_manager.h"
54 #include "midi_tracer.h"
55 #include "shuttle_control.h"
56 #include "global_port_matrix.h"
57 #include "location_ui.h"
58 #include "rc_option_editor.h"
59 #include "time_info_box.h"
60
61 #include "i18n.h"
62
63 using namespace std;
64 using namespace ARDOUR;
65 using namespace PBD;
66 using namespace Gtkmm2ext;
67 using namespace Gtk;
68 using namespace Glib;
69 using namespace ARDOUR_UI_UTILS;
70
71
72 void
73 ARDOUR_UI::setup_tooltips ()
74 {
75         set_tip (roll_button, _("Play from playhead"));
76         set_tip (stop_button, _("Stop playback"));
77         set_tip (rec_button, _("Toggle record"));
78         set_tip (play_selection_button, _("Play range/selection"));
79         set_tip (goto_start_button, _("Go to start of session"));
80         set_tip (goto_end_button, _("Go to end of session"));
81         set_tip (auto_loop_button, _("Play loop range"));
82         set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels"));
83         set_tip (auto_return_button, _("Return to last playback start when stopped"));
84         set_tip (follow_edits_button, _("Playhead follows range selections and edits"));
85         set_tip (auto_input_button, _("Be sensible about input monitoring"));
86         set_tip (click_button, _("Enable/Disable audio click"));
87         set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
88         set_tip (auditioning_alert_button, _("When active, auditioning is taking place.\nClick to stop the audition"));
89         set_tip (feedback_alert_button, _("When active, there is a feedback loop."));
90         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"));
91         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"));
92         set_tip (editor_meter_peak_display, _("Reset All Peak Indicators"));
93         set_tip (error_alert_button, _("Show Error Log and acknowledge warnings"));
94
95         synchronize_sync_source_and_video_pullup ();
96
97         editor->setup_tooltips ();
98 }
99
100 bool
101 ARDOUR_UI::status_bar_button_press (GdkEventButton* ev)
102 {
103         bool handled = false;
104
105         switch (ev->button) {
106         case 1:
107                 status_bar_label.set_text ("");
108                 handled = true;
109                 break;
110         default:
111                 break;
112         }
113
114         return handled;
115 }
116
117 void
118 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
119 {
120         string text;
121
122         UI::display_message (prefix, prefix_len, ptag, mtag, msg);
123
124         ArdourLogLevel ll = LogLevelNone;
125
126         if (strcmp (prefix, _("[ERROR]: ")) == 0) {
127                 text = "<span color=\"red\" weight=\"bold\">";
128                 ll = LogLevelError;
129         } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
130                 text = "<span color=\"yellow\" weight=\"bold\">";
131                 ll = LogLevelWarning;
132         } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
133                 text = "<span color=\"green\" weight=\"bold\">";
134                 ll = LogLevelInfo;
135         } else {
136                 text = "<span color=\"white\" weight=\"bold\">???";
137         }
138
139         _log_not_acknowledged = std::max(_log_not_acknowledged, ll);
140
141 #ifdef TOP_MENUBAR
142         text += prefix;
143         text += "</span>";
144         text += msg;
145
146         status_bar_label.set_markup (text);
147 #endif
148 }
149
150 XMLNode*
151 ARDOUR_UI::tearoff_settings (const char* name) const
152 {
153         XMLNode* ui_node = Config->extra_xml(X_("UI"));
154
155         if (ui_node) {
156                 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
157                 if (tearoff_node) {
158                         XMLNode* mnode = tearoff_node->child (name);
159                         return mnode;
160                 }
161         }
162
163         return 0;
164 }
165
166 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
167
168 static
169 bool drag_failed (const Glib::RefPtr<Gdk::DragContext>& context, DragResult result, Tabbable* tab)
170 {
171         if (result == Gtk::DRAG_RESULT_NO_TARGET) {
172                 tab->detach ();
173                 return true;
174         }
175         return false;
176 }
177
178 void
179 ARDOUR_UI::setup_transport ()
180 {
181         RefPtr<Action> act;
182
183         transport_hbox.set_border_width (PX_SCALE(3));
184         transport_hbox.set_spacing (PX_SCALE(3));
185
186         transport_base.set_name ("TransportBase");
187         transport_base.add (transport_hbox);
188
189         transport_frame.set_shadow_type (SHADOW_OUT);
190         transport_frame.set_name ("BaseFrame");
191         transport_frame.add (transport_base);
192
193         auto_return_button.set_text(_("Auto Return"));
194
195         follow_edits_button.set_text(_("Follow Edits"));
196
197 //      auto_input_button.set_text (_("Auto Input"));
198
199         click_button.set_icon (ArdourIcon::TransportMetronom);
200
201         act = ActionManager::get_action ("Transport", "ToggleClick");
202         click_button.set_related_action (act);
203         click_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::click_button_clicked), false);
204
205         auto_return_button.set_name ("transport option button");
206         follow_edits_button.set_name ("transport option button");
207         auto_input_button.set_name ("transport option button");
208
209         /* these have to provide a clear indication of active state */
210
211         click_button.set_name ("transport button");
212         sync_button.set_name ("transport active option button");
213
214         stop_button.set_active (true);
215
216         goto_start_button.set_icon (ArdourIcon::TransportStart);
217         goto_end_button.set_icon (ArdourIcon::TransportEnd);
218         roll_button.set_icon (ArdourIcon::TransportPlay);
219         stop_button.set_icon (ArdourIcon::TransportStop);
220         play_selection_button.set_icon (ArdourIcon::TransportRange);
221         auto_loop_button.set_icon (ArdourIcon::TransportLoop);
222         rec_button.set_icon (ArdourIcon::RecButton);
223         midi_panic_button.set_icon (ArdourIcon::TransportPanic);
224
225         act = ActionManager::get_action (X_("Transport"), X_("Stop"));
226         stop_button.set_related_action (act);
227         act = ActionManager::get_action (X_("Transport"), X_("Roll"));
228         roll_button.set_related_action (act);
229         act = ActionManager::get_action (X_("Transport"), X_("Record"));
230         rec_button.set_related_action (act);
231         act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
232         goto_start_button.set_related_action (act);
233         act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
234         goto_end_button.set_related_action (act);
235         act = ActionManager::get_action (X_("Transport"), X_("Loop"));
236         auto_loop_button.set_related_action (act);
237         act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
238         play_selection_button.set_related_action (act);
239         act = ActionManager::get_action (X_("MIDI"), X_("panic"));
240         midi_panic_button.set_related_action (act);
241         act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
242         sync_button.set_related_action (act);
243
244         /* clocks, etc. */
245
246         ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
247         ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
248
249         primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
250         secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
251         big_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
252
253         act = ActionManager::get_action ("Transport", "ToggleAutoReturn");
254         auto_return_button.set_related_action (act);
255         act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
256         follow_edits_button.set_related_action (act);
257         act = ActionManager::get_action ("Transport", "ToggleAutoInput");
258         auto_input_button.set_related_action (act);
259
260         /* alerts */
261
262         /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
263
264         solo_alert_button.set_name ("rude solo");
265         act = ActionManager::get_action (X_("Main"), X_("cancel-solo"));
266         solo_alert_button.set_related_action (act);
267         auditioning_alert_button.set_name ("rude audition");
268         auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false);
269         feedback_alert_button.set_name ("feedback alert");
270         feedback_alert_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::feedback_alert_press), false);
271         error_alert_button.set_name ("error alert");
272         error_alert_button.signal_button_release_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::error_alert_press), false);
273         act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
274         error_alert_button.set_related_action(act);
275         error_alert_button.set_fallthrough_to_parent(true);
276
277         alert_box.set_homogeneous (true);
278         alert_box.set_spacing (PX_SCALE(2));
279         alert_box.pack_start (solo_alert_button, true, true);
280         alert_box.pack_start (auditioning_alert_button, true, true);
281         alert_box.pack_start (feedback_alert_button, true, true);
282
283         /* all transport buttons should be the same size vertically and
284          * horizontally
285          */
286
287         Glib::RefPtr<SizeGroup> transport_button_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
288         transport_button_size_group->add_widget (goto_start_button);
289         transport_button_size_group->add_widget (goto_end_button);
290         transport_button_size_group->add_widget (auto_loop_button);
291         transport_button_size_group->add_widget (rec_button);
292         transport_button_size_group->add_widget (play_selection_button);
293         transport_button_size_group->add_widget (roll_button);
294         transport_button_size_group->add_widget (stop_button);
295
296         /* the icon for this has an odd aspect ratio, so fatten up the button */
297         midi_panic_button.set_size_request (PX_SCALE(25), -1);
298         goto_start_button.set_size_request (PX_SCALE(28), PX_SCALE(44));
299         click_button.set_size_request (PX_SCALE(32), PX_SCALE(44));
300
301
302         HBox* tbox1 = manage (new HBox);
303         HBox* tbox2 = manage (new HBox);
304         HBox* tbox = manage (new HBox);
305
306         VBox* vbox1 = manage (new VBox);
307         VBox* vbox2 = manage (new VBox);
308
309         Alignment* a1 = manage (new Alignment);
310         Alignment* a2 = manage (new Alignment);
311
312         tbox1->set_spacing (PX_SCALE(2));
313         tbox2->set_spacing (PX_SCALE(2));
314         tbox->set_spacing (PX_SCALE(2));
315
316         if (!Profile->get_trx()) {
317                 tbox1->pack_start (midi_panic_button, true, true, 5);
318                 tbox1->pack_start (click_button, true, true, 5);
319         }
320
321         tbox1->pack_start (goto_start_button, true, true);
322         tbox1->pack_start (goto_end_button, true, true);
323         tbox1->pack_start (auto_loop_button, true, true);
324
325         if (!Profile->get_trx()) {
326                 tbox2->pack_start (play_selection_button, true, true);
327         }
328         tbox2->pack_start (roll_button, true, true);
329         tbox2->pack_start (stop_button, true, true);
330         tbox2->pack_start (rec_button, true, true, 5);
331
332         vbox1->pack_start (*tbox1, true, true);
333         vbox2->pack_start (*tbox2, true, true);
334
335         a1->add (*vbox1);
336         a1->set (0.5, 0.5, 0.0, 1.0);
337         a2->add (*vbox2);
338         a2->set (0.5, 0.5, 0.0, 1.0);
339
340         tbox->pack_start (*a1, false, false);
341         tbox->pack_start (*a2, false, false);
342
343         HBox* clock_box = manage (new HBox);
344
345         clock_box->pack_start (*primary_clock, false, false);
346         if (!ARDOUR::Profile->get_small_screen() && !ARDOUR::Profile->get_trx()) {
347                 clock_box->pack_start (*secondary_clock, false, false);
348         }
349         clock_box->set_spacing (PX_SCALE(3));
350
351         shuttle_box = manage (new ShuttleControl);
352         shuttle_box->show ();
353
354         VBox* transport_vbox = manage (new VBox);
355         transport_vbox->set_name ("TransportBase");
356         transport_vbox->set_border_width (0);
357         transport_vbox->set_spacing (PX_SCALE(3));
358         transport_vbox->pack_start (*tbox, true, true, 0);
359
360         if (!Profile->get_trx()) {
361                 transport_vbox->pack_start (*shuttle_box, false, false, 0);
362         }
363
364         time_info_box = manage (new TimeInfoBox);
365
366         transport_hbox.pack_start (*transport_vbox, false, true);
367
368         /* transport related toggle controls */
369
370         VBox* auto_box = manage (new VBox);
371         auto_box->set_homogeneous (true);
372         auto_box->set_spacing (PX_SCALE(2));
373         auto_box->pack_start (sync_button, true, true);
374         if (!ARDOUR::Profile->get_trx()) {
375                 auto_box->pack_start (follow_edits_button, true, true);
376                 auto_box->pack_start (auto_return_button, true, true);
377         }
378
379         if (!ARDOUR::Profile->get_trx()) {
380                 transport_hbox.pack_start (*auto_box, false, false);
381         }
382         transport_hbox.pack_start (*clock_box, true, true);
383
384         if (ARDOUR::Profile->get_trx()) {
385                 transport_hbox.pack_start (*auto_box, false, false);
386         }
387
388         if (!ARDOUR::Profile->get_trx()) {
389                 transport_hbox.pack_start (*time_info_box, false, false);
390         }
391
392         if (!ARDOUR::Profile->get_trx()) {
393                 transport_hbox.pack_start (alert_box, false, false);
394                 transport_hbox.pack_start (meter_box, false, false);
395                 transport_hbox.pack_start (editor_meter_peak_display, false, false);
396         }
397
398         Gtk::VBox*   window_button_box = manage (new Gtk::VBox);
399
400         editor_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), editor));
401         mixer_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), mixer));
402         prefs_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), rc_option_editor));
403
404         /* catch context clicks so that we can show a menu on these buttons */
405
406         editor_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("editor")), false);
407         mixer_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("mixer")), false);
408         prefs_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("preferences")), false);
409
410         editor_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-editor-visibility")));
411         editor_visibility_button.set_name (X_("page switch button"));
412         mixer_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-mixer-visibility")));
413         mixer_visibility_button.set_name (X_("page switch button"));
414         prefs_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-preferences-visibility")));
415         prefs_visibility_button.set_name (X_("page switch button"));
416
417         Gtkmm2ext::UI::instance()->set_tip (editor_visibility_button,
418                                             string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
419                                                               "To put the window back, use the Window > %1 > Attach menu action"), editor->name()));
420
421         Gtkmm2ext::UI::instance()->set_tip (mixer_visibility_button,
422                                             string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
423                                                               "To put the window back, use the Window > %1 > Attach menu action"), mixer->name()));
424
425         Gtkmm2ext::UI::instance()->set_tip (prefs_visibility_button,
426                                             string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
427                                                               "To put the window back, use the Window > %1 > Attach menu action"), rc_option_editor->name()));
428
429         window_button_box->pack_start (editor_visibility_button, true, false);
430         window_button_box->pack_start (mixer_visibility_button, true, false);
431         window_button_box->pack_start (prefs_visibility_button, true, false);
432
433         transport_hbox.pack_end (*window_button_box, false, false);
434
435         /* desensitize */
436
437         set_transport_sensitivity (false);
438 }
439 #undef PX_SCALE
440
441 void
442 ARDOUR_UI::soloing_changed (bool onoff)
443 {
444         if (solo_alert_button.get_active() != onoff) {
445                 solo_alert_button.set_active (onoff);
446         }
447 }
448
449 void
450 ARDOUR_UI::_auditioning_changed (bool onoff)
451 {
452         auditioning_alert_button.set_active (onoff);
453         set_transport_sensitivity (!onoff);
454 }
455
456 void
457 ARDOUR_UI::auditioning_changed (bool onoff)
458 {
459         UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::_auditioning_changed, this, onoff));
460 }
461
462 bool
463 ARDOUR_UI::audition_alert_press (GdkEventButton*)
464 {
465         if (_session) {
466                 _session->cancel_audition();
467         }
468         return true;
469 }
470
471 bool
472 ARDOUR_UI::feedback_alert_press (GdkEventButton *)
473 {
474         return true;
475 }
476
477 bool
478 ARDOUR_UI::error_alert_press (GdkEventButton* ev)
479 {
480         bool do_toggle = true;
481         if (ev->button == 1) {
482                 if (_log_not_acknowledged == LogLevelError) {
483                         // just acknowledge the error, don't hide the log if it's already visible
484                         RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
485                         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
486                         if (tact && tact->get_active()) {
487                                 do_toggle = false;
488                         }
489                 }
490                 _log_not_acknowledged = LogLevelNone;
491                 error_blink (false); // immediate acknowledge
492         }
493         // maybe fall through to to button toggle
494         return !do_toggle;
495 }
496
497 void
498 ARDOUR_UI::solo_blink (bool onoff)
499 {
500         if (_session == 0) {
501                 return;
502         }
503
504         if (_session->soloing() || _session->listening()) {
505                 if (onoff) {
506                         solo_alert_button.set_active (true);
507                 } else {
508                         solo_alert_button.set_active (false);
509                 }
510         } else {
511                 solo_alert_button.set_active (false);
512         }
513 }
514
515 void
516 ARDOUR_UI::sync_blink (bool onoff)
517 {
518         if (_session == 0 || !_session->config.get_external_sync()) {
519                 /* internal sync */
520                 sync_button.set_active (false);
521                 return;
522         }
523
524         if (!_session->transport_locked()) {
525                 /* not locked, so blink on and off according to the onoff argument */
526
527                 if (onoff) {
528                         sync_button.set_active (true);
529                 } else {
530                         sync_button.set_active (false);
531                 }
532         } else {
533                 /* locked */
534                 sync_button.set_active (true);
535         }
536 }
537
538 void
539 ARDOUR_UI::audition_blink (bool onoff)
540 {
541         if (_session == 0) {
542                 return;
543         }
544
545         if (_session->is_auditioning()) {
546                 if (onoff) {
547                         auditioning_alert_button.set_active (true);
548                 } else {
549                         auditioning_alert_button.set_active (false);
550                 }
551         } else {
552                 auditioning_alert_button.set_active (false);
553         }
554 }
555
556 void
557 ARDOUR_UI::feedback_blink (bool onoff)
558 {
559         if (_feedback_exists) {
560                 if (onoff) {
561                         feedback_alert_button.set_active (true);
562                 } else {
563                         feedback_alert_button.set_active (false);
564                 }
565         } else {
566                 feedback_alert_button.set_active (false);
567         }
568 }
569
570 void
571 ARDOUR_UI::error_blink (bool onoff)
572 {
573         switch (_log_not_acknowledged) {
574                 case LogLevelError:
575                         // blink
576                         if (onoff) {
577                                 error_alert_button.set_custom_led_color(0xff0000ff); // bright red
578                         } else {
579                                 error_alert_button.set_custom_led_color(0x880000ff); // dark red
580                         }
581                         break;
582                 case LogLevelWarning:
583                         error_alert_button.set_custom_led_color(0xccaa00ff); // yellow
584                         break;
585                 case LogLevelInfo:
586                         error_alert_button.set_custom_led_color(0x88cc00ff); // lime green
587                         break;
588                 default:
589                         error_alert_button.set_custom_led_color(0x333333ff); // gray
590                         break;
591         }
592 }
593
594
595
596 void
597 ARDOUR_UI::set_transport_sensitivity (bool yn)
598 {
599         ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
600         shuttle_box->set_sensitive (yn);
601 }
602
603 void
604 ARDOUR_UI::editor_realized ()
605 {
606         boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
607         Config->map_parameters (pc);
608
609         UIConfiguration::instance().reset_dpi ();
610 }
611
612 void
613 ARDOUR_UI::maximise_editing_space ()
614 {
615         if (editor) {
616                 editor->maximise_editing_space ();
617         }
618 }
619
620 void
621 ARDOUR_UI::restore_editing_space ()
622 {
623         if (editor) {
624                 editor->restore_editing_space ();
625         }
626 }
627
628 void
629 ARDOUR_UI::show_ui_prefs ()
630 {
631         if (rc_option_editor) {
632                 show_tabbable (rc_option_editor);
633                 rc_option_editor->set_current_page (_("GUI"));
634         }
635 }
636
637 bool
638 ARDOUR_UI::click_button_clicked (GdkEventButton* ev)
639 {
640         if (ev->button != 3) {
641                 /* this handler is just for button-3 clicks */
642                 return false;
643         }
644
645         show_tabbable (rc_option_editor);
646         rc_option_editor->set_current_page (_("Misc"));
647         return true;
648 }
649
650 void
651 ARDOUR_UI::toggle_follow_edits ()
652 {
653         RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
654         assert (act);
655
656         RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
657         assert (tact);
658
659         UIConfiguration::instance().set_follow_edits (tact->get_active ());
660 }
661
662 void
663 ARDOUR_UI::update_title ()
664 {
665         if (_session) {
666                 bool dirty = _session->dirty();
667
668                 string session_name;
669
670                 if (_session->snap_name() != _session->name()) {
671                         session_name = _session->snap_name();
672                 } else {
673                         session_name = _session->name();
674                 }
675
676                 if (dirty) {
677                         session_name = "*" + session_name;
678                 }
679
680                 WindowTitle title (session_name);
681                 title += Glib::get_application_name();
682                 _main_window.set_title (title.get_string());
683         } else {
684                 WindowTitle title (Glib::get_application_name());
685                 _main_window.set_title (title.get_string());
686         }
687
688 }