file search added
This commit is contained in:
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
22
main.go
22
main.go
@@ -84,7 +84,6 @@ var desktopEntries []desktopEntry
|
|||||||
// UI elements
|
// UI elements
|
||||||
var (
|
var (
|
||||||
userDirsListBox *gtk.ListBox
|
userDirsListBox *gtk.ListBox
|
||||||
resultWrapper *gtk.Box
|
|
||||||
resultWindow *gtk.ScrolledWindow
|
resultWindow *gtk.ScrolledWindow
|
||||||
fileSearchResults map[string]string
|
fileSearchResults map[string]string
|
||||||
fileSearchResultWindow *gtk.ScrolledWindow
|
fileSearchResultWindow *gtk.ScrolledWindow
|
||||||
@@ -96,12 +95,13 @@ var (
|
|||||||
confirmationBox *gtk.Box
|
confirmationBox *gtk.Box
|
||||||
userDirsMap map[string]string
|
userDirsMap map[string]string
|
||||||
appFlowBox *gtk.FlowBox
|
appFlowBox *gtk.FlowBox
|
||||||
appFlowBoxWrapper *gtk.Box
|
appSearchResultWrapper *gtk.Box
|
||||||
|
fileSearchResultWrapper *gtk.Box
|
||||||
pinnedFlowBox *gtk.FlowBox
|
pinnedFlowBox *gtk.FlowBox
|
||||||
pinnedFlowBoxWrapper *gtk.Box
|
pinnedFlowBoxWrapper *gtk.Box
|
||||||
catButtons []*gtk.Button
|
catButtons []*gtk.Button
|
||||||
statusLabel *gtk.Label
|
statusLabel *gtk.Label
|
||||||
status string
|
status string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
@@ -277,7 +277,6 @@ func main() {
|
|||||||
searchEntry = setUpSearchEntry()
|
searchEntry = setUpSearchEntry()
|
||||||
searchEntry.SetMaxWidthChars(30)
|
searchEntry.SetMaxWidthChars(30)
|
||||||
searchBoxWrapper.PackStart(searchEntry, true, false, 0)
|
searchBoxWrapper.PackStart(searchEntry, true, false, 0)
|
||||||
outerVBox.PackStart(searchBoxWrapper, false, false, 10)
|
|
||||||
|
|
||||||
pinnedWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
pinnedWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
outerVBox.PackStart(pinnedWrapper, false, false, 0)
|
outerVBox.PackStart(pinnedWrapper, false, false, 0)
|
||||||
@@ -298,10 +297,21 @@ func main() {
|
|||||||
})
|
})
|
||||||
outerVBox.PackStart(resultWindow, true, true, 10)
|
outerVBox.PackStart(resultWindow, true, true, 10)
|
||||||
|
|
||||||
appFlowBoxWrapper, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
resultsWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||||
resultWindow.Add(appFlowBoxWrapper)
|
resultWindow.Add(resultsWrapper)
|
||||||
|
|
||||||
|
appSearchResultWrapper, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||||
|
resultsWrapper.PackStart(appSearchResultWrapper, false, false, 0)
|
||||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
appFlowBox = setUpAppsFlowBox(nil, "")
|
||||||
|
|
||||||
|
userDirsMap = mapXdgUserDirs()
|
||||||
|
|
||||||
|
placeholder, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||||
|
resultsWrapper.PackStart(placeholder, true, true, 0)
|
||||||
|
|
||||||
|
fileSearchResultWrapper, _ = gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
|
resultsWrapper.PackEnd(fileSearchResultWrapper, false, false, 10)
|
||||||
|
|
||||||
statusLineWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
statusLineWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
outerVBox.PackStart(statusLineWrapper, false, false, 10)
|
outerVBox.PackStart(statusLineWrapper, false, false, 10)
|
||||||
statusLabel, _ = gtk.LabelNew(status)
|
statusLabel, _ = gtk.LabelNew(status)
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ func setUpAppsFlowBox(categoryList []string, searchPhrase string) *gtk.FlowBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
hWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
appFlowBoxWrapper.PackStart(hWrapper, false, false, 0)
|
appSearchResultWrapper.PackStart(hWrapper, false, false, 0)
|
||||||
hWrapper.PackStart(flowBox, true, false, 0)
|
hWrapper.PackStart(flowBox, true, false, 0)
|
||||||
resultWindow.ShowAll()
|
resultWindow.ShowAll()
|
||||||
|
|
||||||
@@ -246,8 +246,8 @@ func setUpFileSearchResult() *gtk.ListBox {
|
|||||||
if fileSearchResultListBox != nil {
|
if fileSearchResultListBox != nil {
|
||||||
fileSearchResultListBox.Destroy()
|
fileSearchResultListBox.Destroy()
|
||||||
}
|
}
|
||||||
fileSearchResultListBox, _ := gtk.ListBoxNew()
|
listBox, _ := gtk.ListBoxNew()
|
||||||
fileSearchResultListBox.Connect("enter-notify-event", func() {
|
listBox.Connect("enter-notify-event", func() {
|
||||||
cancelClose()
|
cancelClose()
|
||||||
})
|
})
|
||||||
/*fileSearchResultWindow, _ = gtk.ScrolledWindowNew(nil, nil)
|
/*fileSearchResultWindow, _ = gtk.ScrolledWindowNew(nil, nil)
|
||||||
@@ -255,12 +255,12 @@ func setUpFileSearchResult() *gtk.ListBox {
|
|||||||
fileSearchResultWindow.Connect("enter-notify-event", func() {
|
fileSearchResultWindow.Connect("enter-notify-event", func() {
|
||||||
cancelClose()
|
cancelClose()
|
||||||
})*/
|
})*/
|
||||||
resultWrapper.PackStart(fileSearchResultListBox, true, true, 0)
|
fileSearchResultWrapper.PackStart(listBox, true, false, 10)
|
||||||
|
|
||||||
//fileSearchResultWindow.Add(listBox)
|
//fileSearchResultWindow.Add(listBox)
|
||||||
fileSearchResultListBox.ShowAll()
|
listBox.ShowAll()
|
||||||
|
|
||||||
return fileSearchResultListBox
|
return listBox
|
||||||
}
|
}
|
||||||
|
|
||||||
func walk(path string, d fs.DirEntry, e error) error {
|
func walk(path string, d fs.DirEntry, e error) error {
|
||||||
@@ -294,8 +294,8 @@ func setUpSearchEntry() *gtk.SearchEntry {
|
|||||||
appFlowBox = setUpAppsFlowBox(nil, phrase)
|
appFlowBox = setUpAppsFlowBox(nil, phrase)
|
||||||
|
|
||||||
if len(phrase) > 2 {
|
if len(phrase) > 2 {
|
||||||
if fileSearchResultWindow != nil {
|
if fileSearchResultListBox != nil {
|
||||||
fileSearchResultWindow.Destroy()
|
fileSearchResultListBox.Destroy()
|
||||||
}
|
}
|
||||||
fileSearchResultListBox = setUpFileSearchResult()
|
fileSearchResultListBox = setUpFileSearchResult()
|
||||||
for key := range userDirsMap {
|
for key := range userDirsMap {
|
||||||
@@ -309,11 +309,11 @@ func setUpSearchEntry() *gtk.SearchEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fileSearchResultListBox.GetChildren().Length() == 0 {
|
if fileSearchResultListBox.GetChildren().Length() == 0 {
|
||||||
fileSearchResultWindow.Hide()
|
fileSearchResultListBox.Hide()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if fileSearchResultWindow != nil {
|
if fileSearchResultListBox != nil {
|
||||||
fileSearchResultWindow.Destroy()
|
fileSearchResultListBox.Destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -337,12 +337,12 @@ func searchUserDir(dir string) {
|
|||||||
fileSearchResultListBox.Add(row)
|
fileSearchResultListBox.Add(row)
|
||||||
}
|
}
|
||||||
fileSearchResultListBox.ShowAll()
|
fileSearchResultListBox.ShowAll()
|
||||||
|
statusLabel.SetText(fmt.Sprintf("%v files", fileSearchResultListBox.GetChildren().Length()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUpUserFileSearchResultRow(fileName, filePath string) *gtk.ListBoxRow {
|
func setUpUserFileSearchResultRow(fileName, filePath string) *gtk.ListBoxRow {
|
||||||
row, _ := gtk.ListBoxRowNew()
|
row, _ := gtk.ListBoxRowNew()
|
||||||
//row.SetCanFocus(false)
|
|
||||||
row.SetSelectable(false)
|
row.SetSelectable(false)
|
||||||
vBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
vBox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||||
eventBox, _ := gtk.EventBoxNew()
|
eventBox, _ := gtk.EventBoxNew()
|
||||||
@@ -350,6 +350,9 @@ func setUpUserFileSearchResultRow(fileName, filePath string) *gtk.ListBoxRow {
|
|||||||
eventBox.Add(hBox)
|
eventBox.Add(hBox)
|
||||||
vBox.PackStart(eventBox, false, false, *itemPadding)
|
vBox.PackStart(eventBox, false, false, *itemPadding)
|
||||||
|
|
||||||
|
if len(fileName) > 150 {
|
||||||
|
fileName = fmt.Sprintf("%s...", fileName[:147])
|
||||||
|
}
|
||||||
lbl, _ := gtk.LabelNew(fileName)
|
lbl, _ := gtk.LabelNew(fileName)
|
||||||
hBox.PackStart(lbl, false, false, 0)
|
hBox.PackStart(lbl, false, false, 0)
|
||||||
row.Add(vBox)
|
row.Add(vBox)
|
||||||
|
|||||||
Reference in New Issue
Block a user