/* Demo Recorder for MAEMO 5 * Copyright (C) 2010 Dru Moore * 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 EchoPopUp : Hildon.Dialog { Gtk.HScale delay_slider; Gtk.HScale feedback_slider; Gtk.HScale intensity_slider; const uint64 MAX_DELAY = 1 * Time.Milliseconds.SECOND; public signal void delay_updated(uint64 val); public signal void feedback_updated(double val); public signal void intensity_updated(double val); public EchoPopUp (string title, Gtk.Widget parent) { this.set_title(title); this.set_parent(parent); construct_interface(SettingsStructures.EchoSettings()); } public EchoPopUp.with_settings (string title, Gtk.Widget parent, SettingsStructures.EchoSettings settings) { this.set_title(title); this.set_parent(parent); construct_interface(settings); } public SettingsStructures.EchoSettings get_settings_structure() { SettingsStructures.EchoSettings settings = SettingsStructures.EchoSettings(); settings.active = true; settings.max_delay = MAX_DELAY; settings.delay = this.get_delay(); settings.feedback = this.get_feedback(); settings.intensity = this.get_intensity(); return settings; } public void set_settings_structure(SettingsStructures.EchoSettings settings) { // ignore active for now // ignore max_delay for now this.set_delay(settings.delay); this.set_feedback(settings.feedback); this.set_intensity(settings.intensity); } private void construct_interface(SettingsStructures.EchoSettings settings) { this.set_default_response(Gtk.ResponseType.ACCEPT); this.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT); Gtk.VBox control_area = (Gtk.VBox)this.get_content_area(); Gtk.HBox delay_bar = new Gtk.HBox(false, 4); Gtk.Label delay_label = new Gtk.Label("Delay (ms): "); delay_slider = new Gtk.HScale.with_range(0, MAX_DELAY, Time.Milliseconds.MILLISECOND); delay_slider.set_value_pos(Gtk.PositionType.LEFT); delay_slider.set_value(settings.delay); delay_slider.value_changed.connect((s) => {delay_updated((uint64)(s.get_value()) * Time.Nanoseconds.MILLISECOND);}); delay_bar.pack_start(delay_label, false, false, 2); delay_bar.pack_start(delay_slider, true, true, 2); control_area.pack_start(delay_bar, true, true, 2); Gtk.HBox feedback_bar = new Gtk.HBox(false, 4); Gtk.Label feedback_label = new Gtk.Label("Feedback (ratio): "); feedback_slider = new Gtk.HScale.with_range(0.0, 1.0, 0.05); feedback_slider.set_value_pos(Gtk.PositionType.LEFT); feedback_slider.set_value(settings.feedback); feedback_slider.value_changed.connect((s) => {feedback_updated(s.get_value());}); feedback_bar.pack_start(feedback_label, false, false, 2); feedback_bar.pack_start(feedback_slider, true, true, 2); control_area.pack_start(feedback_bar, true, true, 2); Gtk.HBox intensity_bar = new Gtk.HBox(false, 4); Gtk.Label intensity_label = new Gtk.Label("Intensity (ratio): "); intensity_slider = new Gtk.HScale.with_range(0.0, 1.0, 0.05); intensity_slider.set_value_pos(Gtk.PositionType.LEFT); intensity_slider.set_value(settings.intensity); intensity_slider.value_changed.connect((s) => {intensity_updated(s.get_value());}); intensity_bar.pack_start(intensity_label, false, false, 2); intensity_bar.pack_start(intensity_slider, true, true, 2); control_area.pack_start(intensity_bar, true, true, 2); this.show_all(); } public uint64 get_delay() { return (uint64) (delay_slider.get_value() * Time.Nanoseconds.MILLISECOND); } public void set_delay(uint64 val) { delay_slider.set_value((double) (val / Time.Nanoseconds.MILLISECOND)); } public double get_feedback() { return feedback_slider.get_value(); } public void set_feedback(double val) { feedback_slider.set_value(val); } public double get_intensity() { return intensity_slider.get_value(); } public void set_intensity(double val) { intensity_slider.set_value(val); } } }