Skip to content

Slightly improve GTK_USE_PORTAL env evaluation

When checking whether or not to enable desktop portal, the previous way of evaluating the environment variable GTK_USE_PORTAL was to check whether the environment was set and the first character of its value was '1' which had the effect that e.g. all of

GTK_USE_PORTAL=1
GTK_USE_PORTAL=10
GTK_USE_PORTAL=100

would enable the use of the portal, while e.g.

GTK_USE_PORTAL=01
GTK_USE_PORTAL=2

would not. (The sample program from #1820 (comment 834241) can be use for testing.)

This MR makes this a bit more consistent by checking whether the value represents an integer other than 0, which makes all of the above behave the same.

This MR is a result from the review received when suggesting to have Firefox do the same evaluation that gtk curently does, see https://phabricator.services.mozilla.com/D80073#2447190.

An alternative to make the handling more consistent would IMHO be to recognize only GTK_USE_PORTAL=1 to enable the portal, i.e. use

return g_strcmp0 (use_portal, "1") == 0

If this MR is accepted, I plan to submit a similar one for the gtk-3-24 branch.

Merge request reports