This is an automated email from the git hooks/post-receive script. f2404 pushed a commit to branch master in repository apps/ristretto.
commit 2640c26d9b5b4332db8230ba82337ff7d97fb0bd Author: Christian Hesse <m...@eworm.de> Date: Tue Oct 11 15:04:23 2016 +0200 link against and get MIME type form libmagic Signed-off-by: Christian Hesse <m...@eworm.de> Signed-off-by: Igor <f2...@yandex.ru> --- configure.ac.in | 4 ++++ src/Makefile.am | 3 ++- src/file.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index 6044813..34f4909 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -68,6 +68,10 @@ XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.8.0]) XDT_CHECK_LIBX11() +AC_CHECK_HEADERS([magic.h],, [libmagic=false]) +AC_CHECK_LIB(magic, [magic_open], [MAGIC_LIBS="-lmagic"],[libmagic=false]) +AC_SUBST(MAGIC_LIBS) + AC_CHECK_LIBM AC_SUBST(LIBM) diff --git a/src/Makefile.am b/src/Makefile.am index 4f55735..36a31dc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,7 +53,8 @@ ristretto_LDADD = \ $(LIBXFCE4UTIL_LIBS) \ $(LIBXFCE4UI_LIBS) \ $(LIBX11_LIBS) \ - $(LIBM) + $(LIBM) \ + $(MAGIC_LIBS) INCLUDES = \ -I${top_srcdir} diff --git a/src/file.c b/src/file.c index 3a352a5..7caf0c5 100644 --- a/src/file.c +++ b/src/file.c @@ -26,6 +26,10 @@ #include "file.h" #include "thumbnailer.h" +#if HAVE_MAGIC_H +#include <magic.h> +#endif + static guint rstto_thumbnail_size[] = { THUMBNAIL_SIZE_VERY_SMALL_SIZE, @@ -394,9 +398,35 @@ rstto_file_get_collate_key ( RsttoFile *r_file ) const gchar * rstto_file_get_content_type ( RsttoFile *r_file ) { - GFileInfo *file_info = NULL; const gchar *content_type; +#if HAVE_MAGIC_H + magic_t magic = NULL; + + if ((magic = magic_open(MAGIC_MIME_TYPE)) == NULL) + { + fprintf(stderr, "unable to initialize magic library\n"); + return NULL; + } + + if (magic_load(magic, NULL) != 0) + { + fprintf(stderr, "cannot load magic database: %s\n", magic_error(magic)); + magic_close(magic); + return NULL; + } + + content_type = magic_file(magic, rstto_file_get_path(r_file)); + + if (NULL != content_type) + { + r_file->priv->content_type = g_strdup (content_type); + } + + magic_close(magic); +#else + GFileInfo *file_info = NULL; + if ( NULL == r_file->priv->content_type ) { file_info = g_file_query_info ( @@ -415,6 +445,7 @@ rstto_file_get_content_type ( RsttoFile *r_file ) g_object_unref (file_info); } } +#endif return (const gchar *)r_file->priv->content_type; } -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits