From a87aaac4b19c1ea3e4f66460095bac1ce577faf2 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 1 Oct 2019 09:51:56 +0200 Subject: [PATCH] update-portal: Allow overriding portals directory Allow overriding $datadir/xdg-desktop-portal/portals using the $XDG_DESKTOP_PORTAL_DIR env var. We will need this in the test suite when we want to pass in our own (faked) portal implementation. --- portal/portal-impl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/portal/portal-impl.c b/portal/portal-impl.c index cc1bda43..8170adf8 100644 --- a/portal/portal-impl.c +++ b/portal/portal-impl.c @@ -116,12 +116,18 @@ sort_impl_by_name (gconstpointer a, void load_installed_portals (gboolean opt_verbose) { - const char *portal_dir = DATADIR "/xdg-desktop-portal/portals"; - g_autoptr(GFile) dir = g_file_new_for_path (portal_dir); + const char *portal_dir; + g_autoptr(GFile) dir = NULL; g_autoptr(GFileEnumerator) enumerator = NULL; + /* We need to override this in the tests */ + portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + if (portal_dir == NULL) + portal_dir = DATADIR "/xdg-desktop-portal/portals"; + g_debug ("load portals from %s", portal_dir); + dir = g_file_new_for_path (portal_dir); enumerator = g_file_enumerate_children (dir, "*", G_FILE_QUERY_INFO_NONE, NULL, NULL); if (enumerator == NULL)