[gtk/settings-portal-for-3: 2/3] Add a gdk_should_use_portal helper
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/settings-portal-for-3: 2/3] Add a gdk_should_use_portal helper
- Date: Sun, 4 Nov 2018 15:22:45 +0000 (UTC)
commit 4073d0217bea9485f1da6e917e36e0e6d9a0ff4a
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Nov 4 08:20:52 2018 -0500
Add a gdk_should_use_portal helper
We are going to use this in the following commits.
gdk/gdk-private.h | 1 +
gdk/gdk.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
---
diff --git a/gdk/gdk-private.h b/gdk/gdk-private.h
index 5d35eb54d8..9ec724bced 100644
--- a/gdk/gdk-private.h
+++ b/gdk/gdk-private.h
@@ -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__ */
diff --git a/gdk/gdk.c b/gdk/gdk.c
index f4e4413300..26950a87e3 100644
--- a/gdk/gdk.c
+++ b/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:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]