From 6317b2098b741acb6acc2a244a1eea7e56c49444 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 5 Aug 2025 03:36:34 -0400 Subject: [PATCH] Hopefully improve progressbars and update messages with yad. --- .includes/dialog-interface.sh | 55 ++++++++++++++++++++++++++++++++--- .includes/functions.sh | 16 ++++++++-- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/.includes/dialog-interface.sh b/.includes/dialog-interface.sh index 5721428..d5d9b4d 100644 --- a/.includes/dialog-interface.sh +++ b/.includes/dialog-interface.sh @@ -226,20 +226,67 @@ agm_progressbox() { local text="$2" if [[ "$dialogType" == "yad" ]]; then + # More accessible approach: Use a log window instead of pulsating progress + # This shows actual command output which is more informative for screen readers yad --progress \ --title="$title" \ --text="$text" \ - --pulsate \ + --enable-log="Operation Details" \ + --log-expanded \ --auto-close \ - --no-buttons \ - --show-cursor \ - --width=400 + --width=500 \ + --height=300 else dialog --title "$title" \ --progressbox "$text" 20 70 fi } +# Alternative status box for simple operations without meaningful progress +# Usage: agm_statusbox "title" "text" & statusPid=$!; command; kill $statusPid 2>/dev/null +agm_statusbox() { + local title="$1" + local text="$2" + + if [[ "$dialogType" == "yad" ]]; then + # Show a simple status message that screen readers can access + yad --form \ + --title="$title" \ + --field="$text:LBL" \ + --selectable-labels \ + --no-buttons \ + --timeout=0 \ + --width=400 \ + --height=100 + else + # Use infobox for console + dialog --title "$title" \ + --infobox "$text" 5 50 + fi +} + +# Real progress bar with percentage updates (for operations that can report progress) +# Usage: agm_progress_with_percent "title" "text" +# Then send "percentage" or "#status text" to the returned file descriptor +agm_progress_with_percent() { + local title="$1" + local text="$2" + + if [[ "$dialogType" == "yad" ]]; then + # Create a true progress dialog that accepts percentage updates + yad --progress \ + --title="$title" \ + --text="$text" \ + --auto-close \ + --width=400 \ + --height=150 + else + # For dialog, we'll simulate with a gauge + dialog --title "$title" \ + --gauge "$text" 6 50 0 + fi +} + # Wrapper function for file selection # Usage: agm_fselect "title" "backtitle" "default_path" agm_fselect() { diff --git a/.includes/functions.sh b/.includes/functions.sh index 9db7d64..fcfa3e7 100644 --- a/.includes/functions.sh +++ b/.includes/functions.sh @@ -53,9 +53,19 @@ download() { fi # Skip if the item is in cache. [[ -e "${cache}/${dest}" ]] && continue - if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" 2>&1 | agm_progressbox "Audio Game Manager" "Downloading \"$dest\"..."; then - agm_infobox "Audio Game Manager" "Audio Game Manager" "Could not download \"$dest\". Installation cannot continue." - exit 1 + if [[ "$dialogType" == "yad" ]]; then + # Use curl's progress bar with better accessibility for yad + if ! curl -L4 -C - --retry 10 --progress-bar --output "${cache}/${dest}" "${i}" 2>&1 | \ + sed -u 's/.*\r\([0-9]*\)%.*/\1/' | agm_progress_with_percent "Audio Game Manager" "Downloading \"$dest\"..."; then + agm_infobox "Audio Game Manager" "Audio Game Manager" "Could not download \"$dest\". Installation cannot continue." + exit 1 + fi + else + # Use the original method for dialog (console) + if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" 2>&1 | agm_progressbox "Audio Game Manager" "Downloading \"$dest\"..."; then + agm_infobox "Audio Game Manager" "Audio Game Manager" "Could not download \"$dest\". Installation cannot continue." + exit 1 + fi fi local downloadError=1 case "${dest##*.}" in