2 #include <hildon/hildon.h>
3 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
5 /* TODO: read these from disk */
7 static const struct voice {
13 { "en-us", "English (American)" },
14 { "en-sc", "English (Scottish)" },
15 { "af", "Afrikaans" },
21 { "eo", "Esperanto" },
23 { "es-la", "Spanish (Latin America)" },
27 { "hu", "Hungarian" },
32 { "pt", "Portuguese (Brazil)" },
33 { "pt-pt", "Portuguese (European)" },
41 { "zh", "Mandarin Chinese" },
43 static const int num_voices = sizeof(voices) / sizeof(voices[0]);
45 static const struct effect {
64 { "klatt2", "Klatt 2" },
65 { "klatt3", "Klatt 3" },
66 { "whisper", "Whisper" },
68 static const int num_effects = sizeof(effects) / sizeof(effects[0]);
70 static void add_scale(GtkVBox *vbox, GtkSizeGroup *size_group, const char *caption, GtkAdjustment *adjustment)
72 GtkWidget *scale = gtk_hscale_new(adjustment);
73 gtk_scale_set_digits(GTK_SCALE(scale), 0);
74 gtk_box_pack_start(GTK_BOX(vbox),
75 hildon_caption_new(size_group, caption, scale, NULL, HILDON_CAPTION_MANDATORY),
79 static GtkWidget *build_ui(void)
82 GtkVBox *vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0));
83 GtkSizeGroup *title_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
84 GtkSizeGroup *value_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
87 HildonTouchSelector *voice_selector = HILDON_TOUCH_SELECTOR(hildon_touch_selector_new_text());
88 for (k = 0; k < num_voices; k++)
89 hildon_touch_selector_append_text(voice_selector, voices[k].name);
91 HildonTouchSelector *effect_selector = HILDON_TOUCH_SELECTOR(hildon_touch_selector_new_text());
92 for (k = 0; k < num_effects; k++)
93 hildon_touch_selector_append_text(effect_selector, effects[k].name);
95 HildonPickerButton *voice = HILDON_PICKER_BUTTON(hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
96 hildon_button_set_title(HILDON_BUTTON(voice), "Voice");
97 hildon_picker_button_set_selector(voice, voice_selector);
98 hildon_picker_button_set_active(voice, 0);
99 hildon_button_add_size_groups(HILDON_BUTTON(voice), title_group, value_group, NULL);
100 gtk_button_set_alignment(GTK_BUTTON(voice), 0.0, 0.5);
101 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(voice), FALSE, FALSE, 0);
103 HildonPickerButton *effect = HILDON_PICKER_BUTTON(hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
104 hildon_button_set_title(HILDON_BUTTON(effect), "Effect");
105 hildon_picker_button_set_selector(effect, effect_selector);
106 hildon_picker_button_set_active(effect, 0);
107 hildon_button_add_size_groups(HILDON_BUTTON(effect), title_group, value_group, NULL);
108 gtk_button_set_alignment(GTK_BUTTON(effect), 0.0, 0.5);
109 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(effect), FALSE, FALSE, 0);
111 HildonEntry *text = HILDON_ENTRY(hildon_entry_new(HILDON_SIZE_AUTO));
112 gtk_box_pack_start(GTK_BOX(vbox),
113 hildon_caption_new(title_group, "Speech string", GTK_WIDGET(text), NULL, HILDON_CAPTION_MANDATORY),
116 GtkAdjustment *amplitude_adj = GTK_ADJUSTMENT(gtk_adjustment_new(100, 0, 200, 1, 10, 0));
117 add_scale(vbox, title_group, "Amplitude", amplitude_adj);
119 GtkAdjustment *pitch_adj = GTK_ADJUSTMENT(gtk_adjustment_new(50, 00, 99, 1, 10, 0));
120 add_scale(vbox, title_group, "Pitch", pitch_adj);
122 GtkAdjustment *speed_adj = GTK_ADJUSTMENT(gtk_adjustment_new(170, 80, 390, 1, 10, 0));
123 add_scale(vbox, title_group, "Words per minute", speed_adj);
125 GtkWidget *ignore_silent = hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT);
126 gtk_button_set_label(GTK_BUTTON(ignore_silent), "Ignore silent profile");
127 gtk_box_pack_start(GTK_BOX(vbox), ignore_silent, FALSE, FALSE, 0);
129 GtkWidget *panarea = hildon_pannable_area_new();
130 gtk_widget_set_size_request(panarea, -1, 800);
131 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(panarea), GTK_WIDGET(vbox));
135 osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
139 dialog = gtk_dialog_new_with_buttons(
140 "eSpeakTime Settings",
142 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
144 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
145 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
148 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), build_ui());
149 gtk_widget_show_all(dialog);
151 int result = gtk_dialog_run(GTK_DIALOG(dialog));
154 g_print("Test button\n");
156 case GTK_RESPONSE_OK:
162 gtk_widget_destroy(GTK_WIDGET(dialog));
167 osso_return_t save_state(osso_context_t *osso, gpointer data)
169 g_print("save_state called\n");
174 int main(int argc, char *argv[])
176 gtk_init(&argc, &argv);
177 return execute(NULL, NULL, 0);