Add a gdk_should_use_portal helper

We are going to use this in the following commits.
This commit is contained in:
Matthias Clasen 2018-11-04 08:20:52 -05:00
parent fb709e96f1
commit 4073d0217b
2 changed files with 21 additions and 0 deletions

View File

@ -62,5 +62,6 @@ GDK_AVAILABLE_IN_ALL
GdkPrivateVTable * gdk__private__ (void);
gboolean gdk_running_in_sandbox (void);
gboolean gdk_should_use_portal (void);
#endif /* __GDK__PRIVATE_H__ */

View File

@ -474,6 +474,26 @@ gdk_running_in_sandbox (void)
return g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
}
gboolean
gdk_should_use_portal (void)
{
static const char *use_portal = NULL;
if (G_UNLIKELY (use_portal == NULL))
{
if (gdk_running_in_sandbox ())
use_portal = "1";
else
{
use_portal = g_getenv ("GTK_USE_PORTAL");
if (!use_portal)
use_portal = "";
}
}
return use_portal[0] == '1';
}
/**
* gdk_display_open_default_libgtk_only:
*