[gtk+/portal: 3/18] Add a portal helper
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/portal: 3/18] Add a portal helper
- Date: Wed, 6 Jul 2016 17:02:38 +0000 (UTC)
commit 69f63cd99cce3c59648bb55f3c9d77859bc9b76a
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. This function is identical
to glib_should_use_portal() in gio.
gtk/gtkprivate.c | 20 ++++++++++++++++++++
gtk/gtkprivate.h | 2 ++
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c
index 8f0da6d..7f2a335 100644
--- a/gtk/gtkprivate.c
+++ b/gtk/gtkprivate.c
@@ -267,3 +267,23 @@ _gtk_ensure_resources (void)
g_once (®ister_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");
+}
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]