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 MixdownPopUp : Hildon.Dialog {
22 Hildon.TouchSelector encoder_selector;
23 Hildon.TouchSelector quality_selector;
24 Hildon.Entry title_entry;
25 Hildon.Entry artist_entry;
26 Hildon.Entry album_entry;
27 //Hildon.Entry description_entry;
28 Hildon.Button location_btn;
30 public SettingsStructures.MixdownSettings get_settings_structure() {
31 SettingsStructures.MixdownSettings settings = SettingsStructures.MixdownSettings();
32 settings.location = location_btn.get_value();
33 settings.encoder = encoder_selector.get_current_text();
34 settings.quality = quality_selector.get_current_text();
35 settings.title = title_entry.get_text();
36 settings.album = album_entry.get_text();
37 settings.artist = artist_entry.get_text();
40 public void set_settings_structure(SettingsStructures.MixdownSettings settings) {
41 location_btn.set_value(settings.location);
42 this.set_encoder(settings.encoder);
43 this.set_quality(settings.quality);
44 title_entry.set_text(settings.title);
45 album_entry.set_text(settings.album);
46 artist_entry.set_text(settings.artist);
49 private void set_encoder(string encoder) {
71 encoder_selector.set_active(0, idx);
74 private void set_quality(string quality) {
90 quality_selector.set_active(0, idx);
93 public MixdownPopUp(string title, Gtk.Widget parent) {
94 this.set_title(title);
95 this.set_parent(parent);
96 construct_interface(SettingsStructures.MixdownSettings());
98 public MixdownPopUp.with_settings(string title, Gtk.Widget parent, SettingsStructures.MixdownSettings settings) {
99 this.set_title(title);
100 this.set_parent(parent);
101 construct_interface(settings);
104 private void construct_interface(SettingsStructures.MixdownSettings settings) {
105 this.set_default_response(Gtk.ResponseType.CANCEL);
106 this.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK);
107 this.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL);
109 Gtk.VBox control_area = (Gtk.VBox)this.get_content_area();
112 location_btn = new Hildon.Button.with_text(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL, "Location", settings.location);
113 location_btn.set_style(Hildon.ButtonStyle.PICKER);
114 location_btn.set_alignment(0, 0, 1, 1);
115 location_btn.clicked.connect(select_location);
116 control_area.pack_start(location_btn, true, true, 2);
118 Gtk.HButtonBox button_bar = new Gtk.HButtonBox();
119 button_bar.set_layout(Gtk.ButtonBoxStyle.START);
120 button_bar.set_homogeneous(false);
121 button_bar.set_spacing(4);
124 encoder_selector = new Hildon.TouchSelector.text();
125 encoder_selector.append_text("vorbisenc");
126 encoder_selector.append_text("wavenc");
127 encoder_selector.append_text("nokiaaacenc");
128 encoder_selector.append_text("mpegaudio");
129 encoder_selector.append_text("lame");
130 this.set_encoder(settings.encoder);
131 Hildon.PickerButton encoder_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.AUTO_WIDTH, Hildon.ButtonArrangement.VERTICAL);
132 encoder_picker.set_title("Encoder");
133 encoder_picker.set_selector(encoder_selector);
134 //encoder_picker.value_changed.connect( (s) => { this.settings.encoder = s.get_selector().get_current_text(); } );
135 button_bar.pack_start(encoder_picker, true, true, 2);
138 quality_selector = new Hildon.TouchSelector.text();
139 quality_selector.append_text("high");
140 quality_selector.append_text("medium");
141 quality_selector.append_text("low");
142 this.set_quality(settings.quality);
143 Hildon.PickerButton quality_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.AUTO_WIDTH, Hildon.ButtonArrangement.VERTICAL);
144 quality_picker.set_title("Quality");
145 quality_picker.set_selector(quality_selector);
146 //quality_picker.value_changed.connect( (s) => { this.settings.quality = s.get_selector().get_current_text(); } );
147 button_bar.pack_start(quality_picker, true, true, 2);
149 control_area.pack_start(button_bar, true, true, 2);
152 Gtk.HBox artist_bar = new Gtk.HBox(false, 4);
154 Gtk.Label artist_label = new Gtk.Label("Artist");
155 artist_bar.pack_start(artist_label, false, false, 2);
156 artist_entry = new Hildon.Entry(Hildon.SizeType.HALFSCREEN_WIDTH);
157 artist_entry.set_text(settings.artist);
158 artist_entry.set_placeholder("Unknown Artist");
159 artist_bar.pack_start(artist_entry, true, true, 2);
161 control_area.pack_start(artist_bar, true, true, 2);
164 Gtk.HBox title_bar = new Gtk.HBox(false, 4);
166 Gtk.Label title_label = new Gtk.Label("Title");
167 title_bar.pack_start(title_label, false, false, 2);
168 title_entry = new Hildon.Entry(Hildon.SizeType.HALFSCREEN_WIDTH);
169 title_entry.set_text(settings.title);
170 title_entry.set_placeholder("Untitled");
171 title_bar.pack_start(title_entry, true, true, 2);
173 control_area.pack_start(title_bar, true, true, 2);
176 Gtk.HBox album_bar = new Gtk.HBox(false, 4);
178 Gtk.Label album_label = new Gtk.Label("Album");
179 album_bar.pack_start(album_label, false, false, 2);
180 album_entry = new Hildon.Entry(Hildon.SizeType.HALFSCREEN_WIDTH);
181 album_entry.set_text(settings.album);
182 album_entry.set_placeholder("Untitled");
183 album_bar.pack_start(album_entry, true, true, 2);
185 control_area.pack_start(album_bar, true, true, 2);
189 /*Gtk.HBox description_bar = new Gtk.HBox(false, 4);
191 Gtk.Label description_label = new Gtk.Label("Description");
192 description_bar.pack_start(description_label, false, false, 2);
193 description_entry = new Hildon.Entry();
194 description_entry.truncate_multiline = false;
195 description_entry.text = "";
196 description_bar.pack_start(description_entry, true, true, 2);
198 control_area.pack_start(description_bar, true, true, 2);
204 private void select_location() {
206 Hildon.FileChooserDialog file_chooser = new Hildon.FileChooserDialog(this, Gtk.FileChooserAction.SAVE);
207 file_chooser.set_show_upnp(false);
208 Gtk.ResponseType ret = (Gtk.ResponseType) file_chooser.run();
209 if (Gtk.ResponseType.OK == ret) {
210 this.location_btn.value = file_chooser.get_filename();
212 file_chooser.destroy ();