From cf910fdceadda8de4adcb78d25d655497e042b28 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Fri, 16 Aug 2019 13:04:33 +0100
Subject: [PATCH] unruntime: Show an error with zenity if the GUI isn't going
 to work

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 pressure-vessel-test-ui   |  3 ++-
 pressure-vessel-unruntime | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/pressure-vessel-test-ui b/pressure-vessel-test-ui
index 30340030c..fdf001f04 100755
--- a/pressure-vessel-test-ui
+++ b/pressure-vessel-test-ui
@@ -273,4 +273,5 @@ class Gui:
 
 
 if __name__ == '__main__':
-    Gui().run()
+    if '--check-gui-dependencies' not in sys.argv:
+        Gui().run()
diff --git a/pressure-vessel-unruntime b/pressure-vessel-unruntime
index d8ee9b715..7f4d194d0 100755
--- a/pressure-vessel-unruntime
+++ b/pressure-vessel-unruntime
@@ -36,6 +36,7 @@ here="${me%/*}"
 me="${me##*/}"
 
 default_path="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
+steam_runtime="${STEAM_RUNTIME-}"
 
 # Undo any weird environment before we start running external
 # executables. We put it back before running the actual app/game.
@@ -97,6 +98,24 @@ done
 IFS="$old_IFS"
 
 if [ -n "${PRESSURE_VESSEL_WRAP_GUI+set}" ]; then
+    if ! result="$("${here}/pressure-vessel-test-ui" --check-gui-dependencies 2>&1)"; then
+        result="$(printf '%s' "$result" | sed -e 's/&/\&amp;/' -e 's/</\&lt;/' -e 's/>/\&gt;/')"
+        run="env"
+
+        case "$steam_runtime" in
+            (/*)
+                # Re-enter the Steam Runtime, because STEAM_ZENITY might
+                # not work otherwise
+                run="$steam_runtime/run.sh"
+                ;;
+        esac
+
+        exec "$run" "${STEAM_ZENITY:-zenity}" --error --width 500 --text \
+            "The pressure-vessel developer/debugging options menu requires Python 3, PyGI, GTK 3, and GTK 3 GObject-Introspection data.
+
+<small>$result</small>"
+    fi
+
     exec "${here}/pressure-vessel-test-ui" ${options+"${options[@]}"} "$@"
 fi
 
-- 
GitLab