focus 1st power button on Tab key

This commit is contained in:
piotr
2024-02-08 02:23:34 +01:00
parent 3ea4a7824c
commit b59058c5c2

40
main.go
View File

@@ -34,6 +34,7 @@ var (
exclusions []string exclusions []string
hyprlandMonitors []monitor hyprlandMonitors []monitor
beenScrolled bool beenScrolled bool
firstPowerBtn *gtk.Button
) )
var categoryNames = [...]string{ var categoryNames = [...]string{
@@ -462,6 +463,10 @@ func main() {
} }
} }
return true return true
} else if key.KeyVal() == gdk.KEY_Tab {
if firstPowerBtn != nil {
firstPowerBtn.ToWidget().GrabFocus()
}
} }
return false return false
}) })
@@ -588,25 +593,30 @@ func main() {
powerButtonsWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0) powerButtonsWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
powerBarWrapper.PackStart(powerButtonsWrapper, true, false, 12) powerBarWrapper.PackStart(powerButtonsWrapper, true, false, 12)
if *pbLock != "" { if *pbPoweroff != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/lock.svg"), *pbLock) btn := powerButton(filepath.Join(dataDirectory, "img/poweroff.svg"), *pbPoweroff)
powerButtonsWrapper.PackStart(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
} firstPowerBtn = btn
if *pbExit != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/exit.svg"), *pbExit)
powerButtonsWrapper.PackStart(btn, true, false, 0)
}
if *pbReboot != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/reboot.svg"), *pbReboot)
powerButtonsWrapper.PackStart(btn, true, false, 0)
} }
if *pbSleep != "" { if *pbSleep != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/sleep.svg"), *pbSleep) btn := powerButton(filepath.Join(dataDirectory, "img/sleep.svg"), *pbSleep)
powerButtonsWrapper.PackStart(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn
} }
if *pbPoweroff != "" { if *pbReboot != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/poweroff.svg"), *pbPoweroff) btn := powerButton(filepath.Join(dataDirectory, "img/reboot.svg"), *pbReboot)
powerButtonsWrapper.PackStart(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn
}
if *pbExit != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/exit.svg"), *pbExit)
powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn
}
if *pbLock != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/lock.svg"), *pbLock)
powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn
} }
} }
} else { } else {