gio: Rename GTK_USE_PORTAL to GIO_USE_PORTALS

The `GTK_USE_PORTAL` environment variable has started to be misused by
users, which is causing deployment issues (such as portal services
themselves ending up being forced to use portals, which is never going
to work).

Try and sidestep users’ broken configurations by renaming the
environment variable, and also separating it from the old GTK
environment variable, since the GLib one affects a lot more processes.
This environment variable is meant to be used for
debugging and development, and never in production.

GTK already renamed their environment variable in
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4829, so keeping the
`GTK_USE_PORTAL` name in GLib doesn’t make sense anyway.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #3107
This commit is contained in:
Philip Withnall 2023-10-02 15:00:23 +01:00
parent 722dba7ccf
commit 5bc6c2035a
5 changed files with 14 additions and 4 deletions

View File

@ -428,6 +428,16 @@ Gvfs is also heavily distributed and relies on a session bus to be present.
</para>
</formalpara>
<formalpara>
<title><envar>GIO_USE_PORTALS</envar></title>
<para>
This variable can be set to override detection of portals and force them
to be used to provide various bits of GIO functionality, for testing and
debugging. This variable is not intended to be used in production.
</para>
</formalpara>
<formalpara>
<title><envar>GIO_MODULE_DIR</envar></title>

View File

@ -125,7 +125,7 @@ sandbox_info_read (void)
{
const char *var;
var = g_getenv ("GTK_USE_PORTAL");
var = g_getenv ("GIO_USE_PORTALS");
if (var && var[0] == '1')
use_portal = TRUE;
network_available = TRUE;

View File

@ -73,7 +73,7 @@ try:
raise
# subprocess.Popen(['gdbus', 'monitor', '--session', '--dest', 'org.freedesktop.portal.Desktop'])
os.environ['GTK_USE_PORTAL'] = "1"
os.environ['GIO_USE_PORTALS'] = "1"
self.memory_monitor = Gio.MemoryMonitor.dup_default()
assert("GMemoryMonitorPortal" in str(self.memory_monitor))
self.memory_monitor.connect("low-memory-warning", self.portal_memory_warning_cb)

View File

@ -37,7 +37,7 @@ main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_setenv ("GTK_USE_PORTAL", "1", TRUE);
g_setenv ("GIO_USE_PORTALS", "1", TRUE);
g_test_add_func ("/portal-support/env-var", test_portal_support_env_var);

View File

@ -79,7 +79,7 @@ try:
raise
# subprocess.Popen(['gdbus', 'monitor', '--session', '--dest', 'org.freedesktop.portal.Desktop'])
os.environ['GTK_USE_PORTAL'] = "1"
os.environ['GIO_USE_PORTALS'] = "1"
self.power_profile_monitor = Gio.PowerProfileMonitor.dup_default()
assert("GPowerProfileMonitorPortal" in str(self.power_profile_monitor))
self.power_profile_monitor.connect("notify::power-saver-enabled", self.power_saver_enabled_cb)