updated the addAccelerator function to accept an AccelGroup to add command to

updated the displayFirstRun function to have Return mapped to the 'Login' button
master
Zachary Epps 4 years ago
parent 27b4697f2c
commit 327496cd41
  1. 12
      main.go

@ -48,16 +48,18 @@ func main() {
}
func displayFirstRun() {
loginAccel, _ := gtk.AccelGroupNew()
obj, _ := mainBuilder.GetObject("LoginPopup")
popup := obj.(*gtk.Dialog)
popup.AddAccelGroup(loginAccel)
popup.Connect("destroy", func() {
if firstRun {
gtk.MainQuit()
} else {
popup.Hide()
}
})
})
obj, _ = mainBuilder.GetObject("LoginCancelBtn")
cancelBtn := obj.(*gtk.Button)
@ -72,6 +74,7 @@ func displayFirstRun() {
obj, _ = mainBuilder.GetObject("LoginAuthBtn")
authBtn := obj.(*gtk.Button)
addAccelerator(&authBtn.Bin.Container.Widget, loginAccel, "Return", "clicked")
// hook up our login button
authBtn.Connect("clicked", func() {
@ -142,7 +145,8 @@ func setupMainWindow() {
btn.Connect("clicked", func() {
fmt.Println("new toot window!")
})
addAccelerator(&btn.Bin.Container.Widget, "<Ctrl>Return", "clicked")
addAccelerator(&btn.Bin.Container.Widget, AccelGroup,
"<Ctrl>Return", "clicked")
MainWindow.Hide()
}
@ -170,8 +174,8 @@ func addRow(bldr *gtk.Builder, i int) {
tootList.Prepend(row)
}
func addAccelerator(w *gtk.Widget, controlString, signal string) {
func addAccelerator(w *gtk.Widget, accel *gtk.AccelGroup, controlString, signal string) {
key, mod := gtk.AcceleratorParse(controlString)
w.AddAccelerator(signal, AccelGroup, key, mod, gtk.ACCEL_VISIBLE)
w.AddAccelerator(signal, accel, key, mod, gtk.ACCEL_VISIBLE)
}