import os import subprocess import sys import gi if 'QRCODE_TESTER_SELF_RUN' not in os.environ: ARCH_TRIPLET = subprocess.check_output( ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).decode().strip() os.environ['GI_TYPELIB_PATH'] = ':'.join([ f'/usr/lib/{ARCH_TRIPLET}/gnome-shell', f'/usr/lib/gnome-shell', f'/usr/lib/{ARCH_TRIPLET}/mutter-14', f'/usr/lib/{ARCH_TRIPLET}/girepository-1.0', os.getenv('GI_TYPELIB_PATH', ''), ]) os.environ['LD_LIBRARY_PATH'] = ':'.join([ f'/usr/lib/{ARCH_TRIPLET}/gnome-shell', f'/usr/lib/gnome-shell', f'/usr/lib/{ARCH_TRIPLET}/mutter-14', f'/usr/lib/{ARCH_TRIPLET}/girepository-1.0', os.getenv('LD_LIBRARY_PATH', ''), ]) os.environ['QRCODE_TESTER_SELF_RUN'] = "1" os.execv(sys.executable, [sys.executable] + sys.argv) gi.require_version('Shell', '14') gi.require_version('Meta', '14') gi.require_version('Gtk', '4.0') from gi.repository import Gtk, Shell, Meta os.environ["XDG_RUNTIME_DIR"] = "/tmp/mutter-tester" SIZE = 350 image = Gtk.Image.new() def on_activate(app): win = Gtk.ApplicationWindow(application=app) win.set_default_size(SIZE, SIZE) image.set_from_icon_name('start-here') win.set_child(image) win.present() def on_generate_cb(generator, res): icon = generator.generate_qr_code_finish(res) print("finished", icon) image.set_from_gicon(icon) image.set_pixel_size(SIZE) app = Gtk.Application() app.connect('activate', on_activate) ctx = Meta.create_context("tester") ctx.set_plugin_name("libdefault") ctx.configure([sys.argv[0], "--wayland", "--headless"]) ctx.setup() qrcode_generator = Shell.QrCodeGenerator.new() qrcode_generator.generate_qr_code(url="https://bugs.launchpad.net/ubuntu/+source/gnome-shell", width=SIZE, height=SIZE, callback=on_generate_cb) app.run(None)