From bb67df716cfab257a6309df121e6399ddadcc78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Thu, 6 Jan 2022 08:15:26 +0100 Subject: Mildly improve Ubuntu 20.04 compatibility --- fiv-sidebar.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'fiv-sidebar.c') diff --git a/fiv-sidebar.c b/fiv-sidebar.c index c29ef4d..e956d08 100644 --- a/fiv-sidebar.c +++ b/fiv-sidebar.c @@ -244,10 +244,21 @@ resolve_location(FivSidebar *self, const char *text) // Relative paths produce invalid GFile objects with this function. // And even if they didn't, we have our own root for them. GFile *file = g_file_parse_name(text); - if (g_uri_is_valid(text, G_URI_FLAGS_PARSE_RELAXED, NULL) || - g_file_peek_path(file)) + if (g_file_peek_path(file)) return file; + // Neither branch looks like a particularly good solution. + // Though in general, false positives are preferred over negatives. +#if GLIB_CHECK_VERSION(2, 66, 0) + if (g_uri_is_valid(text, G_URI_FLAGS_PARSE_RELAXED, NULL)) + return file; +#else + gchar *scheme = g_uri_parse_scheme(text); + g_free(scheme); + if (scheme) + return file; +#endif + GFile *absolute = g_file_get_child_for_display_name( fiv_io_model_get_location(self->model), text, NULL); if (!absolute) -- cgit v1.2.3