diff --git a/README.md b/README.md index 7cb3f8a..f5558bc 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ Photos are found [Here](https://goo.gl/photos/VtBUL6DyZTMidj5n6) # TODO (Might be in order) 1. MAKE IT BETTER -1. Launching of .exe files via wine (wine will have to be installed on the host system, unless there is some portable wine (I may have found one)) 1. Add settings menu 1. Add updater for .AppImage files 1. Download .AppImage files (maybe) diff --git a/main.go b/main.go index 2d26e22..203fa7e 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,8 @@ import ( var ( appMaster map[string][]prtap cats []string + wineOnly []string + linOnly []string conf *os.File common string commEnbl bool @@ -44,7 +46,7 @@ func main() { appstmp, _ := pa.Readdir(-1) var folds []string for _, v := range appstmp { - if v.IsDir() && v.Name() != "LinuxPACom" { + if v.IsDir() && v.Name() != "LinuxPACom" && v.Name() != "PortableApps.com" { folds = append(folds, v.Name()) } } @@ -54,11 +56,29 @@ func main() { pat := processApp(fi) if (pat != prtap{}) { if _, ok := appMaster[pat.cat]; !ok { - cats = append(cats, pat.cat) + if pat.wine { + wineOnly = append(wineOnly, pat.cat) + cats = append(cats, pat.cat) + } else { + linOnly = append(linOnly, pat.cat) + cats = append(cats, pat.cat) + } + } else { + if !pat.wine { + for i, v := range wineOnly { + if pat.cat == v { + wineOnly = append(wineOnly[:i], wineOnly[i+1:]...) + break + } + } + } } appMaster[pat.cat] = append(appMaster[pat.cat], pat) } } + sort.Strings(linOnly) + sort.Strings(wineOnly) + sort.Strings(cats) gl.StartDriver(uiMain) } @@ -73,13 +93,13 @@ func processApp(fi *os.File) (out prtap) { fil, _ = os.Open(fi.Name() + "/appinfo.ini") out.cat = getCat(fil) } else { - out.cat = "other" + out.cat = "Other" } if out.name == "" { out.name = path.Base(fi.Name()) } if out.cat == "" { - out.cat = "other" + out.cat = "Other" } //executable detection wd, _ := os.Getwd() diff --git a/prtapAdap.go b/prtapAdap.go index 957d367..400a9a9 100644 --- a/prtapAdap.go +++ b/prtapAdap.go @@ -27,7 +27,9 @@ func (p *prtapAdap) SetApps(apps []prtap) { } else { p.cur = make([]prtap, 0) for _, v := range p.master { - p.cur = append(p.cur, v) + if !v.wine { + p.cur = append(p.cur, v) + } } } p.DataChanged(false) @@ -44,7 +46,9 @@ func (p *prtapAdap) Wine(show bool) { } else { p.cur = make([]prtap, 0) for _, v := range p.master { - p.cur = append(p.cur, v) + if !v.wine { + p.cur = append(p.cur, v) + } } } p.DataChanged(false) diff --git a/ui.go b/ui.go index abedd07..b0f8768 100644 --- a/ui.go +++ b/ui.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "os/exec" "path" @@ -16,8 +17,9 @@ var ( func uiMain(dri gxui.Driver) { dr = dri catAdap := &StrList{} - catAdap.SetStrings(cats) + catAdap.SetStrings(linOnly) appAdap := &prtapAdap{} + appAdap.Wine(false) th := dark.CreateTheme(dr) win := th.CreateWindow(500, 500, "LinuxPA") top := th.CreateLinearLayout() @@ -59,18 +61,25 @@ func uiMain(dri gxui.Driver) { cmd.Start() } }) - wine := th.CreateButton() - wine.SetType(gxui.ToggleButton) - wine.OnClick(func(gxui.MouseEvent) { - if wine.IsChecked() { - appAdap.Wine(true) - } else { - appAdap.Wine(false) - } - }) - wine.SetText("Show Windows apps") - wine.SetChecked(appAdap.wine) - but.AddChild(wine) + if _, err := exec.LookPath("wine"); err == nil { + fmt.Println("Wine found!") + wine := th.CreateButton() + wine.SetType(gxui.ToggleButton) + wine.OnClick(func(gxui.MouseEvent) { + if wine.IsChecked() { + catAdap.SetStrings(cats) + appAdap.Wine(true) + } else { + catAdap.SetStrings(linOnly) + appAdap.Wine(false) + } + }) + wine.SetText("Show Windows Apps") + wine.SetChecked(appAdap.wine) + but.AddChild(wine) + } else { + fmt.Println("Wine not found!") + } but.AddChild(launch) top.AddChild(but) top.AddChild(spl)