summary refs log tree commit diff
path: root/pkgs/development/libraries/xdg-desktop-portal/respect-path-env-var.patch
blob: f884899ecd19ff9de925d1e0515612fb67a1e213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--- a/src/xdg-desktop-portal.c
+++ b/src/xdg-desktop-portal.c
@@ -177,38 +177,50 @@
 static void
 load_installed_portals (void)
 {
-  const char *portal_dir = PKGDATADIR "/portals";
-  g_autoptr(GFile) dir = g_file_new_for_path (portal_dir);
-  g_autoptr(GFileEnumerator) enumerator = NULL;
 
-  enumerator = g_file_enumerate_children (dir, "*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
+  g_auto(GStrv) portal_dir_list;
+  int i;
+  const char *portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_PATH");
+
+  if (portal_dir == NULL)
+    portal_dir = PKGDATADIR "/portals";
 
-  if (enumerator == NULL)
-    return;
+  portal_dir_list = g_strsplit (portal_dir, G_SEARCHPATH_SEPARATOR_S, 0);
 
-  while (TRUE)
+  for (i = 0; portal_dir_list[i] != NULL; i++)
     {
-      g_autoptr(GFileInfo) info = g_file_enumerator_next_file (enumerator, NULL, NULL);
-      g_autoptr(GFile) child = NULL;
-      g_autofree char *path = NULL;
-      const char *name;
-      g_autoptr(GError) error = NULL;
+      portal_dir = portal_dir_list[i];
+      g_autoptr(GFile) dir = g_file_new_for_path (portal_dir);
+      g_autoptr(GFileEnumerator) enumerator = NULL;
+      enumerator = g_file_enumerate_children (dir, "*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
 
-      if (info == NULL)
-        break;
+      if (enumerator == NULL)
+        continue;
 
-      name = g_file_info_get_name (info);
+      while (TRUE)
+        {
+          g_autoptr(GFileInfo) info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+          g_autoptr(GFile) child = NULL;
+          g_autofree char *path = NULL;
+          const char *name;
+          g_autoptr(GError) error = NULL;
 
-      if (!g_str_has_suffix (name, ".portal"))
-        continue;
+          if (info == NULL)
+            break;
 
-      child = g_file_enumerator_get_child (enumerator, info);
-      path = g_file_get_path (child);
+          name = g_file_info_get_name (info);
 
-      if (!register_portal (path, &error))
-        {
-          g_warning ("Error loading %s: %s", path, error->message);
-          continue;
+          if (!g_str_has_suffix (name, ".portal"))
+            continue;
+
+          child = g_file_enumerator_get_child (enumerator, info);
+          path = g_file_get_path (child);
+
+          if (!register_portal (path, &error))
+            {
+              g_warning ("Error loading %s: %s", path, error->message);
+              continue;
+            }
         }
     }