From adf8261424a5287124dde7daa99a94675a89f5e8 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Fri, 3 May 2024 16:14:54 -0700 Subject: [PATCH] Try to use WebKit2Gtk v4.1 rather than v4.0, if available Thanks to @jbicha in https://github.com/dlenski/gp-saml-gui/issues/92 for bringing this to my attention; I've chosen to implement this with automatic fallback to v4.0, with a warning. --- gp_saml_gui.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gp_saml_gui.py b/gp_saml_gui.py index dad87cf..7e873b6 100755 --- a/gp_saml_gui.py +++ b/gp_saml_gui.py @@ -1,9 +1,15 @@ #!/usr/bin/env python3 +import warnings try: import gi + gi.require_version('Gtk', '3.0') - gi.require_version('WebKit2', '4.0') + try: + gi.require_version('WebKit2', '4.1') + except ValueError: # I wish this were ImportError + gi.require_version('WebKit2', '4.0') + warnings.warn("Using WebKit2Gtk 4.0 (obsolete); please upgrade to WebKit2Gtk 4.1") from gi.repository import Gtk, WebKit2, GLib except ImportError: try: @@ -11,10 +17,11 @@ gi.require_version('Gtk', '3.0') gi.require_version('WebKit2', '4.0') from pgi.repository import Gtk, WebKit2, GLib + warnings.warn("Using PGI and WebKit2Gtk 4.0 (both obsolete); please upgrade to PyGObject and WebKit2Gtk 4.1") except ImportError: gi = None if gi is None: - raise ImportError("Either gi (PyGObject) or pgi module is required.") + raise ImportError("Either gi (PyGObject) or pgi (obsolete) module is required.") import argparse import urllib3