8 Commits

Author SHA1 Message Date
Piotr Miller
2058f124fd Merge pull request #75 from nwg-piotr/fix74
sanitize no longer valid pinned items #74
2022-11-12 15:40:14 +01:00
piotr
ebdbe71ac6 hide and delete invalid pinned items #74 2022-11-12 03:41:24 +01:00
Piotr Miller
3fe6d71234 Merge pull request #73 from nwg-piotr/fix-72
Fix inconsistent behaviour of normal resident instance
2022-10-30 23:54:41 +01:00
piotr
0e5b1cf659 bump to 0.3.3 2022-10-30 22:58:19 +01:00
piotr
6494557979 focus 1st pinned if any, or focus 1st appBox entry; fixes #72 2022-10-30 22:53:06 +01:00
Piotr Miller
f68678f687 Merge pull request #71 from nwg-piotr/fix-45-revisited
Fix 45 revisited
2022-10-26 02:13:02 +02:00
piotr
e31df6e721 bump to 0.3.2 2022-10-25 04:06:30 +02:00
piotr
9509a65625 attempt to fix #45 (revisited) 2022-10-25 04:02:05 +02:00
4 changed files with 34 additions and 12 deletions

10
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/nwg-piotr/nwg-drawer
go 1.16
go 1.18
require (
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
@@ -10,3 +10,11 @@ require (
github.com/joshuarubin/go-sway v0.0.4
github.com/sirupsen/logrus v1.8.1
)
require (
github.com/joshuarubin/lifecycle v1.0.0 // indirect
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
golang.org/x/sync v0.0.0-20190412183630-56d357773e84 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
)

21
main.go
View File

@@ -21,7 +21,7 @@ import (
"github.com/gotk3/gotk3/gtk"
)
const version = "0.3.1"
const version = "0.3.4"
var (
appDirs []string
@@ -200,7 +200,10 @@ func main() {
log.Warnf("Resident instance already running (PID %v)", i)
} else {
log.Infof("Showing resident instance (PID %v)", i)
syscall.Kill(i, syscall.SIGUSR1)
err := syscall.Kill(i, syscall.SIGUSR1)
if err != nil {
return
}
}
}
}
@@ -546,14 +549,16 @@ func main() {
fileSearchResultWrapper.Hide()
}
// focus 1st element
b := appFlowBox.GetChildAtIndex(0)
if b != nil {
button, err := b.GetChild()
var button gtk.IWidget
if pinnedFlowBox.GetChildren().Length() > 0 {
button, err = pinnedFlowBox.GetChildAtIndex(0).GetChild()
} else {
button, err = appFlowBox.GetChildAtIndex(0).GetChild()
}
if err == nil {
button.ToWidget().GrabFocus()
}
}
}
return false
})
@@ -577,7 +582,9 @@ func main() {
func restoreStateAndHide() {
timeStart1 := time.Now()
if win != nil {
win.Hide()
}
// clear search
searchEntry.SetText("")
@@ -590,7 +597,9 @@ func restoreStateAndHide() {
}
// scroll to the top
if resultWindow != nil {
resultWindow.GetVAdjustment().SetValue(0)
}
t := time.Now()
log.Debugf(fmt.Sprintf("UI hidden and restored in the backgroud in %v ms", t.Sub(timeStart1).Milliseconds()))

View File

@@ -534,7 +534,8 @@ func savePinned() {
}(f)
for _, line := range pinned {
if line != "" {
//skip invalid lines
if line != "" && id2entry[line].DesktopID != "" {
_, err := f.WriteString(line + "\n")
if err != nil {

View File

@@ -32,6 +32,10 @@ func setUpPinnedFlowBox() *gtk.FlowBox {
if len(pinned) > 0 {
for _, desktopID := range pinned {
entry := id2entry[desktopID]
if entry.DesktopID == "" {
log.Debugf("Pinned item doesn't seem to exist: %s", desktopID)
continue
}
btn, _ := gtk.ButtonNew()