Revert "Tried some stuff that I didn't like"
This reverts commit 78c6842fab.
This commit is contained in:
@@ -20,8 +20,8 @@ type app struct {
|
|||||||
ini *os.File
|
ini *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *app) getTreeIter(store *gtk.TreeStore) *gtk.TreeIter {
|
func (a *app) getTreeIter(store *gtk.TreeStore, parent *gtk.TreeIter) *gtk.TreeIter {
|
||||||
it := store.Append(nil)
|
it := store.Append(parent)
|
||||||
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 {
|
||||||
@@ -131,178 +131,3 @@ func (a *app) launchSub(sub int) {
|
|||||||
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
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@@ -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 {
|
||||||
|
|||||||
@@ -14,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
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/gotk3/gotk3/glib"
|
|
||||||
"github.com/gotk3/gotk3/gtk"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ui(win *gtk.Window) {
|
|
||||||
ls := getCatRows()
|
|
||||||
var treeApps []*gtk.TreeIter
|
|
||||||
header, _ := gtk.HeaderBarNew()
|
|
||||||
header.SetShowCloseButton(true)
|
|
||||||
header.SetTitle("LinuxPA")
|
|
||||||
header.SetSubtitle("PortableApps.com type launcher")
|
|
||||||
settings, _ := gtk.ButtonNewFromIconName("applications-system", gtk.ICON_SIZE_SMALL_TOOLBAR)
|
|
||||||
settings.Connect("clicked", func() {
|
|
||||||
settingsUI()
|
|
||||||
})
|
|
||||||
settings.SetTooltipText("Settings (Coming Soon!)")
|
|
||||||
header.PackStart(settings)
|
|
||||||
win.SetTitlebar(header)
|
|
||||||
topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
|
|
||||||
lrBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
|
|
||||||
catList, _ := gtk.ListBoxNew()
|
|
||||||
catList.SetActivateOnSingleClick(true)
|
|
||||||
store, _ := gtk.TreeStoreNew(glib.TYPE_OBJECT, glib.TYPE_STRING)
|
|
||||||
appsList, _ := gtk.TreeViewNewWithModel(store)
|
|
||||||
render, _ := gtk.CellRendererPixbufNew()
|
|
||||||
pixColumn, _ := gtk.TreeViewColumnNewWithAttribute("", render, "pixbuf", 0)
|
|
||||||
txtRender, _ := gtk.CellRendererTextNew()
|
|
||||||
txtColumn, _ := gtk.TreeViewColumnNewWithAttribute("", txtRender, "text", 1)
|
|
||||||
appsList.AppendColumn(pixColumn)
|
|
||||||
appsList.AppendColumn(txtColumn)
|
|
||||||
appsList.SetHeadersVisible(false)
|
|
||||||
catList.SetHExpand(true)
|
|
||||||
catList.SetVExpand(true)
|
|
||||||
appsList.SetHExpand(true)
|
|
||||||
appsList.SetVExpand(true)
|
|
||||||
vScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
|
||||||
hScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
|
||||||
vScrollApp, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
|
||||||
hScrollApp, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
|
||||||
catScrl, _ := gtk.ScrolledWindowNew(hScrollCat, vScrollCat)
|
|
||||||
catScrl.Add(catList)
|
|
||||||
catScrl.SetSizeRequest(170, 500)
|
|
||||||
appScrl, _ := gtk.ScrolledWindowNew(hScrollApp, vScrollApp)
|
|
||||||
appScrl.Add(appsList)
|
|
||||||
appScrl.SetSizeRequest(300, 500)
|
|
||||||
lrBox.Add(catScrl)
|
|
||||||
lrBox.Add(appScrl)
|
|
||||||
botBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 2)
|
|
||||||
wineCheck, _ := gtk.CheckButtonNewWithLabel("Show Windows apps (Wine)")
|
|
||||||
if !wineAvail {
|
|
||||||
wineCheck.SetSensitive(false)
|
|
||||||
wineCheck.SetTooltipText("Download wine to run windows apps")
|
|
||||||
}
|
|
||||||
wineCheck.Connect("toggled", func() {
|
|
||||||
wine = wineCheck.GetActive()
|
|
||||||
for i := range ls {
|
|
||||||
catList.Remove(catList.GetRowAtIndex(i))
|
|
||||||
}
|
|
||||||
ls = getCatRows()
|
|
||||||
for i, v := range ls {
|
|
||||||
catList.Insert(v, i)
|
|
||||||
}
|
|
||||||
catList.ShowAll()
|
|
||||||
})
|
|
||||||
botBox.Add(wineCheck)
|
|
||||||
topLvl.Add(lrBox)
|
|
||||||
topLvl.PackEnd(botBox, false, true, 0)
|
|
||||||
win.Add(topLvl)
|
|
||||||
for _, v := range ls {
|
|
||||||
catList.Prepend(v)
|
|
||||||
}
|
|
||||||
catList.Connect("row-selected", func() {
|
|
||||||
store.Clear()
|
|
||||||
if catList.GetSelectedRow().GetIndex() >= 0 {
|
|
||||||
treeApps = make([]*gtk.TreeIter, 0)
|
|
||||||
if wine {
|
|
||||||
apps := master[cats[catList.GetSelectedRow().GetIndex()]]
|
|
||||||
for _, v := range apps {
|
|
||||||
treeApps = append(treeApps, v.getTreeIter(store))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
apps := linmaster[lin[catList.GetSelectedRow().GetIndex()]]
|
|
||||||
for _, v := range apps {
|
|
||||||
treeApps = append(treeApps, v.getTreeIter(store))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
appsList.Connect("row-activated", func() {
|
|
||||||
selec, _ := appsList.GetSelection()
|
|
||||||
_, it, ok := selec.GetSelected()
|
|
||||||
if ok {
|
|
||||||
pth, _ := store.GetPath(it)
|
|
||||||
ind := pth.GetIndices()
|
|
||||||
if len(ind) == 1 {
|
|
||||||
if wine {
|
|
||||||
app := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]]
|
|
||||||
app.launch()
|
|
||||||
} else {
|
|
||||||
app := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]]
|
|
||||||
app.launch()
|
|
||||||
}
|
|
||||||
} else if len(ind) == 2 {
|
|
||||||
if wine {
|
|
||||||
app := master[cats[catList.GetSelectedRow().GetIndex()]][ind[0]]
|
|
||||||
app.launchSub(ind[1])
|
|
||||||
} else {
|
|
||||||
app := linmaster[lin[catList.GetSelectedRow().GetIndex()]][ind[0]]
|
|
||||||
app.launchSub(ind[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCatRows() (out []*gtk.Label) {
|
|
||||||
if wine {
|
|
||||||
for _, v := range cats {
|
|
||||||
txt, _ := gtk.LabelNew(v)
|
|
||||||
out = append(out, txt)
|
|
||||||
fmt.Println(v)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for _, v := range lin {
|
|
||||||
txt, _ := gtk.LabelNew(v)
|
|
||||||
out = append(out, txt)
|
|
||||||
fmt.Println(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user