using Gtk; using Glade; using System; namespace AmicEditor { public class PreferencesDialog : Dialog { [Widget] Gtk.Dialog PrefsDlg; [Widget] HBox BoxRBMale; [Widget] HBox BoxRBFem; RadioButton RBMale; RadioButton RBFem; [Widget] Gtk.Button BtCancel; [Widget] Gtk.Button BtOk; [Widget] Gtk.SpinButton SpinSpeed; string voice="female"; public PreferencesDialog () { Application.Init (); voice=Preferences.lang_voice; Glade.XML gxml = new Glade.XML(null, "Prefs.glade", "PrefsDlg", null); gxml.Autoconnect (this); // Inicialitzem la velocitat SpinSpeed.Value=double.Parse(Preferences.speed_speech); // Inicialització dels radiobuttons RBMale = new RadioButton(null, Mono.Unix.Catalog.GetString("Male Voice")); BoxRBMale.PackStart(RBMale, true, true, 0); if(Preferences.lang_voice=="male") RBMale.Active = true; RBMale.Show(); RBFem = new RadioButton(RBMale, Mono.Unix.Catalog.GetString("Female Voice")); //if(Preferences.lang_voice=="female") RBFem.Activate=true; if(Preferences.lang_voice=="female") RBFem.Active = true; BoxRBFem.PackStart(RBFem, true, true, 0); RBFem.Show(); // Gestors d'events BtCancel.Clicked += HandleBtCancelClicked; BtOk.Clicked += HandleBtOkClicked; RBFem.Toggled += HandleRBFemToggled; RBMale.Toggled += HandleRBMaleToggled; //PrefsDlg.ShowAll(); //Gtk.Application.Run(); } public new void Show(){ PrefsDlg.ShowAll(); PrefsDlg.Modal=true; PrefsDlg.SetPosition(WindowPosition.CenterAlways); Application.Run(); } void HandleRBMaleToggled (object sender, EventArgs e) { voice="male"; } void HandleRBFemToggled (object sender, EventArgs e) { voice="female"; } void HandleBtOkClicked (object sender, EventArgs e) { Preferences.lang_voice=voice; Preferences.speed_speech=SpinSpeed.Text.Replace(",", "."); Application.Quit(); PrefsDlg.Destroy(); } void HandleBtCancelClicked (object sender, EventArgs e) { Application.Quit(); PrefsDlg.Destroy(); } } }