--- /dev/null
+/* Demo Recorder for MAEMO 5
+* Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2,
+* or (at your option) any later version, as published by the Free
+* Software Foundation
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details
+*
+* You should have received a copy of the GNU General Public
+* License along with this program; if not, write to the
+* Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+namespace IdWorks {
+
+public class PlayerTransport : Gtk.HBox {
+
+ public Gtk.Window window;
+
+ //Gtk.HScale progress;
+ Gtk.Label label_position;
+ Gtk.Label label_duration;
+ Gtk.ToggleButton record;
+ Gtk.Button play;
+ Gtk.ToggleButton pause;
+ Gtk.Button stop;
+
+ double volume;
+ public double get_volume() {
+ return volume;
+ }
+ public void set_volume(double volume) {
+ this.volume = volume;
+ }
+
+ double panorama;
+ public double get_panorama() {
+ return panorama;
+ }
+ public void set_panorama(double panorama) {
+ this.panorama = panorama;
+ }
+ /*
+ bool record_state;
+ public bool get_record_state() {
+ return record_state;
+ }
+ public void set_record_state(bool state) {
+ this.record_state = state;
+ }
+
+ bool pause_state;
+ public bool get_pause_state() {
+ return pause_state;
+ }
+ public void set_pause_state(bool state) {
+ this.pause_state = state;
+ }
+ */
+ public signal void record_toggled(bool val);
+ public signal void play_clicked();
+ public signal void stop_clicked();
+ public signal void pause_toggled(bool val);
+ public signal void volume_updated(double val);
+ public signal void panorama_updated(double val);
+ public signal void eq_updated(int band, double val);
+
+ private void show_volume_and_pan() {
+ VolumeAndPanPopUp dlg = new VolumeAndPanPopUp("Mixer Volume", this);
+ dlg.set_transient_for(this.window);
+ dlg.set_volume(this.volume);
+ dlg.set_panorama(this.panorama);
+ dlg.volume_updated.connect(volume_updated_callback);
+ dlg.panorama_updated.connect(panorama_updated_callback);
+ dlg.run();
+ dlg.destroy();
+ dlg = null;
+ }
+
+ private void show_equalizer() {
+ EqualizerPopUp dlg = new EqualizerPopUp("Mixer EQ", this);
+ dlg.set_transient_for(this.window);
+ dlg.eq_updated.connect(eq_updated_callback);
+ dlg.run();
+ dlg.destroy();
+ dlg = null;
+ }
+
+ private void volume_updated_callback(VolumeAndPanPopUp sender, double volume)
+ {
+ this.volume = volume;
+ volume_updated(this.volume);
+ }
+
+ private void panorama_updated_callback(VolumeAndPanPopUp sender, double panorama)
+ {
+ this.panorama = panorama;
+ panorama_updated(this.panorama);
+ }
+
+ private void eq_updated_callback(EqualizerPopUp sender, int band, double val)
+ {
+ eq_updated(band, val);
+ }
+
+ /*private static string time_to_string(int64 t) {
+ uint64 ut = (uint64)t / Time.Nanoseconds.MILLISECOND;
+ return Time.CLOCK_FORMAT.printf((ut / Time.Milliseconds.MINUTE), (ut / Time.Milliseconds.SECOND) % Time.Seconds.MINUTE, (ut % Time.Milliseconds.SECOND) / 100);
+ }*/
+ public void position_duration_callback(int64 position, int64 duration) {
+ label_position.set_text("%s\n%s".printf(Time.time_to_string(position), Time.time_to_string(duration)));
+ }
+
+ construct {
+ //record_state = false;
+ //pause_state = false;
+ volume = 1.0;
+ panorama = 0.0;
+ Gtk.HBox transport = new Gtk.HBox(true, 0);
+ //transport.add(new Gtk.Label("Test"));
+ 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));
+ transport.pack_end(label_position, false, false, 0);
+ /*progress = new Gtk.HScale.with_range(0.0, 100.0, 0.1);
+ progress.set_draw_value(false);
+ progress.value_changed.connect((s) => { label_position.set_text("%02.2f".printf(s.get_value())); });
+ transport.pack_start(progress, true, true, 2);
+ label_duration = new Gtk.Label("100.0");
+ transport.pack_start(label_duration, false, false, 0);*/
+ Gtk.HButtonBox buttons = new Gtk.HButtonBox();
+ record = new Gtk.ToggleButton(); //.with_label("Re");
+ record.set_image(new Gtk.Image.from_icon_name("camera_video_recording", Gtk.IconSize.BUTTON));
+ record.toggled.connect((b) => { record_toggled(b.active); set_recording(); });
+ buttons.add(record);
+ play = new Gtk.Button(); //.with_label("Pl");
+ play.set_image(new Gtk.Image.from_icon_name("camera_playback", Gtk.IconSize.BUTTON));
+ play.clicked.connect((b) => { play_clicked(); set_playing(); });
+ buttons.add(play);
+ pause = new Gtk.ToggleButton(); //.with_label("Pa");
+ pause.set_image(new Gtk.Image.from_icon_name("camera_video_pause", Gtk.IconSize.BUTTON));
+ pause.toggled.connect((b) => { pause_toggled(b.active); set_paused(); });
+ buttons.add(pause);
+ stop = new Gtk.Button(); //.with_label("St");
+ stop.set_image(new Gtk.Image.from_icon_name("camera_video_stop", Gtk.IconSize.BUTTON));
+ stop.clicked.connect((b) => { stop_clicked(); set_idle(); });
+ buttons.add(stop);
+ Gtk.Button vol = new Gtk.Button(); //.with_label("Vo");
+ //Gtk.Image vol_img = new Gtk.Image.from_icon_name("general_gtalk", Gtk.IconSize.BUTTON);
+ vol.set_image(new Gtk.Image.from_icon_name("statusarea_volumelevel4", Gtk.IconSize.BUTTON));
+ vol.clicked.connect(show_volume_and_pan);
+ buttons.add(vol);
+ Gtk.Button eq = new Gtk.Button.with_label("EQ");
+ eq.clicked.connect(show_equalizer);
+ buttons.add(eq);
+ this.pack_start(buttons, false, false, 0);
+ this.pack_start(transport, true, true, 0);
+ set_idle();
+ }
+
+ private void set_recording() {
+ play.set_sensitive(true);
+ record.set_sensitive(true);
+ pause.set_sensitive(false);
+ stop.set_sensitive(false);
+ }
+ private void set_playing() {
+ play.set_sensitive(false);
+ record.set_sensitive(false);
+ pause.set_sensitive(true);
+ stop.set_sensitive(true);
+ }
+ private void set_idle() {
+ play.set_sensitive(true);
+ record.set_sensitive(true);
+ record.set_active(false);
+ pause.set_sensitive(false);
+ stop.set_sensitive(false);
+ }
+ private void set_paused() {
+ play.set_sensitive(false);
+ record.set_sensitive(false);
+ pause.set_sensitive(true);
+ stop.set_sensitive(true);
+ }
+
+ private override void add(Gtk.Widget w) {
+ base.add(w);
+ }
+
+ private new void pack_start(Gtk.Widget w, bool expand, bool fill, uint padding = 0) {
+ base.pack_start(w, expand, fill, padding);
+ }
+
+ private new void pack_end(Gtk.Widget w, bool expand, bool fill, uint padding = 0) {
+ base.pack_start(w, expand, fill, padding);
+ }
+
+
+
+}
+
+}