mirror of
https://github.com/nwg-piotr/nwg-drawer.git
synced 2024-10-26 14:53:57 +03:00
Fix regression that prevented pinned items to update while window is open
This commit is contained in:
parent
058f8684aa
commit
165b925da2
76
main.go
76
main.go
@ -101,7 +101,7 @@ var (
|
|||||||
status string
|
status string
|
||||||
ignore string
|
ignore string
|
||||||
desktopTrigger bool
|
desktopTrigger bool
|
||||||
pinnedTrigger bool
|
pinnedItemsChanged chan interface{} = make(chan interface{}, 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultStringIfBlank(s, fallback string) string {
|
func defaultStringIfBlank(s, fallback string) string {
|
||||||
@ -494,47 +494,49 @@ func main() {
|
|||||||
// Check if showing the window has been requested (SIGUSR1)
|
// Check if showing the window has been requested (SIGUSR1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
<-showWindowChannel
|
select {
|
||||||
|
case <-showWindowChannel:
|
||||||
|
log.Debug("Showing window")
|
||||||
|
glib.TimeoutAdd(0, func() bool {
|
||||||
|
if win != nil && !win.IsVisible() {
|
||||||
|
|
||||||
log.Debug("SHOW WINDOW")
|
// Refresh files before displaying the root window
|
||||||
glib.TimeoutAdd(0, func() bool {
|
// some .desktop file changed
|
||||||
if win != nil && !win.IsVisible() {
|
if desktopTrigger {
|
||||||
|
log.Debug(".desktop file changed")
|
||||||
|
desktopFiles = listDesktopFiles()
|
||||||
|
status = parseDesktopFiles(desktopFiles)
|
||||||
|
appFlowBox = setUpAppsFlowBox(nil, "")
|
||||||
|
desktopTrigger = false
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh files before displaying the root window
|
// Show window and focus the search box
|
||||||
// some .desktop file changed
|
win.ShowAll()
|
||||||
if desktopTrigger {
|
if fileSearchResultWrapper != nil {
|
||||||
log.Debug(".desktop file changed")
|
fileSearchResultWrapper.Hide()
|
||||||
desktopFiles = listDesktopFiles()
|
}
|
||||||
status = parseDesktopFiles(desktopFiles)
|
// focus 1st element
|
||||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
b := appFlowBox.GetChildAtIndex(0)
|
||||||
desktopTrigger = false
|
if b != nil {
|
||||||
}
|
button, err := b.GetChild()
|
||||||
|
if err == nil {
|
||||||
// pinned file changed
|
button.ToWidget().GrabFocus()
|
||||||
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 {
|
|
||||||
fileSearchResultWrapper.Hide()
|
|
||||||
}
|
|
||||||
// focus 1st element
|
|
||||||
b := appFlowBox.GetChildAtIndex(0)
|
|
||||||
if b != nil {
|
|
||||||
button, err := b.GetChild()
|
|
||||||
if err == nil {
|
|
||||||
button.ToWidget().GrabFocus()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case <-pinnedItemsChanged:
|
||||||
|
glib.TimeoutAdd(0, func() bool {
|
||||||
|
log.Debug("pinned file changed")
|
||||||
|
pinned, _ = loadTextFile(pinnedFile)
|
||||||
|
pinnedFlowBox = setUpPinnedFlowBox()
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -41,7 +41,9 @@ func watchFiles() {
|
|||||||
event.Op.String() == "RENAME") {
|
event.Op.String() == "RENAME") {
|
||||||
desktopTrigger = true
|
desktopTrigger = true
|
||||||
} else if event.Name == pinnedFile {
|
} 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:
|
case err := <-watcher.Errors:
|
||||||
|
Loading…
Reference in New Issue
Block a user