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