forked from Leak_Technologies/VideoTools
Compare commits
10 Commits
bec66816df
...
29bc1ac19c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29bc1ac19c | ||
|
|
20c4b5d177 | ||
|
|
5cd4c22764 | ||
|
|
aac6d6eb95 | ||
|
|
32434dbc28 | ||
|
|
fdb0f44fa7 | ||
|
|
6fc4d80e6c | ||
|
|
2239c5cf3a | ||
|
|
93bd8a1424 | ||
|
|
4d33e1ec71 |
|
|
@ -5,6 +5,7 @@ import (
|
|||
"log"
|
||||
"path/filepath"
|
||||
"time"
|
||||
"strings"
|
||||
|
||||
"git.leaktechnologies.dev/stu/VT_Player/player/mpvembed"
|
||||
|
||||
|
|
@ -176,7 +177,12 @@ func buildControls(win *gtk.Window, left, right *pane) *gtk.Box {
|
|||
defer t.Stop()
|
||||
for range t.C {
|
||||
text := metaSummary(left, right)
|
||||
glib.IdleAdd(func() { info.SetText(text) })
|
||||
_ = glib.IdleAdd(func() {
|
||||
defer func() {
|
||||
_ = recover()
|
||||
}()
|
||||
info.SetText(text)
|
||||
})
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -236,6 +242,7 @@ func getWindowID(w *gdk.Window) uint64 {
|
|||
if w == nil {
|
||||
return 0
|
||||
}
|
||||
// gdk_x11_window_get_xid only works on X11; return 0 on other backends.
|
||||
return uint64(gdkWindowGetXID(w))
|
||||
}
|
||||
|
||||
|
|
@ -266,16 +273,43 @@ func preferDark() {
|
|||
}
|
||||
|
||||
func setupDragDest(p *pane, win *gtk.Window) {
|
||||
// Accept URI drops
|
||||
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, []gtk.TargetEntry{gtk.TargetEntry{}} /* dummy */, gdk.ACTION_COPY)
|
||||
// Accept URI drops using a target list
|
||||
target, err := gtk.TargetEntryNew("text/uri-list", gtk.TARGET_OTHER_APP, 0)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// DragDestSet requires at least one target; use the URI target.
|
||||
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, []gtk.TargetEntry{*target}, gdk.ACTION_COPY)
|
||||
p.area.Connect("drag-data-received", func(_ *gtk.DrawingArea, ctx *gdk.DragContext, x, y int, data *gtk.SelectionData, info uint, t uint32) {
|
||||
uris := data.GetURIs()
|
||||
if len(uris) == 0 {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("drag handler panic: %v", r)
|
||||
}
|
||||
}()
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
// Take first URI
|
||||
if path := uriToPath(uris[0]); path != "" {
|
||||
loadIntoPane(p, path)
|
||||
raw := data.GetData()
|
||||
if len(raw) == 0 {
|
||||
// try text fallback
|
||||
if txt := data.GetText(); txt != "" {
|
||||
raw = []byte(txt)
|
||||
}
|
||||
}
|
||||
if len(raw) == 0 {
|
||||
return
|
||||
}
|
||||
// text/uri-list: newline or CRLF separated
|
||||
lines := strings.Split(string(raw), "\n")
|
||||
for _, ln := range lines {
|
||||
ln = strings.TrimSpace(ln)
|
||||
if ln == "" {
|
||||
continue
|
||||
}
|
||||
if path := uriToPath(ln); path != "" {
|
||||
loadIntoPane(p, path)
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,27 @@
|
|||
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BUILD_OUTPUT="$PROJECT_ROOT/vt_player"
|
||||
GTK_ENTRY="$PROJECT_ROOT/cmd/gtkplayer"
|
||||
|
||||
echo "════════════════════════════════════════════════════════════════"
|
||||
echo " VT Player - Run Script"
|
||||
echo "════════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
# Check if binary exists
|
||||
# If a GTK entry exists, run it directly (uses mpv embedded)
|
||||
if [ -d "$GTK_ENTRY" ]; then
|
||||
echo "🚀 Starting VT Player (GTK/mpv)..."
|
||||
echo "════════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
export GDK_BACKEND=x11
|
||||
export GOCACHE="$PROJECT_ROOT/.cache/go-build"
|
||||
export GOMODCACHE="$PROJECT_ROOT/.cache/go-mod"
|
||||
GOCACHE="$GOCACHE" GOMODCACHE="$GOMODCACHE" \
|
||||
go run "$GTK_ENTRY"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Fallback to legacy binary
|
||||
if [ ! -f "$BUILD_OUTPUT" ]; then
|
||||
echo "⚠️ Binary not found. Building..."
|
||||
echo ""
|
||||
|
|
@ -18,7 +32,6 @@ if [ ! -f "$BUILD_OUTPUT" ]; then
|
|||
echo ""
|
||||
fi
|
||||
|
||||
# Verify binary exists
|
||||
if [ ! -f "$BUILD_OUTPUT" ]; then
|
||||
echo "❌ ERROR: Build failed, cannot run."
|
||||
exit 1
|
||||
|
|
@ -28,12 +41,9 @@ echo "🚀 Starting VT Player..."
|
|||
echo "════════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
# Optional software rendering fallback:
|
||||
# Default to software (avoid GLX errors); set VTPLAYER_HW=1 to force hardware.
|
||||
if [ "$VTPLAYER_HW" != "1" ]; then
|
||||
export FYNE_SW_CANVAS=1
|
||||
export LIBGL_ALWAYS_SOFTWARE=1
|
||||
fi
|
||||
|
||||
# Run the application
|
||||
"$BUILD_OUTPUT" "$@"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user