Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a0213d1886 | |||
| 695ce815d9 | |||
| 01556c1eb0 | |||
| d7410bb88f | |||
| bc63e6d10f | |||
| 0403825c3d | |||
| 0f1bb3fabd | |||
| 78c6842fab | |||
| dc1edbad3a | |||
| 6dd00c5f8f | |||
| e68337886f |
@@ -30,8 +30,6 @@ Photos are found [Here](https://goo.gl/photos/VtBUL6DyZTMidj5n6)
|
|||||||
|
|
||||||
# TODO (Might be in order)
|
# TODO (Might be in order)
|
||||||
1. MAKE IT BETTER
|
1. MAKE IT BETTER
|
||||||
1. Add settings menu
|
|
||||||
1. Add updater for .AppImage files
|
1. Add updater for .AppImage files
|
||||||
1. Download .AppImage files (maybe)
|
1. Download .AppImage files (maybe)
|
||||||
1. Check if all apps are closed when it closes and ask if you want to force stop the apps.
|
1. Check if all apps are closed when it closes and ask if you want to force stop the apps.
|
||||||
1. Portable wine (Should be able to get a working version from PlayOnLinux, but I need to add a check to see if filesystem is EXT as Wine doesn't like filesystems w/o permission control)
|
|
||||||
|
|||||||
@@ -25,10 +25,17 @@ func (a *app) getTreeIter(store *gtk.TreeStore) *gtk.TreeIter {
|
|||||||
store.SetValue(it, 0, a.icon)
|
store.SetValue(it, 0, a.icon)
|
||||||
store.SetValue(it, 1, a.name)
|
store.SetValue(it, 1, a.name)
|
||||||
if len(a.ex) > 1 {
|
if len(a.ex) > 1 {
|
||||||
|
if wine {
|
||||||
for _, v := range a.ex {
|
for _, v := range a.ex {
|
||||||
i := store.Append(it)
|
i := store.Append(it)
|
||||||
store.SetValue(i, 1, v)
|
store.SetValue(i, 1, v)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for _, v := range a.lin {
|
||||||
|
i := store.Append(it)
|
||||||
|
store.SetValue(i, 1, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
@@ -38,7 +45,11 @@ func (a *app) launch() {
|
|||||||
if wine {
|
if wine {
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if !contains(a.lin, a.ex[0]) {
|
if !contains(a.lin, a.ex[0]) {
|
||||||
|
if comEnbld {
|
||||||
|
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; wine \""+a.ex[0]+"\"")
|
||||||
|
} else {
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+a.ex[0]+"\"")
|
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+a.ex[0]+"\"")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if comEnbld {
|
if comEnbld {
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[0]+"\"")
|
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[0]+"\"")
|
||||||
@@ -64,7 +75,11 @@ func (a *app) launch() {
|
|||||||
if wine {
|
if wine {
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if len(a.lin) == 0 {
|
if len(a.lin) == 0 {
|
||||||
|
if comEnbld {
|
||||||
|
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; wine \""+a.ex[0]+"\"")
|
||||||
|
} else {
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+a.ex[0]+"\"")
|
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+a.ex[0]+"\"")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var ind int
|
var ind int
|
||||||
for i, v := range a.lin {
|
for i, v := range a.lin {
|
||||||
@@ -109,7 +124,11 @@ func (a *app) launchSub(sub int) {
|
|||||||
if wine {
|
if wine {
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if !contains(a.lin, a.ex[sub]) {
|
if !contains(a.lin, a.ex[sub]) {
|
||||||
|
if comEnbld {
|
||||||
|
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; wine \""+a.ex[sub]+"\"")
|
||||||
|
} else {
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+a.ex[sub]+"\"")
|
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+a.ex[sub]+"\"")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if comEnbld {
|
if comEnbld {
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
|
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
|
||||||
@@ -120,7 +139,7 @@ func (a *app) launchSub(sub int) {
|
|||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Start()
|
cmd.Start()
|
||||||
}
|
} else {
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if comEnbld {
|
if comEnbld {
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
|
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
|
||||||
@@ -130,179 +149,5 @@ func (a *app) launchSub(sub int) {
|
|||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Start()
|
cmd.Start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// type appExNode struct {
|
|
||||||
// ap app
|
|
||||||
// exInd int
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appExNode) launch() {
|
|
||||||
// if wine {
|
|
||||||
// var cmd *exec.Cmd
|
|
||||||
// if !contains(a.ap.lin, a.ap.ex[a.exInd]) {
|
|
||||||
// cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[a.exInd]+"\"")
|
|
||||||
// } else {
|
|
||||||
// if comEnbld {
|
|
||||||
// cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"")
|
|
||||||
// } else {
|
|
||||||
// cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// cmd.Stdout = os.Stdout
|
|
||||||
// cmd.Stderr = os.Stderr
|
|
||||||
// cmd.Start()
|
|
||||||
// }
|
|
||||||
// var cmd *exec.Cmd
|
|
||||||
// if comEnbld {
|
|
||||||
// cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"")
|
|
||||||
// } else {
|
|
||||||
// cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"")
|
|
||||||
// }
|
|
||||||
// cmd.Stdout = os.Stdout
|
|
||||||
// cmd.Stderr = os.Stderr
|
|
||||||
// cmd.Start()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (a *appExNode) Count() int {
|
|
||||||
// return 0
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appExNode) NodeAt(int) gxui.TreeNode {
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appExNode) ItemIndex(gxui.AdapterItem) int {
|
|
||||||
// return -1
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appExNode) Item() gxui.AdapterItem {
|
|
||||||
// if wine {
|
|
||||||
// return a.ap.ex[a.exInd]
|
|
||||||
// }
|
|
||||||
// return a.ap.lin[a.exInd]
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appExNode) Create(the gxui.Theme) gxui.Control {
|
|
||||||
// box := the.CreateLinearLayout()
|
|
||||||
// box.SetDirection(gxui.LeftToRight)
|
|
||||||
// box.SetVerticalAlignment(gxui.AlignMiddle)
|
|
||||||
// img := the.CreateImage()
|
|
||||||
// img.SetTexture(a.ap.icon)
|
|
||||||
// img.SetExplicitSize(math.Size{H: 32, W: 32})
|
|
||||||
// lbl := the.CreateLabel()
|
|
||||||
// lbl.SetText(a.ap.ex[a.exInd])
|
|
||||||
// box.AddChild(img)
|
|
||||||
// box.AddChild(lbl)
|
|
||||||
// box.OnDoubleClick(func(gxui.MouseEvent) {
|
|
||||||
// a.launch()
|
|
||||||
// })
|
|
||||||
// return box
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (a *appNode) Count() int {
|
|
||||||
// if wine {
|
|
||||||
// if len(a.ex) > 1 {
|
|
||||||
// return len(a.ap.ex)
|
|
||||||
// }
|
|
||||||
// return 0
|
|
||||||
// }
|
|
||||||
// if len(a.ap.lin) > 1 {
|
|
||||||
// return len(a.ap.lin)
|
|
||||||
// }
|
|
||||||
// return 0
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appNode) NodeAt(i int) gxui.TreeNode {
|
|
||||||
// return &appExNode{ap: a.ap, exInd: i}
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appNode) ItemIndex(item gxui.AdapterItem) int {
|
|
||||||
// if wine {
|
|
||||||
// for i, v := range a.ap.ex {
|
|
||||||
// if v == item {
|
|
||||||
// return i
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// for i, v := range a.ap.lin {
|
|
||||||
// if v == item {
|
|
||||||
// return i
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return -1
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appNode) Item() gxui.AdapterItem {
|
|
||||||
// return a.ap.name
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *appNode) Create(the gxui.Theme) gxui.Control {
|
|
||||||
// box := the.CreateLinearLayout()
|
|
||||||
// box.SetDirection(gxui.LeftToRight)
|
|
||||||
// box.SetPadding(math.CreateSpacing(2))
|
|
||||||
// box.SetVerticalAlignment(gxui.AlignMiddle)
|
|
||||||
// img := the.CreateImage()
|
|
||||||
// if a.ap.icon != nil {
|
|
||||||
// img.SetTexture(a.ap.icon)
|
|
||||||
// }
|
|
||||||
// img.SetExplicitSize(math.Size{H: 32, W: 32})
|
|
||||||
// lbl := the.CreateLabel()
|
|
||||||
// lbl.SetText(a.ap.name)
|
|
||||||
// box.AddChild(img)
|
|
||||||
// box.AddChild(lbl)
|
|
||||||
// box.OnDoubleClick(func(gxui.MouseEvent) {
|
|
||||||
// a.launch()
|
|
||||||
// })
|
|
||||||
// return box
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type catAdap struct {
|
|
||||||
// gxui.AdapterBase
|
|
||||||
// cat string
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *catAdap) setCat(cat string) {
|
|
||||||
// a.cat = cat
|
|
||||||
// a.DataChanged(false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *catAdap) refresh() {
|
|
||||||
// a.DataChanged(false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *catAdap) Count() int {
|
|
||||||
// if wine {
|
|
||||||
// return len(master[a.cat])
|
|
||||||
// }
|
|
||||||
// return len(linmaster[a.cat])
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *catAdap) NodeAt(i int) gxui.TreeNode {
|
|
||||||
// if wine {
|
|
||||||
// return &appNode{ap: master[a.cat][i]}
|
|
||||||
// }
|
|
||||||
// return &appNode{ap: linmaster[a.cat][i]}
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *catAdap) Size(gxui.Theme) math.Size {
|
|
||||||
// return math.Size{H: 34, W: math.MaxSize.W}
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func (a *catAdap) ItemIndex(item gxui.AdapterItem) int {
|
|
||||||
// if wine {
|
|
||||||
// for i, v := range master[a.cat] {
|
|
||||||
// if v.name == item {
|
|
||||||
// return i
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// for i, v := range linmaster[a.cat] {
|
|
||||||
// if v.name == item {
|
|
||||||
// return i
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return -1
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package appimg
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
|
func convert(in string) (out []tag) {
|
||||||
|
for i := 0; i < len(in); i++ {
|
||||||
|
v := in[i]
|
||||||
|
if v == '<' {
|
||||||
|
for j := i; j < len(in); j++ {
|
||||||
|
val := in[j]
|
||||||
|
if val == '>' {
|
||||||
|
var tmp tag
|
||||||
|
tmp.process(in[i+1 : j+1])
|
||||||
|
if !tmp.end && tmp.typ == "a" {
|
||||||
|
tmp.index[0] = i
|
||||||
|
tmp.index[1] = j
|
||||||
|
nd := fndend(tmp, in[j+1:])
|
||||||
|
if !reflect.DeepEqual(nd, tag{}) {
|
||||||
|
tmp.Meat = in[j+1 : nd.index[0]]
|
||||||
|
out = append(out, tmp)
|
||||||
|
str := in[tmp.index[1]:nd.index[0]]
|
||||||
|
in = in[:i] + str + in[nd.index[1]+1:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func fndend(fnt tag, area string) tag {
|
||||||
|
var count int
|
||||||
|
for i, v := range area {
|
||||||
|
if v == '<' {
|
||||||
|
for j, val := range area[i:] {
|
||||||
|
if val == '>' {
|
||||||
|
var tmp tag
|
||||||
|
tmp.process(area[i+1 : i+j+1])
|
||||||
|
if tmp.typ == fnt.typ {
|
||||||
|
if tmp.end {
|
||||||
|
if count == 0 {
|
||||||
|
tmp.index[0] = fnt.index[1] + 1 + i
|
||||||
|
tmp.index[1] = fnt.index[1] + j + i + 1
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
count--
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
count++
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tag{}
|
||||||
|
}
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
package appimg
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
type tag struct {
|
||||||
|
typ string
|
||||||
|
end bool
|
||||||
|
params map[string]string
|
||||||
|
index [2]int
|
||||||
|
Meat string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *tag) value(param string) string {
|
||||||
|
return t.params[param]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *tag) setValue(param, value string) {
|
||||||
|
if t.params == nil {
|
||||||
|
t.params = make(map[string]string)
|
||||||
|
}
|
||||||
|
t.params[strings.TrimSpace(strings.ToLower(param))] = strings.TrimSpace(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *tag) process(bbtag string) {
|
||||||
|
if strings.HasPrefix(bbtag, "/") {
|
||||||
|
t.end = true
|
||||||
|
t.typ = strings.ToLower(strings.TrimPrefix(bbtag[:len(bbtag)-1], "/"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i, v := range bbtag {
|
||||||
|
if v == '=' || v == ' ' || v == '>' {
|
||||||
|
t.typ = strings.ToLower(bbtag[:i])
|
||||||
|
switch v {
|
||||||
|
case '=':
|
||||||
|
if qt := bbtag[i+1]; qt == '\'' || qt == '"' {
|
||||||
|
for j := i + 2; j < len(bbtag); j++ {
|
||||||
|
if bbtag[j] == qt {
|
||||||
|
t.setValue("starting", bbtag[i+2:j])
|
||||||
|
bbtag = bbtag[j+1:]
|
||||||
|
break
|
||||||
|
} else if bbtag[j] == '>' {
|
||||||
|
t.setValue("starting", bbtag[i+2:j])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for j := i + 1; j < len(bbtag); j++ {
|
||||||
|
if bbtag[j] == '>' {
|
||||||
|
t.setValue("starting", bbtag[i+1:j])
|
||||||
|
return
|
||||||
|
} else if bbtag[j] == ' ' {
|
||||||
|
t.setValue("starting", bbtag[i+1:j])
|
||||||
|
bbtag = bbtag[j+1:]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case '>':
|
||||||
|
return
|
||||||
|
case ' ':
|
||||||
|
bbtag = bbtag[i:]
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.processFurther(bbtag)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *tag) processFurther(further string) {
|
||||||
|
further = strings.TrimSpace(further)
|
||||||
|
for i := 0; i < len(further); i++ {
|
||||||
|
switch further[i] {
|
||||||
|
case ' ':
|
||||||
|
t.setValue(strings.ToLower(further[:i]), further[:i])
|
||||||
|
further = strings.TrimSpace(further[i:])
|
||||||
|
i = -1
|
||||||
|
case '=':
|
||||||
|
if qt := further[i+1]; qt == '\'' || qt == '"' {
|
||||||
|
outloopqt:
|
||||||
|
for j := i + 2; j < len(further); j++ {
|
||||||
|
switch further[j] {
|
||||||
|
case '>':
|
||||||
|
t.setValue(strings.ToLower(further[:i]), further[i+2:j])
|
||||||
|
return
|
||||||
|
case qt:
|
||||||
|
t.setValue(strings.ToLower(further[:i]), further[i+2:j])
|
||||||
|
further = strings.TrimSpace(further[j+1:])
|
||||||
|
i = -1
|
||||||
|
break outloopqt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
outloop:
|
||||||
|
for j := i + 1; j < len(further); j++ {
|
||||||
|
switch further[j] {
|
||||||
|
case '>':
|
||||||
|
t.setValue(strings.ToLower(further[:i]), further[i+1:j])
|
||||||
|
return
|
||||||
|
case ' ':
|
||||||
|
t.setValue(strings.ToLower(further[:i]), further[i+1:j])
|
||||||
|
further = strings.TrimSpace(further[j:])
|
||||||
|
i = -1
|
||||||
|
break outloop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case '>':
|
||||||
|
if i != 0 {
|
||||||
|
t.setValue(strings.ToLower(further[:i]), further[:i])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package appimg
|
||||||
|
|
||||||
|
type appimg struct {
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newApp(name string) appimg {
|
||||||
|
var out appimg
|
||||||
|
out.name = name
|
||||||
|
return out
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package appimg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gotk3/gotk3/gtk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func downloadApp(parent *gtk.Window, ap appimg) {
|
||||||
|
parent.SetSensitive(false)
|
||||||
|
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||||
|
win.SetTransientFor(parent)
|
||||||
|
win.Connect("destroy", func() {
|
||||||
|
parent.SetSensitive(true)
|
||||||
|
})
|
||||||
|
spn, _ := gtk.SpinnerNew()
|
||||||
|
spn.Start()
|
||||||
|
lbl, _ := gtk.LabelNew("Downloading " + ap.name + "...")
|
||||||
|
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
|
box.SetMarginStart(10)
|
||||||
|
box.SetMarginEnd(10)
|
||||||
|
box.SetMarginTop(10)
|
||||||
|
box.SetMarginBottom(10)
|
||||||
|
box.Add(spn)
|
||||||
|
box.Add(lbl)
|
||||||
|
win.Add(box)
|
||||||
|
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||||
|
win.ShowAll()
|
||||||
|
win.Show()
|
||||||
|
go func(win *gtk.Window, ap appimg) {
|
||||||
|
defer win.Close()
|
||||||
|
check := http.Client{
|
||||||
|
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||||
|
r.URL.Opaque = r.URL.Path
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
resp, err := check.Get(urlBase + ap.name)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
name := strings.Split(ap.name, "-")[0]
|
||||||
|
var foldName string
|
||||||
|
if _, err = os.Open("PortableApps/" + name + "Portable"); err == nil {
|
||||||
|
foldName = "PortableApps/" + name + "Portable"
|
||||||
|
} else if _, err = os.Open("PortableApps/" + name); err == nil {
|
||||||
|
foldName = "PortableApps/" + name
|
||||||
|
} else {
|
||||||
|
os.Mkdir("PortableApps/"+name, 0777)
|
||||||
|
foldName = "PortableApps/" + name
|
||||||
|
}
|
||||||
|
fil, err := os.Create(foldName + "/" + ap.name)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
io.Copy(fil, resp.Body)
|
||||||
|
_ = fil.Chmod(0777)
|
||||||
|
}(win, ap)
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
//Package appimg is for downloading new AppImages for LinuxPA
|
||||||
|
package appimg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gotk3/gotk3/glib"
|
||||||
|
"github.com/gotk3/gotk3/gtk"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
urlBase = "https://dl.bintray.com/probono/AppImages/"
|
||||||
|
)
|
||||||
|
|
||||||
|
//ShowUI shows the list of possible AppImages to be downloaded in a gtk.Window
|
||||||
|
func ShowUI(clsFunc func()) {
|
||||||
|
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||||
|
win.Connect("destroy", func() {
|
||||||
|
clsFunc()
|
||||||
|
})
|
||||||
|
apps := make([]appimg, 0)
|
||||||
|
win.SetSizeRequest(400, 400)
|
||||||
|
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
|
appList, _ := gtk.ListBoxNew()
|
||||||
|
apch := make(chan appimg)
|
||||||
|
appList.SetHExpand(true)
|
||||||
|
appList.SetVExpand(true)
|
||||||
|
vScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||||
|
hScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||||
|
lst, _ := gtk.ScrolledWindowNew(hScrollCat, vScrollCat)
|
||||||
|
lst.SetSizeRequest(170, 500)
|
||||||
|
lst.Add(appList)
|
||||||
|
box.Add(lst)
|
||||||
|
win.Add(box)
|
||||||
|
appList.Connect("row-activated", func() {
|
||||||
|
if appList.GetSelectedRow().GetIndex() >= 0 {
|
||||||
|
downloadApp(win, apps[appList.GetSelectedRow().GetIndex()])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||||
|
win.ShowAll()
|
||||||
|
win.Show()
|
||||||
|
getList(win, apch)
|
||||||
|
go func(win *gtk.Window, apch chan appimg, list *gtk.ListBox) {
|
||||||
|
for i := range apch {
|
||||||
|
glib.IdleAdd(func(list *gtk.ListBox, i appimg) {
|
||||||
|
lbl, _ := gtk.LabelNew(i.name)
|
||||||
|
list.Add(lbl)
|
||||||
|
apps = append(apps, i)
|
||||||
|
lbl.Show()
|
||||||
|
}, list, i)
|
||||||
|
}
|
||||||
|
}(win, apch, appList)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getList(parent *gtk.Window, apch chan appimg) {
|
||||||
|
win, _ := gtk.WindowNew(gtk.WINDOW_POPUP)
|
||||||
|
win.SetTransientFor(parent)
|
||||||
|
win.SetDestroyWithParent(true)
|
||||||
|
win.Connect("destroy", func() {
|
||||||
|
parent.SetSensitive(true)
|
||||||
|
})
|
||||||
|
parent.SetSensitive(false)
|
||||||
|
spin, _ := gtk.SpinnerNew()
|
||||||
|
spin.Start()
|
||||||
|
txt, _ := gtk.LabelNew("Getting List...")
|
||||||
|
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
|
box.SetMarginBottom(10)
|
||||||
|
box.SetMarginEnd(10)
|
||||||
|
box.SetMarginStart(10)
|
||||||
|
box.SetMarginTop(10)
|
||||||
|
box.Add(spin)
|
||||||
|
box.Add(txt)
|
||||||
|
win.Add(box)
|
||||||
|
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||||
|
win.ShowAll()
|
||||||
|
win.Show()
|
||||||
|
go func(win *gtk.Window, apch chan appimg) {
|
||||||
|
check := http.Client{
|
||||||
|
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||||
|
r.URL.Opaque = r.URL.Path
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
resp, err := check.Get(urlBase)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
close(apch)
|
||||||
|
win.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
btys, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
close(apch)
|
||||||
|
win.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tgs := convert(string(btys))
|
||||||
|
for _, v := range tgs {
|
||||||
|
if strings.HasSuffix(strings.ToLower(v.Meat), ".appimage") {
|
||||||
|
apch <- newApp(v.Meat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(apch)
|
||||||
|
win.Close()
|
||||||
|
}(win, apch)
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/gotk3/gotk3/gtk"
|
"github.com/gotk3/gotk3/gtk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "2.0.0.1"
|
version = "2.0.1.0"
|
||||||
defIni = ""
|
defIni = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,10 +21,11 @@ var (
|
|||||||
lin []string
|
lin []string
|
||||||
wine bool
|
wine bool
|
||||||
comEnbld bool
|
comEnbld bool
|
||||||
darkTheme = true
|
wineAvail bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
runtime.GOMAXPROCS(4)
|
||||||
os.MkdirAll("PortableApps/LinuxPACom", 0777)
|
os.MkdirAll("PortableApps/LinuxPACom", 0777)
|
||||||
master = make(map[string][]app)
|
master = make(map[string][]app)
|
||||||
linmaster = make(map[string][]app)
|
linmaster = make(map[string][]app)
|
||||||
@@ -38,6 +41,7 @@ func uiStart() {
|
|||||||
}
|
}
|
||||||
win.SetTitle("LinuxPA")
|
win.SetTitle("LinuxPA")
|
||||||
win.Connect("destroy", func() {
|
win.Connect("destroy", func() {
|
||||||
|
savePrefs()
|
||||||
gtk.MainQuit()
|
gtk.MainQuit()
|
||||||
})
|
})
|
||||||
win.SetDefaultSize(500, 500)
|
win.SetDefaultSize(500, 500)
|
||||||
@@ -49,6 +53,27 @@ func uiStart() {
|
|||||||
gtk.Main()
|
gtk.Main()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func savePrefs() {
|
||||||
|
fil, err := os.Open("PortableApps/LinuxPACom/Prefs.gob")
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
fil, err = os.Create("PortableApps/LinuxPACom/Prefs.gob")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
enc := gob.NewEncoder(fil)
|
||||||
|
enc.Encode(wine)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadPrefs() {
|
||||||
|
fil, err := os.Open("PortableApps/LinuxPACom/Prefs.gob")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dec := gob.NewDecoder(fil)
|
||||||
|
dec.Decode(&wine)
|
||||||
|
}
|
||||||
|
|
||||||
func contains(arr []string, str string) bool {
|
func contains(arr []string, str string) bool {
|
||||||
for _, v := range arr {
|
for _, v := range arr {
|
||||||
if v == str {
|
if v == str {
|
||||||
|
|||||||
+108
@@ -0,0 +1,108 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/gotk3/gotk3/gtk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func settingsUI() {
|
||||||
|
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||||
|
win.SetDefaultSize(600, 300)
|
||||||
|
win.SetPosition(gtk.WIN_POS_CENTER)
|
||||||
|
comTagTbl, _ := gtk.TextTagTableNew()
|
||||||
|
comBuf, _ := gtk.TextBufferNew(comTagTbl)
|
||||||
|
ntbk, _ := gtk.NotebookNew()
|
||||||
|
gnrl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
|
gnrl.SetMarginStart(10)
|
||||||
|
gnrl.SetMarginEnd(10)
|
||||||
|
gnrl.SetMarginTop(10)
|
||||||
|
gnrl.SetMarginBottom(10)
|
||||||
|
dlWine, _ := gtk.ButtonNewWithLabel("Download Wine")
|
||||||
|
wineLbl, _ := gtk.LabelNew("PortableApps/LinuxPACom/Wine present")
|
||||||
|
gnrl.Add(wineLbl)
|
||||||
|
dlWine.Connect("clicked", func() {
|
||||||
|
cb := make(chan bool)
|
||||||
|
downloadWine(win, cb)
|
||||||
|
go func() {
|
||||||
|
v := <-cb
|
||||||
|
if v {
|
||||||
|
setupTxt(comBuf)
|
||||||
|
wineLbl.Show()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
})
|
||||||
|
if !comEnbld {
|
||||||
|
dlWine.SetSensitive(false)
|
||||||
|
dlWine.SetTooltipText("common.sh needed")
|
||||||
|
}
|
||||||
|
gnrl.Add(dlWine)
|
||||||
|
ntbk.AppendPage(gnrl, getLabel("General"))
|
||||||
|
com, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
|
com.SetMarginStart(10)
|
||||||
|
com.SetMarginEnd(10)
|
||||||
|
com.SetMarginTop(10)
|
||||||
|
com.SetMarginBottom(10)
|
||||||
|
comEdit, _ := gtk.TextViewNewWithBuffer(comBuf)
|
||||||
|
comEdit.SetVExpand(true)
|
||||||
|
comEdit.SetHExpand(true)
|
||||||
|
vScroll, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||||
|
hScroll, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||||
|
comScrl, _ := gtk.ScrolledWindowNew(hScroll, vScroll)
|
||||||
|
comScrl.Add(comEdit)
|
||||||
|
com.Add(comScrl)
|
||||||
|
svBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
|
||||||
|
sv, _ := gtk.ButtonNewWithLabel("Save")
|
||||||
|
sv.Connect("clicked", func() {
|
||||||
|
beg, end := comBuf.GetBounds()
|
||||||
|
txt, _ := comBuf.GetText(beg, end, true)
|
||||||
|
ioutil.WriteFile("PortableApps/LinuxPACom/common.sh", []byte(txt), 0777)
|
||||||
|
})
|
||||||
|
cnl, _ := gtk.ButtonNewWithLabel("Cancel")
|
||||||
|
cnl.Connect("clicked", func() {
|
||||||
|
setupTxt(comBuf)
|
||||||
|
})
|
||||||
|
svBox.Add(sv)
|
||||||
|
svBox.Add(cnl)
|
||||||
|
com.Add(svBox)
|
||||||
|
ntbk.AppendPage(com, getLabel("common.sh"))
|
||||||
|
win.Add(ntbk)
|
||||||
|
win.ShowAll()
|
||||||
|
if !comEnbld {
|
||||||
|
comScrl.Hide()
|
||||||
|
svBox.Hide()
|
||||||
|
mkCom, _ := gtk.ButtonNewWithLabel("Create common.sh")
|
||||||
|
mkCom.Connect("clicked", func() {
|
||||||
|
err := ioutil.WriteFile("PortableApps/LinuxPACom/common.sh", []byte("export HOME=$PWD/PortableApps/LinuxPACom/Home"), 0777)
|
||||||
|
if err == nil {
|
||||||
|
mkCom.Hide()
|
||||||
|
comScrl.Show()
|
||||||
|
svBox.Show()
|
||||||
|
setupTxt(comBuf)
|
||||||
|
comEnbld = true
|
||||||
|
dlWine.SetSensitive(true)
|
||||||
|
dlWine.SetTooltipText("")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
mkCom.Show()
|
||||||
|
com.Add(mkCom)
|
||||||
|
} else {
|
||||||
|
setupTxt(comBuf)
|
||||||
|
}
|
||||||
|
if _, err := os.Open("PortableApps/LinuxPACom/Wine"); err != nil && os.IsNotExist(err) {
|
||||||
|
wineLbl.Hide()
|
||||||
|
}
|
||||||
|
win.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupTxt(buf *gtk.TextBuffer) {
|
||||||
|
fil, _ := os.Open("PortableApps/LinuxPACom/common.sh")
|
||||||
|
btys, _ := ioutil.ReadAll(fil)
|
||||||
|
buf.SetText(string(btys))
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLabel(name string) *gtk.Label {
|
||||||
|
lbl, _ := gtk.LabelNew(name)
|
||||||
|
return lbl
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -14,6 +14,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func setup() {
|
func setup() {
|
||||||
|
loadPrefs()
|
||||||
|
if _, err := os.Open("PortableApps/LinuxPACom/Wine"); os.IsNotExist(err) {
|
||||||
|
if _, errd := exec.LookPath("wine"); errd == nil {
|
||||||
|
wineAvail = true
|
||||||
|
}
|
||||||
|
} else if err == nil {
|
||||||
|
wineAvail = true
|
||||||
|
}
|
||||||
|
if !wineAvail {
|
||||||
|
wine = false
|
||||||
|
}
|
||||||
PortableAppsFold, err := os.Open("PortableApps")
|
PortableAppsFold, err := os.Open("PortableApps")
|
||||||
if PAStat, _ := PortableAppsFold.Stat(); err != nil || !PAStat.IsDir() {
|
if PAStat, _ := PortableAppsFold.Stat(); err != nil || !PAStat.IsDir() {
|
||||||
os.Mkdir("PortableApps", 0777)
|
os.Mkdir("PortableApps", 0777)
|
||||||
@@ -25,34 +36,10 @@ func setup() {
|
|||||||
if _, err = os.Open("PortableApps/LinuxPACom"); err != nil {
|
if _, err = os.Open("PortableApps/LinuxPACom"); err != nil {
|
||||||
os.Mkdir("PortableApps/LinuxPACom", 0777)
|
os.Mkdir("PortableApps/LinuxPACom", 0777)
|
||||||
}
|
}
|
||||||
fmt.Println(err)
|
|
||||||
_, err = os.Open("PortableApps/LinuxPACom/common.sh")
|
_, err = os.Open("PortableApps/LinuxPACom/common.sh")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
comEnbld = true
|
comEnbld = true
|
||||||
}
|
}
|
||||||
fi, err := os.Open("PortableApps/LinuxPACom/Info.ini")
|
|
||||||
if err != nil {
|
|
||||||
fi, err = os.Create("PortableApps/LinuxPACom/Info.ini")
|
|
||||||
if err == nil {
|
|
||||||
wrt := bufio.NewWriter(fi)
|
|
||||||
wrt.WriteString(defIni)
|
|
||||||
wrt.Flush()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
rdr := bufio.NewReader(fi)
|
|
||||||
for err != nil {
|
|
||||||
ln, _, error := rdr.ReadLine()
|
|
||||||
err = error
|
|
||||||
str := string(ln)
|
|
||||||
if strings.HasPrefix(str, "theme=") {
|
|
||||||
str = strings.TrimPrefix(str, "theme=")
|
|
||||||
if str == "lt" {
|
|
||||||
darkTheme = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PAFolds, _ := PortableAppsFold.Readdirnames(-1)
|
PAFolds, _ := PortableAppsFold.Readdirnames(-1)
|
||||||
sort.Strings(PAFolds)
|
sort.Strings(PAFolds)
|
||||||
for _, v := range PAFolds {
|
for _, v := range PAFolds {
|
||||||
@@ -135,6 +122,8 @@ func getCat(ini *os.File) string {
|
|||||||
if strings.HasPrefix(string(line), "Category=") {
|
if strings.HasPrefix(string(line), "Category=") {
|
||||||
ret = strings.TrimPrefix(string(line), "Category=")
|
ret = strings.TrimPrefix(string(line), "Category=")
|
||||||
break
|
break
|
||||||
|
} else if strings.HasPrefix(string(line), "category=") {
|
||||||
|
ret = strings.TrimPrefix(string(line), "category=")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rdr.Reset(ini)
|
rdr.Reset(ini)
|
||||||
@@ -148,6 +137,9 @@ func getName(ini *os.File) string {
|
|||||||
if strings.HasPrefix(string(line), "Name=") {
|
if strings.HasPrefix(string(line), "Name=") {
|
||||||
ret = strings.TrimPrefix(string(line), "Name=")
|
ret = strings.TrimPrefix(string(line), "Name=")
|
||||||
break
|
break
|
||||||
|
} else if strings.HasPrefix(string(line), "name=") {
|
||||||
|
ret = strings.TrimPrefix(string(line), "name=")
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rdr.Reset(ini)
|
rdr.Reset(ini)
|
||||||
@@ -178,7 +170,7 @@ func getIcon(fold string) *gdk.Pixbuf {
|
|||||||
pic = fold + "/appicon.png"
|
pic = fold + "/appicon.png"
|
||||||
} else {
|
} else {
|
||||||
img, _ := gtk.ImageNewFromIconName("application-x-executable", gtk.ICON_SIZE_BUTTON)
|
img, _ := gtk.ImageNewFromIconName("application-x-executable", gtk.ICON_SIZE_BUTTON)
|
||||||
buf, _ := img.GetPixbuf().ScaleSimple(32, 32, gdk.INTERP_BILINEAR)
|
buf := img.GetPixbuf()
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
img, _ := gtk.ImageNewFromFile(pic)
|
img, _ := gtk.ImageNewFromFile(pic)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/CalebQ42/LinuxPA/appimg"
|
||||||
"github.com/gotk3/gotk3/glib"
|
"github.com/gotk3/gotk3/glib"
|
||||||
"github.com/gotk3/gotk3/gtk"
|
"github.com/gotk3/gotk3/gtk"
|
||||||
)
|
)
|
||||||
@@ -16,10 +17,13 @@ func ui(win *gtk.Window) {
|
|||||||
header.SetSubtitle("PortableApps.com type launcher")
|
header.SetSubtitle("PortableApps.com type launcher")
|
||||||
settings, _ := gtk.ButtonNewFromIconName("applications-system", gtk.ICON_SIZE_SMALL_TOOLBAR)
|
settings, _ := gtk.ButtonNewFromIconName("applications-system", gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||||
settings.Connect("clicked", func() {
|
settings.Connect("clicked", func() {
|
||||||
//Open Settings window!
|
settingsUI()
|
||||||
})
|
})
|
||||||
settings.SetTooltipText("Settings (Coming Soon!)")
|
settings.SetTooltipText("Settings")
|
||||||
|
dnl, _ := gtk.ButtonNewFromIconName("emblem-downloads", gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||||
|
dnl.SetTooltipText("Download Apps")
|
||||||
header.PackStart(settings)
|
header.PackStart(settings)
|
||||||
|
header.PackEnd(dnl)
|
||||||
win.SetTitlebar(header)
|
win.SetTitlebar(header)
|
||||||
topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
||||||
lrBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
|
lrBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
|
||||||
@@ -33,6 +37,7 @@ func ui(win *gtk.Window) {
|
|||||||
txtColumn, _ := gtk.TreeViewColumnNewWithAttribute("", txtRender, "text", 1)
|
txtColumn, _ := gtk.TreeViewColumnNewWithAttribute("", txtRender, "text", 1)
|
||||||
appsList.AppendColumn(pixColumn)
|
appsList.AppendColumn(pixColumn)
|
||||||
appsList.AppendColumn(txtColumn)
|
appsList.AppendColumn(txtColumn)
|
||||||
|
appsList.SetHeadersVisible(false)
|
||||||
catList.SetHExpand(true)
|
catList.SetHExpand(true)
|
||||||
catList.SetVExpand(true)
|
catList.SetVExpand(true)
|
||||||
appsList.SetHExpand(true)
|
appsList.SetHExpand(true)
|
||||||
@@ -43,16 +48,24 @@ func ui(win *gtk.Window) {
|
|||||||
hScrollApp, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
hScrollApp, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||||
catScrl, _ := gtk.ScrolledWindowNew(hScrollCat, vScrollCat)
|
catScrl, _ := gtk.ScrolledWindowNew(hScrollCat, vScrollCat)
|
||||||
catScrl.Add(catList)
|
catScrl.Add(catList)
|
||||||
|
catScrl.SetSizeRequest(170, 500)
|
||||||
appScrl, _ := gtk.ScrolledWindowNew(hScrollApp, vScrollApp)
|
appScrl, _ := gtk.ScrolledWindowNew(hScrollApp, vScrollApp)
|
||||||
appScrl.Add(appsList)
|
appScrl.Add(appsList)
|
||||||
|
appScrl.SetSizeRequest(300, 500)
|
||||||
lrBox.Add(catScrl)
|
lrBox.Add(catScrl)
|
||||||
lrBox.Add(appScrl)
|
lrBox.Add(appScrl)
|
||||||
botBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 2)
|
botBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 2)
|
||||||
wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)")
|
wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)")
|
||||||
|
if !wineAvail {
|
||||||
|
wineCheck.SetSensitive(false)
|
||||||
|
wineCheck.SetTooltipText("Download wine to run windows apps")
|
||||||
|
}
|
||||||
|
wineCheck.SetActive(wine)
|
||||||
wineCheck.Connect("toggled", func() {
|
wineCheck.Connect("toggled", func() {
|
||||||
wine = wineCheck.GetActive()
|
wine = wineCheck.GetActive()
|
||||||
for i := range ls {
|
for i := range ls {
|
||||||
catList.Remove(catList.GetRowAtIndex(i))
|
fmt.Println(len(ls) - i)
|
||||||
|
catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1))
|
||||||
}
|
}
|
||||||
ls = getCatRows()
|
ls = getCatRows()
|
||||||
for _, v := range ls {
|
for _, v := range ls {
|
||||||
@@ -65,7 +78,7 @@ func ui(win *gtk.Window) {
|
|||||||
topLvl.PackEnd(botBox, false, true, 0)
|
topLvl.PackEnd(botBox, false, true, 0)
|
||||||
win.Add(topLvl)
|
win.Add(topLvl)
|
||||||
for _, v := range ls {
|
for _, v := range ls {
|
||||||
catList.Prepend(v)
|
catList.Add(v)
|
||||||
}
|
}
|
||||||
catList.Connect("row-selected", func() {
|
catList.Connect("row-selected", func() {
|
||||||
store.Clear()
|
store.Clear()
|
||||||
@@ -109,6 +122,15 @@ func ui(win *gtk.Window) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
dnl.Connect("clicked", func() {
|
||||||
|
appimg.ShowUI(func() {
|
||||||
|
store.Clear()
|
||||||
|
ls = getCatRows()
|
||||||
|
for _, v := range ls {
|
||||||
|
catList.Add(v)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCatRows() (out []*gtk.Label) {
|
func getCatRows() (out []*gtk.Label) {
|
||||||
@@ -116,13 +138,11 @@ func getCatRows() (out []*gtk.Label) {
|
|||||||
for _, v := range cats {
|
for _, v := range cats {
|
||||||
txt, _ := gtk.LabelNew(v)
|
txt, _ := gtk.LabelNew(v)
|
||||||
out = append(out, txt)
|
out = append(out, txt)
|
||||||
fmt.Println(v)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, v := range lin {
|
for _, v := range lin {
|
||||||
txt, _ := gtk.LabelNew(v)
|
txt, _ := gtk.LabelNew(v)
|
||||||
out = append(out, txt)
|
out = append(out, txt)
|
||||||
fmt.Println(v)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func downloadUpdate(newVersion string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func update(win *gtk.Window) {
|
func update(win *gtk.Window) {
|
||||||
updateWin, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
updateWin, _ := gtk.WindowNew(gtk.WINDOW_POPUP)
|
||||||
updateWin.SetTransientFor(win)
|
updateWin.SetTransientFor(win)
|
||||||
topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
spin, _ := gtk.SpinnerNew()
|
spin, _ := gtk.SpinnerNew()
|
||||||
@@ -129,6 +129,7 @@ func update(win *gtk.Window) {
|
|||||||
updateWin.ShowAll()
|
updateWin.ShowAll()
|
||||||
updateWin.Show()
|
updateWin.Show()
|
||||||
go func(win, updateWin *gtk.Window) {
|
go func(win, updateWin *gtk.Window) {
|
||||||
|
defer updateWin.Close()
|
||||||
stat, err := versionDL()
|
stat, err := versionDL()
|
||||||
if stat {
|
if stat {
|
||||||
res := getVersionFileInfo()
|
res := getVersionFileInfo()
|
||||||
@@ -137,7 +138,6 @@ func update(win *gtk.Window) {
|
|||||||
if stat {
|
if stat {
|
||||||
lbl.SetText("Updating!")
|
lbl.SetText("Updating!")
|
||||||
downloadUpdate(res)
|
downloadUpdate(res)
|
||||||
updateWin.Close()
|
|
||||||
win.Close()
|
win.Close()
|
||||||
cmd := exec.Command("./LinuxPA")
|
cmd := exec.Command("./LinuxPA")
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
@@ -145,15 +145,12 @@ func update(win *gtk.Window) {
|
|||||||
cmd.Start()
|
cmd.Start()
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
updateWin.Close()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Failed Version File Info")
|
fmt.Println("Failed Version File Info")
|
||||||
updateWin.Close()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
updateWin.Close()
|
|
||||||
}
|
}
|
||||||
}(win, updateWin)
|
}(win, updateWin)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gotk3/gotk3/gtk"
|
||||||
"github.com/mholt/archiver"
|
"github.com/mholt/archiver"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,12 +16,36 @@ const (
|
|||||||
wineURL = "https://www.playonlinux.com/wine/binaries/linux-amd64/PlayOnLinux-wine-2.5-linux-amd64.pol"
|
wineURL = "https://www.playonlinux.com/wine/binaries/linux-amd64/PlayOnLinux-wine-2.5-linux-amd64.pol"
|
||||||
)
|
)
|
||||||
|
|
||||||
func downloadWine() (bool, error) {
|
func downloadWine(parent *gtk.Window, cb chan bool) {
|
||||||
|
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||||
|
win.SetTransientFor(parent)
|
||||||
|
win.SetDestroyWithParent(true)
|
||||||
|
win.Connect("destroy", func() {
|
||||||
|
parent.SetSensitive(true)
|
||||||
|
})
|
||||||
|
parent.SetSensitive(false)
|
||||||
|
spin, _ := gtk.SpinnerNew()
|
||||||
|
spin.Start()
|
||||||
|
txt, _ := gtk.LabelNew("Downloading Wine")
|
||||||
|
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||||
|
box.SetMarginBottom(10)
|
||||||
|
box.SetMarginEnd(10)
|
||||||
|
box.SetMarginStart(10)
|
||||||
|
box.SetMarginTop(10)
|
||||||
|
box.Add(spin)
|
||||||
|
box.Add(txt)
|
||||||
|
win.Add(box)
|
||||||
|
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||||
|
win.ShowAll()
|
||||||
|
win.Show()
|
||||||
|
go func(win *gtk.Window, txt *gtk.Label) {
|
||||||
|
defer win.Close()
|
||||||
wineTar, err := os.Create("PortableApps/LinuxPACom/wine2.5.tar.bz2")
|
wineTar, err := os.Create("PortableApps/LinuxPACom/wine2.5.tar.bz2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
}
|
}
|
||||||
wineTar.Chmod(0777)
|
|
||||||
defer wineTar.Close()
|
defer wineTar.Close()
|
||||||
check := http.Client{
|
check := http.Client{
|
||||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||||
@@ -27,16 +55,47 @@ func downloadWine() (bool, error) {
|
|||||||
}
|
}
|
||||||
resp, err := check.Get(wineURL)
|
resp, err := check.Get(wineURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
os.RemoveAll("PortableApps/LinuxPACom/Wine")
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
_, err = io.Copy(wineTar, resp.Body)
|
_, err = io.Copy(wineTar, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
txt.SetText("Extracting Wine")
|
||||||
err = archiver.TarBz2.Open("PortableApps/LinuxPACom/wine2.5.tar.bz2", "PortableApps/LinuxPACom/Wine")
|
err = archiver.TarBz2.Open("PortableApps/LinuxPACom/wine2.5.tar.bz2", "PortableApps/LinuxPACom/Wine")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return true, nil
|
fil, err := os.Open("PortableApps/LinuxPACom/common.sh")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tmp, err := ioutil.ReadAll(fil)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !strings.Contains(string(tmp), "export PATH=$PWD/PortableApps/LinuxPACom/Wine/wineversion/2.5/bin:$PATH") {
|
||||||
|
tmp = append(tmp, []byte("\nexport PATH=$PWD/PortableApps/LinuxPACom/Wine/wineversion/2.5/bin:$PATH")...)
|
||||||
|
ioutil.WriteFile("PortableApps/LinuxPACom/common.sh", tmp, 0777)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
cb <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb <- true
|
||||||
|
return
|
||||||
|
}(win, txt)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user