First rendition of wine support (needs some work still)
This commit is contained in:
@@ -24,6 +24,7 @@ type prtap struct {
|
|||||||
cat string
|
cat string
|
||||||
ex string
|
ex string
|
||||||
desc string
|
desc string
|
||||||
|
wine bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -116,6 +117,18 @@ func processApp(fi *os.File) (out prtap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, v := range fis {
|
||||||
|
fil, err := os.Open(wd + "/" + fi.Name() + "/" + v.Name())
|
||||||
|
if err == nil {
|
||||||
|
stat, _ := fil.Stat()
|
||||||
|
if !stat.IsDir() && strings.HasSuffix(stat.Name(), "exe") {
|
||||||
|
out.wine = true
|
||||||
|
out.ex = wd + "/" + fi.Name() + "/" + v.Name()
|
||||||
|
out.name += " (Wine)"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return prtap{}
|
return prtap{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-7
@@ -15,16 +15,39 @@ import (
|
|||||||
|
|
||||||
type prtapAdap struct {
|
type prtapAdap struct {
|
||||||
gxui.AdapterBase
|
gxui.AdapterBase
|
||||||
apps []prtap
|
wine bool
|
||||||
|
master []prtap
|
||||||
|
cur []prtap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prtapAdap) SetApps(apps []prtap) {
|
func (p *prtapAdap) SetApps(apps []prtap) {
|
||||||
p.apps = apps
|
p.master = apps
|
||||||
|
if p.wine {
|
||||||
|
p.cur = p.master
|
||||||
|
} else {
|
||||||
|
p.cur = make([]prtap, 0)
|
||||||
|
for _, v := range p.master {
|
||||||
|
p.cur = append(p.cur, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
p.DataChanged(false)
|
p.DataChanged(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prtapAdap) Count() int {
|
func (p *prtapAdap) Count() int {
|
||||||
return len(p.apps)
|
return len(p.cur)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *prtapAdap) Wine(show bool) {
|
||||||
|
p.wine = show
|
||||||
|
if show {
|
||||||
|
p.cur = p.master
|
||||||
|
} else {
|
||||||
|
p.cur = make([]prtap, 0)
|
||||||
|
for _, v := range p.master {
|
||||||
|
p.cur = append(p.cur, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.DataChanged(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prtapAdap) Create(th gxui.Theme, index int) gxui.Control {
|
func (p *prtapAdap) Create(th gxui.Theme, index int) gxui.Control {
|
||||||
@@ -32,7 +55,7 @@ func (p *prtapAdap) Create(th gxui.Theme, index int) gxui.Control {
|
|||||||
box.SetPadding(math.CreateSpacing(2))
|
box.SetPadding(math.CreateSpacing(2))
|
||||||
box.SetDirection(gxui.LeftToRight)
|
box.SetDirection(gxui.LeftToRight)
|
||||||
box.SetVerticalAlignment(gxui.AlignMiddle)
|
box.SetVerticalAlignment(gxui.AlignMiddle)
|
||||||
dir := path.Dir(p.apps[index].ex)
|
dir := path.Dir(p.cur[index].ex)
|
||||||
if fold, err := os.Open(dir + "/App/AppInfo"); err == nil {
|
if fold, err := os.Open(dir + "/App/AppInfo"); err == nil {
|
||||||
var pics []string
|
var pics []string
|
||||||
fi, _ := fold.Readdirnames(-1)
|
fi, _ := fold.Readdirnames(-1)
|
||||||
@@ -76,13 +99,13 @@ func (p *prtapAdap) Create(th gxui.Theme, index int) gxui.Control {
|
|||||||
box.AddChild(icon)
|
box.AddChild(icon)
|
||||||
}
|
}
|
||||||
lbl := th.CreateLabel()
|
lbl := th.CreateLabel()
|
||||||
lbl.SetText(p.apps[index].name)
|
lbl.SetText(p.cur[index].name)
|
||||||
box.AddChild(lbl)
|
box.AddChild(lbl)
|
||||||
return box
|
return box
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prtapAdap) ItemAt(index int) gxui.AdapterItem {
|
func (p *prtapAdap) ItemAt(index int) gxui.AdapterItem {
|
||||||
return p.apps[index]
|
return p.cur[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prtapAdap) ItemIndex(item gxui.AdapterItem) int {
|
func (p *prtapAdap) ItemIndex(item gxui.AdapterItem) int {
|
||||||
@@ -90,7 +113,7 @@ func (p *prtapAdap) ItemIndex(item gxui.AdapterItem) int {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
for i, v := range p.apps {
|
for i, v := range p.cur {
|
||||||
if v == it {
|
if v == it {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,17 +44,33 @@ func uiMain(dri gxui.Driver) {
|
|||||||
app := applist.Selected().(prtap)
|
app := applist.Selected().(prtap)
|
||||||
dir, fi := path.Split(app.ex)
|
dir, fi := path.Split(app.ex)
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if commEnbl {
|
if app.wine {
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". "+common+" || exit 1;cd \""+dir+"\"; \"./"+fi+"\"")
|
cmd = exec.Command("/bin/sh", "-c", "cd \""+dir+"\"; wine \""+fi+"\"")
|
||||||
} else {
|
} else {
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+dir+"\"; \"./"+fi+"\"")
|
if commEnbl {
|
||||||
|
cmd = exec.Command("/bin/sh", "-c", ". "+common+" || exit 1;cd \""+dir+"\"; \"./"+fi+"\"")
|
||||||
|
} else {
|
||||||
|
cmd = exec.Command("/bin/sh", "-c", "cd \""+dir+"\"; \"./"+fi+"\"")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
go cmd.Run()
|
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)
|
||||||
but.AddChild(launch)
|
but.AddChild(launch)
|
||||||
top.AddChild(but)
|
top.AddChild(but)
|
||||||
top.AddChild(spl)
|
top.AddChild(spl)
|
||||||
|
|||||||
Reference in New Issue
Block a user