2 Commits

Author SHA1 Message Date
Piotr Miller
c5e39f179f Merge pull request #18 from nwg-piotr/searchres
focus first search result #17
2021-08-30 03:17:49 +02:00
piotr
ce48848589 focus first search result #17 2021-08-29 03:37:00 +02:00
3 changed files with 33 additions and 5 deletions

Binary file not shown.

View File

@@ -19,7 +19,7 @@ import (
"github.com/gotk3/gotk3/gtk"
)
const version = "0.1.8"
const version = "0.1.9"
var (
appDirs []string
@@ -197,7 +197,6 @@ func main() {
println(fmt.Sprintf("Custom associations file %s not found or invalid", paFile))
} else {
println(fmt.Sprintf("Found %v associations in %s", len(preferredApps), paFile))
fmt.Println(preferredApps)
}
// USER INTERFACE
@@ -273,7 +272,7 @@ func main() {
default:
if !searchEntry.IsFocus() {
searchEntry.GrabFocus()
searchEntry.GrabFocusWithoutSelecting()
}
return false
}

View File

@@ -351,6 +351,29 @@ func setUpSearchEntry() *gtk.SearchEntry {
fileSearchResultWrapper.Hide()
}
}
// focus 1st search result #17
var w *gtk.Widget
if appFlowBox != nil {
b := appFlowBox.GetChildAtIndex(0)
if b != nil {
button, err := b.GetChild()
if err == nil {
button.ToWidget().GrabFocus()
w = button.ToWidget()
}
}
}
if w == nil && fileSearchResultFlowBox != nil {
f := fileSearchResultFlowBox.GetChildAtIndex(0)
if f != nil {
//f.SetCanFocus(false)
button, err := f.GetChild()
if err == nil {
button.ToWidget().SetCanFocus(true)
button.ToWidget().GrabFocus()
}
}
}
} else {
// clear search results
appFlowBox = setUpAppsFlowBox(nil, "")
@@ -364,9 +387,9 @@ func setUpSearchEntry() *gtk.SearchEntry {
}
}
})
searchEntry.Connect("focus-in-event", func() {
/*searchEntry.Connect("focus-in-event", func() {
searchEntry.SetText("")
})
})*/
return searchEntry
}
@@ -409,6 +432,7 @@ func setUpUserDirButton(iconName, displayName, entryName string, userDirsMap map
}
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
button, _ := gtk.ButtonNew()
button.SetAlwaysShowImage(true)
img, _ := gtk.ImageNewFromIconName(iconName, gtk.ICON_SIZE_MENU)
button.SetImage(img)
@@ -441,6 +465,7 @@ func setUpUserFileSearchResultButton(fileName, filePath string) *gtk.Box {
if strings.HasPrefix(filePath, "#is_dir#") {
filePath = filePath[8:]
img, _ := gtk.ImageNewFromIconName("folder", gtk.ICON_SIZE_MENU)
button.SetAlwaysShowImage(true)
button.SetImage(img)
}
@@ -466,6 +491,10 @@ func setUpUserFileSearchResultButton(fileName, filePath string) *gtk.Box {
return false
})
button.Connect("activate", func() {
open(filePath, true)
})
box.PackStart(button, false, true, 0)
return box
}