8 "github.com/gotk3/gotk3/gtk"
11 type Applicant struct {
28 type Education struct {
32 GradeOrPercentage string
47 /* func SaveToJson(a *Applicant) {
48 b, err := json.Marshal(a)
51 fmt.Println(err.Error())
54 err = ioutil.WriteFile("test.json", b, 0644)
56 fmt.Println(err.Error())
61 func getLineText(fieldname string) (string, error) {
62 obj, err := ui.GetObject(fieldname)
66 field, ok := obj.(*gtk.Entry)
70 fieldstr, err := field.GetText()
77 func getMultilineText(fieldname string) (string, error) {
78 obj, err := ui.GetObject(fieldname)
82 fieldctl, ok := obj.(*gtk.TextView)
86 textbuf, err := fieldctl.GetBuffer()
90 start, end := textbuf.GetBounds()
91 textstr, err := textbuf.GetText(start, end, true)
98 func getBasicDetails() (*Applicant, error) {
99 // Retrieve all the fields.
101 firstname, err := getLineText("FirstName")
105 lastname, err := getLineText("LastName")
110 address, err := getMultilineText("Address")
115 contact, err := getLineText("ContactNumber")
119 email, err := getLineText("Email")
124 // Store the contents in Applicant object
125 var applicant = new(Applicant)
127 applicant.FirstName = firstname
128 applicant.LastName = lastname
129 applicant.DateOfBirth = selecteddate
130 applicant.Sex = selectedsex
131 applicant.Address = address
132 applicant.ContactNo = contact
133 applicant.Email = email
135 return applicant, nil
138 func getWindow() (*gtk.Window, error) {
139 obj, err := ui.GetObject("MainWindow")
141 fmt.Println(err.Error())
144 wnd, ok := obj.(*gtk.Window)
154 ui, err = gtk.BuilderNew()
156 fmt.Println(err.Error())
159 asset, err := Asset("resources/resumebuilder.glade")
161 fmt.Println(err.Error())
164 ui.AddFromString(string(asset))
165 ui.ConnectSignals(map[string]interface{}{"SexMaleSelected": sexMaleSelected,
166 "SexFemaleSelected": sexFemaleSelected, "SexOtherSelected": sexOtherSelected,
167 "SaveButtonClicked": saveButtonClicked, "DoBSelected": doBSelected,
168 "AddEducationClicked": addEducationClicked})
170 wnd, err := getWindow()
175 wnd.SetTitle("Resume Builder")
179 wnd.Connect("destroy", func() {
185 func sexMaleSelected(male *gtk.RadioButton) {
186 if male.GetActive() {
191 func sexFemaleSelected(female *gtk.RadioButton) {
192 if female.GetActive() {
197 func sexOtherSelected(other *gtk.RadioButton) {
198 if other.GetActive() {
203 func doBSelected(dob *gtk.Calendar) {
204 selecteddate.Year, selecteddate.Month, selecteddate.Day = dob.GetDate()
207 func getEducationFields() (*Education, error) {
209 qual, err := getLineText("QualificationTitle")
213 inst, err := getLineText("InstitutionName")
217 yearp, err := getLineText("YearPassing")
221 year, err := strconv.Atoi(yearp)
225 gradep, err := getLineText("GradeOrPercentag")
229 ed.Qualification = qual
230 ed.Institution = inst
231 ed.YearOfPassing = uint(year)
232 ed.GradeOrPercentage = gradep
237 func addEducationClicked() {
238 ed, err := getEducationFields()
242 lstore, err := ui.GetObject("EducationStore")
246 edustore, ok := lstore.(*gtk.ListStore)
250 iter := edustore.Append()
251 edustore.SetValue(iter, 0, ed.Qualification)
252 edustore.SetValue(iter, 1, ed.Institution)
253 edustore.SetValue(iter, 2, ed.YearOfPassing)
254 edustore.SetValue(iter, 3, ed.GradeOrPercentage)
257 func saveButtonClicked() {
258 a, err := getBasicDetails()
260 fmt.Println(err.Error())