Skip to content

Commit

Permalink
Some refinement
Browse files Browse the repository at this point in the history
Moved more complex appimage stuff to seperate package (github.com/CalebQ42/GoAppImage)
Moved settings to a seperate file for organization
Some work to allow asyncronouse app loading (Since goappimage is super slow)
Comments to show what's going to be there in the future.
  • Loading branch information
CalebQ42 committed Jun 14, 2018
1 parent c442ef5 commit ec4d66f
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 165 deletions.
79 changes: 0 additions & 79 deletions appimg/CTesting.go

This file was deleted.

75 changes: 6 additions & 69 deletions main.go
@@ -1,7 +1,6 @@
package main

import (
"encoding/gob"
"flag"
"fmt"
"os"
Expand All @@ -14,17 +13,12 @@ const (
)

var (
master map[string][]app
linmaster map[string][]app
cats []string
lin []string
wine bool
comEnbld bool
wineAvail bool
portableHide bool
betaUpdate bool
versionNewest = true
paDirs = true
master map[string][]app
linmaster map[string][]app
cats []string
lin []string
comEnbld bool
populated bool
)

func main() {
Expand Down Expand Up @@ -57,63 +51,6 @@ func uiStart(forced bool) {
gtk.Main()
}

func savePrefs() {
os.Remove("PortableApps/LinuxPACom/Prefs.gob")
fil, err := os.Create("PortableApps/LinuxPACom/Prefs.gob")
if err != nil {
return
}
enc := gob.NewEncoder(fil)
err = enc.Encode(wine)
if err != nil {
return
}
err = enc.Encode(portableHide)
if err != nil {
return
}
err = enc.Encode(versionNewest)
if err != nil {
return
}
err = enc.Encode(paDirs)
if err != nil {
return
}
err = enc.Encode(betaUpdate)
if err != nil {
return
}
}

func loadPrefs() {
fil, err := os.Open("PortableApps/LinuxPACom/Prefs.gob")
if err != nil {
return
}
dec := gob.NewDecoder(fil)
err = dec.Decode(&wine)
if err != nil {
return
}
err = dec.Decode(&portableHide)
if err != nil {
return
}
err = dec.Decode(&versionNewest)
if err != nil {
return
}
err = dec.Decode(&paDirs)
if err != nil {
return
}
err = dec.Decode(&betaUpdate)
if err != nil {
return
}
}

func contains(arr []string, str string) bool {
for _, v := range arr {
if v == str {
Expand Down
72 changes: 72 additions & 0 deletions preferences.go
@@ -0,0 +1,72 @@
package main

import (
"encoding/gob"
"os"
)

var (
wine bool
wineAvail bool
portableHide bool
betaUpdate bool
versionNewest = true
paDirs = true
)

func savePrefs() {
os.Remove("PortableApps/LinuxPACom/Prefs.gob")
fil, err := os.Create("PortableApps/LinuxPACom/Prefs.gob")
if err != nil {
return
}
enc := gob.NewEncoder(fil)
err = enc.Encode(wine)
if err != nil {
return
}
err = enc.Encode(portableHide)
if err != nil {
return
}
err = enc.Encode(versionNewest)
if err != nil {
return
}
err = enc.Encode(paDirs)
if err != nil {
return
}
err = enc.Encode(betaUpdate)
if err != nil {
return
}
}

func loadPrefs() {
fil, err := os.Open("PortableApps/LinuxPACom/Prefs.gob")
if err != nil {
return
}
dec := gob.NewDecoder(fil)
err = dec.Decode(&wine)
if err != nil {
return
}
err = dec.Decode(&portableHide)
if err != nil {
return
}
err = dec.Decode(&versionNewest)
if err != nil {
return
}
err = dec.Decode(&paDirs)
if err != nil {
return
}
err = dec.Decode(&betaUpdate)
if err != nil {
return
}
}
50 changes: 33 additions & 17 deletions setup.go
Expand Up @@ -2,13 +2,15 @@ package main

import (
"bufio"
"encoding/json"
_ "image/png"
"os"
"os/exec"
"reflect"
"sort"
"strings"

"github.com/CalebQ42/GoAppImage"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/gtk"
)
Expand Down Expand Up @@ -64,28 +66,12 @@ func setup() {
}
}
}
populated = true
}

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"
}
if portableHide {
out.name = strings.TrimSuffix(out.name, "Portable")
}
out.icon = getIcon(fold)
folder, _ := os.Open(fold)
fis, _ := folder.Readdirnames(-1)
for _, v := range fis {
Expand Down Expand Up @@ -116,6 +102,36 @@ func processApp(fold string) (out app) {
out.name += " (Wine)"
out.wine = true
}
out.icon = getIcon(fold)
if len(out.appimg) > 0 {
os.Mkdir(out.dir+"/.appimageconfig", 0777)
fil, err := os.Open(out.dir + "/.appimageconfig/info.json")
if err == os.ErrNotExist {
fil, _ = os.Create(out.dir + "/.appimageconfig/info.json")
ai := goappimage.NewAppImage(out.dir + "/" + out.appimg[0])
ai.ExtractDesktop(out.dir + "/.appimageconfig/the.desktop")
//extract desktop and parse info then send to json
//also md5 so when updating happens it can update the desktop file
ai.Free()
} else {
//decode json, check if desktop needs to be updated
}
//Parse extracted desktop file
}
out.ini = findInfo(fold)
if out.ini != nil {
out.name = getName(out.ini)
out.cat = getCat(out.ini)
}
if out.name == "" {
out.name = strings.TrimPrefix(fold, "PortableApps/")
}
if out.cat == "" {
out.cat = "Other"
}
if portableHide {
out.name = strings.TrimSuffix(out.name, "Portable")
}
return
}

Expand Down

0 comments on commit ec4d66f

Please sign in to comment.