[gtk+] Add a portal helper
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a portal helper
- Date: Fri, 8 Jul 2016 04:09:48 +0000 (UTC)
commit 96d8afbccb08709db70995be6f273309a6e484e5
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jul 4 20:29:59 2016 -0400
Add a portal helper
Instead of open-coding checks for sandboxing in multiple
places, add a helper function that caches the information.
https://bugzilla.gnome.org/show_bug.cgi?id=768499
gtk/gtkprivate.c | 24 ++++++++++++++++++++++++
gtk/gtkprivate.h | 2 ++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c
index 8f0da6d..02448d7 100644
--- a/gtk/gtkprivate.c
+++ b/gtk/gtkprivate.c
@@ -267,3 +267,27 @@ _gtk_ensure_resources (void)
g_once (®ister_resources_once, register_resources, NULL);
}
+
+gboolean
+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";
+ else
+ {
+ use_portal = g_getenv ("GTK_USE_PORTAL");
+ if (!use_portal)
+ use_portal = "";
+ }
+ g_free (path);
+ }
+
+ return use_portal[0] == '1';
+}
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 7602394..af130cd 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]