Fix regression that prevented pinned items to update while window is open

This commit is contained in:
Raphael Ludwig
2022-02-14 20:59:48 +01:00
parent 058f8684aa
commit 165b925da2
2 changed files with 42 additions and 38 deletions

26
main.go
View File

@@ -101,7 +101,7 @@ var (
status string
ignore string
desktopTrigger bool
pinnedTrigger bool
pinnedItemsChanged chan interface{} = make(chan interface{}, 1)
)
func defaultStringIfBlank(s, fallback string) string {
@@ -494,9 +494,9 @@ func main() {
// Check if showing the window has been requested (SIGUSR1)
go func() {
for {
<-showWindowChannel
log.Debug("SHOW WINDOW")
select {
case <-showWindowChannel:
log.Debug("Showing window")
glib.TimeoutAdd(0, func() bool {
if win != nil && !win.IsVisible() {
@@ -510,14 +510,6 @@ func main() {
desktopTrigger = false
}
// pinned file changed
if pinnedTrigger {
log.Debug("pinned file changed")
pinnedTrigger = false
pinned, _ = loadTextFile(pinnedFile)
pinnedFlowBox = setUpPinnedFlowBox()
}
// Show window and focus the search box
win.ShowAll()
if fileSearchResultWrapper != nil {
@@ -535,6 +527,16 @@ func main() {
return false
})
case <-pinnedItemsChanged:
glib.TimeoutAdd(0, func() bool {
log.Debug("pinned file changed")
pinned, _ = loadTextFile(pinnedFile)
pinnedFlowBox = setUpPinnedFlowBox()
return false
})
}
}
}()

View File

@@ -41,7 +41,9 @@ func watchFiles() {
event.Op.String() == "RENAME") {
desktopTrigger = true
} else if event.Name == pinnedFile {
pinnedTrigger = true
// TODO: This can be used to propagate information about the changed file to the
// GUI to avoid recreating everything
pinnedItemsChanged <- struct{}{}
}
case err := <-watcher.Errors: