Add a portal helper

Instead of open-coding checks for sandboxing in multiple
places, add a helper function. This function is identical
to glib_should_use_portal() in gio.
This commit is contained in:
Matthias Clasen
2016-07-04 20:29:59 -04:00
parent 66e2522c5a
commit 69f63cd99c
2 changed files with 22 additions and 0 deletions

View File

@@ -267,3 +267,23 @@ _gtk_ensure_resources (void)
g_once (&register_resources_once, register_resources, NULL);
}
gboolean
gtk_should_use_portal (void)
{
const char *use_portal;
char *path;
path = g_strdup_printf ("%s/flatpak-info", g_get_user_runtime_dir ());
if (g_file_test (path, G_FILE_TEST_EXISTS))
use_portal = "1";
else
{
use_portal = g_getenv ("GTK_USE_PORTAL");
if (!use_portal)
use_portal = "";
}
g_free (path);
return g_str_equal (use_portal, "1");
}

View File

@@ -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);
#endif