From 06af1a3cc9920780c7edeba34677fc66b18ff5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Thu, 18 Nov 2021 12:44:25 +0100 Subject: Add a command line option to list supported types Make it work without a display connection. --- fastiv-io.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'fastiv-io.c') diff --git a/fastiv-io.c b/fastiv-io.c index 82c3229..e1bb60a 100644 --- a/fastiv-io.c +++ b/fastiv-io.c @@ -78,6 +78,28 @@ const char *fastiv_io_supported_media_types[] = { NULL }; +char ** +fastiv_io_all_supported_media_types(void) +{ + GPtrArray *types = g_ptr_array_new(); + for (const char **p = fastiv_io_supported_media_types; *p; p++) + g_ptr_array_add(types, g_strdup(*p)); + +#ifdef HAVE_GDKPIXBUF + GSList *formats = gdk_pixbuf_get_formats(); + for (GSList *iter = formats; iter; iter = iter->next) { + gchar **subtypes = gdk_pixbuf_format_get_mime_types(iter->data); + for (gchar **p = subtypes; *p; p++) + g_ptr_array_add(types, *p); + g_free(subtypes); + } + g_slist_free(formats); +#endif // HAVE_GDKPIXBUF + + g_ptr_array_add(types, NULL); + return (char **) g_ptr_array_free(types, FALSE); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define FASTIV_IO_ERROR fastiv_io_error_quark() -- cgit v1.2.3