enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / ruler_dialog.cc
1 /*
2     Copyright (C) 2014 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 <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 void
64 RulerDialog::on_response (int)
65 {
66         hide ();
67 }
68
69 void
70 RulerDialog::connect_action (Gtk::CheckButton& button, std::string const &action_name_part)
71 {
72         std::string action_name = "toggle-";
73         action_name += action_name_part;
74
75         Glib::RefPtr<Gtk::Action> act = ActionManager::get_action ("Rulers", action_name.c_str());
76         if (!act) {
77                 return;
78         }
79
80         Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic (act);
81         if (!tact) {
82                 return;
83         }
84
85         tact->connect_proxy (button);
86 }