gosxappinfo: Correctly launch list of files

Fixes #3587
This commit is contained in:
Andre Miranda 2025-01-24 12:29:54 +00:00 committed by Philip Withnall
parent 0c38fd3c14
commit 8b64bb8751

View File

@ -224,20 +224,18 @@ url_escape_hostname (const char *url)
} }
static CFURLRef static CFURLRef
create_url_from_cstr (const gchar *cstr, create_url_from_cstr_or_file (gpointer data,
gboolean is_file) gboolean is_file)
{ {
const char *cstr;
gchar *puny_cstr; gchar *puny_cstr;
CFStringRef str; CFStringRef str;
CFURLRef url; CFURLRef url;
cstr = is_file ? g_file_get_uri ((GFile *) data) : (char *) data;
puny_cstr = url_escape_hostname (cstr); puny_cstr = url_escape_hostname (cstr);
str = CFStringCreateWithCString (NULL, puny_cstr ? puny_cstr : cstr, kCFStringEncodingUTF8); str = CFStringCreateWithCString (NULL, puny_cstr ? puny_cstr : cstr, kCFStringEncodingUTF8);
url = CFURLCreateWithString (NULL, str, NULL);
if (is_file)
url = CFURLCreateWithFileSystemPath (NULL, str, kCFURLPOSIXPathStyle, FALSE);
else
url = CFURLCreateWithString (NULL, str, NULL);
if (!url) if (!url)
g_debug ("Creating CFURL from %s %s failed!", cstr, is_file ? "file" : "uri"); g_debug ("Creating CFURL from %s %s failed!", cstr, is_file ? "file" : "uri");
@ -264,7 +262,8 @@ create_url_list_from_glist (GList *uris,
for (lst = uris; lst != NULL && lst->data; lst = lst->next) for (lst = uris; lst != NULL && lst->data; lst = lst->next)
{ {
CFURLRef url = create_url_from_cstr ((char*)lst->data, are_files); /* lst->data is either a GFile* or a char* URI, depending on are_files */
CFURLRef url = create_url_from_cstr_or_file (lst->data, are_files);
if (url) if (url)
CFArrayAppendValue (array, url); CFArrayAppendValue (array, url);
} }