status line

This commit is contained in:
piotr 2021-05-24 04:34:11 +02:00
parent 1c9ad42e8b
commit 30287ff669
4 changed files with 20 additions and 4 deletions

Binary file not shown.

View File

@ -100,6 +100,8 @@ var (
pinnedFlowBox *gtk.FlowBox
pinnedFlowBoxWrapper *gtk.Box
catButtons []*gtk.Button
statusLabel *gtk.Label
status string
)
// Flags
@ -186,7 +188,7 @@ func main() {
desktopFiles := listDesktopFiles()
println(fmt.Sprintf("Found %v desktop files", len(desktopFiles)))
parseDesktopFiles(desktopFiles)
status = parseDesktopFiles(desktopFiles)
// USER INTERFACE
gtk.Init(nil)
@ -300,6 +302,11 @@ func main() {
resultWindow.Add(appFlowBoxWrapper)
appFlowBox = setUpAppsFlowBox(nil, "")
statusLineWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
outerVBox.PackStart(statusLineWrapper, false, false, 10)
statusLabel, _ = gtk.LabelNew(status)
statusLineWrapper.PackStart(statusLabel, true, false, 0)
/*alignmentBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
outerBox.PackStart(alignmentBox, true, true, 0)

View File

@ -324,7 +324,7 @@ func setUpCategories() {
categories = append(categories, other)
}
func parseDesktopFiles(desktopFiles []string) {
func parseDesktopFiles(desktopFiles []string) string {
id2entry = make(map[string]desktopEntry)
var added []string
skipped := 0
@ -429,7 +429,9 @@ func parseDesktopFiles(desktopFiles []string) {
sort.Slice(desktopEntries, func(i, j int) bool {
return desktopEntries[i].NameLoc < desktopEntries[j].NameLoc
})
println(fmt.Sprintf("Skipped %v duplicates; %v .desktop entries hidden by \"NoDisplay=true\"", skipped, hidden))
summary := fmt.Sprintf("%v entries (+%v hidden)", len(desktopEntries)-hidden, hidden)
println("Skipped %v duplicates; %v .desktop entries hidden by \"NoDisplay=true\"", skipped, hidden)
return summary
}
// freedesktop Main Categories list consists of 13 entries. Let's contract it to 8+1 ("Other").

View File

@ -221,7 +221,8 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
ID := entry.DesktopID
exec := entry.Exec
terminal := entry.Terminal
button.Connect("button-release-event", func(row *gtk.Button, e *gdk.Event) bool {
desc := entry.CommentLoc
button.Connect("button-release-event", func(btn *gtk.Button, e *gdk.Event) bool {
btnEvent := gdk.EventButtonNewFromEvent(e)
if btnEvent.Button() == 1 {
launch(exec, terminal)
@ -232,6 +233,12 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
}
return false
})
button.Connect("enter-notify-event", func() {
statusLabel.SetText(desc)
})
button.Connect("leave-notify-event", func() {
statusLabel.SetText(status)
})
return button
}