4 #include <hildon/hildon.h>
5 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
6 #include <gconf/gconf-client.h>
9 /* TODO: read these from disk */
11 static const struct voice {
17 { "en-us", "English (American)" },
18 { "en-sc", "English (Scottish)" },
19 { "af", "Afrikaans" },
25 { "eo", "Esperanto" },
27 { "es-la", "Spanish (Latin America)" },
31 { "hu", "Hungarian" },
36 { "pt", "Portuguese (Brazil)" },
37 { "pt-pt", "Portuguese (European)" },
45 { "zh", "Mandarin Chinese" },
47 static const int num_voices = sizeof(voices) / sizeof(voices[0]);
49 static const struct effect {
68 { "klatt2", "Klatt 2" },
69 { "klatt3", "Klatt 3" },
70 { "whisper", "Whisper" },
72 static const int num_effects = sizeof(effects) / sizeof(effects[0]);
75 static void add_scale(GtkVBox *vbox, GtkSizeGroup *size_group, const char *caption, GtkAdjustment *adjustment)
77 GtkWidget *scale = gtk_hscale_new(adjustment);
78 gtk_scale_set_digits(GTK_SCALE(scale), 0);
79 gtk_box_pack_start(GTK_BOX(vbox),
80 hildon_caption_new(size_group, caption, scale, NULL, HILDON_CAPTION_MANDATORY),
84 osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
86 struct espeaktime_settings cfg = {
92 .ignore_silent = TRUE,
95 GConfClient *client = gconf_client_get_default();
96 cfg_read(client, &cfg);
99 dialog = gtk_dialog_new_with_buttons(
100 "eSpeakTime Settings",
102 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
104 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
105 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
108 int k, voice_sel = 0, effect_sel = 0;
109 GtkVBox *vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0));
110 GtkSizeGroup *title_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
111 GtkSizeGroup *value_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
114 HildonTouchSelector *voice_selector = HILDON_TOUCH_SELECTOR(hildon_touch_selector_new_text());
115 for (k = 0; k < num_voices; k++) {
116 hildon_touch_selector_append_text(voice_selector, voices[k].name);
117 if (!strcmp(voices[k].id, cfg.voice))
121 HildonTouchSelector *effect_selector = HILDON_TOUCH_SELECTOR(hildon_touch_selector_new_text());
122 for (k = 0; k < num_effects; k++) {
123 hildon_touch_selector_append_text(effect_selector, effects[k].name);
124 if (!strcmp(effects[k].id, cfg.effect))
128 HildonPickerButton *voice = HILDON_PICKER_BUTTON(hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
129 hildon_button_set_title(HILDON_BUTTON(voice), "Voice");
130 hildon_picker_button_set_selector(voice, voice_selector);
131 hildon_picker_button_set_active(voice, voice_sel);
132 hildon_button_add_size_groups(HILDON_BUTTON(voice), title_group, value_group, NULL);
133 gtk_button_set_alignment(GTK_BUTTON(voice), 0.0, 0.5);
134 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(voice), FALSE, FALSE, 0);
136 HildonPickerButton *effect = HILDON_PICKER_BUTTON(hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
137 hildon_button_set_title(HILDON_BUTTON(effect), "Effect");
138 hildon_picker_button_set_selector(effect, effect_selector);
139 hildon_picker_button_set_active(effect, effect_sel);
140 hildon_button_add_size_groups(HILDON_BUTTON(effect), title_group, value_group, NULL);
141 gtk_button_set_alignment(GTK_BUTTON(effect), 0.0, 0.5);
142 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(effect), FALSE, FALSE, 0);
144 HildonEntry *text = HILDON_ENTRY(hildon_entry_new(HILDON_SIZE_AUTO));
145 gtk_entry_set_text(GTK_ENTRY(text), "%H:%M");
146 gtk_box_pack_start(GTK_BOX(vbox),
147 hildon_caption_new(title_group, "Speech string", GTK_WIDGET(text), NULL, HILDON_CAPTION_MANDATORY),
150 GtkAdjustment *amplitude_adj = GTK_ADJUSTMENT(gtk_adjustment_new(cfg.amplitude, 0, 200, 1, 10, 0));
151 add_scale(vbox, title_group, "Amplitude", amplitude_adj);
153 GtkAdjustment *pitch_adj = GTK_ADJUSTMENT(gtk_adjustment_new(cfg.pitch, 00, 99, 1, 10, 0));
154 add_scale(vbox, title_group, "Pitch", pitch_adj);
156 GtkAdjustment *speed_adj = GTK_ADJUSTMENT(gtk_adjustment_new(cfg.speed, 80, 390, 1, 10, 0));
157 add_scale(vbox, title_group, "Words per minute", speed_adj);
159 HildonCheckButton *ignore_silent = HILDON_CHECK_BUTTON(hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT));
160 hildon_check_button_set_active(ignore_silent, cfg.ignore_silent);
161 gtk_button_set_label(GTK_BUTTON(ignore_silent), "Ignore silent profile");
162 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(ignore_silent), FALSE, FALSE, 0);
164 GtkWidget *panarea = hildon_pannable_area_new();
165 gtk_widget_set_size_request(panarea, -1, 800);
166 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(panarea), GTK_WIDGET(vbox));
168 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), panarea);
169 gtk_widget_show_all(dialog);
171 int result = gtk_dialog_run(GTK_DIALOG(dialog));
176 cfg.voice = g_strdup(voices[hildon_picker_button_get_active(voice)].id);
177 cfg.effect = g_strdup(effects[hildon_picker_button_get_active(effect)].id);
178 cfg.text = g_strdup(gtk_entry_get_text(GTK_ENTRY(text)));
179 cfg.amplitude = gtk_adjustment_get_value(amplitude_adj);
180 cfg.pitch = gtk_adjustment_get_value(pitch_adj);
181 cfg.speed = gtk_adjustment_get_value(speed_adj);
182 cfg.ignore_silent = hildon_check_button_get_active(ignore_silent);
186 g_print("Test button\n");
187 cfg_speak(&cfg, TRUE);
189 case GTK_RESPONSE_OK:
191 cfg_write(client, &cfg);
196 gtk_widget_destroy(GTK_WIDGET(dialog));
199 g_object_unref(G_OBJECT(client));
204 osso_return_t save_state(osso_context_t *osso, gpointer data)
206 g_print("save_state called\n");
211 int main(int argc, char *argv[])
213 gtk_init(&argc, &argv);
214 return execute(NULL, NULL, 0);