Repos / gorts / fa3ffd4b9f
commit fa3ffd4b9f68a56c66b520f7fa8085332e5e6870
Author: Nhân <hi@imnhan.com>
Date: Sat Jun 17 23:11:54 2023 +0700
set tk window icon too
diff --git a/Makefile b/Makefile
index 3c17458..30dd7c8 100644
--- a/Makefile
+++ b/Makefile
@@ -9,10 +9,14 @@ dist-windows:
go build -o dist/windows/gorts.exe -ldflags -H=windowsgui
cp -r web dist/windows/web
-# gorts.ico was produced from Haiku OS's midiplayer icon using imagemagick:
-# convert -background transparent -density 300 \
-# -define 'icon:auto-resize=256,128,64,32,24,16' \
-# App_MidiPlayer.svg ~/pj/gorts/gorts.ico
+gorts.png: gorts.svg
+ convert -background transparent -density 300 -resize 256x256 gorts.svg gorts.png
+
+gorts.ico: gorts.svg
+ convert -background transparent -density 300 \
+ -define 'icon:auto-resize=256,128,64,32,24,16' \
+ gorts.svg gorts.ico
+
gorts.syso: gorts.ico
# needs `go install github.com/akavel/rsrc@latest`
rsrc -ico gorts.ico -o gorts.syso
diff --git a/gorts.png b/gorts.png
new file mode 100644
index 0000000..c4f08de
Binary files /dev/null and b/gorts.png differ
diff --git a/gorts.svg b/gorts.svg
new file mode 100644
index 0000000..e3522e8
--- /dev/null
+++ b/gorts.svg
@@ -0,0 +1,139 @@
+<!--
+This icon was originally named App_MidiPlayer.svg,
+taken from https://github.com/darealshinji/haiku-icons.
+The following is its original license:
+
+The MIT License (MIT)
+
+Copyright (c) 2007-2020 Haiku, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+-->
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<svg version="1.1" width="64" height="64" color-interpolation="linearRGB"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg">
+ <g>
+ <path style="fill:#000000; fill-opacity:0.3882"
+ d="M60 31.39L32 60H38L64 33.39L60 31.39z"
+ />
+ <path style="fill:none; stroke:#000000; stroke-width:4"
+ d="M2 31V43L32 58L58 32V20L30 10L2 31z"
+ />
+ <linearGradient id="gradient0" gradientUnits="userSpaceOnUse" x1="45.2" y1="-3.44" x2="66.1" y2="20.77">
+ <stop offset="0" stop-color="#3578dc"/>
+ <stop offset="1" stop-color="#124ea9"/>
+ </linearGradient>
+ <path style="fill:url(#gradient0)"
+ d="M32 44L2 31V43L32 58V44z"
+ />
+ <linearGradient id="gradient1" gradientUnits="userSpaceOnUse" x1="56.48" y1="3.36" x2="71.86" y2="12.73">
+ <stop offset="0" stop-color="#033177"/>
+ <stop offset="1" stop-color="#154ea2"/>
+ </linearGradient>
+ <path style="fill:url(#gradient1)"
+ d="M32 44L58 20V32L32 58V44z"
+ />
+ <linearGradient id="gradient2" gradientUnits="userSpaceOnUse" x1="8" y1="-64" x2="56" y2="-64">
+ <stop offset="0" stop-color="#c0d9ff"/>
+ <stop offset="1" stop-color="#5e95e8"/>
+ </linearGradient>
+ <path style="fill:url(#gradient2)"
+ d="M32 44L58 20L30 10L2 31L32 44z"
+ />
+ <path style="fill:#c7ddff"
+ d="M34.62 13.91L34.82 15.62L36.82 16.38L17.33 33.86L17.52 34.59L38.51 15.6L34.62 13.91z"
+ />
+ <linearGradient id="gradient3" gradientUnits="userSpaceOnUse" x1="56.48" y1="3.36" x2="71.86" y2="12.73">
+ <stop offset="0" stop-color="#033177"/>
+ <stop offset="1" stop-color="#154ea2"/>
+ </linearGradient>
+ <path style="fill:url(#gradient3)"
+ d="M15.33 32.87L34.81 15.62L34.62 13.91L13.64 32.64L17.52 34.59L17.33 33.86L15.33 32.87z"
+ />
+ <path style="fill:#140262"
+ d="M17.33 33.86L36.81 16.38L34.81 15.62L15.33 32.87L17.33 33.86z"
+ />
+ <path style="fill:none; stroke:#000000; stroke-width:4"
+ d="M22 20L19 23V26L25 29L28 26V23C28 23 26.52 21.76 25 21C23.52 20.26 22 20 22 20z"
+ />
+ <linearGradient id="gradient4" gradientUnits="userSpaceOnUse" x1="29.57" y1="15.76" x2="33.84" y2="20.45">
+ <stop offset="0" stop-color="#ffffff"/>
+ <stop offset="1" stop-color="#c9c9c9"/>
+ </linearGradient>
+ <path style="fill:url(#gradient4)"
+ d="M22 20L19 23C19 23 20.5 23.25 22 24C23.5 24.75 25 26 25 26L28 23C28 23 26.5 21.75 25 21C23.5 20.25 22 20 22 20z"
+ />
+ <linearGradient id="gradient5" gradientUnits="userSpaceOnUse" x1="62.28" y1="-13.24" x2="69.02" y2="-5.42">
+ <stop offset="0" stop-color="#e2e2e2"/>
+ <stop offset="1" stop-color="#898989"/>
+ </linearGradient>
+ <path style="fill:url(#gradient5)"
+ d="M19 23V26L25 29V26C25 26 23.5 24.75 22 24C20.5 23.25 19 23 19 23z"
+ />
+ <path style="fill:#979797"
+ d="M25 26V29L28 26V23L25 26z"
+ />
+ <path style="fill:none; stroke:#000000; stroke-width:2"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ />
+ <radialGradient id="gradient6" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="64" gradientTransform="matrix(0.0781,0,0,0.0468,30,37)">
+ <stop offset="0" stop-color="#75ff75"/>
+ <stop offset="1" stop-color="#04a904"/>
+ </radialGradient>
+ <path style="fill:url(#gradient6)"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ />
+ <path style="fill:none; stroke:#000000; stroke-width:2"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ transform="matrix(1,0,0,1,5,-5)"
+ />
+ <radialGradient id="gradient7" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="64" gradientTransform="matrix(0.0781,0,0,0.0468,30,37)">
+ <stop offset="0" stop-color="#75ff75"/>
+ <stop offset="1" stop-color="#04a904"/>
+ </radialGradient>
+ <path style="fill:url(#gradient7)"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ transform="matrix(1,0,0,1,5,-5)"
+ />
+ <path style="fill:none; stroke:#000000; stroke-width:2"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ transform="matrix(1,0,0,1,10,-10)"
+ />
+ <radialGradient id="gradient8" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="64" gradientTransform="matrix(0.0781,0,0,0.0468,30,37)">
+ <stop offset="0" stop-color="#fff589"/>
+ <stop offset="1" stop-color="#ff9630"/>
+ </radialGradient>
+ <path style="fill:url(#gradient8)"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ transform="matrix(1,0,0,1,10,-10)"
+ />
+ <path style="fill:none; stroke:#000000; stroke-width:2"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ transform="matrix(1,0,0,1,15,-15)"
+ />
+ <radialGradient id="gradient9" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="64" gradientTransform="matrix(0.0781,0,0,0.0468,30,37)">
+ <stop offset="0" stop-color="#ffb3b3"/>
+ <stop offset="1" stop-color="#ed0606"/>
+ </radialGradient>
+ <path style="fill:url(#gradient9)"
+ d="M29 35C27.89 35 27 35.67 27 36.5C27 37.32 27.89 38 29 38C30.1 38 31 37.32 31 36.5C31 35.67 30.1 35 29 35z"
+ transform="matrix(1,0,0,1,15,-15)"
+ />
+ </g>
+</svg>
diff --git a/main.go b/main.go
index c011b33..9602b59 100644
--- a/main.go
+++ b/main.go
@@ -3,7 +3,9 @@
import (
"bufio"
_ "embed"
+ "encoding/base64"
"encoding/json"
+ "fmt"
"io"
"io/ioutil"
"log"
@@ -21,6 +23,9 @@
//go:embed tcl/main.tcl
var mainTcl string
+//go:embed gorts.png
+var gortsPngIcon []byte
+
func main() {
// No need to wait on the http server,
// just let it die when the GUI is closed.
@@ -65,6 +70,9 @@ func startGUI() {
// TODO: this should probably be refactored out
state := initState()
+ b64icon := base64.StdEncoding.EncodeToString(gortsPngIcon)
+ fmt.Fprintf(stdin, "seticon %s\n", b64icon)
+
io.WriteString(stdin, "readstate\n")
scanner := bufio.NewScanner(stdout)
diff --git a/tcl/main.tcl b/tcl/main.tcl
index bafb957..f23fb36 100644
--- a/tcl/main.tcl
+++ b/tcl/main.tcl
@@ -77,8 +77,16 @@ grid columnconfigure .c.buttons 1 -pad 15
grid columnconfigure .c.buttons 3 -pad 15
-# Very simple line-based IPC where Tcl client talks to Go server
-# via stdin/stdout.
+# The following procs constitute a very simple line-based IPC system where Tcl
+# client talks to Go server via stdin/stdout.
+
+proc seticon {b64data} {
+ image create photo applicationIcon -data [
+ binary decode base64 $b64data
+ ]
+ wm iconphoto . -default applicationIcon
+}
+
proc readstate {} {
puts "readstate"
variable description