Merge pull request #18 from nwg-piotr/searchres
focus first search result #17
This commit is contained in:
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
5
main.go
5
main.go
@@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/gotk3/gotk3/gtk"
|
"github.com/gotk3/gotk3/gtk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.1.8"
|
const version = "0.1.9"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
appDirs []string
|
appDirs []string
|
||||||
@@ -197,7 +197,6 @@ func main() {
|
|||||||
println(fmt.Sprintf("Custom associations file %s not found or invalid", paFile))
|
println(fmt.Sprintf("Custom associations file %s not found or invalid", paFile))
|
||||||
} else {
|
} else {
|
||||||
println(fmt.Sprintf("Found %v associations in %s", len(preferredApps), paFile))
|
println(fmt.Sprintf("Found %v associations in %s", len(preferredApps), paFile))
|
||||||
fmt.Println(preferredApps)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// USER INTERFACE
|
// USER INTERFACE
|
||||||
@@ -273,7 +272,7 @@ func main() {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if !searchEntry.IsFocus() {
|
if !searchEntry.IsFocus() {
|
||||||
searchEntry.GrabFocus()
|
searchEntry.GrabFocusWithoutSelecting()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,6 +351,29 @@ func setUpSearchEntry() *gtk.SearchEntry {
|
|||||||
fileSearchResultWrapper.Hide()
|
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 {
|
} else {
|
||||||
// clear search results
|
// clear search results
|
||||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
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("")
|
searchEntry.SetText("")
|
||||||
})
|
})*/
|
||||||
|
|
||||||
return searchEntry
|
return searchEntry
|
||||||
}
|
}
|
||||||
@@ -409,6 +432,7 @@ func setUpUserDirButton(iconName, displayName, entryName string, userDirsMap map
|
|||||||
}
|
}
|
||||||
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
button, _ := gtk.ButtonNew()
|
button, _ := gtk.ButtonNew()
|
||||||
|
button.SetAlwaysShowImage(true)
|
||||||
img, _ := gtk.ImageNewFromIconName(iconName, gtk.ICON_SIZE_MENU)
|
img, _ := gtk.ImageNewFromIconName(iconName, gtk.ICON_SIZE_MENU)
|
||||||
button.SetImage(img)
|
button.SetImage(img)
|
||||||
|
|
||||||
@@ -441,6 +465,7 @@ func setUpUserFileSearchResultButton(fileName, filePath string) *gtk.Box {
|
|||||||
if strings.HasPrefix(filePath, "#is_dir#") {
|
if strings.HasPrefix(filePath, "#is_dir#") {
|
||||||
filePath = filePath[8:]
|
filePath = filePath[8:]
|
||||||
img, _ := gtk.ImageNewFromIconName("folder", gtk.ICON_SIZE_MENU)
|
img, _ := gtk.ImageNewFromIconName("folder", gtk.ICON_SIZE_MENU)
|
||||||
|
button.SetAlwaysShowImage(true)
|
||||||
button.SetImage(img)
|
button.SetImage(img)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,6 +491,10 @@ func setUpUserFileSearchResultButton(fileName, filePath string) *gtk.Box {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
button.Connect("activate", func() {
|
||||||
|
open(filePath, true)
|
||||||
|
})
|
||||||
|
|
||||||
box.PackStart(button, false, true, 0)
|
box.PackStart(button, false, true, 0)
|
||||||
return box
|
return box
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user