gdk: Add a private api to find sandboxes
authorMatthias Clasen <mclasen@redhat.com>
Mon, 28 May 2018 16:04:17 +0000 (12:04 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 30 May 2018 00:17:22 +0000 (20:17 -0400)
This will be used in more places in the future.

gdk/gdk-private.h
gdk/gdk.c

index b4a16c5659465ef82ab06a9572bd72e87f282dd9..0618f8187f636e6c4ba66c8dec1f57d628084767 100644 (file)
@@ -39,5 +39,6 @@ void gdk_display_set_double_click_distance (GdkDisplay   *display,
 void gdk_display_set_cursor_theme          (GdkDisplay   *display,
                                             const char   *theme,
                                             int           size);
+gboolean gdk_running_in_sandbox (void);
 
 #endif /* __GDK__PRIVATE_H__ */
index 72d1478f694dc932cfb69eb66b81014464d1086c..b92d374cc95df87200db3848843e1f19ecef341e 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -216,6 +216,19 @@ gdk_display_open_default (void)
   return display;
 }
 
+gboolean
+gdk_running_in_sandbox (void)
+{
+  char *path;
+  gboolean ret;
+
+  path = g_build_filename (g_get_user_runtime_dir (), "flatpak-info", NULL);
+  ret = g_file_test (path, G_FILE_TEST_EXISTS);
+  g_free (path);
+
+  return ret;
+}
+
 /**
  * SECTION:threads
  * @Short_description: Functions for using GDK in multi-threaded programs
@@ -266,3 +279,4 @@ gdk_display_open_default (void)
  * expensive tasks from worker threads, and will handle thread
  * management for you.
  */
+