mirror of
https://github.com/nwg-piotr/nwg-drawer.git
synced 2024-08-16 17:20:22 +03:00
code cleanup
This commit is contained in:
parent
bd153b8ff4
commit
48bc9f47b3
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
2
go.mod
2
go.mod
@ -5,6 +5,6 @@ go 1.16
|
||||
require (
|
||||
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
|
||||
github.com/dlasky/gotk3-layershell v0.0.0-20210331230524-5cca0b819261
|
||||
github.com/gotk3/gotk3 v0.5.3-0.20210223154815-289cfb6dbf32
|
||||
github.com/gotk3/gotk3 v0.6.0
|
||||
github.com/joshuarubin/go-sway v0.0.4
|
||||
)
|
||||
|
5
go.sum
5
go.sum
@ -4,10 +4,9 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dlasky/gotk3-layershell v0.0.0-20210331230524-5cca0b819261 h1:eoXn91ckLWKMXmQKX34UHEF2XMyQpRnnP80fDiu+kys=
|
||||
github.com/dlasky/gotk3-layershell v0.0.0-20210331230524-5cca0b819261/go.mod h1:d56Gslp3IaiT8lqxD/lO1Msz1wYgD8D/HTKHgSdg9tU=
|
||||
github.com/gotk3/gotk3 v0.5.3-0.20210223154815-289cfb6dbf32 h1:wE6C/HgLUBHi8YhHlCEulrmQMntVl4PFdh3kA0sWyAY=
|
||||
github.com/gotk3/gotk3 v0.5.3-0.20210223154815-289cfb6dbf32/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
|
||||
github.com/joshuarubin/go-sway v0.0.3 h1:uuY+dAMz+iAJvso+DP7TSRczDWhaV47nEPHJoRDOqjA=
|
||||
github.com/joshuarubin/go-sway v0.0.3/go.mod h1:qcDd6f25vJ0++wICwA1BainIcRC67p2Mb4lsrZ0k3/k=
|
||||
github.com/gotk3/gotk3 v0.6.0 h1:Aqlq4/6VabNwtCyA9M9zFNad5yHAqCi5heWnZ9y+3dA=
|
||||
github.com/gotk3/gotk3 v0.6.0/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
|
||||
github.com/joshuarubin/go-sway v0.0.4 h1:dpmIwQ/LytG+oMrjmaVKdk1aPdW2feXK/+wAcLKIx4A=
|
||||
github.com/joshuarubin/go-sway v0.0.4/go.mod h1:qcDd6f25vJ0++wICwA1BainIcRC67p2Mb4lsrZ0k3/k=
|
||||
github.com/joshuarubin/lifecycle v1.0.0 h1:N/lPEC8f+dBZ1Tn99vShqp36LwB+LI7XNAiNadZeLUQ=
|
||||
|
24
main.go
24
main.go
@ -19,19 +19,15 @@ import (
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
)
|
||||
|
||||
const version = "0.0.2"
|
||||
const version = "0.0.3"
|
||||
|
||||
var (
|
||||
appDirs []string
|
||||
configDirectory string
|
||||
pinnedFile string
|
||||
pinned []string
|
||||
rightBox *gtk.Box
|
||||
src glib.SourceHandle
|
||||
imgSizeScaled int
|
||||
currentWsNum, targetWsNum int64
|
||||
win *gtk.Window
|
||||
id2entry map[string]desktopEntry
|
||||
appDirs []string
|
||||
configDirectory string
|
||||
pinnedFile string
|
||||
pinned []string
|
||||
src glib.SourceHandle
|
||||
id2entry map[string]desktopEntry
|
||||
)
|
||||
|
||||
var categoryNames = [...]string{
|
||||
@ -87,10 +83,7 @@ var (
|
||||
fileSearchResults []string
|
||||
searchEntry *gtk.SearchEntry
|
||||
phrase string
|
||||
fileSearchResultListBox *gtk.ListBox // tbd
|
||||
fileSearchResultFlowBox *gtk.FlowBox
|
||||
buttonsWrapper *gtk.Box
|
||||
buttonBox *gtk.EventBox
|
||||
userDirsMap map[string]string
|
||||
appFlowBox *gtk.FlowBox
|
||||
appSearchResultWrapper *gtk.Box
|
||||
@ -100,7 +93,6 @@ var (
|
||||
catButtons []*gtk.Button
|
||||
statusLabel *gtk.Label
|
||||
status string
|
||||
mainColumnWidth int
|
||||
ignore string
|
||||
)
|
||||
|
||||
@ -272,7 +264,7 @@ func main() {
|
||||
|
||||
// Close the window on leave, but not immediately, to avoid accidental closes
|
||||
win.Connect("leave-notify-event", func() {
|
||||
src, err = glib.TimeoutAdd(uint(500), func() bool {
|
||||
src = glib.TimeoutAdd(uint(500), func() bool {
|
||||
gtk.MainQuit()
|
||||
return false
|
||||
})
|
||||
|
17
tools.go
17
tools.go
@ -33,15 +33,6 @@ func cancelClose() {
|
||||
}
|
||||
}
|
||||
|
||||
func inPinned(taskID string) bool {
|
||||
for _, id := range pinned {
|
||||
if strings.TrimSpace(taskID) == strings.TrimSpace(id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func createPixbuf(icon string, size int) (*gdk.Pixbuf, error) {
|
||||
iconTheme, err := gtk.IconThemeGetDefault()
|
||||
if err != nil {
|
||||
@ -373,9 +364,7 @@ func parseDesktopFiles(desktopFiles []string) string {
|
||||
exec = strings.Split(l, "Exec=")[1]
|
||||
disallowed := [2]string{"\"", "'"}
|
||||
for _, char := range disallowed {
|
||||
if strings.Contains(exec, char) {
|
||||
exec = strings.Replace(exec, char, "", -1)
|
||||
}
|
||||
exec = strings.Replace(exec, char, "", -1)
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -606,9 +595,7 @@ func launch(command string, terminal bool) {
|
||||
// set env variables
|
||||
if len(envVars) > 0 {
|
||||
cmd.Env = os.Environ()
|
||||
for _, envVar := range envVars {
|
||||
cmd.Env = append(cmd.Env, envVar)
|
||||
}
|
||||
cmd.Env = append(cmd.Env, envVars...)
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("env vars: %s; command: '%s'; args: %s\n", envVars, elements[cmdIdx], elements[1+cmdIdx:])
|
||||
|
@ -164,7 +164,7 @@ func notEmpty(listCategory []string) bool {
|
||||
}
|
||||
for _, desktopID := range listCategory {
|
||||
entry := id2entry[desktopID]
|
||||
if entry.NoDisplay == false {
|
||||
if !entry.NoDisplay {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ func searchUserDir(dir string) {
|
||||
ignore = userDirsMap[dir]
|
||||
filepath.WalkDir(userDirsMap[dir], walk)
|
||||
|
||||
if fileSearchResults != nil && len(fileSearchResults) > 0 {
|
||||
if len(fileSearchResults) > 0 {
|
||||
btn := setUpUserDirButton(fmt.Sprintf("folder-%s", dir), "", dir, userDirsMap)
|
||||
fileSearchResultFlowBox.Add(btn)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user