11 Commits

Author SHA1 Message Date
Belac Darkstorm ea91d3cd80 Bumping version number 2017-04-11 00:18:23 -05:00
Belac Darkstorm 2a0d53db09 Edit and some bugs 2017-04-11 00:18:00 -05:00
Belac Darkstorm a0213d1886 Finished up downloading 2017-04-09 01:44:02 -05:00
Belac Darkstorm 695ce815d9 Nearly done with download :) 2017-04-09 01:26:31 -05:00
Belac Darkstorm 01556c1eb0 Getting ready for AppImage downloading 2017-04-08 20:06:50 -05:00
Belac Darkstorm d7410bb88f Got things back to normal with a couple bug fixes 2017-04-06 09:26:21 -05:00
Belac Darkstorm bc63e6d10f Revert "Tried some stuff that I didn't like"
This reverts commit 78c6842fab.
2017-04-06 09:23:10 -05:00
Belac Darkstorm 0403825c3d Doing some stuff 2017-04-06 09:20:00 -05:00
Belac Darkstorm 0f1bb3fabd Updated README 2017-04-06 09:00:09 -05:00
Belac Darkstorm 78c6842fab Tried some stuff that I didn't like
Revert "Jasdfasdf"

This reverts commit dc1edbad3a.
2017-04-06 08:47:11 -05:00
Belac Darkstorm dc1edbad3a Jasdfasdf 2017-04-06 08:46:39 -05:00
11 changed files with 648 additions and 227 deletions
-2
View File
@@ -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)
+160 -187
View File
@@ -1,6 +1,8 @@
package main package main
import ( import (
"bufio"
"fmt"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
@@ -25,9 +27,16 @@ 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 {
for _, v := range a.ex { if wine {
i := store.Append(it) for _, v := range a.ex {
store.SetValue(i, 1, v) i := store.Append(it)
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 +47,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]) {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+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]+"\"")
}
} 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 +77,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 {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+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]+"\"")
}
} else { } else {
var ind int var ind int
for i, v := range a.lin { for i, v := range a.lin {
@@ -109,7 +126,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]) {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; wine \""+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]+"\"")
}
} 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,189 +141,141 @@ 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()
}
var cmd *exec.Cmd
if comEnbld {
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
} else { } else {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"") var cmd *exec.Cmd
if comEnbld {
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
} else {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.dir+"\"; \"./"+a.ex[sub]+"\"")
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Start()
} }
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Start()
} }
// type appExNode struct { func (a *app) edit(parent *gtk.Window, reload func()) {
// ap app tmp := *a
// exInd int parent.SetSensitive(false)
// } win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
// win.Connect("destroy", func() {
// func (a *appExNode) launch() { master = make(map[string][]app)
// if wine { linmaster = make(map[string][]app)
// var cmd *exec.Cmd cats = make([]string, 0)
// if !contains(a.ap.lin, a.ap.ex[a.exInd]) { lin = make([]string, 0)
// cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[a.exInd]+"\"") setup()
// } else { reload()
// if comEnbld { parent.SetSensitive(true)
// cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"") })
// } else { win.SetDefaultSize(400, 135)
// cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"") topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
// } topLvl.SetMarginStart(10)
// } topLvl.SetMarginEnd(10)
// cmd.Stdout = os.Stdout topLvl.SetMarginTop(10)
// cmd.Stderr = os.Stderr topLvl.SetMarginBottom(10)
// cmd.Start() top, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
// } img, _ := gtk.ImageNewFromPixbuf(a.icon)
// var cmd *exec.Cmd imgBut, _ := gtk.ButtonNew()
// if comEnbld { imgBut.SetImage(img)
// cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"") imgBut.SetSizeRequest(100, 100)
// } else { imgBut.Connect("clicked", func() {
// cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[a.exInd]+"\"") fil, _ := gtk.FileChooserDialogNewWith2Buttons("Select Icon", win, gtk.FILE_CHOOSER_ACTION_OPEN, "Cancel", gtk.RESPONSE_CANCEL, "Open", gtk.RESPONSE_ACCEPT)
// } filter, _ := gtk.FileFilterNew()
// cmd.Stdout = os.Stdout filter.AddPixbufFormats()
// cmd.Stderr = os.Stderr filter.SetName("Supported Pictures")
// cmd.Start() fil.AddFilter(filter)
// } resp := fil.Run()
if resp == int(gtk.RESPONSE_ACCEPT) {
filename := fil.GetFilename()
_, err := os.Open(filename)
if err != nil {
fmt.Println(err)
return
}
pix, _ := gdk.PixbufNewFromFileAtSize(filename, 32, 32)
tmp.icon = pix
img.SetFromPixbuf(pix)
fil.Close()
}
})
topRt, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
nameLbl, _ := gtk.LabelNew("Name:")
nameLbl.SetHAlign(gtk.ALIGN_START)
txtgtbl, _ := gtk.TextTagTableNew()
txtBuf, _ := gtk.TextBufferNew(txtgtbl)
nameTxt, _ := gtk.TextViewNewWithBuffer(txtBuf)
nameTxt.SetAcceptsTab(false)
nameTxt.SetWrapMode(gtk.WRAP_CHAR)
nameTxt.SetPixelsBelowLines(5)
nameTxt.SetHExpand(true)
nameTxt.SetVExpand(false)
nameTxt.SetBorderWindowSize(gtk.TEXT_WINDOW_BOTTOM, 5)
txtBuf.SetText(tmp.name)
vScrollName, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
hScrollName, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
nameScr, _ := gtk.ScrolledWindowNew(hScrollName, vScrollName)
nameScr.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
nameScr.SetSizeRequest(300, 25)
nameScr.SetVExpand(false)
nameScr.Add(nameTxt)
catLbl, _ := gtk.LabelNew("Category:")
catLbl.SetHAlign(gtk.ALIGN_START)
catTbl, _ := gtk.TextTagTableNew()
catBuf, _ := gtk.TextBufferNew(catTbl)
catTxt, _ := gtk.TextViewNewWithBuffer(catBuf)
catBuf.SetText(tmp.cat)
catTxt.SetAcceptsTab(false)
catTxt.SetWrapMode(gtk.WRAP_CHAR)
catTxt.SetPixelsBelowLines(5)
catTxt.SetHExpand(true)
catTxt.SetVExpand(false)
catTxt.SetBorderWindowSize(gtk.TEXT_WINDOW_BOTTOM, 5)
vScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
hScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
catScr, _ := gtk.ScrolledWindowNew(hScrollCat, vScrollCat)
catScr.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
catScr.SetSizeRequest(300, 25)
catScr.SetVExpand(false)
catScr.Add(catTxt)
topRt.Add(nameLbl)
topRt.Add(nameScr)
topRt.Add(catLbl)
topRt.Add(catScr)
top.Add(imgBut)
top.Add(topRt)
bot, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
sv, _ := gtk.ButtonNewWithLabel("Save")
sv.Connect("clicked", func() {
tmp.name, _ = txtBuf.GetText(txtBuf.GetStartIter(), txtBuf.GetEndIter(), true)
tmp.cat, _ = catBuf.GetText(catBuf.GetStartIter(), catBuf.GetEndIter(), true)
tmp.makeIni()
os.Remove(a.dir + "/appicon.png")
tmp.icon.SavePNG(a.dir+"/appicon.png", 0)
win.Close()
})
cnl, _ := gtk.ButtonNewWithLabel("Cancel")
cnl.Connect("clicked", func() {
win.Close()
})
bot.PackEnd(sv, false, false, 0)
bot.PackEnd(cnl, false, false, 0)
topLvl.Add(top)
topLvl.Add(bot)
win.Add(topLvl)
win.ShowAll()
win.Show()
}
// func (a *appExNode) Count() int { func (a *app) makeIni() {
// return 0 os.Remove(a.dir + "/appinfo.ini")
// } fil, err := os.Create(a.dir + "/appinfo.ini")
// if err != nil {
// func (a *appExNode) NodeAt(int) gxui.TreeNode { return
// return nil }
// } ini := "[General]\n"
// ini += "Category=" + a.cat + "\n"
// func (a *appExNode) ItemIndex(gxui.AdapterItem) int { ini += "Name=" + a.name + "\n"
// return -1 wrt := bufio.NewWriter(fil)
// } wrt.WriteString(ini)
// wrt.Flush()
// 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
// }
+60
View File
@@ -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
View File
@@ -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
}
}
}
+11
View File
@@ -0,0 +1,11 @@
package appimg
type appimg struct {
name string
}
func newApp(name string) appimg {
var out appimg
out.name = name
return out
}
+66
View File
@@ -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)
}
+112
View File
@@ -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)
}
+24 -2
View File
@@ -1,6 +1,7 @@
package main package main
import ( import (
"encoding/gob"
"fmt" "fmt"
"os" "os"
@@ -8,7 +9,7 @@ import (
) )
const ( const (
version = "2.0.1.0" version = "2.1.0.5"
defIni = "" defIni = ""
) )
@@ -20,7 +21,6 @@ var (
wine bool wine bool
comEnbld bool comEnbld bool
wineAvail bool wineAvail bool
showMsg = true
) )
func main() { func main() {
@@ -39,6 +39,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)
@@ -50,6 +51,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 {
+16 -13
View File
@@ -2,7 +2,6 @@ package main
import ( import (
"bufio" "bufio"
"fmt"
_ "image/png" _ "image/png"
"os" "os"
"os/exec" "os/exec"
@@ -15,6 +14,7 @@ import (
) )
func setup() { func setup() {
loadPrefs()
if _, err := os.Open("PortableApps/LinuxPACom/Wine"); os.IsNotExist(err) { if _, err := os.Open("PortableApps/LinuxPACom/Wine"); os.IsNotExist(err) {
if _, errd := exec.LookPath("wine"); errd == nil { if _, errd := exec.LookPath("wine"); errd == nil {
wineAvail = true wineAvail = true
@@ -22,6 +22,9 @@ func setup() {
} else if err == nil { } else if err == nil {
wineAvail = true 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)
@@ -33,15 +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
} }
_, err = os.Open("PortableApps/LinuxPACom/Info.ini")
if err != nil {
os.Create("PortableApps/LinuxPACom/Info.ini")
}
PAFolds, _ := PortableAppsFold.Readdirnames(-1) PAFolds, _ := PortableAppsFold.Readdirnames(-1)
sort.Strings(PAFolds) sort.Strings(PAFolds)
for _, v := range PAFolds { for _, v := range PAFolds {
@@ -124,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)
@@ -137,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)
@@ -145,7 +148,9 @@ func getName(ini *os.File) string {
func getIcon(fold string) *gdk.Pixbuf { func getIcon(fold string) *gdk.Pixbuf {
var pic string var pic string
if folder, err := os.Open(fold + "/App/AppInfo"); err == nil { if _, err := os.Open(fold + "/appicon.png"); err == nil {
pic = fold + "/appicon.png"
} else if folder, err := os.Open(fold + "/App/AppInfo"); err == nil {
fis, _ := folder.Readdir(-1) fis, _ := folder.Readdir(-1)
var pics []string var pics []string
for _, v := range fis { for _, v := range fis {
@@ -163,11 +168,9 @@ func getIcon(fold string) *gdk.Pixbuf {
} }
pic = fold + "/App/AppInfo/" + pics[ind] pic = fold + "/App/AppInfo/" + pics[ind]
} }
} else if _, err := os.Open(fold + "/appicon.png"); err == nil {
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)
@@ -176,6 +179,9 @@ func getIcon(fold string) *gdk.Pixbuf {
} }
func findInfo(fold string) *os.File { func findInfo(fold string) *os.File {
if fi, err := os.Open(fold + "/appinfo.ini"); err == nil {
return fi
}
tmp, err := os.Open(fold + "/App/AppInfo") tmp, err := os.Open(fold + "/App/AppInfo")
if err == nil { if err == nil {
fis, _ := tmp.Readdirnames(-1) fis, _ := tmp.Readdirnames(-1)
@@ -186,8 +192,5 @@ func findInfo(fold string) *os.File {
} }
} }
} }
if fi, err := os.Open(fold + "/appinfo.ini"); err == nil {
return fi
}
return nil return nil
} }
+76 -15
View File
@@ -1,8 +1,7 @@
package main package main
import ( import (
"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"
) )
@@ -18,8 +17,11 @@ func ui(win *gtk.Window) {
settings.Connect("clicked", func() { settings.Connect("clicked", func() {
settingsUI() 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)
@@ -51,15 +53,21 @@ func ui(win *gtk.Window) {
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)
botBox.SetMarginStart(10)
botBox.SetMarginEnd(10)
botBox.SetMarginTop(10)
botBox.SetMarginBottom(10)
wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)") wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)")
if !wineAvail { if !wineAvail {
wineCheck.SetSensitive(false) wineCheck.SetSensitive(false)
wineCheck.SetTooltipText("Download wine to run windows apps") 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()
store.Clear()
for i := range ls { for i := range ls {
catList.Remove(catList.GetRowAtIndex(i)) catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1))
} }
ls = getCatRows() ls = getCatRows()
for _, v := range ls { for _, v := range ls {
@@ -67,12 +75,49 @@ func ui(win *gtk.Window) {
} }
catList.ShowAll() catList.ShowAll()
}) })
edit, _ := gtk.ButtonNewWithLabel("Edit App..")
edit.Connect("clicked", func() {
selec, _ := appsList.GetSelection()
_, it, ok := selec.GetSelected()
if ok {
pth, _ := store.GetPath(it)
ind := pth.GetIndices()
if wine {
appLnch := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]]
appLnch.edit(win, func() {
store.Clear()
for i := range ls {
catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1))
}
ls = getCatRows()
for i, v := range ls {
catList.Insert(v, i)
}
catList.ShowAll()
})
} else {
appLnch := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]]
appLnch.edit(win, func() {
store.Clear()
for i := range ls {
catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1))
}
ls = getCatRows()
for i, v := range ls {
catList.Insert(v, i)
}
catList.ShowAll()
})
}
}
})
botBox.Add(wineCheck) botBox.Add(wineCheck)
botBox.PackEnd(edit, false, false, 0)
topLvl.Add(lrBox) topLvl.Add(lrBox)
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()
@@ -99,23 +144,41 @@ func ui(win *gtk.Window) {
ind := pth.GetIndices() ind := pth.GetIndices()
if len(ind) == 1 { if len(ind) == 1 {
if wine { if wine {
app := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]] appLnch := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]]
app.launch() appLnch.launch()
} else { } else {
app := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]] appLnch := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]]
app.launch() appLnch.launch()
} }
} else if len(ind) == 2 { } else if len(ind) == 2 {
if wine { if wine {
app := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]] appLnch := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]]
app.launchSub(ind[1]) appLnch.launchSub(ind[1])
} else { } else {
app := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]] appLnch := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]]
app.launchSub(ind[1]) appLnch.launchSub(ind[1])
} }
} }
} }
}) })
dnl.Connect("clicked", func() {
appimg.ShowUI(func() {
master = make(map[string][]app)
linmaster = make(map[string][]app)
cats = make([]string, 0)
lin = make([]string, 0)
setup()
store.Clear()
for i := range ls {
catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1))
}
ls = getCatRows()
for i, v := range ls {
catList.Insert(v, i)
}
catList.ShowAll()
})
})
} }
func getCatRows() (out []*gtk.Label) { func getCatRows() (out []*gtk.Label) {
@@ -123,13 +186,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
+8 -8
View File
@@ -19,6 +19,11 @@ const (
func downloadWine(parent *gtk.Window, cb chan bool) { func downloadWine(parent *gtk.Window, cb chan bool) {
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
win.SetTransientFor(parent) win.SetTransientFor(parent)
win.SetDestroyWithParent(true)
win.Connect("destroy", func() {
parent.SetSensitive(true)
})
parent.SetSensitive(false)
spin, _ := gtk.SpinnerNew() spin, _ := gtk.SpinnerNew()
spin.Start() spin.Start()
txt, _ := gtk.LabelNew("Downloading Wine") txt, _ := gtk.LabelNew("Downloading Wine")
@@ -33,7 +38,7 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT) win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
win.ShowAll() win.ShowAll()
win.Show() win.Show()
go func(win *gtk.Window) { go func(win *gtk.Window, txt *gtk.Label) {
defer win.Close() 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 {
@@ -41,7 +46,6 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
cb <- false cb <- false
return 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 {
@@ -55,6 +59,7 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
cb <- false cb <- false
return 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 {
@@ -63,14 +68,12 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
return return
} }
txt.SetText("Extracting Wine") txt.SetText("Extracting Wine")
os.RemoveAll("PortableApps/LinuxPACom/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 {
fmt.Println(err) fmt.Println(err)
cb <- false cb <- false
return return
} }
os.Remove("PortableApps/LinuxPACom/wine2.5.tar.bz2")
fil, err := os.Open("PortableApps/LinuxPACom/common.sh") fil, err := os.Open("PortableApps/LinuxPACom/common.sh")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -83,19 +86,16 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
cb <- false cb <- false
return return
} }
fmt.Println("Hello")
if !strings.Contains(string(tmp), "export PATH=$PWD/PortableApps/LinuxPACom/Wine/wineversion/2.5/bin:$PATH") { 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")...) tmp = append(tmp, []byte("\nexport PATH=$PWD/PortableApps/LinuxPACom/Wine/wineversion/2.5/bin:$PATH")...)
ioutil.WriteFile("PortableApps/LinuxPACom/common.sh", tmp, 0777) ioutil.WriteFile("PortableApps/LinuxPACom/common.sh", tmp, 0777)
fmt.Println("Hello2")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
cb <- false cb <- false
return return
} }
} }
fmt.Println("HelloT")
cb <- true cb <- true
return return
}(win) }(win, txt)
} }