Commit 96d8afbc authored by Matthias Clasen's avatar Matthias Clasen

Add a portal helper

Instead of open-coding checks for sandboxing in multiple
places, add a helper function that caches the information.
parent b840a597
......@@ -267,3 +267,27 @@ _gtk_ensure_resources (void)
g_once (&register_resources_once, register_resources, NULL);
gtk_should_use_portal (void)
static const char *use_portal = NULL;
if (G_UNLIKELY (use_portal == NULL))
char *path;
path = g_build_filename (g_get_user_runtime_dir (), "flatpak-info", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
use_portal = "1";
use_portal = g_getenv ("GTK_USE_PORTAL");
if (!use_portal)
use_portal = "";
g_free (path);
return use_portal[0] == '1';
......@@ -95,6 +95,8 @@ gboolean _gtk_propagate_captured_event (GtkWidget *widget,
gdouble _gtk_get_slowdown ();
void _gtk_set_slowdown (gdouble slowdown_factor);
gboolean gtk_should_use_portal (void);
#ifdef G_OS_WIN32
void _gtk_load_dll_with_libgtk3_manifest (const char *dllname);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment