Merge branch 'macos-file-filter-pixbufs' into 'main'

macos: Add pixbuf formats similar to mime-types

Closes #5296

See merge request GNOME/gtk!6754
This commit is contained in:
Matthias Clasen 2024-01-30 16:56:52 +00:00
commit ff4db4ed71

View File

@ -770,15 +770,21 @@ NSArray * _gtk_file_filter_get_as_pattern_nsstrings (GtkFileFilter *filter)
switch (rule->type)
{
case FILTER_RULE_MIME_TYPE:
case FILTER_RULE_PIXBUF_FORMATS:
{
int i;
// GContentType from GIO use UTI on macOS since glib version 2.51
NSString *uti_nsstring = [NSString stringWithUTF8String: rule->u.content_types[0]];
if (uti_nsstring == NULL)
for (i = 0; rule->u.content_types[i] != NULL; i++)
{
[array release];
return NULL;
NSString *uti_nsstring = [NSString stringWithUTF8String: rule->u.content_types[i]];
if (uti_nsstring == NULL)
{
[array release];
return NULL;
}
[array addObject:uti_nsstring];
}
[array addObject:uti_nsstring];
}
break;
@ -798,34 +804,9 @@ NSArray * _gtk_file_filter_get_as_pattern_nsstrings (GtkFileFilter *filter)
char *pattern_c = g_string_free (pattern, FALSE);
NSString *pattern_nsstring = [NSString stringWithUTF8String:pattern_c];
g_free (pattern_c);
[pattern_nsstring retain];
[array addObject:pattern_nsstring];
}
break;
case FILTER_RULE_PIXBUF_FORMATS:
{
GSList *formats, *l;
formats = gdk_pixbuf_get_formats ();
for (l = formats; l; l = l->next)
{
int i;
char **extensions;
extensions = gdk_pixbuf_format_get_extensions (l->data);
for (i = 0; extensions[i] != NULL; i++)
{
NSString *extension = [NSString stringWithUTF8String: extensions[i]];
[extension retain];
[array addObject:extension];
}
g_strfreev (extensions);
}
g_slist_free (formats);
break;
}
}
}
return array;