type Sex int
+var ui *gtk.Builder
+
const (
Male Sex = 1
Female = 2
}
} */
-func getWindow(ui gtk.Builder) (*gtk.Window, error) {
+func getBasicDetails() (*Applicant, error) {
+ obj, err := ui.GetObject("FirstName")
+ if err != nil {
+ return nil, err
+ }
+ fsname, ok := obj.(*gtk.Entry)
+ if !ok {
+ return nil, err
+ }
+ firstname, err := fsname.GetText()
+ if err != nil {
+ return nil, err
+ }
+ obj, err = ui.GetObject("LastName")
+ if err != nil {
+ return nil, err
+ }
+ lsname, ok := obj.(*gtk.Entry)
+ if !ok {
+ return nil, err
+ }
+ lastname, err := lsname.GetText()
+ if err != nil {
+ return nil, err
+ }
+
+ var applicant = new(Applicant)
+
+ applicant.FirstName = firstname
+ applicant.LastName = lastname
+
+ return applicant, nil
+}
+
+func getWindow() (*gtk.Window, error) {
obj, err := ui.GetObject("MainWindow")
if err != nil {
fmt.Println(err.Error())
return wnd, nil
}
+func getSaveButton() (*gtk.Button, error) {
+ btnobj, err := ui.GetObject("SaveButton")
+ if err != nil {
+ fmt.Println(err.Error())
+ return nil, err
+ }
+ btn, ok := btnobj.(*gtk.Button)
+ if !ok {
+ return nil, err
+ }
+ return btn, nil
+}
+
func LoadMain() {
gtk.Init(nil)
- ui, err := gtk.BuilderNewFromFile("resumebuilder.glade")
+ var err error
+ ui, err = gtk.BuilderNewFromFile("resumebuilder.glade")
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
- wnd, err := getWindow(*ui)
+ wnd, err := getWindow()
if err != nil {
os.Exit(1)
}
- btnobj, err := ui.GetObject("SaveButton")
+ btn, err := getSaveButton()
if err != nil {
- fmt.Println(err.Error())
- os.Exit(1)
- }
- btn, ok := btnobj.(*gtk.Button)
- if !ok {
os.Exit(1)
}
btn.Connect("clicked", SaveButtonClicked)
}
func SaveButtonClicked() {
-
+ a, err := getBasicDetails()
+ if err != nil {
+ fmt.Println(err.Error())
+ os.Exit(1)
+ }
+ fmt.Println(*a)
}
func main() {