1 /* Demo Recorder for MAEMO 5
2 * Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 public class PlayerTransport : Gtk.HBox {
22 public Gtk.Window window;
24 //Gtk.HScale progress;
25 Gtk.Label label_position;
26 Gtk.Label label_duration;
27 Gtk.ToggleButton record;
29 Gtk.ToggleButton pause;
33 public double get_volume() {
36 public void set_volume(double volume) {
41 public double get_panorama() {
44 public void set_panorama(double panorama) {
45 this.panorama = panorama;
49 public bool get_record_state() {
52 public void set_record_state(bool state) {
53 this.record_state = state;
57 public bool get_pause_state() {
60 public void set_pause_state(bool state) {
61 this.pause_state = state;
64 public signal void record_toggled(bool val);
65 public signal void play_clicked();
66 public signal void stop_clicked();
67 public signal void pause_toggled(bool val);
68 public signal void volume_updated(double val);
69 public signal void panorama_updated(double val);
70 public signal void eq_updated(int band, double val);
72 private void show_volume_and_pan() {
73 VolumeAndPanPopUp dlg = new VolumeAndPanPopUp("Mixer Volume", this);
74 dlg.set_transient_for(this.window);
75 dlg.set_volume(this.volume);
76 dlg.set_panorama(this.panorama);
77 dlg.volume_updated.connect(volume_updated_callback);
78 dlg.panorama_updated.connect(panorama_updated_callback);
84 private void show_equalizer() {
85 EqualizerPopUp dlg = new EqualizerPopUp("Mixer EQ", this);
86 dlg.set_transient_for(this.window);
87 dlg.eq_updated.connect(eq_updated_callback);
93 private void volume_updated_callback(VolumeAndPanPopUp sender, double volume)
96 volume_updated(this.volume);
99 private void panorama_updated_callback(VolumeAndPanPopUp sender, double panorama)
101 this.panorama = panorama;
102 panorama_updated(this.panorama);
105 private void eq_updated_callback(EqualizerPopUp sender, int band, double val)
107 eq_updated(band, val);
110 /*private static string time_to_string(int64 t) {
111 uint64 ut = (uint64)t / Time.Nanoseconds.MILLISECOND;
112 return Time.CLOCK_FORMAT.printf((ut / Time.Milliseconds.MINUTE), (ut / Time.Milliseconds.SECOND) % Time.Seconds.MINUTE, (ut % Time.Milliseconds.SECOND) / 100);
114 public void position_duration_callback(int64 position, int64 duration) {
115 label_position.set_text("%s\n%s".printf(Time.time_to_string(position), Time.time_to_string(duration)));
119 //record_state = false;
120 //pause_state = false;
123 Gtk.HBox transport = new Gtk.HBox(true, 0);
124 //transport.add(new Gtk.Label("Test"));
125 label_position = new Gtk.Label((Time.CLOCK_FORMAT + "\n" + Time.CLOCK_FORMAT).printf((uint64)0,(uint64)0,(uint64)0,(uint64)0,(uint64)0,(uint64)0));
126 transport.pack_end(label_position, false, false, 0);
127 /*progress = new Gtk.HScale.with_range(0.0, 100.0, 0.1);
128 progress.set_draw_value(false);
129 progress.value_changed.connect((s) => { label_position.set_text("%02.2f".printf(s.get_value())); });
130 transport.pack_start(progress, true, true, 2);
131 label_duration = new Gtk.Label("100.0");
132 transport.pack_start(label_duration, false, false, 0);*/
133 Gtk.HButtonBox buttons = new Gtk.HButtonBox();
134 record = new Gtk.ToggleButton(); //.with_label("Re");
135 record.set_image(new Gtk.Image.from_icon_name("camera_video_recording", Gtk.IconSize.BUTTON));
136 record.toggled.connect((b) => { record_toggled(b.active); set_recording(); });
138 play = new Gtk.Button(); //.with_label("Pl");
139 play.set_image(new Gtk.Image.from_icon_name("camera_playback", Gtk.IconSize.BUTTON));
140 play.clicked.connect((b) => { play_clicked(); set_playing(); });
142 pause = new Gtk.ToggleButton(); //.with_label("Pa");
143 pause.set_image(new Gtk.Image.from_icon_name("camera_video_pause", Gtk.IconSize.BUTTON));
144 pause.toggled.connect((b) => { pause_toggled(b.active); set_paused(); });
146 stop = new Gtk.Button(); //.with_label("St");
147 stop.set_image(new Gtk.Image.from_icon_name("camera_video_stop", Gtk.IconSize.BUTTON));
148 stop.clicked.connect((b) => { stop_clicked(); set_idle(); });
150 Gtk.Button vol = new Gtk.Button(); //.with_label("Vo");
151 //Gtk.Image vol_img = new Gtk.Image.from_icon_name("general_gtalk", Gtk.IconSize.BUTTON);
152 vol.set_image(new Gtk.Image.from_icon_name("statusarea_volumelevel4", Gtk.IconSize.BUTTON));
153 vol.clicked.connect(show_volume_and_pan);
155 Gtk.Button eq = new Gtk.Button.with_label("EQ");
156 eq.clicked.connect(show_equalizer);
158 this.pack_start(buttons, false, false, 0);
159 this.pack_start(transport, true, true, 0);
163 private void set_recording() {
164 play.set_sensitive(true);
165 record.set_sensitive(true);
166 pause.set_sensitive(false);
167 stop.set_sensitive(false);
169 private void set_playing() {
170 play.set_sensitive(false);
171 record.set_sensitive(false);
172 pause.set_sensitive(true);
173 stop.set_sensitive(true);
175 private void set_idle() {
176 play.set_sensitive(true);
177 record.set_sensitive(true);
178 record.set_active(false);
179 pause.set_sensitive(false);
180 stop.set_sensitive(false);
182 private void set_paused() {
183 play.set_sensitive(false);
184 record.set_sensitive(false);
185 pause.set_sensitive(true);
186 stop.set_sensitive(true);
189 private override void add(Gtk.Widget w) {
193 private new void pack_start(Gtk.Widget w, bool expand, bool fill, uint padding = 0) {
194 base.pack_start(w, expand, fill, padding);
197 private new void pack_end(Gtk.Widget w, bool expand, bool fill, uint padding = 0) {
198 base.pack_start(w, expand, fill, padding);