-
Notifications
You must be signed in to change notification settings - Fork 0
/
panels.go
53 lines (46 loc) · 1.38 KB
/
panels.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
xWidget "fyne.io/x/fyne/widget"
)
func (h *hgui) makeFilesPanel() *xWidget.FileTree {
files := xWidget.NewFileTree(h.projectRoot)
files.Sorter = func(u1, u2 fyne.URI) bool {
return u1.String() < u2.String() // Sort alphabetically
}
files.OnSelected = func(uid widget.TreeNodeID) {
u, err := storage.ParseURI(uid)
if err != nil {
dialog.ShowError(err, h.win)
return
}
h.OpenHashlooker(u)
files.UnselectAll()
return
}
return files
}
func (h *hgui) makeResultsPanel() fyne.CanvasObject {
h.openedHashlooker = make(map[*container.TabItem]*hashlookupTab)
welcome := widget.NewLabel("Welcome to Hashlookup-gui, the GUI to query hashlookup service.\n\nChoose a starting folder in the list to investigate whether the files it contains are known from hashlookup.")
h.resultsTabs = container.NewDocTabs(
container.NewTabItemWithIcon("Welcome", theme.HomeIcon(),
container.NewCenter(welcome)))
h.resultsTabs.CloseIntercept = func(t *container.TabItem) {
hl, ok := h.openedHashlooker[t]
if !ok { // welcome tab or bloom filter tab won't close for now
return
} else {
hl.close()
h.resultsTabs.Remove(t)
delete(h.openedHashlooker, t)
return
}
}
return container.NewMax(h.resultsTabs)
}