From ce605084802f98baac2f6aab3f064947acc07eaa Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Sat, 29 Nov 2025 19:53:47 -0500 Subject: [PATCH] Add build/run scripts and fix DVD options visibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added scripts folder with three convenience scripts: • scripts/build.sh - Clean build with dependency verification • scripts/run.sh - Run application (auto-builds if needed) • scripts/alias.sh - Create 'VideoTools' command alias Usage: source scripts/alias.sh VideoTools # Run app VideoToolsRebuild # Force rebuild VideoToolsClean # Clean artifacts Fixed main.go DVD options: • Fixed callback ordering so updateDVDOptions is called on format selection • DVD aspect ratio selector now appears when DVD format is selected • DVD info display shows specs for NTSC and PAL formats • Works in both Simple and Advanced tabs DVD options are now fully functional in the UI. --- main.go | 30 ++++++++++-------------- scripts/alias.sh | 36 ++++++++++++++++++++++++++++ scripts/build.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/run.sh | 32 +++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 18 deletions(-) create mode 100755 scripts/alias.sh create mode 100755 scripts/build.sh create mode 100755 scripts/run.sh diff --git a/main.go b/main.go index e53ffc3..0bbb934 100644 --- a/main.go +++ b/main.go @@ -1397,17 +1397,6 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { formatLabels = append(formatLabels, opt.Label) } outputHint := widget.NewLabel(fmt.Sprintf("Output file: %s", state.convert.OutputFile())) - formatSelect := widget.NewSelect(formatLabels, func(value string) { - for _, opt := range formatOptions { - if opt.Label == value { - logging.Debug(logging.CatUI, "format set to %s", value) - state.convert.SelectedFormat = opt - outputHint.SetText(fmt.Sprintf("Output file: %s", state.convert.OutputFile())) - break - } - } - }) - formatSelect.SetSelected(state.convert.SelectedFormat.Label) // DVD-specific aspect ratio selector (only shown for DVD formats) dvdAspectSelect := widget.NewSelect([]string{"4:3", "16:9"}, func(value string) { @@ -1442,14 +1431,19 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { } } - // Update formatSelect callback to also handle DVD options visibility - originalFormatCallback := formatSelect.OnChanged - formatSelect.OnChanged = func(value string) { - if originalFormatCallback != nil { - originalFormatCallback(value) + // Create formatSelect with callback that updates DVD options + formatSelect := widget.NewSelect(formatLabels, func(value string) { + for _, opt := range formatOptions { + if opt.Label == value { + logging.Debug(logging.CatUI, "format set to %s", value) + state.convert.SelectedFormat = opt + outputHint.SetText(fmt.Sprintf("Output file: %s", state.convert.OutputFile())) + updateDVDOptions() // Show/hide DVD options + break + } } - updateDVDOptions() - } + }) + formatSelect.SetSelected(state.convert.SelectedFormat.Label) qualitySelect := widget.NewSelect([]string{"Draft (CRF 28)", "Standard (CRF 23)", "High (CRF 18)", "Lossless"}, func(value string) { logging.Debug(logging.CatUI, "quality preset %s", value) diff --git a/scripts/alias.sh b/scripts/alias.sh new file mode 100755 index 0000000..227a375 --- /dev/null +++ b/scripts/alias.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# VideoTools Convenience Script +# Source this file in your shell to add the 'VideoTools' command + +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +# Create alias and function for VideoTools +alias VideoTools="bash $PROJECT_ROOT/scripts/run.sh" + +# Also create a rebuild function for quick rebuilds +VideoToolsRebuild() { + echo "🔨 Rebuilding VideoTools..." + bash "$PROJECT_ROOT/scripts/build.sh" +} + +# Create a clean function +VideoToolsClean() { + echo "🧹 Cleaning VideoTools build artifacts..." + cd "$PROJECT_ROOT" + go clean -cache -modcache -testcache + rm -f "$PROJECT_ROOT/VideoTools" + echo "✓ Clean complete" +} + +echo "════════════════════════════════════════════════════════════════" +echo "✅ VideoTools Commands Available" +echo "════════════════════════════════════════════════════════════════" +echo "" +echo "Commands:" +echo " VideoTools - Run VideoTools (auto-builds if needed)" +echo " VideoToolsRebuild - Force rebuild of VideoTools" +echo " VideoToolsClean - Clean build artifacts and cache" +echo "" +echo "To make these permanent, add this line to your ~/.bashrc or ~/.zshrc:" +echo " source $PROJECT_ROOT/scripts/alias.sh" +echo "" diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..6b03a9e --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# VideoTools Build Script +# Cleans dependencies and builds the application with proper error handling + +set -e + +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BUILD_OUTPUT="$PROJECT_ROOT/VideoTools" + +echo "════════════════════════════════════════════════════════════════" +echo " VideoTools Build Script" +echo "════════════════════════════════════════════════════════════════" +echo "" + +# Check if go is installed +if ! command -v go &> /dev/null; then + echo "❌ ERROR: Go is not installed. Please install Go 1.21 or later." + exit 1 +fi + +echo "📦 Go version:" +go version +echo "" + +# Change to project directory +cd "$PROJECT_ROOT" + +echo "🧹 Cleaning previous builds and cache..." +go clean -cache -modcache -testcache 2>/dev/null || true +rm -f "$BUILD_OUTPUT" 2>/dev/null || true +echo "✓ Cache cleaned" +echo "" + +echo "⬇️ Downloading and verifying dependencies..." +go mod download +go mod verify +echo "✓ Dependencies verified" +echo "" + +echo "🔨 Building VideoTools..." +if CGO_ENABLED=0 go build -o "$BUILD_OUTPUT" .; then + echo "✓ Build successful!" + echo "" + echo "════════════════════════════════════════════════════════════════" + echo "✅ BUILD COMPLETE" + echo "════════════════════════════════════════════════════════════════" + echo "" + echo "Output: $BUILD_OUTPUT" + echo "Size: $(du -h "$BUILD_OUTPUT" | cut -f1)" + echo "" + echo "To run:" + echo " $PROJECT_ROOT/VideoTools" + echo "" + echo "Or use the convenience script:" + echo " source $PROJECT_ROOT/scripts/alias.sh" + echo " VideoTools" + echo "" +else + echo "❌ Build failed!" + exit 1 +fi diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000..023e1e1 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# VideoTools Run Script +# Builds (if needed) and runs the application + +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BUILD_OUTPUT="$PROJECT_ROOT/VideoTools" + +echo "════════════════════════════════════════════════════════════════" +echo " VideoTools - Run Script" +echo "════════════════════════════════════════════════════════════════" +echo "" + +# Check if binary exists +if [ ! -f "$BUILD_OUTPUT" ]; then + echo "⚠️ Binary not found. Building..." + echo "" + bash "$PROJECT_ROOT/scripts/build.sh" + echo "" +fi + +# Verify binary exists +if [ ! -f "$BUILD_OUTPUT" ]; then + echo "❌ ERROR: Build failed, cannot run." + exit 1 +fi + +echo "🚀 Starting VideoTools..." +echo "════════════════════════════════════════════════════════════════" +echo "" + +# Run the application +"$BUILD_OUTPUT" "$@"