fix merge conflict from master
[ardour.git] / gtk2_ardour / main_clock.cc
1 /*
2     Copyright (C) 2012 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 #include "ardour/rc_configuration.h"
21 #include "main_clock.h"
22 #include "i18n.h"
23
24 using namespace Gtk;
25
26 MainClock::MainClock (
27         const std::string& clock_name,
28         bool is_transient,
29         const std::string& widget_name,
30         bool editable,
31         bool follows_playhead,
32         bool primary,
33         bool duration,
34         bool with_info
35         )
36         : AudioClock (clock_name, is_transient, widget_name, editable, follows_playhead, duration, with_info)
37           , _primary (primary)
38 {
39
40 }
41
42 void
43 MainClock::build_ops_menu ()
44 {
45         using namespace Menu_Helpers;
46
47         AudioClock::build_ops_menu ();
48
49         MenuList& ops_items = ops_menu->items();
50         ops_items.push_back (SeparatorElem ());
51         ops_items.push_back (CheckMenuElem (_("Display delta to edit cursor"), sigc::mem_fun (*this, &MainClock::display_delta_to_edit_cursor)));
52         Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem *> (&ops_items.back());
53         if (_primary) {
54                 if (ARDOUR::Config->get_primary_clock_delta_edit_cursor ()) {
55                         ARDOUR::Config->set_primary_clock_delta_edit_cursor (false);
56                         c->set_active (true);
57                 }
58         } else {
59                 if (ARDOUR::Config->get_secondary_clock_delta_edit_cursor ()) {
60                         ARDOUR::Config->set_secondary_clock_delta_edit_cursor (false);
61                         c->set_active (true);
62                 }
63         }
64 }
65
66 void
67 MainClock::display_delta_to_edit_cursor ()
68 {
69         if (_primary) {
70                 ARDOUR::Config->set_primary_clock_delta_edit_cursor (!ARDOUR::Config->get_primary_clock_delta_edit_cursor ());
71         } else {
72                 ARDOUR::Config->set_secondary_clock_delta_edit_cursor (!ARDOUR::Config->get_secondary_clock_delta_edit_cursor ());
73         }
74 }