Compare commits
58 Commits
v1.0.1
...
raylib-exp
| Author | SHA1 | Date | |
|---|---|---|---|
| 50105c242a | |||
| 6e8d97f29b | |||
| c8e0f08aae | |||
| 916f9cc79b | |||
| e4e5adaf13 | |||
| 7a2ebd533e | |||
| 2f0ca5418c | |||
| ce9d4aed23 | |||
| 712a5ab33d | |||
| 6723f933b4 | |||
| 016fc35745 | |||
| ba5e3510ec | |||
| 7e2d7ee14b | |||
| b20de4f1d6 | |||
| d2e91baa6b | |||
| a0f22e480b | |||
| 57f921c2cb | |||
| 55f897db46 | |||
| 3d9583281e | |||
| ec4d66f6b2 | |||
| c442ef5688 | |||
| 78d3723bf4 | |||
| 828b9f4cda | |||
| be64aa083f | |||
| 3111705cae | |||
| 868ae8f700 | |||
| 226e9d6210 | |||
| 56748f043e | |||
| 3d3239fe0a | |||
| 6e643b68ac | |||
| 539f33d25e | |||
| 4d3cb9f486 | |||
| a55c82483a | |||
| 9e9bb82025 | |||
| ea91d3cd80 | |||
| 2a0d53db09 | |||
| a0213d1886 | |||
| 695ce815d9 | |||
| 01556c1eb0 | |||
| d7410bb88f | |||
| bc63e6d10f | |||
| 0403825c3d | |||
| 0f1bb3fabd | |||
| 78c6842fab | |||
| dc1edbad3a | |||
| 6dd00c5f8f | |||
| e68337886f | |||
| 3b639f53fd | |||
| 3199ad88fd | |||
| a221d18d33 | |||
| a9eeb3bb1c | |||
| 844a282fd7 | |||
| 9da352a315 | |||
| 34b8f7c926 | |||
| 5d5cedec58 | |||
| 8441a8b752 | |||
| d64d88e0a5 | |||
| 5eeb9cc702 |
@@ -0,0 +1 @@
|
|||||||
|
testing/
|
||||||
@@ -1,32 +1,51 @@
|
|||||||
# LinuxPA
|
# LinuxPA
|
||||||
|
|
||||||
LinuxPA is a try to bring a [PortableApps.com](http://portableapps.com) type launcher to Linux.
|
LinuxPA is a try to bring a [PortableApps.com](http://portableapps.com) type launcher to Linux.
|
||||||
|
|
||||||
# How to use
|
## How to use
|
||||||
Just double click on an app to launch it! If there are multiple executables, you can either select the specific executable, or if you just double click the app it'll launch the first linux executable, but if one isn't found it launches the first executable in general.
|
|
||||||
|
Just double click on an app to launch it! If there are multiple executables, you can either select the specific executable, or if you just double click the app it'll launch the first linux executable it finds. .sh script files have priority over other executable files.
|
||||||
|
|
||||||
|
## Apps
|
||||||
|
|
||||||
|
The below place provides linux executables that don't need libs installed on the host system:
|
||||||
|
[https://appimage.github.io/](https://appimage.github.io/)
|
||||||
|
|
||||||
|
## PortableApps.com Compatibility
|
||||||
|
|
||||||
# PortableApps.com Compatibility
|
|
||||||
LinuxPA works will with the PortableApps.com launcher, as it looks for apps in the PortableApps folder and grabs the app's name and icon from where it should be in the PortableApps.com format.
|
LinuxPA works will with the PortableApps.com launcher, as it looks for apps in the PortableApps folder and grabs the app's name and icon from where it should be in the PortableApps.com format.
|
||||||
|
My forum at PortableApps.com can be found [here](http://portableapps.com/node/54998).
|
||||||
|
|
||||||
# common.sh
|
## common.sh
|
||||||
common.sh is found in the PortableApps/LinuxPACom folder and is executed before the app. I mainly use it to set environment variables (such as HOME).
|
|
||||||
|
|
||||||
# Simple App Setup
|
common.sh is found in the PortableApps/LinuxPACom folder and is executed before the app. I mainly use it to set environment variables (such as HOME). You can create and edit the common.sh from settings.
|
||||||
Because apps aren't natively formated in the PortableApps.com format, if LinuxPA doesn't find the AppInfo.ini or appicon_\*.png in the App/AppInfo folder of the app it looks for them in the root directory of the app (except it looks, nor for appicon_\*.png, but appicon.png). If an AppInfo.ini file isn't found then the name of the app is grabbed from the folder name and it's category is set to other. It specifically looks for the lines starting with `Name=` and `Category=`
|
|
||||||
|
## Simple App Setup
|
||||||
|
|
||||||
|
Because apps aren't natively formated in the PortableApps.com format, LinuxPA will look in the root directory for a AppInfo.ini (for basic info such as category and name) and appicon.png. If they aren't found, it looks where the appicon_\*.png and AppInfo.ini is in PortableApps format. You can set what the AppInfo.ini and appicon.png are from LinuxPA.
|
||||||
|
|
||||||
|
## AppImage Support
|
||||||
|
|
||||||
# AppImage Support
|
|
||||||
[AppImage Website](http://appimage.org)
|
[AppImage Website](http://appimage.org)
|
||||||
Right now AppImages are simply supported via the native linux executable support, but later I'm hoping to add downloading and automatic updating support later on.
|
I'm looking into improving AppImage support. As of 2.1.5.0 IF `unsquashfs` is in $PATH then some advanced AppImage support is available and it will automagically get the name and possibly the icon of it. I'm looking into better support, but it might be a while.
|
||||||
|
|
||||||
# USB mount
|
## USB mount
|
||||||
Unfortunately Linux, by default, doesn't support running executables off of flash drives, requiring you to mount your drive with special mount arguments, I personally use the arguments `exec,noauto,nodev,nosuid,umask=0000`
|
|
||||||
|
|
||||||
# Screenshots
|
Unfortunately Linux, by default, doesn't support running executables off of FAT formated flash drives, requiring you to mount your drive with special mount arguments or format in a linux friendly format (such as EXT4). I personally use the arguments `exec,noauto,nodev,nosuid,umask=0000`
|
||||||
Photos are found [Here](https://goo.gl/photos/VtBUL6DyZTMidj5n6)
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
Photos are found [Here](https://goo.gl/photos/VtBUL6DyZTMidj5n6). The screenshots are with the adapta gtk theme
|
||||||
|
|
||||||
|
## TODO (Might be in order)
|
||||||
|
|
||||||
# TODO (Might be in order)
|
|
||||||
1. MAKE IT BETTER
|
1. MAKE IT BETTER
|
||||||
1. Add settings menu
|
1. Integrate [goappimage](https://github.com/probonod/go-appimage) library for better AppImage integration.
|
||||||
1. Add updater for .AppImage files
|
1. Try to `chmod +x` executables if they don't have the permission
|
||||||
1. Download .AppImage files (maybe)
|
1. Manual update check
|
||||||
1. Check if all apps are closed when it closes and ask if you want to force stop the apps.
|
1. Better AppImage integrations (Specifically updating and better appimage downloading)
|
||||||
1. Portable wine???
|
1. Get information (such as name and icon) directly from an appimage
|
||||||
|
1. Better appimage downloading (probably based around [AppImageHub](https://appimage.github.io/apps/))
|
||||||
|
1. Sandboxing support
|
||||||
|
1. Might be possible by packaging as an AppImage and providing Firejail, or simply just downloading it (like with Wine)
|
||||||
|
1. Check if all apps are closed when it closes and ask if you want to force stop the apps
|
||||||
|
|||||||
@@ -1,259 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
"github.com/nelsam/gxui"
|
|
||||||
"github.com/nelsam/gxui/math"
|
|
||||||
)
|
|
||||||
|
|
||||||
type app struct {
|
|
||||||
name string
|
|
||||||
cat string
|
|
||||||
appimg []string
|
|
||||||
lin []string
|
|
||||||
ex []string
|
|
||||||
icon gxui.Texture
|
|
||||||
dir string
|
|
||||||
ini *os.File
|
|
||||||
}
|
|
||||||
|
|
||||||
type appExNode struct {
|
|
||||||
ap app
|
|
||||||
exInd int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *appExNode) launch() {
|
|
||||||
if wine {
|
|
||||||
var cmd *exec.Cmd
|
|
||||||
if ind := sort.SearchStrings(a.ap.lin, a.ap.ex[a.exInd]); ind == len(a.ap.lin) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
type appNode struct {
|
|
||||||
ap app
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *appNode) launch() {
|
|
||||||
|
|
||||||
if len(a.ap.ex) == 1 {
|
|
||||||
if wine {
|
|
||||||
var cmd *exec.Cmd
|
|
||||||
if ind := sort.SearchStrings(a.ap.lin, a.ap.ex[0]); ind == len(a.ap.lin) {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[0]+"\"")
|
|
||||||
} else {
|
|
||||||
if comEnbld {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[0]+"\"")
|
|
||||||
} else {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[0]+"\"")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Start()
|
|
||||||
} else {
|
|
||||||
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[0]+"\"")
|
|
||||||
} else {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.ex[0]+"\"")
|
|
||||||
}
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Start()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if wine {
|
|
||||||
var cmd *exec.Cmd
|
|
||||||
if len(a.ap.lin) == 0 {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[0]+"\"")
|
|
||||||
} else {
|
|
||||||
if comEnbld {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
|
|
||||||
} else {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Start()
|
|
||||||
} else {
|
|
||||||
if len(a.ap.lin) != 0 {
|
|
||||||
var cmd *exec.Cmd
|
|
||||||
if comEnbld {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
|
|
||||||
} else {
|
|
||||||
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
|
|
||||||
}
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *appNode) Count() int {
|
|
||||||
if wine {
|
|
||||||
if len(a.ap.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,11 @@
|
|||||||
|
module github.com/CalebQ42/LinuxPA
|
||||||
|
|
||||||
|
go 1.23.1
|
||||||
|
|
||||||
|
require github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/ebitengine/purego v0.8.2 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
|
||||||
|
golang.org/x/sys v0.29.0 // indirect
|
||||||
|
)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
|
||||||
|
github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||||
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b h1:JJfspevP3YOXcSKVABizYOv++yMpTJIdPUtoDzF/RWw=
|
||||||
|
github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b/go.mod h1:BaY76bZk7nw1/kVOSQObPY1v1iwVE1KHAGMfvI6oK1Q=
|
||||||
|
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
|
||||||
|
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
|
||||||
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"image/color"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
rl "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A rectangle with borders.
|
||||||
|
// Default only has black borders.
|
||||||
|
type Rect struct {
|
||||||
|
x int32
|
||||||
|
y int32
|
||||||
|
h int32
|
||||||
|
w int32
|
||||||
|
radius int32
|
||||||
|
reload bool
|
||||||
|
shown bool
|
||||||
|
rendering bool
|
||||||
|
|
||||||
|
borderWidth int32
|
||||||
|
borderColor color.RGBA
|
||||||
|
fillColor color.RGBA
|
||||||
|
|
||||||
|
curTweens map[string]*Tween
|
||||||
|
tex rl.RenderTexture2D
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRect(x, y, height, width int32) *Rect {
|
||||||
|
r := &Rect{
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
h: height,
|
||||||
|
w: width,
|
||||||
|
radius: 0,
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: rl.Black,
|
||||||
|
fillColor: rl.Blank,
|
||||||
|
reload: true,
|
||||||
|
curTweens: make(map[string]*Tween),
|
||||||
|
}
|
||||||
|
r.tex = rl.LoadRenderTexture(width, height)
|
||||||
|
rl.SetTextureFilter(r.tex.Texture, rl.FilterAnisotropic8x|rl.FilterBilinear)
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) Copy() *Rect {
|
||||||
|
return &Rect{
|
||||||
|
x: r.x,
|
||||||
|
y: r.y,
|
||||||
|
h: r.h,
|
||||||
|
w: r.w,
|
||||||
|
radius: r.radius,
|
||||||
|
borderWidth: r.borderWidth,
|
||||||
|
borderColor: r.borderColor,
|
||||||
|
fillColor: r.fillColor,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) addTween(key string, old, new int32) {
|
||||||
|
r.curTweens[key] = NewTween(old, new, 1000*time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) SetPosition(x, y int32) {
|
||||||
|
if !r.shown {
|
||||||
|
r.x, r.y = x, y
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r.x != x {
|
||||||
|
r.addTween("x", r.x, x)
|
||||||
|
}
|
||||||
|
if r.y != y {
|
||||||
|
r.addTween("y", r.y, y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) SetSize(h, w int32) {
|
||||||
|
if !r.shown {
|
||||||
|
r.h, r.w = h, w
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r.h != h {
|
||||||
|
r.addTween("h", r.h, h)
|
||||||
|
r.reload = true
|
||||||
|
}
|
||||||
|
if r.w != w {
|
||||||
|
r.addTween("w", r.w, w)
|
||||||
|
r.reload = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) SetBorderRadius(radius int32) {
|
||||||
|
if !r.shown {
|
||||||
|
r.radius = radius
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r.radius != radius {
|
||||||
|
r.addTween("radius", r.radius, radius)
|
||||||
|
r.reload = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) SetBorderWidth(w int32) {
|
||||||
|
if !r.shown {
|
||||||
|
r.borderWidth = w
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r.borderWidth != w {
|
||||||
|
r.addTween("borderWidth", r.borderWidth, w)
|
||||||
|
r.reload = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) SetBorderColor(c color.RGBA) {
|
||||||
|
if r.borderColor != c {
|
||||||
|
r.reload = true
|
||||||
|
}
|
||||||
|
r.borderColor = c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) SetFillColor(c color.RGBA) {
|
||||||
|
if r.fillColor != c {
|
||||||
|
r.reload = true
|
||||||
|
}
|
||||||
|
r.fillColor = c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect) Draw() {
|
||||||
|
r.shown = true
|
||||||
|
if !r.reload && len(r.curTweens) == 0 {
|
||||||
|
rl.DrawTextureEx(r.tex.Texture, rl.NewVector2(float32(r.x), float32(r.y)), 0, 1, rl.White)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var curRect *Rect
|
||||||
|
updateTex := false
|
||||||
|
if len(r.curTweens) != 0 {
|
||||||
|
curRect = r.Copy()
|
||||||
|
tween, ok := r.curTweens["x"]
|
||||||
|
if ok {
|
||||||
|
curRect.x = tween.CurVal()
|
||||||
|
if tween.Ended() {
|
||||||
|
r.x = curRect.x
|
||||||
|
delete(r.curTweens, "x")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tween, ok = r.curTweens["y"]
|
||||||
|
if ok {
|
||||||
|
curRect.y = tween.CurVal()
|
||||||
|
if tween.Ended() {
|
||||||
|
r.y = curRect.y
|
||||||
|
delete(r.curTweens, "y")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tween, ok = r.curTweens["h"]
|
||||||
|
if ok {
|
||||||
|
curRect.h = tween.CurVal()
|
||||||
|
if curRect.h != r.h {
|
||||||
|
updateTex = true
|
||||||
|
}
|
||||||
|
if tween.Ended() {
|
||||||
|
r.h = curRect.h
|
||||||
|
delete(r.curTweens, "h")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tween, ok = r.curTweens["w"]
|
||||||
|
if ok {
|
||||||
|
curRect.w = tween.CurVal()
|
||||||
|
if curRect.w != r.w {
|
||||||
|
updateTex = true
|
||||||
|
}
|
||||||
|
if tween.Ended() {
|
||||||
|
r.w = curRect.w
|
||||||
|
delete(r.curTweens, "w")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tween, ok = r.curTweens["radius"]
|
||||||
|
if ok {
|
||||||
|
curRect.radius = tween.CurVal()
|
||||||
|
if curRect.radius != r.radius {
|
||||||
|
updateTex = true
|
||||||
|
}
|
||||||
|
if tween.Ended() {
|
||||||
|
r.radius = curRect.radius
|
||||||
|
delete(r.curTweens, "radius")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tween, ok = r.curTweens["borderWidth"]
|
||||||
|
if ok {
|
||||||
|
curRect.borderWidth = tween.CurVal()
|
||||||
|
if curRect.borderWidth != r.borderWidth {
|
||||||
|
updateTex = true
|
||||||
|
}
|
||||||
|
if tween.Ended() {
|
||||||
|
r.borderWidth = curRect.borderWidth
|
||||||
|
delete(r.curTweens, "borderWidth")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
curRect = r
|
||||||
|
}
|
||||||
|
if r.reload || updateTex {
|
||||||
|
// rl.UnloadTexture(r.tex)
|
||||||
|
// r.tex = rl.LoadTextureFromImage(curRect.buildImage())
|
||||||
|
// rl.UpdateTexture(r.tex, rl.LoadImageColors(curRect.buildImage()))
|
||||||
|
rl.BeginTextureMode(r.tex)
|
||||||
|
curRect.drawTexture()
|
||||||
|
rl.EndTextureMode()
|
||||||
|
}
|
||||||
|
rl.DrawTexturePro(r.tex.Texture, rl.NewRectangle(0, 0, float32(curRect.w), float32(curRect.h)), rl.NewRectangle(float32(curRect.x), float32(curRect.y), float32(curRect.w), float32(curRect.h)), rl.NewVector2(0, 0), 0, rl.White)
|
||||||
|
// rl.DrawTextureEx(r.tex.Texture, rl.NewVector2(float32(curRect.x), float32(curRect.y)), 0, 1, rl.White)
|
||||||
|
r.reload = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Rect) drawTexture() {
|
||||||
|
rl.ClearBackground(rl.Blank)
|
||||||
|
// Filled areas
|
||||||
|
if r.fillColor != rl.Blank {
|
||||||
|
rl.DrawRectangle(r.radius, 0, (r.w - (2 * r.radius)), r.h, r.fillColor)
|
||||||
|
if r.radius > 0 {
|
||||||
|
rl.DrawRectangle((r.w - r.radius), r.radius, r.radius, (r.h - (2 * r.radius)), r.fillColor)
|
||||||
|
rl.DrawRectangle(0, r.radius, r.radius, (r.h - (2 * r.radius)), r.fillColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.borderColor != rl.Blank {
|
||||||
|
// Horizontal lines
|
||||||
|
rl.DrawRectangle(r.radius, 0, (r.w - (2 * r.radius)), r.borderWidth, r.borderColor)
|
||||||
|
rl.DrawRectangle(r.radius, (r.h)-(r.borderWidth), (r.w - (2 * r.radius)), r.borderWidth, r.borderColor)
|
||||||
|
// Vertical lines
|
||||||
|
rl.DrawRectangle(0, r.radius, r.borderWidth, (r.h - (2 * r.radius)), r.borderColor)
|
||||||
|
rl.DrawRectangle((r.w)-(r.borderWidth), r.radius, r.borderWidth, (r.h - (2 * r.radius)), r.borderColor)
|
||||||
|
}
|
||||||
|
if r.radius > 0 {
|
||||||
|
r.placeCorners()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Rect) placeCorners() {
|
||||||
|
//bl
|
||||||
|
if r.borderWidth > 0 {
|
||||||
|
rl.DrawRing(rl.NewVector2(float32(r.radius), float32(r.radius)), float32(r.radius-r.borderWidth), float32(r.radius), 180, 270, 20, r.borderColor)
|
||||||
|
}
|
||||||
|
rl.DrawCircleSector(rl.NewVector2(float32(r.radius), float32(r.radius)), float32(r.radius-r.borderWidth), 180, 270, 20, r.fillColor)
|
||||||
|
//tl
|
||||||
|
if r.borderWidth > 0 {
|
||||||
|
rl.DrawRing(rl.NewVector2(float32(r.radius), float32(r.h-r.radius)), float32(r.radius-r.borderWidth), float32(r.radius), 90, 180, 20, r.borderColor)
|
||||||
|
}
|
||||||
|
rl.DrawCircleSector(rl.NewVector2(float32(r.radius), float32(r.h-r.radius)), float32(r.radius-r.borderWidth), 90, 180, 20, r.fillColor)
|
||||||
|
//tr
|
||||||
|
if r.borderWidth > 0 {
|
||||||
|
rl.DrawRing(rl.NewVector2(float32(r.w-r.radius), float32(r.h-r.radius)), float32(r.radius-r.borderWidth), float32(r.radius), 0, 90, 20, r.borderColor)
|
||||||
|
}
|
||||||
|
rl.DrawCircleSector(rl.NewVector2(float32(r.w-r.radius), float32(r.h-r.radius)), float32(r.radius-r.borderWidth), 0, 90, 20, r.fillColor)
|
||||||
|
//br
|
||||||
|
if r.borderWidth > 0 {
|
||||||
|
rl.DrawRing(rl.NewVector2(float32(r.w-r.radius), float32(r.radius)), float32(r.radius-r.borderWidth), float32(r.radius), 270, 360, 20, r.borderColor)
|
||||||
|
}
|
||||||
|
rl.DrawCircleSector(rl.NewVector2(float32(r.w-r.radius), float32(r.radius)), float32(r.radius-r.borderWidth), 270, 360, 20, r.fillColor)
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
rl "github.com/gen2brain/raylib-go/raylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Window struct{}
|
||||||
|
|
||||||
|
func Test() {
|
||||||
|
rl.SetConfigFlags(rl.FlagWindowResizable | rl.FlagWindowHighdpi | rl.FlagVsyncHint | rl.FlagMsaa4xHint)
|
||||||
|
rl.InitWindow(800, 450, "raylib [core] example - basic window")
|
||||||
|
defer rl.CloseWindow()
|
||||||
|
rl.SetTargetFPS(60)
|
||||||
|
|
||||||
|
noto := rl.LoadFont("./noto-sans.ttf")
|
||||||
|
txtImg := rl.ImageTextEx(noto, "Hello World!", 50, 0, rl.Black)
|
||||||
|
txt := rl.LoadTextureFromImage(txtImg)
|
||||||
|
|
||||||
|
tmpRect := NewRect(10, 10, 250, 500)
|
||||||
|
tmpRect.SetBorderRadius(25)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
// tmpRect.SetBorderRadius(0)
|
||||||
|
// tmpRect.SetPosition(100, 100)
|
||||||
|
tmpRect.SetSize(400, 700)
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
// tmpRect.SetBorderRadius(25)
|
||||||
|
// tmpRect.SetPosition(10, 10)
|
||||||
|
tmpRect.SetSize(250, 500)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// tmpRect.SetFillColor(rl.Green)
|
||||||
|
for !rl.WindowShouldClose() {
|
||||||
|
rl.BeginDrawing()
|
||||||
|
rl.DrawFPS(0, 0)
|
||||||
|
|
||||||
|
rl.ClearBackground(rl.DarkGray)
|
||||||
|
// rl.DrawText("Congrats! You created your first window!", 190, 100, 20, rl.LightGray)
|
||||||
|
// // rl.DrawTextEx(noto, "Congrats! You created your first window!", rl.NewVector2(190, 200), 48, 0, rl.Black)
|
||||||
|
tmpRect.Draw()
|
||||||
|
rl.DrawTexture(txt, 50, 50, rl.Black)
|
||||||
|
rl.EndDrawing()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Tween struct {
|
||||||
|
startVal int32
|
||||||
|
startTime time.Time
|
||||||
|
dif int32
|
||||||
|
dur time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTween(startVal, endVal int32, duration time.Duration) *Tween {
|
||||||
|
return &Tween{
|
||||||
|
startVal: startVal,
|
||||||
|
dif: endVal - startVal,
|
||||||
|
dur: duration,
|
||||||
|
startTime: time.Now().Round(time.Millisecond),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Tween) CurVal() int32 {
|
||||||
|
since := time.Now().Round(time.Millisecond).Sub(t.startTime)
|
||||||
|
if since <= 0 {
|
||||||
|
return t.startVal
|
||||||
|
}
|
||||||
|
if since >= t.dur {
|
||||||
|
return t.startVal + t.dif
|
||||||
|
}
|
||||||
|
m := float32(since.Milliseconds()) / float32(t.dur.Milliseconds())
|
||||||
|
m = -1 * float32(math.Log10(-.9*float64(m)+1))
|
||||||
|
return t.startVal + int32(math.Round(float64(float32(t.dif)*m)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Tween) Ended() bool {
|
||||||
|
return time.Now().Round(time.Millisecond).Sub(t.startTime) >= t.dur
|
||||||
|
}
|
||||||
@@ -1,37 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import "github.com/CalebQ42/LinuxPA/internal/ui"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/nelsam/gxui"
|
|
||||||
"github.com/nelsam/gxui/drivers/gl"
|
|
||||||
"github.com/nelsam/gxui/themes/dark"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
dr gxui.Driver
|
|
||||||
th gxui.Theme
|
|
||||||
master map[string][]app
|
|
||||||
linmaster map[string][]app
|
|
||||||
cats []string
|
|
||||||
lin []string
|
|
||||||
wine bool
|
|
||||||
comEnbld bool
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
_, err := os.Open("PortableApps/LinuxPACom/common.sh")
|
ui.Test()
|
||||||
if err == nil {
|
|
||||||
comEnbld = true
|
|
||||||
}
|
|
||||||
master = make(map[string][]app)
|
|
||||||
linmaster = make(map[string][]app)
|
|
||||||
gl.StartDriver(appMain)
|
|
||||||
}
|
|
||||||
|
|
||||||
func appMain(dri gxui.Driver) {
|
|
||||||
dr = dri
|
|
||||||
th = dark.CreateTheme(dr)
|
|
||||||
setup()
|
|
||||||
ui()
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1,176 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"image"
|
|
||||||
"image/draw"
|
|
||||||
_ "image/png"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/nelsam/gxui"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setup() {
|
|
||||||
PortableAppsFold, err := os.Open("PortableApps")
|
|
||||||
if PAStat, _ := PortableAppsFold.Stat(); err != nil || !PAStat.IsDir() {
|
|
||||||
panic("PortableApps folder not found!!")
|
|
||||||
}
|
|
||||||
PAFolds, _ := PortableAppsFold.Readdirnames(-1)
|
|
||||||
sort.Strings(PAFolds)
|
|
||||||
for _, v := range PAFolds {
|
|
||||||
fold, _ := os.Open("PortableApps/" + v)
|
|
||||||
if stat, _ := fold.Stat(); stat.IsDir() && stat.Name() != "PortableApps.com" && stat.Name() != "LinuxPACom" {
|
|
||||||
ap := processApp("PortableApps/" + v)
|
|
||||||
if !reflect.DeepEqual(ap, app{}) {
|
|
||||||
if _, ok := master[ap.cat]; !ok {
|
|
||||||
cats = append(cats, ap.cat)
|
|
||||||
sort.Strings(cats)
|
|
||||||
if len(ap.lin) != 0 {
|
|
||||||
lin = append(lin, ap.cat)
|
|
||||||
sort.Strings(lin)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if len(ap.lin) != 0 {
|
|
||||||
ind := sort.SearchStrings(lin, ap.cat)
|
|
||||||
if ind == len(lin) {
|
|
||||||
lin = append(lin, ap.cat)
|
|
||||||
sort.Strings(lin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(ap.lin) != 0 {
|
|
||||||
linmaster[ap.cat] = append(linmaster[ap.cat], ap)
|
|
||||||
}
|
|
||||||
master[ap.cat] = append(master[ap.cat], ap)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func processApp(fold string) (out app) {
|
|
||||||
wd, _ := os.Getwd()
|
|
||||||
out.dir = wd + "/" + fold
|
|
||||||
out.ini = findInfo(fold)
|
|
||||||
if out.ini != nil {
|
|
||||||
out.name = getName(out.ini)
|
|
||||||
out.ini = findInfo(fold)
|
|
||||||
out.cat = getCat(out.ini)
|
|
||||||
out.ini = findInfo(fold)
|
|
||||||
}
|
|
||||||
if out.name == "" {
|
|
||||||
out.name = strings.TrimPrefix(fold, "PortableApps/")
|
|
||||||
}
|
|
||||||
if out.cat == "" {
|
|
||||||
out.cat = "Other"
|
|
||||||
}
|
|
||||||
out.icon = getIcon(fold)
|
|
||||||
folder, _ := os.Open(fold)
|
|
||||||
fis, _ := folder.Readdirnames(-1)
|
|
||||||
for _, v := range fis {
|
|
||||||
tmp, _ := os.Open(fold + "/" + v)
|
|
||||||
if stat, _ := tmp.Stat(); stat.IsDir() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.HasSuffix(strings.ToLower(v), ".appimage") {
|
|
||||||
out.appimg = append(out.appimg, v)
|
|
||||||
out.ex = append(out.ex, v)
|
|
||||||
out.lin = append(out.lin, v)
|
|
||||||
} else if strings.HasSuffix(strings.ToLower(v), ".exe") {
|
|
||||||
out.ex = append(out.ex, v)
|
|
||||||
} else {
|
|
||||||
btys := make([]byte, 4)
|
|
||||||
rdr := bufio.NewReader(tmp)
|
|
||||||
rdr.Read(btys)
|
|
||||||
if strings.HasPrefix(strings.ToLower(string(btys)), "ELF") || strings.HasPrefix(strings.ToLower(string(btys)), "#!") {
|
|
||||||
out.ex = append(out.ex, v)
|
|
||||||
out.lin = append(out.lin, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(out.ex) == 0 {
|
|
||||||
return app{}
|
|
||||||
}
|
|
||||||
if len(out.lin) == 0 {
|
|
||||||
out.name += " (Wine)"
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCat(ini *os.File) string {
|
|
||||||
rdr := bufio.NewReader(ini)
|
|
||||||
var ret string
|
|
||||||
for line, _, err := rdr.ReadLine(); err == nil; line, _, err = rdr.ReadLine() {
|
|
||||||
if strings.HasPrefix(string(line), "Category=") {
|
|
||||||
ret = strings.TrimPrefix(string(line), "Category=")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rdr.Reset(ini)
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func getName(ini *os.File) string {
|
|
||||||
rdr := bufio.NewReader(ini)
|
|
||||||
var ret string
|
|
||||||
for line, _, err := rdr.ReadLine(); err == nil; line, _, err = rdr.ReadLine() {
|
|
||||||
if strings.HasPrefix(string(line), "Name=") {
|
|
||||||
ret = strings.TrimPrefix(string(line), "Name=")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rdr.Reset(ini)
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func getIcon(fold string) gxui.Texture {
|
|
||||||
var pic *os.File
|
|
||||||
if folder, err := os.Open(fold + "/App/AppInfo"); err == nil {
|
|
||||||
fis, _ := folder.Readdir(-1)
|
|
||||||
var pics []string
|
|
||||||
for _, v := range fis {
|
|
||||||
if !v.IsDir() && strings.HasSuffix(strings.ToLower(v.Name()), ".png") && strings.HasPrefix(strings.ToLower(v.Name()), "appicon_") {
|
|
||||||
pics = append(pics, v.Name())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Strings(pics)
|
|
||||||
if len(pics) > 1 {
|
|
||||||
ind := sort.SearchStrings(pics, "appicon_32.png")
|
|
||||||
if ind == len(pics) {
|
|
||||||
ind--
|
|
||||||
}
|
|
||||||
pic, _ = os.Open(fold + "/App/AppInfo/" + pics[ind])
|
|
||||||
}
|
|
||||||
} else if fi, err := os.Open(fold + "/appicon.png"); err == nil {
|
|
||||||
pic = fi
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
img, _, err := image.Decode(pic)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
rgba := image.NewRGBA(img.Bounds())
|
|
||||||
draw.Draw(rgba, img.Bounds(), img, image.ZP, draw.Src)
|
|
||||||
ret := dr.CreateTexture(rgba, 1)
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func findInfo(fold string) *os.File {
|
|
||||||
tmp, err := os.Open(fold + "/App/AppInfo")
|
|
||||||
if err == nil {
|
|
||||||
fis, _ := tmp.Readdirnames(-1)
|
|
||||||
for _, v := range fis {
|
|
||||||
if strings.ToLower(v) == "appinfo.ini" {
|
|
||||||
tmp, _ := os.Open(fold + "/App/AppInfo/" + v)
|
|
||||||
return tmp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if fi, err := os.Open(fold + "/appinfo.ini"); err == nil {
|
|
||||||
return fi
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
-65
@@ -1,65 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nelsam/gxui"
|
|
||||||
"github.com/nelsam/gxui/math"
|
|
||||||
)
|
|
||||||
|
|
||||||
//StrList TODO
|
|
||||||
type StrList struct {
|
|
||||||
gxui.AdapterBase
|
|
||||||
strs []string
|
|
||||||
}
|
|
||||||
|
|
||||||
//AddString TODO
|
|
||||||
func (s *StrList) AddString(add string) {
|
|
||||||
s.strs = append(s.strs, add)
|
|
||||||
s.DataChanged(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
//Remove TODO
|
|
||||||
func (s *StrList) Remove(index int) {
|
|
||||||
s.strs = append(s.strs[:index], s.strs[index+1:]...)
|
|
||||||
s.DataChanged(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
//SetStrings TODO
|
|
||||||
func (s *StrList) SetStrings(strs []string) {
|
|
||||||
s.strs = strs
|
|
||||||
s.DataChanged(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
//Count TODO
|
|
||||||
func (s *StrList) Count() int {
|
|
||||||
return len(s.strs)
|
|
||||||
}
|
|
||||||
|
|
||||||
//ItemAt TODO
|
|
||||||
func (s *StrList) ItemAt(index int) gxui.AdapterItem {
|
|
||||||
return s.strs[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
//ItemIndex TODO
|
|
||||||
func (s *StrList) ItemIndex(item gxui.AdapterItem) int {
|
|
||||||
for i, v := range s.strs {
|
|
||||||
if v == item {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create TODO
|
|
||||||
func (s *StrList) Create(th gxui.Theme, index int) gxui.Control {
|
|
||||||
box := th.CreateLinearLayout()
|
|
||||||
box.SetDirection(gxui.LeftToRight)
|
|
||||||
lbl := th.CreateLabel()
|
|
||||||
lbl.SetText(s.strs[index])
|
|
||||||
box.AddChild(lbl)
|
|
||||||
return box
|
|
||||||
}
|
|
||||||
|
|
||||||
//Size TODO
|
|
||||||
func (s *StrList) Size(gxui.Theme) math.Size {
|
|
||||||
return math.Size{W: math.MaxSize.W, H: 20}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
"github.com/nelsam/gxui"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ui() {
|
|
||||||
catListAdap := &StrList{}
|
|
||||||
appListAdap := &catAdap{}
|
|
||||||
catListAdap.SetStrings(lin)
|
|
||||||
win := th.CreateWindow(500, 500, "LinuxPA")
|
|
||||||
top := th.CreateLinearLayout()
|
|
||||||
top.SetDirection(gxui.BottomToTop)
|
|
||||||
splBox := th.CreateLinearLayout()
|
|
||||||
spl := th.CreateSplitterLayout()
|
|
||||||
spl.SetOrientation(gxui.Horizontal)
|
|
||||||
catList := th.CreateList()
|
|
||||||
catList.SetAdapter(catListAdap)
|
|
||||||
catList.OnSelectionChanged(func(it gxui.AdapterItem) {
|
|
||||||
appListAdap.setCat(it.(string))
|
|
||||||
})
|
|
||||||
appList := th.CreateTree()
|
|
||||||
appList.SetAdapter(appListAdap)
|
|
||||||
spl.AddChild(catList)
|
|
||||||
spl.AddChild(appList)
|
|
||||||
splBox.AddChild(spl)
|
|
||||||
butBox := th.CreateLinearLayout()
|
|
||||||
butBox.SetDirection(gxui.LeftToRight)
|
|
||||||
if _, err := exec.LookPath("wine"); err == nil {
|
|
||||||
wineBut := th.CreateButton()
|
|
||||||
wineBut.SetType(gxui.ToggleButton)
|
|
||||||
wineBut.SetChecked(wine)
|
|
||||||
wineBut.SetText("Show Windows Apps")
|
|
||||||
wineBut.OnClick(func(gxui.MouseEvent) {
|
|
||||||
wine = wineBut.IsChecked()
|
|
||||||
appListAdap.refresh()
|
|
||||||
if wineBut.IsChecked() {
|
|
||||||
catListAdap.SetStrings(cats)
|
|
||||||
wineBut.SetText("Hide Windows Apps")
|
|
||||||
} else {
|
|
||||||
catListAdap.SetStrings(lin)
|
|
||||||
wineBut.SetText("Show Windows Apps")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
_, err := os.Open("Start.exe")
|
|
||||||
if err == nil {
|
|
||||||
pa := th.CreateButton()
|
|
||||||
pa.SetText("Open PortableApps Launcher")
|
|
||||||
pa.OnClick(func(gxui.MouseEvent) {
|
|
||||||
cmd := exec.Command("wine", "Start.exe")
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Start()
|
|
||||||
})
|
|
||||||
butBox.AddChild(pa)
|
|
||||||
}
|
|
||||||
butBox.AddChild(wineBut)
|
|
||||||
}
|
|
||||||
top.AddChild(butBox)
|
|
||||||
top.AddChild(splBox)
|
|
||||||
win.AddChild(top)
|
|
||||||
win.OnClose(dr.Terminate)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user