7 "github.com/gotk3/gotk3/gtk"
10 type Applicant struct {
27 type Education struct {
31 GradeOrPercentage string
46 /* func SaveToJson(a *Applicant) {
47 b, err := json.Marshal(a)
50 fmt.Println(err.Error())
53 err = ioutil.WriteFile("test.json", b, 0644)
55 fmt.Println(err.Error())
60 func getLineText(fieldname string) (string, error) {
61 obj, err := ui.GetObject(fieldname)
65 field, ok := obj.(*gtk.Entry)
69 fieldstr, err := field.GetText()
76 func getMultilineText(fieldname string) (string, error) {
77 obj, err := ui.GetObject(fieldname)
81 fieldctl, ok := obj.(*gtk.TextView)
85 textbuf, err := fieldctl.GetBuffer()
89 start, end := textbuf.GetBounds()
90 textstr, err := textbuf.GetText(start, end, true)
97 func getBasicDetails() (*Applicant, error) {
98 // Retrieve all the fields.
100 firstname, err := getLineText("FirstName")
104 lastname, err := getLineText("LastName")
109 address, err := getMultilineText("Address")
114 contact, err := getLineText("ContactNumber")
118 email, err := getLineText("Email")
123 // Store the contents in Applicant object
124 var applicant = new(Applicant)
126 applicant.FirstName = firstname
127 applicant.LastName = lastname
128 applicant.DateOfBirth = selecteddate
129 applicant.Sex = selectedsex
130 applicant.Address = address
131 applicant.ContactNo = contact
132 applicant.Email = email
134 return applicant, nil
137 func getWindow() (*gtk.Window, error) {
138 obj, err := ui.GetObject("MainWindow")
140 fmt.Println(err.Error())
143 wnd, ok := obj.(*gtk.Window)
153 ui, err = gtk.BuilderNew()
155 fmt.Println(err.Error())
158 asset, err := Asset("resources/resumebuilder.glade")
160 fmt.Println(err.Error())
163 ui.AddFromString(string(asset))
164 ui.ConnectSignals(map[string]interface{}{"SexMaleSelected": sexMaleSelected,
165 "SexFemaleSelected": sexFemaleSelected, "SexOtherSelected": sexOtherSelected,
166 "SaveButtonClicked": SaveButtonClicked, "DoBSelected": doBSelected})
168 wnd, err := getWindow()
173 wnd.SetTitle("Resume Builder")
177 wnd.Connect("destroy", func() {
183 func sexMaleSelected(male *gtk.RadioButton) {
184 if male.GetActive() {
189 func sexFemaleSelected(female *gtk.RadioButton) {
190 if female.GetActive() {
195 func sexOtherSelected(other *gtk.RadioButton) {
196 if other.GetActive() {
201 func doBSelected(dob *gtk.Calendar) {
202 selecteddate.Year, selecteddate.Month, selecteddate.Day = dob.GetDate()
205 func SaveButtonClicked() {
206 a, err := getBasicDetails()
208 fmt.Println(err.Error())