provide a way to get back to the default voice profile.
This commit is contained in:
1 parent
322f151344
commit
cad3360bd8
8 files changed
+107
-14
No files matched your search
@@ -20,6 +20,8 @@ void prefs_profiles_init(void) {
|
||||
profilePage = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(profilePage), 12);
|
||||
profileCombo = gtk_combo_box_text_new();
|
||||
// Focus the internal combo button so Tab and Shift+Tab leave it normally.
|
||||
gtk_widget_set_can_focus(profileCombo, FALSE);
|
||||
atk_object_set_name(gtk_widget_get_accessible(profileCombo), "Voice Profiles");
|
||||
gtk_box_pack_start(GTK_BOX(profilePage), profileCombo, FALSE, FALSE, 0);
|
||||
GtkWidget **buttons[] = {&profileAdd, &profileEdit, &profileRemove, &profileUse};
|
||||
@@ -86,6 +88,7 @@ void prefs_profile_control(const char *id, const char *label, int kind, int row,
|
||||
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(widget), TRUE);
|
||||
} else {
|
||||
widget = gtk_combo_box_text_new();
|
||||
gtk_widget_set_can_focus(widget, FALSE);
|
||||
g_object_set_data_full(G_OBJECT(widget), "profile-label", g_strdup(label), g_free);
|
||||
g_signal_connect(widget, "changed", G_CALLBACK(profile_combo_changed), NULL);
|
||||
}
|
||||
|
||||
@@ -112,6 +112,26 @@ func set_profile_control(c ui.Control) {
|
||||
C.prefs_profile_set(id, C.int(c.Kind), text, C.double(c.Number), C.int(c.Selected), boolean(c.Hidden))
|
||||
}
|
||||
|
||||
// set_profile_state updates a combo's selection and visibility in place.
|
||||
func set_profile_state(c ui.Control) {
|
||||
id, text := C.CString(c.ID), C.CString(c.Text)
|
||||
defer C.free(unsafe.Pointer(id))
|
||||
defer C.free(unsafe.Pointer(text))
|
||||
C.prefs_profile_set(id, C.int(c.Kind), text, C.double(c.Number), C.int(c.Selected), boolean(c.Hidden))
|
||||
}
|
||||
|
||||
func same_choices(a, b []ui.Choice) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
for index := range a {
|
||||
if a[index].ID != b[index].ID || a[index].Label != b[index].Label {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (session *uiSession) profile_tick() bool {
|
||||
if session.profileEditor == nil {
|
||||
return false
|
||||
@@ -135,7 +155,13 @@ func (session *uiSession) profile_tick() bool {
|
||||
if c.Kind == ui.Entry {
|
||||
c.Text = values[voiceprofiles.PageID+"."+c.ID].Text
|
||||
}
|
||||
set_profile_control(c)
|
||||
// Rebuilding the combo the user is changing moves GTK focus out of
|
||||
// it. Like the main speech page, refill only lists that changed.
|
||||
if old := values[voiceprofiles.PageID+"."+c.ID]; c.Kind != ui.ComboBox || !same_choices(old.Choices, c.Choices) {
|
||||
set_profile_control(c)
|
||||
} else if old.Selected != c.Selected || old.Hidden != c.Hidden {
|
||||
set_profile_state(c)
|
||||
}
|
||||
values[voiceprofiles.PageID+"."+c.ID] = c
|
||||
for index, old := range session.profileControls {
|
||||
if old.ID == c.ID {
|
||||
|
||||
Reference in new issue
Block a user