This change allows GTK3 themes to make the gnome-calculator window transparent. It checks if a RGBA visual is available and if a compositor is running, and only then uses the RGBA visual, and falls back to the default screen visual otherwise.
When updating the application to GTK4, this will not be necessary anymore since they use RGBA visuals by default. (https://developer.gnome.org/gtk4/stable/gtk-migrating-3-to-4.html#id-220.127.116.11.9)
Here is a little demo video of the old, sad and not transparent gnome-calculator on the right, and the new, happy and exciting gnome-calculator with transparency support on the left:
Make sure my code is fine, since i have literally learned what vala is like 25 minutes ago.