Skip to content

Commit

Permalink
load portals from XDG_DATA_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
andychenbruce committed Jan 9, 2025
1 parent 34ff12c commit cee26bb
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions src/xdp-portal-impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,10 @@ sort_impl_by_use_in_and_name (gconstpointer a,
return strcmp (pa->source, pb->source);
}

void
load_installed_portals (gboolean opt_verbose)
void *
load_installed_portals_dir (gboolean opt_verbose,
const char *portal_dir)
{
g_autoptr(GFileEnumerator) enumerator = NULL;
g_autoptr(GFile) dir = NULL;
const char *portal_dir;

/* 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);
Expand Down Expand Up @@ -319,6 +311,34 @@ load_installed_portals (gboolean opt_verbose)
implementations = g_list_sort (implementations, sort_impl_by_use_in_and_name);
}

void
load_installed_portals (gboolean opt_verbose)
{
g_autoptr(GFileEnumerator) enumerator = NULL;
g_autoptr(GFile) dir = NULL;
const char *portal_dir;

/* We need to override this in the tests */
portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR");
bool dir_set_from_env = (portal_dir == NULL);
if (portal_dir == NULL)
portal_dir = DATADIR "/xdg-desktop-portal/portals";

load_installed_portals_dir(opt_verbose, portal_dir);

if(dir_set_from_env)
return

const char * const *dirs = g_get_system_data_dirs ();

for (iter = dirs; iter != NULL && *iter != NULL; iter++)
{
g_autofree char *dir = g_build_filename (*iter, XDP_SUBDIR, NULL);

load_installed_portals_dir(opt_verbose, dir)
}
}

static PortalConfig *
load_portal_configuration_for_dir (gboolean opt_verbose,
const char *base_directory,
Expand Down

0 comments on commit cee26bb

Please sign in to comment.