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 FirstRunWizard : Hildon.WizardDialog {
22 public ApplicationSettings app_settings {public get; public set;}
23 Gtk.Notebook notebook;
24 Hildon.Button directory_btn;
25 Hildon.TouchSelector on_open_selector;
26 Hildon.TouchSelector on_close_selector;
27 Hildon.TouchSelector on_add_selector;
28 Hildon.TouchSelector on_bounce_selector;
29 Hildon.TouchSelector on_remove_selector;
30 Hildon.TouchSelector on_mixdown_selector;
31 private enum WizardPage {
41 public FirstRunWizard(Gtk.Window parent, string wizard_name) {
42 app_settings = new ApplicationSettings();
43 this.set_parent(parent);
44 this.wizard_name = wizard_name;
45 this.autotitle = true;
46 this.wizard_notebook = get_notebook(app_settings);
47 //Hildon.WizardDialogPageFunc func_delegate = forward_page_function;
48 this.set_forward_page_func(forward_page_function);
52 private void on_open_updated(string val) {
53 this.app_settings.open_action = ApplicationSettings.OpenAction.from_label(val);
55 private void on_close_updated(string val) {
56 this.app_settings.close_action = ApplicationSettings.CloseAction.from_label(val);
58 private void on_add_updated(string val) {
59 this.app_settings.add_track_action = ApplicationSettings.AddTrackAction.from_label(val);
61 private void on_bounce_updated(string val) {
62 this.app_settings.bounce_tracks_action = ApplicationSettings.BounceTracksAction.from_label(val);
64 private void on_remove_updated(string val) {
65 this.app_settings.remove_track_action = ApplicationSettings.RemoveTrackAction.from_label(val);
67 private void on_mixdown_updated(string val) {
68 this.app_settings.mixdown_action = ApplicationSettings.MixdownAction.from_label(val);
71 private Gtk.Notebook get_notebook(ApplicationSettings settings) {
72 notebook = new Gtk.Notebook();
74 // page 1 - WORKING_FOLDER
75 Gtk.VBox page_1 = new Gtk.VBox(false, 4);
76 Gtk.Label msg_1 = new Gtk.Label("Pick a working directory, this is where all your projects will be stored.\n\nFor better performance try using an SD card.");
77 msg_1.set_line_wrap(true);
78 msg_1.set_alignment(0, 0);
79 directory_btn = new Hildon.Button.with_text(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL, "Working folder", settings.working_directory);
80 directory_btn.set_style(Hildon.ButtonStyle.PICKER);
81 directory_btn.set_alignment(0, 0, 1, 1);
82 directory_btn.set_value(settings.working_directory);
83 directory_btn.clicked.connect(select_directory);
84 page_1.pack_start(directory_btn, false, false, 4);
87 notebook.append_page(page_1, null);
90 Gtk.VBox page_2 = new Gtk.VBox(false, 4);
91 Gtk.Label msg_2 = new Gtk.Label("What should happen at application start?\nIf you are unsure accept the defaults.");
92 msg_2.set_line_wrap(true);
93 msg_2.set_alignment(0, 0);
94 on_open_selector = new Hildon.TouchSelector.text();
95 on_open_selector.append_text(ApplicationSettings.OpenAction.to_label(ApplicationSettings.OpenAction.LAST_PROJECT));
96 on_open_selector.append_text(ApplicationSettings.OpenAction.to_label(ApplicationSettings.OpenAction.RECENT_PROJECTS));
97 on_open_selector.append_text(ApplicationSettings.OpenAction.to_label(ApplicationSettings.OpenAction.NEW_PROJECT));
98 on_open_selector.append_text(ApplicationSettings.OpenAction.to_label(ApplicationSettings.OpenAction.NAMED_PROJECT));
99 on_open_selector.set_active(0, (int)settings.open_action);
100 Hildon.PickerButton on_open_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL);
101 on_open_picker.set_title("Application start behaviour");
102 on_open_picker.set_selector(on_open_selector);
103 on_open_picker.set_alignment(0, 0, 1, 1);
104 on_open_picker.value_changed.connect( (s) => { on_open_updated(s.get_selector().get_current_text()); } );
105 page_2.pack_start(on_open_picker, false, false, 4);
108 notebook.append_page(page_2, null);
111 Gtk.VBox page_3 = new Gtk.VBox(false, 4);
112 Gtk.Label msg_3 = new Gtk.Label("What should happen at application end?\nIf you are unsure accept the defaults.");
113 msg_3.set_line_wrap(true);
114 msg_3.set_alignment(0, 0);
115 on_close_selector = new Hildon.TouchSelector.text();
116 on_close_selector.append_text(ApplicationSettings.CloseAction.to_label(ApplicationSettings.CloseAction.AUTO_SAVE_PROJECT));
117 on_close_selector.append_text(ApplicationSettings.CloseAction.to_label(ApplicationSettings.CloseAction.PROMPT_SAVE_PROJECT));
118 on_close_selector.append_text(ApplicationSettings.CloseAction.to_label(ApplicationSettings.CloseAction.DO_NOTHING));
119 on_close_selector.set_active(0, (int)settings.close_action);
120 Hildon.PickerButton on_close_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL);
121 on_close_picker.set_title("Application end behaviour");
122 on_close_picker.set_selector(on_close_selector);
123 on_close_picker.set_alignment(0, 0, 1, 1);
124 on_close_picker.value_changed.connect( (s) => { on_close_updated(s.get_selector().get_current_text()); } );
125 page_3.pack_start(on_close_picker, false, false, 4);
128 notebook.append_page(page_3, null);
131 Gtk.VBox page_4 = new Gtk.VBox(false, 4);
132 Gtk.Label msg_4 = new Gtk.Label("What should happen when you add a track?\nIf you are unsure accept the defaults.");
133 msg_4.set_line_wrap(true);
134 msg_4.set_alignment(0, 0);
135 on_add_selector = new Hildon.TouchSelector.text();
136 on_add_selector.append_text(ApplicationSettings.AddTrackAction.to_label(ApplicationSettings.AddTrackAction.SET_ACTIVE));
137 on_add_selector.append_text(ApplicationSettings.AddTrackAction.to_label(ApplicationSettings.AddTrackAction.SET_SOLO));
138 on_add_selector.append_text(ApplicationSettings.AddTrackAction.to_label(ApplicationSettings.AddTrackAction.SET_INACTIVE));
139 on_add_selector.append_text(ApplicationSettings.AddTrackAction.to_label(ApplicationSettings.AddTrackAction.SET_MUTE));
140 on_add_selector.set_active(0, (int)settings.add_track_action);
141 Hildon.PickerButton on_add_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL);
142 on_add_picker.set_title("Add track behaviour");
143 on_add_picker.set_selector(on_add_selector);
144 on_add_picker.set_alignment(0, 0, 1, 1);
145 on_add_picker.value_changed.connect( (s) => { on_add_updated(s.get_selector().get_current_text()); } );
146 page_4.pack_start(on_add_picker, false, false, 4);
149 notebook.append_page(page_4, null);
151 // page 5 - ON_BOUNCE
152 Gtk.VBox page_5 = new Gtk.VBox(false, 4);
153 Gtk.Label msg_5 = new Gtk.Label("What should happen when you bounce tracks?\nIf you are unsure accept the defaults.");
154 msg_5.set_line_wrap(true);
155 msg_5.set_alignment(0, 0);
156 on_bounce_selector = new Hildon.TouchSelector.text();
157 on_bounce_selector.append_text(ApplicationSettings.BounceTracksAction.to_label(ApplicationSettings.BounceTracksAction.SET_SOURCE_INACTIVE));
158 on_bounce_selector.append_text(ApplicationSettings.BounceTracksAction.to_label(ApplicationSettings.BounceTracksAction.SET_SOURCE_MUTE));
159 on_bounce_selector.append_text(ApplicationSettings.BounceTracksAction.to_label(ApplicationSettings.BounceTracksAction.SET_TARGET_SOLO));
160 on_bounce_selector.append_text(ApplicationSettings.BounceTracksAction.to_label(ApplicationSettings.BounceTracksAction.SET_TARGET_INACTIVE));
161 on_bounce_selector.append_text(ApplicationSettings.BounceTracksAction.to_label(ApplicationSettings.BounceTracksAction.SET_TARGET_MUTE));
162 on_bounce_selector.set_active(0, (int)settings.bounce_tracks_action);
163 Hildon.PickerButton on_bounce_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL);
164 on_bounce_picker.set_title("Bounce tracks behaviour");
165 on_bounce_picker.set_selector(on_bounce_selector);
166 on_bounce_picker.set_alignment(0, 0, 1, 1);
167 on_bounce_picker.value_changed.connect( (s) => { on_bounce_updated(s.get_selector().get_current_text()); } );
168 page_5.pack_start(on_bounce_picker, false, false, 4);
171 notebook.append_page(page_5, null);
173 // page 6 - ON_REMOVE
174 Gtk.VBox page_6 = new Gtk.VBox(false, 4);
175 Gtk.Label msg_6 = new Gtk.Label("What should happen when you remove a track?\nIf you are unsure accept the defaults.");
176 msg_6.set_line_wrap(true);
177 msg_6.set_alignment(0, 0);
178 on_remove_selector = new Hildon.TouchSelector.text();
179 on_remove_selector.append_text(ApplicationSettings.RemoveTrackAction.to_label(ApplicationSettings.RemoveTrackAction.PROMPT));
180 on_remove_selector.append_text(ApplicationSettings.RemoveTrackAction.to_label(ApplicationSettings.RemoveTrackAction.DELETE_FILE));
181 on_remove_selector.append_text(ApplicationSettings.RemoveTrackAction.to_label(ApplicationSettings.RemoveTrackAction.PRESERVE_FILE));
182 on_remove_selector.set_active(0, (int)settings.remove_track_action);
183 Hildon.PickerButton on_remove_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL);
184 on_remove_picker.set_title("Remove tracks behaviour");
185 on_remove_picker.set_selector(on_remove_selector);
186 on_remove_picker.set_alignment(0, 0, 1, 1);
187 on_remove_picker.value_changed.connect( (s) => { on_remove_updated(s.get_selector().get_current_text()); } );
188 page_6.pack_start(on_remove_picker, false, false, 4);
191 notebook.append_page(page_6, null);
193 // page 7 - ON_MIXDOWN
194 Gtk.VBox page_7 = new Gtk.VBox(false, 4);
195 Gtk.Label msg_7 = new Gtk.Label("What should happen when you mixdown your tracks?\nIf you are unsure accept the defaults.");
196 msg_7.set_line_wrap(true);
197 msg_7.set_alignment(0, 0);
198 on_mixdown_selector = new Hildon.TouchSelector.text();
199 on_mixdown_selector.append_text(ApplicationSettings.MixdownAction.to_label(ApplicationSettings.MixdownAction.NONE));
200 on_mixdown_selector.append_text(ApplicationSettings.MixdownAction.to_label(ApplicationSettings.MixdownAction.PLAY_TARGET));
201 on_mixdown_selector.set_active(0, (int)settings.mixdown_action);
202 Hildon.PickerButton on_mixdown_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.HALFSCREEN_WIDTH, Hildon.ButtonArrangement.VERTICAL);
203 on_mixdown_picker.set_title("Mixdown behaviour");
204 on_mixdown_picker.set_selector(on_mixdown_selector);
205 on_mixdown_picker.set_alignment(0, 0, 1, 1);
206 on_mixdown_picker.value_changed.connect( (s) => { on_mixdown_updated(s.get_selector().get_current_text()); } );
207 page_7.pack_start(on_mixdown_picker, false, false, 4);
210 notebook.append_page(page_7, null);
212 // page 8 - Thank You
213 Gtk.VBox page_8 = new Gtk.VBox(false, 4);
214 Gtk.Label msg_8 = new Gtk.Label("That's all for now. \n\nYou can change these settings at any time from the settings menu option.\n\nEnjoy!");
215 msg_8.set_line_wrap(true);
216 msg_8.set_alignment(0, 0);
219 notebook.append_page(page_8, null);
225 public bool forward_page_function(Gtk.Notebook notebook, int current_page) {
227 // current page is page about to be left!
228 switch (current_page) {
229 case WizardPage.WORKING_FOLDER:
232 case WizardPage.ON_OPEN:
233 this.directory_btn.value = this.app_settings.working_directory;
236 case WizardPage.ON_CLOSE:
239 case WizardPage.ON_ADD:
242 case WizardPage.ON_BOUNCE:
245 case WizardPage.ON_REMOVE:
248 case WizardPage.ON_MIXDOWN:
252 this.directory_btn.value = this.app_settings.working_directory;
259 private void select_directory() {
261 Hildon.FileChooserDialog file_chooser = new Hildon.FileChooserDialog(this, Gtk.FileChooserAction.SELECT_FOLDER);
262 file_chooser.set_show_upnp(false);
263 Gtk.ResponseType ret = (Gtk.ResponseType) file_chooser.run();
264 if (Gtk.ResponseType.OK == ret) {
265 this.directory_btn.value = file_chooser.get_filename();
266 this.app_settings.working_directory = file_chooser.get_filename();
268 file_chooser.destroy ();
271 /*public void destroy_notify(ApplicationSettings* data) {