code cleanup
This commit is contained in:
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 (
|
require (
|
||||||
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
|
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
|
||||||
github.com/dlasky/gotk3-layershell v0.0.0-20210331230524-5cca0b819261
|
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
|
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/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 h1:eoXn91ckLWKMXmQKX34UHEF2XMyQpRnnP80fDiu+kys=
|
||||||
github.com/dlasky/gotk3-layershell v0.0.0-20210331230524-5cca0b819261/go.mod h1:d56Gslp3IaiT8lqxD/lO1Msz1wYgD8D/HTKHgSdg9tU=
|
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/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/gotk3/gotk3 v0.6.0 h1:Aqlq4/6VabNwtCyA9M9zFNad5yHAqCi5heWnZ9y+3dA=
|
||||||
github.com/joshuarubin/go-sway v0.0.3/go.mod h1:qcDd6f25vJ0++wICwA1BainIcRC67p2Mb4lsrZ0k3/k=
|
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 h1:dpmIwQ/LytG+oMrjmaVKdk1aPdW2feXK/+wAcLKIx4A=
|
||||||
github.com/joshuarubin/go-sway v0.0.4/go.mod h1:qcDd6f25vJ0++wICwA1BainIcRC67p2Mb4lsrZ0k3/k=
|
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=
|
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"
|
"github.com/gotk3/gotk3/gtk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.0.2"
|
const version = "0.0.3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
appDirs []string
|
appDirs []string
|
||||||
configDirectory string
|
configDirectory string
|
||||||
pinnedFile string
|
pinnedFile string
|
||||||
pinned []string
|
pinned []string
|
||||||
rightBox *gtk.Box
|
src glib.SourceHandle
|
||||||
src glib.SourceHandle
|
id2entry map[string]desktopEntry
|
||||||
imgSizeScaled int
|
|
||||||
currentWsNum, targetWsNum int64
|
|
||||||
win *gtk.Window
|
|
||||||
id2entry map[string]desktopEntry
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var categoryNames = [...]string{
|
var categoryNames = [...]string{
|
||||||
@@ -87,10 +83,7 @@ var (
|
|||||||
fileSearchResults []string
|
fileSearchResults []string
|
||||||
searchEntry *gtk.SearchEntry
|
searchEntry *gtk.SearchEntry
|
||||||
phrase string
|
phrase string
|
||||||
fileSearchResultListBox *gtk.ListBox // tbd
|
|
||||||
fileSearchResultFlowBox *gtk.FlowBox
|
fileSearchResultFlowBox *gtk.FlowBox
|
||||||
buttonsWrapper *gtk.Box
|
|
||||||
buttonBox *gtk.EventBox
|
|
||||||
userDirsMap map[string]string
|
userDirsMap map[string]string
|
||||||
appFlowBox *gtk.FlowBox
|
appFlowBox *gtk.FlowBox
|
||||||
appSearchResultWrapper *gtk.Box
|
appSearchResultWrapper *gtk.Box
|
||||||
@@ -100,7 +93,6 @@ var (
|
|||||||
catButtons []*gtk.Button
|
catButtons []*gtk.Button
|
||||||
statusLabel *gtk.Label
|
statusLabel *gtk.Label
|
||||||
status string
|
status string
|
||||||
mainColumnWidth int
|
|
||||||
ignore string
|
ignore string
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -272,7 +264,7 @@ func main() {
|
|||||||
|
|
||||||
// Close the window on leave, but not immediately, to avoid accidental closes
|
// Close the window on leave, but not immediately, to avoid accidental closes
|
||||||
win.Connect("leave-notify-event", func() {
|
win.Connect("leave-notify-event", func() {
|
||||||
src, err = glib.TimeoutAdd(uint(500), func() bool {
|
src = glib.TimeoutAdd(uint(500), func() bool {
|
||||||
gtk.MainQuit()
|
gtk.MainQuit()
|
||||||
return false
|
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) {
|
func createPixbuf(icon string, size int) (*gdk.Pixbuf, error) {
|
||||||
iconTheme, err := gtk.IconThemeGetDefault()
|
iconTheme, err := gtk.IconThemeGetDefault()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -373,9 +364,7 @@ func parseDesktopFiles(desktopFiles []string) string {
|
|||||||
exec = strings.Split(l, "Exec=")[1]
|
exec = strings.Split(l, "Exec=")[1]
|
||||||
disallowed := [2]string{"\"", "'"}
|
disallowed := [2]string{"\"", "'"}
|
||||||
for _, char := range disallowed {
|
for _, char := range disallowed {
|
||||||
if strings.Contains(exec, char) {
|
exec = strings.Replace(exec, char, "", -1)
|
||||||
exec = strings.Replace(exec, char, "", -1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -606,9 +595,7 @@ func launch(command string, terminal bool) {
|
|||||||
// set env variables
|
// set env variables
|
||||||
if len(envVars) > 0 {
|
if len(envVars) > 0 {
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
for _, envVar := range envVars {
|
cmd.Env = append(cmd.Env, envVars...)
|
||||||
cmd.Env = append(cmd.Env, envVar)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := fmt.Sprintf("env vars: %s; command: '%s'; args: %s\n", envVars, elements[cmdIdx], elements[1+cmdIdx:])
|
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 {
|
for _, desktopID := range listCategory {
|
||||||
entry := id2entry[desktopID]
|
entry := id2entry[desktopID]
|
||||||
if entry.NoDisplay == false {
|
if !entry.NoDisplay {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ func searchUserDir(dir string) {
|
|||||||
ignore = userDirsMap[dir]
|
ignore = userDirsMap[dir]
|
||||||
filepath.WalkDir(userDirsMap[dir], walk)
|
filepath.WalkDir(userDirsMap[dir], walk)
|
||||||
|
|
||||||
if fileSearchResults != nil && len(fileSearchResults) > 0 {
|
if len(fileSearchResults) > 0 {
|
||||||
btn := setUpUserDirButton(fmt.Sprintf("folder-%s", dir), "", dir, userDirsMap)
|
btn := setUpUserDirButton(fmt.Sprintf("folder-%s", dir), "", dir, userDirsMap)
|
||||||
fileSearchResultFlowBox.Add(btn)
|
fileSearchResultFlowBox.Add(btn)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user