7 "github.com/gotk3/gotk3/gtk"
10 type Applicant struct {
25 type Education struct {
28 PassPercentage float32
43 /* func SaveToJson(a *Applicant) {
44 b, err := json.Marshal(a)
47 fmt.Println(err.Error())
50 err = ioutil.WriteFile("test.json", b, 0644)
52 fmt.Println(err.Error())
57 func getLineText(fieldname string) (string, error) {
58 obj, err := ui.GetObject(fieldname)
62 field, ok := obj.(*gtk.Entry)
66 fieldstr, err := field.GetText()
73 func getMultilineText(fieldname string) (string, error) {
74 obj, err := ui.GetObject(fieldname)
78 fieldctl, ok := obj.(*gtk.TextView)
82 textbuf, err := fieldctl.GetBuffer()
86 start, end := textbuf.GetBounds()
87 textstr, err := textbuf.GetText(start, end, true)
94 func getBasicDetails() (*Applicant, error) {
95 // Retrieve all the fields.
97 firstname, err := getLineText("FirstName")
101 lastname, err := getLineText("LastName")
106 address, err := getMultilineText("Address")
111 // Store the contents in Applicant object
112 var applicant = new(Applicant)
114 applicant.FirstName = firstname
115 applicant.LastName = lastname
116 applicant.DateOfBirth = selecteddate
117 applicant.Sex = selectedsex
118 applicant.Address = address
120 return applicant, nil
123 func getWindow() (*gtk.Window, error) {
124 obj, err := ui.GetObject("MainWindow")
126 fmt.Println(err.Error())
129 wnd, ok := obj.(*gtk.Window)
139 ui, err = gtk.BuilderNew()
141 fmt.Println(err.Error())
144 asset, err := Asset("resources/resumebuilder.glade")
146 fmt.Println(err.Error())
149 ui.AddFromString(string(asset))
150 ui.ConnectSignals(map[string]interface{}{"SexMaleSelected": sexMaleSelected,
151 "SexFemaleSelected": sexFemaleSelected, "SexOtherSelected": sexOtherSelected,
152 "SaveButtonClicked": SaveButtonClicked, "DoBSelected": doBSelected})
154 wnd, err := getWindow()
159 wnd.SetTitle("Resume Builder")
163 wnd.Connect("destroy", func() {
169 func sexMaleSelected(male *gtk.RadioButton) {
170 if male.GetActive() {
175 func sexFemaleSelected(female *gtk.RadioButton) {
176 if female.GetActive() {
181 func sexOtherSelected(other *gtk.RadioButton) {
182 if other.GetActive() {
187 func doBSelected(dob *gtk.Calendar) {
188 selecteddate.Year, selecteddate.Month, selecteddate.Day = dob.GetDate()
191 func SaveButtonClicked() {
192 a, err := getBasicDetails()
194 fmt.Println(err.Error())