8 "github.com/gotk3/gotk3/gtk"
11 type Applicant struct {
19 type Education struct {
22 PassPercentage float32
36 /* func SaveToJson(a *Applicant) {
37 b, err := json.Marshal(a)
40 fmt.Println(err.Error())
43 err = ioutil.WriteFile("test.json", b, 0644)
45 fmt.Println(err.Error())
50 func getBasicDetails() (*Applicant, error) {
51 // Retrieve all the fields.
52 obj, err := ui.GetObject("FirstName")
56 fsname, ok := obj.(*gtk.Entry)
60 firstname, err := fsname.GetText()
64 obj, err = ui.GetObject("LastName")
68 lsname, ok := obj.(*gtk.Entry)
72 lastname, err := lsname.GetText()
77 obj, err = ui.GetObject("Age")
81 agectl, ok := obj.(*gtk.Entry)
85 agetxt, err := agectl.GetText()
89 age, err := strconv.Atoi(agetxt)
93 obj, err = ui.GetObject("Male")
98 // Store the contents in Applicant object
99 var applicant = new(Applicant)
101 applicant.FirstName = firstname
102 applicant.LastName = lastname
104 applicant.Sex = selectedsex
106 return applicant, nil
109 func getWindow() (*gtk.Window, error) {
110 obj, err := ui.GetObject("MainWindow")
112 fmt.Println(err.Error())
115 wnd, ok := obj.(*gtk.Window)
122 func getSaveButton() (*gtk.Button, error) {
123 btnobj, err := ui.GetObject("SaveButton")
125 fmt.Println(err.Error())
128 btn, ok := btnobj.(*gtk.Button)
138 ui, err = gtk.BuilderNew()
140 fmt.Println(err.Error())
143 asset, err := Asset("resources/resumebuilder.glade")
145 fmt.Println(err.Error())
148 ui.AddFromString(string(asset))
149 ui.ConnectSignals(map[string]interface{}{"SexMaleSelected": sexMaleSelected,
150 "SexFemaleSelected": sexFemaleSelected, "SexOtherSelected": sexOtherSelected,
151 "SaveButtonClicked": SaveButtonClicked})
153 wnd, err := getWindow()
158 wnd.SetTitle("Resume Builder")
162 wnd.Connect("destroy", func() {
168 func sexMaleSelected(male *gtk.RadioButton) {
169 if male.GetActive() {
174 func sexFemaleSelected(female *gtk.RadioButton) {
175 if female.GetActive() {
180 func sexOtherSelected(other *gtk.RadioButton) {
181 if other.GetActive() {
186 func SaveButtonClicked() {
187 a, err := getBasicDetails()
189 fmt.Println(err.Error())