Vkeybd: use ArdourWidgets for all GUI elements
[ardour.git] / gtk2_ardour / ruler_dialog.cc
1 /*
2  * Copyright (C) 2014-2016 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2015-2017 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
20 #include <gtkmm/stock.h>
21
22 #include "actions.h"
23 #include "ruler_dialog.h"
24
25 #include "pbd/i18n.h"
26
27 RulerDialog::RulerDialog ()
28         : ArdourDialog (_("Rulers"))
29 {
30         add_button (Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
31
32         get_vbox()->pack_start (minsec_button);
33         get_vbox()->pack_start (timecode_button);
34         get_vbox()->pack_start (samples_button);
35         get_vbox()->pack_start (bbt_button);
36         get_vbox()->pack_start (meter_button);
37         get_vbox()->pack_start (tempo_button);
38         get_vbox()->pack_start (range_button);
39         get_vbox()->pack_start (loop_punch_button);
40         get_vbox()->pack_start (cdmark_button);
41         get_vbox()->pack_start (mark_button);
42         get_vbox()->pack_start (video_button);
43
44         get_vbox()->show_all ();
45
46         connect_action (samples_button, "samples-ruler");
47         connect_action (timecode_button, "timecode-ruler");
48         connect_action (minsec_button, "minsec-ruler");
49         connect_action (bbt_button, "bbt-ruler");
50         connect_action (tempo_button, "tempo-ruler");
51         connect_action (meter_button, "meter-ruler");
52         connect_action (loop_punch_button, "loop-punch-ruler");
53         connect_action (range_button, "range-ruler");
54         connect_action (mark_button, "marker-ruler");
55         connect_action (cdmark_button, "cd-marker-ruler");
56         connect_action (video_button, "video-ruler");
57 }
58
59 RulerDialog::~RulerDialog ()
60 {
61 }
62
63
64 void
65 RulerDialog::connect_action (Gtk::CheckButton& button, std::string const &action_name_part)
66 {
67         std::string action_name = "toggle-";
68         action_name += action_name_part;
69
70         Glib::RefPtr<Gtk::Action> act = ActionManager::get_action ("Rulers", action_name.c_str());
71         if (!act) {
72                 return;
73         }
74
75         Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic (act);
76         if (!tact) {
77                 return;
78         }
79
80         tact->connect_proxy (button);
81 }