mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-06 02:40:07 +00:00
Add a gdk_should_use_portal helper
We are going to use this in the following commits.
This commit is contained in:
parent
fb709e96f1
commit
4073d0217b
@ -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__ */
|
||||
|
20
gdk/gdk.c
20
gdk/gdk.c
@ -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:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user