Finishing up gui

This commit is contained in:
Belac Darkstorm
2017-04-04 18:35:28 -05:00
parent a221d18d33
commit 3199ad88fd
6 changed files with 506 additions and 336 deletions
+13 -17
View File
@@ -3,15 +3,14 @@ package main
import (
"bufio"
"fmt"
"image"
"image/draw"
_ "image/png"
"os"
"reflect"
"sort"
"strings"
"github.com/nelsam/gxui"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/gtk"
)
func setup() {
@@ -155,8 +154,8 @@ func getName(ini *os.File) string {
return ret
}
func getIcon(fold string) gxui.Texture {
var pic *os.File
func getIcon(fold string) *gdk.Pixbuf {
var pic string
if folder, err := os.Open(fold + "/App/AppInfo"); err == nil {
fis, _ := folder.Readdir(-1)
var pics []string
@@ -173,21 +172,18 @@ func getIcon(fold string) gxui.Texture {
} else {
ind = sort.SearchStrings(pics, "appicon_32.png")
}
pic, _ = os.Open(fold + "/App/AppInfo/" + pics[ind])
pic = fold + "/App/AppInfo/" + pics[ind]
}
} else if fi, err := os.Open(fold + "/appicon.png"); err == nil {
pic = fi
} else if _, err := os.Open(fold + "/appicon.png"); err == nil {
pic = fold + "/appicon.png"
} else {
return nil
img, _ := gtk.ImageNewFromIconName("application-x-executable", gtk.ICON_SIZE_BUTTON)
buf, _ := img.GetPixbuf().ScaleSimple(32, 32, gdk.INTERP_BILINEAR)
return buf
}
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
img, _ := gtk.ImageNewFromFile(pic)
buf, _ := img.GetPixbuf().ScaleSimple(32, 32, gdk.INTERP_BILINEAR)
return buf
}
func findInfo(fold string) *os.File {