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 EchoPopUp : Hildon.Dialog {
22 Gtk.HScale delay_slider;
23 Gtk.HScale feedback_slider;
24 Gtk.HScale intensity_slider;
26 const uint64 MAX_DELAY = 1 * Time.Milliseconds.SECOND;
28 public signal void delay_updated(uint64 val);
29 public signal void feedback_updated(double val);
30 public signal void intensity_updated(double val);
32 public EchoPopUp (string title, Gtk.Widget parent) {
33 this.set_title(title);
34 this.set_parent(parent);
36 construct_interface(SettingsStructures.EchoSettings());
38 public EchoPopUp.with_settings (string title, Gtk.Widget parent, SettingsStructures.EchoSettings settings) {
39 this.set_title(title);
40 this.set_parent(parent);
42 construct_interface(settings);
45 public SettingsStructures.EchoSettings get_settings_structure() {
46 SettingsStructures.EchoSettings settings = SettingsStructures.EchoSettings();
47 settings.active = true;
48 settings.max_delay = MAX_DELAY;
49 settings.delay = this.get_delay();
50 settings.feedback = this.get_feedback();
51 settings.intensity = this.get_intensity();
54 public void set_settings_structure(SettingsStructures.EchoSettings settings) {
55 // ignore active for now
56 // ignore max_delay for now
57 this.set_delay(settings.delay);
58 this.set_feedback(settings.feedback);
59 this.set_intensity(settings.intensity);
62 private void construct_interface(SettingsStructures.EchoSettings settings) {
64 this.set_default_response(Gtk.ResponseType.ACCEPT);
65 this.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT);
67 Gtk.VBox control_area = (Gtk.VBox)this.get_content_area();
69 Gtk.HBox delay_bar = new Gtk.HBox(false, 4);
71 Gtk.Label delay_label = new Gtk.Label("Delay (ms): ");
72 delay_slider = new Gtk.HScale.with_range(0, MAX_DELAY, Time.Milliseconds.MILLISECOND);
73 delay_slider.set_value_pos(Gtk.PositionType.LEFT);
74 delay_slider.set_value(settings.delay);
75 delay_slider.value_changed.connect((s) => {delay_updated((uint64)(s.get_value()) * Time.Nanoseconds.MILLISECOND);});
76 delay_bar.pack_start(delay_label, false, false, 2);
77 delay_bar.pack_start(delay_slider, true, true, 2);
79 control_area.pack_start(delay_bar, true, true, 2);
81 Gtk.HBox feedback_bar = new Gtk.HBox(false, 4);
83 Gtk.Label feedback_label = new Gtk.Label("Feedback (ratio): ");
84 feedback_slider = new Gtk.HScale.with_range(0.0, 1.0, 0.05);
85 feedback_slider.set_value_pos(Gtk.PositionType.LEFT);
86 feedback_slider.set_value(settings.feedback);
87 feedback_slider.value_changed.connect((s) => {feedback_updated(s.get_value());});
88 feedback_bar.pack_start(feedback_label, false, false, 2);
89 feedback_bar.pack_start(feedback_slider, true, true, 2);
91 control_area.pack_start(feedback_bar, true, true, 2);
93 Gtk.HBox intensity_bar = new Gtk.HBox(false, 4);
95 Gtk.Label intensity_label = new Gtk.Label("Intensity (ratio): ");
96 intensity_slider = new Gtk.HScale.with_range(0.0, 1.0, 0.05);
97 intensity_slider.set_value_pos(Gtk.PositionType.LEFT);
98 intensity_slider.set_value(settings.intensity);
99 intensity_slider.value_changed.connect((s) => {intensity_updated(s.get_value());});
100 intensity_bar.pack_start(intensity_label, false, false, 2);
101 intensity_bar.pack_start(intensity_slider, true, true, 2);
103 control_area.pack_start(intensity_bar, true, true, 2);
108 public uint64 get_delay() {
109 return (uint64) (delay_slider.get_value() * Time.Nanoseconds.MILLISECOND);
111 public void set_delay(uint64 val) {
112 delay_slider.set_value((double) (val / Time.Nanoseconds.MILLISECOND));
115 public double get_feedback() {
116 return feedback_slider.get_value();
118 public void set_feedback(double val) {
119 feedback_slider.set_value(val);
122 public double get_intensity() {
123 return intensity_slider.get_value();
125 public void set_intensity(double val) {
126 intensity_slider.set_value(val);