3 #include <hildon/hildon.h>
4 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
5 #include <gconf/gconf-client.h>
8 /* TODO: read these from disk */
10 static const struct voice {
16 { "en-us", "English (American)" },
17 { "en-sc", "English (Scottish)" },
18 { "af", "Afrikaans" },
24 { "eo", "Esperanto" },
26 { "es-la", "Spanish (Latin America)" },
30 { "hu", "Hungarian" },
35 { "pt", "Portuguese (Brazil)" },
36 { "pt-pt", "Portuguese (European)" },
44 { "zh", "Mandarin Chinese" },
46 static const int num_voices = sizeof(voices) / sizeof(voices[0]);
48 static const struct effect {
67 { "klatt2", "Klatt 2" },
68 { "klatt3", "Klatt 3" },
69 { "whisper", "Whisper" },
71 static const int num_effects = sizeof(effects) / sizeof(effects[0]);
74 static void add_scale(GtkVBox *vbox, GtkSizeGroup *size_group, const char *caption, GtkAdjustment *adjustment)
76 GtkWidget *scale = gtk_hscale_new(adjustment);
77 gtk_scale_set_digits(GTK_SCALE(scale), 0);
78 gtk_box_pack_start(GTK_BOX(vbox),
79 hildon_caption_new(size_group, caption, scale, NULL, HILDON_CAPTION_MANDATORY),
83 osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
85 struct espeaktime_settings cfg = {
91 .ignore_silent = TRUE,
94 GConfClient *client = gconf_client_get_default();
95 cfg_read(client, &cfg);
98 dialog = gtk_dialog_new_with_buttons(
99 "eSpeakTime Settings",
101 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
103 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
104 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
107 int k, voice_sel = 0, effect_sel = 0;
108 GtkVBox *vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0));
109 GtkSizeGroup *title_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
110 GtkSizeGroup *value_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
113 HildonTouchSelector *voice_selector = HILDON_TOUCH_SELECTOR(hildon_touch_selector_new_text());
114 for (k = 0; k < num_voices; k++) {
115 hildon_touch_selector_append_text(voice_selector, voices[k].name);
116 if (!strcmp(voices[k].id, cfg.voice))
120 HildonTouchSelector *effect_selector = HILDON_TOUCH_SELECTOR(hildon_touch_selector_new_text());
121 for (k = 0; k < num_effects; k++) {
122 hildon_touch_selector_append_text(effect_selector, effects[k].name);
123 if (!strcmp(effects[k].id, cfg.effect))
127 HildonPickerButton *voice = HILDON_PICKER_BUTTON(hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
128 hildon_button_set_title(HILDON_BUTTON(voice), "Voice");
129 hildon_picker_button_set_selector(voice, voice_selector);
130 hildon_picker_button_set_active(voice, voice_sel);
131 hildon_button_add_size_groups(HILDON_BUTTON(voice), title_group, value_group, NULL);
132 gtk_button_set_alignment(GTK_BUTTON(voice), 0.0, 0.5);
133 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(voice), FALSE, FALSE, 0);
135 HildonPickerButton *effect = HILDON_PICKER_BUTTON(hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
136 hildon_button_set_title(HILDON_BUTTON(effect), "Effect");
137 hildon_picker_button_set_selector(effect, effect_selector);
138 hildon_picker_button_set_active(effect, effect_sel);
139 hildon_button_add_size_groups(HILDON_BUTTON(effect), title_group, value_group, NULL);
140 gtk_button_set_alignment(GTK_BUTTON(effect), 0.0, 0.5);
141 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(effect), FALSE, FALSE, 0);
143 HildonEntry *text = HILDON_ENTRY(hildon_entry_new(HILDON_SIZE_AUTO));
144 gtk_entry_set_text(GTK_ENTRY(text), "%H:%M");
145 gtk_box_pack_start(GTK_BOX(vbox),
146 hildon_caption_new(title_group, "Speech string", GTK_WIDGET(text), NULL, HILDON_CAPTION_MANDATORY),
149 GtkAdjustment *amplitude_adj = GTK_ADJUSTMENT(gtk_adjustment_new(cfg.amplitude, 0, 200, 1, 10, 0));
150 add_scale(vbox, title_group, "Amplitude", amplitude_adj);
152 GtkAdjustment *pitch_adj = GTK_ADJUSTMENT(gtk_adjustment_new(cfg.pitch, 00, 99, 1, 10, 0));
153 add_scale(vbox, title_group, "Pitch", pitch_adj);
155 GtkAdjustment *speed_adj = GTK_ADJUSTMENT(gtk_adjustment_new(cfg.speed, 80, 390, 1, 10, 0));
156 add_scale(vbox, title_group, "Words per minute", speed_adj);
158 HildonCheckButton *ignore_silent = HILDON_CHECK_BUTTON(hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT));
159 hildon_check_button_set_active(ignore_silent, cfg.ignore_silent);
160 gtk_button_set_label(GTK_BUTTON(ignore_silent), "Ignore silent profile");
161 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(ignore_silent), FALSE, FALSE, 0);
163 GtkWidget *panarea = hildon_pannable_area_new();
164 gtk_widget_set_size_request(panarea, -1, 800);
165 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(panarea), GTK_WIDGET(vbox));
167 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), panarea);
168 gtk_widget_show_all(dialog);
170 int result = gtk_dialog_run(GTK_DIALOG(dialog));
175 cfg.voice = g_strdup(voices[hildon_picker_button_get_active(voice)].id);
176 cfg.effect = g_strdup(effects[hildon_picker_button_get_active(effect)].id);
177 cfg.text = g_strdup(gtk_entry_get_text(GTK_ENTRY(text)));
178 cfg.amplitude = gtk_adjustment_get_value(amplitude_adj);
179 cfg.pitch = gtk_adjustment_get_value(pitch_adj);
180 cfg.speed = gtk_adjustment_get_value(speed_adj);
181 cfg.ignore_silent = hildon_check_button_get_active(ignore_silent);
185 g_print("Test button\n");
186 cfg_speak(&cfg, TRUE);
188 case GTK_RESPONSE_OK:
190 cfg_write(client, &cfg);
195 gtk_widget_destroy(GTK_WIDGET(dialog));
198 g_object_unref(G_OBJECT(client));
203 osso_return_t save_state(osso_context_t *osso, gpointer data)
205 g_print("save_state called\n");
210 int main(int argc, char *argv[])
212 gtk_init(&argc, &argv);
213 return execute(NULL, NULL, 0);