status line
This commit is contained in:
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
9
main.go
9
main.go
@@ -100,6 +100,8 @@ var (
|
|||||||
pinnedFlowBox *gtk.FlowBox
|
pinnedFlowBox *gtk.FlowBox
|
||||||
pinnedFlowBoxWrapper *gtk.Box
|
pinnedFlowBoxWrapper *gtk.Box
|
||||||
catButtons []*gtk.Button
|
catButtons []*gtk.Button
|
||||||
|
statusLabel *gtk.Label
|
||||||
|
status string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
@@ -186,7 +188,7 @@ func main() {
|
|||||||
desktopFiles := listDesktopFiles()
|
desktopFiles := listDesktopFiles()
|
||||||
println(fmt.Sprintf("Found %v desktop files", len(desktopFiles)))
|
println(fmt.Sprintf("Found %v desktop files", len(desktopFiles)))
|
||||||
|
|
||||||
parseDesktopFiles(desktopFiles)
|
status = parseDesktopFiles(desktopFiles)
|
||||||
|
|
||||||
// USER INTERFACE
|
// USER INTERFACE
|
||||||
gtk.Init(nil)
|
gtk.Init(nil)
|
||||||
@@ -300,6 +302,11 @@ func main() {
|
|||||||
resultWindow.Add(appFlowBoxWrapper)
|
resultWindow.Add(appFlowBoxWrapper)
|
||||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
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)
|
/*alignmentBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
outerBox.PackStart(alignmentBox, true, true, 0)
|
outerBox.PackStart(alignmentBox, true, true, 0)
|
||||||
|
|
||||||
|
|||||||
6
tools.go
6
tools.go
@@ -324,7 +324,7 @@ func setUpCategories() {
|
|||||||
categories = append(categories, other)
|
categories = append(categories, other)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseDesktopFiles(desktopFiles []string) {
|
func parseDesktopFiles(desktopFiles []string) string {
|
||||||
id2entry = make(map[string]desktopEntry)
|
id2entry = make(map[string]desktopEntry)
|
||||||
var added []string
|
var added []string
|
||||||
skipped := 0
|
skipped := 0
|
||||||
@@ -429,7 +429,9 @@ func parseDesktopFiles(desktopFiles []string) {
|
|||||||
sort.Slice(desktopEntries, func(i, j int) bool {
|
sort.Slice(desktopEntries, func(i, j int) bool {
|
||||||
return desktopEntries[i].NameLoc < desktopEntries[j].NameLoc
|
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").
|
// freedesktop Main Categories list consists of 13 entries. Let's contract it to 8+1 ("Other").
|
||||||
|
|||||||
@@ -221,7 +221,8 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
|
|||||||
ID := entry.DesktopID
|
ID := entry.DesktopID
|
||||||
exec := entry.Exec
|
exec := entry.Exec
|
||||||
terminal := entry.Terminal
|
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)
|
btnEvent := gdk.EventButtonNewFromEvent(e)
|
||||||
if btnEvent.Button() == 1 {
|
if btnEvent.Button() == 1 {
|
||||||
launch(exec, terminal)
|
launch(exec, terminal)
|
||||||
@@ -232,6 +233,12 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
button.Connect("enter-notify-event", func() {
|
||||||
|
statusLabel.SetText(desc)
|
||||||
|
})
|
||||||
|
button.Connect("leave-notify-event", func() {
|
||||||
|
statusLabel.SetText(status)
|
||||||
|
})
|
||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user