mate:mate-desktop is ready for Pisi Linux
This commit is contained in:
@@ -0,0 +1,370 @@
|
||||
AC_PREREQ(2.59)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
m4_define(eom_major_version, 1)
|
||||
m4_define(eom_minor_version, 22)
|
||||
m4_define(eom_micro_version, 2)
|
||||
m4_define(eom_version, eom_major_version.eom_minor_version.eom_micro_version)
|
||||
|
||||
AC_INIT([eom], eom_version, [http://www.mate-desktop.org], [eom])
|
||||
AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-xz check-news])
|
||||
|
||||
# Support silencing the build output if supported (automake-1.11+)
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_DEFINE(EOM_MAJOR_VERSION, eom_major_version, [EOM major version])
|
||||
AC_SUBST(EOM_MAJOR_VERSION, eom_major_version)
|
||||
AC_DEFINE(EOM_MINOR_VERSION, eom_minor_version, [EOM minor version])
|
||||
AC_SUBST(EOM_MINOR_VERSION, eom_minor_version)
|
||||
AC_DEFINE(EOM_MICRO_VERSION, eom_micro_version, [EOM micro version])
|
||||
AC_SUBST(EOM_MICRO_VERSION, eom_micro_version)
|
||||
|
||||
EOM_API_VERSION=2.20
|
||||
AC_SUBST(EOM_API_VERSION)
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
MATE_COMMON_INIT
|
||||
MATE_MAINTAINER_MODE_DEFINES
|
||||
MATE_COMPILE_WARNINGS
|
||||
MATE_DEBUG_CHECK
|
||||
|
||||
# Disable building static archives by default
|
||||
AC_DISABLE_STATIC
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
|
||||
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
|
||||
AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
|
||||
|
||||
GTK_DOC_CHECK(1.9)
|
||||
|
||||
AC_CHECK_FUNCS(strptime)
|
||||
|
||||
# ****************************************************************
|
||||
# Support for nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) (optional)
|
||||
# ****************************************************************
|
||||
AC_MSG_CHECKING([for _NL_MEASUREMENT_MEASUREMENT])
|
||||
AC_TRY_LINK([#include <langinfo.h>], [
|
||||
char c;
|
||||
c = *((unsigned char *) nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
|
||||
], have_langinfo_measurement=yes, have_langinfo_measurement=no)
|
||||
AC_MSG_RESULT($have_langinfo_measurement)
|
||||
if test "$have_langinfo_measurement" = "yes"; then
|
||||
AC_DEFINE([HAVE__NL_MEASUREMENT_MEASUREMENT], [1],
|
||||
[Define if _NL_MEASUREMENT_MEASUREMENT is available])
|
||||
fi
|
||||
|
||||
# ***********
|
||||
# Translation
|
||||
# ***********
|
||||
|
||||
AM_GLIB_GNU_GETTEXT
|
||||
IT_PROG_INTLTOOL([0.50.1])
|
||||
|
||||
GETTEXT_PACKAGE=AC_PACKAGE_NAME
|
||||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package.])
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
|
||||
# ***************
|
||||
# mate-doc-utils
|
||||
# ***************
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
YELP_HELP_INIT
|
||||
|
||||
# **********
|
||||
# MATE Libs
|
||||
# **********
|
||||
|
||||
GLIB_REQUIRED=2.52.0
|
||||
GIO_REQUIRED=2.50.0
|
||||
GTK_REQUIRED=3.22.0
|
||||
MATE_DESKTOP_REQUIRED=1.17.0
|
||||
GDKPIXBUF_REQUIRED=2.30.0
|
||||
SHARED_MIME_INFO_REQUIRED=0.20
|
||||
EXEMPI_REQUIRED=1.99.5
|
||||
LIBPEAS_REQUIRED=1.8.0
|
||||
|
||||
PKG_CHECK_MODULES(GMODULE, gmodule-2.0, [GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
|
||||
EOM_MODULES="gtk+-3.0 >= $GTK_REQUIRED \
|
||||
glib-2.0 >= $GLIB_REQUIRED \
|
||||
$GMODULE_ADD \
|
||||
gio-2.0 >= $GLIB_REQUIRED \
|
||||
gio-unix-2.0 >= $GLIB_REQUIRED \
|
||||
gthread-2.0 >= $GLIB_REQUIRED \
|
||||
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED \
|
||||
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED \
|
||||
gio-2.0 >= $GIO_REQUIRED \
|
||||
gtk+-unix-print-3.0 >= $GTK_REQUIRED \
|
||||
shared-mime-info >= $SHARED_MIME_INFO_REQUIRED \
|
||||
libpeas-1.0 >= $LIBPEAS_REQUIRED \
|
||||
libpeas-gtk-1.0 >= $LIBPEAS_REQUIRED"
|
||||
|
||||
# Introspection
|
||||
GOBJECT_INTROSPECTION_CHECK([0.9.3])
|
||||
|
||||
if test "$found_introspection" = "yes"; then
|
||||
have_introspection=yes
|
||||
AC_DEFINE([HAVE_INTROSPECTION], [1], [Define to enable GObject Introspection])
|
||||
else
|
||||
have_introspection=no
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$have_introspection" = xyes)
|
||||
|
||||
# ***************
|
||||
# ZLIB (required)
|
||||
# ***************
|
||||
|
||||
have_zlib=yes
|
||||
AC_CHECK_HEADERS([zlib.h],
|
||||
[AC_CHECK_LIB([z], [inflate],
|
||||
[AC_CHECK_LIB([z], [crc32], [], [have_zlib=no])],
|
||||
[have_zlib=no])],
|
||||
[have_zlib=no])
|
||||
|
||||
if test x$have_zlib = xno; then
|
||||
AC_MSG_ERROR([No sufficient zlib library found on your system.])
|
||||
fi
|
||||
|
||||
# ***************
|
||||
# EXIF (optional)
|
||||
# ***************
|
||||
|
||||
LIBEXIF_REQUIRED=0.6.14
|
||||
|
||||
AC_ARG_WITH([libexif], AC_HELP_STRING([--without-libexif], [disable EXIF support]))
|
||||
have_exif=no
|
||||
if test x$with_libexif != xno; then
|
||||
PKG_CHECK_MODULES(EXIF, libexif >= $LIBEXIF_REQUIRED, have_exif=yes, have_exif=no)
|
||||
fi
|
||||
if test "x$have_exif" = "xyes"; then
|
||||
AC_DEFINE(HAVE_EXIF, 1, [EXIF Support.])
|
||||
EOM_MODULES="$EOM_MODULES libexif >= $LIBEXIF_REQUIRED"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_EXIF], [test "x$have_exif" = "xyes"])
|
||||
|
||||
# *********************
|
||||
# Little CMS (optional)
|
||||
# *********************
|
||||
|
||||
AC_ARG_WITH([cms], AC_HELP_STRING([--without-cms], [disable colour management support]))
|
||||
have_lcms=no
|
||||
if test x$with_cms != xno; then
|
||||
PKG_CHECK_MODULES(LCMS, lcms2, have_lcms=yes, have_lcms=no)
|
||||
fi
|
||||
if test "x$have_lcms" = "xyes"; then
|
||||
AC_DEFINE(HAVE_LCMS, 1, [Little CMS Support.])
|
||||
EOM_MODULES="$EOM_MODULES lcms2"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_LCMS], [test "x$have_lcms" = "xyes"])
|
||||
|
||||
# *********************
|
||||
# Exempi (optional)
|
||||
# *********************
|
||||
AC_ARG_WITH(xmp, AC_HELP_STRING([--without-xmp], [disable special XMP support]))
|
||||
have_exempi=no
|
||||
if test x$with_xmp != xno; then
|
||||
PKG_CHECK_MODULES(EXEMPI, exempi-2.0 >= $EXEMPI_REQUIRED, have_exempi=yes, have_exempi=no)
|
||||
fi
|
||||
if test "x$have_exempi" = "xyes"; then
|
||||
AC_DEFINE(HAVE_EXEMPI,1, [XMP support.])
|
||||
EOM_MODULES="$EOM_MODULES exempi-2.0 >= $EXEMPI_REQUIRED"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_EXEMPI], [test "x$have_exempi" = "xyes"])
|
||||
|
||||
# Build EXIF-related documentation if we really have support for it
|
||||
if test "x$have_exif" = "xyes" || test "x$have_exempi" = "xyes"; then
|
||||
EOM_DOC_EXIF_START=""
|
||||
EOM_DOC_EXIF_STOP=""
|
||||
else
|
||||
EOM_DOC_EXIF_START="<!--"
|
||||
EOM_DOC_EXIF_STOP="-->"
|
||||
fi
|
||||
|
||||
AC_SUBST([EOM_DOC_EXIF_START])
|
||||
AC_SUBST([EOM_DOC_EXIF_STOP])
|
||||
|
||||
# ********************
|
||||
# Jpeg (semi-optional)
|
||||
# ********************
|
||||
|
||||
AC_ARG_WITH(libjpeg, AC_HELP_STRING([--without-libjpeg], [disable special JPEG support]))
|
||||
have_jpeg=no
|
||||
have_libjpeg_80=no
|
||||
if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
|
||||
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
|
||||
have_jpeg=yes,
|
||||
have_jpeg=no
|
||||
AC_MSG_WARN(*** JPEG loader will not be built (JPEG library not found) ***))
|
||||
if test "$have_jpeg" = yes; then
|
||||
AC_MSG_CHECKING([for jpeglib.h])
|
||||
AC_TRY_CPP(
|
||||
[#include <stdio.h>
|
||||
#undef PACKAGE
|
||||
#undef VERSION
|
||||
#undef HAVE_STDLIB_H
|
||||
#include <jpeglib.h>],
|
||||
have_jpeg=yes,
|
||||
have_jpeg=no)
|
||||
AC_MSG_RESULT($have_jpeg)
|
||||
if test "$have_jpeg" = yes; then
|
||||
LIBJPEG='-ljpeg'
|
||||
AC_DEFINE(HAVE_JPEG, 1, [Jpeg Support.])
|
||||
AC_DEFINE(HAVE_LIBJPEG, 1, [libjpeg is Present.])
|
||||
AC_CHECK_LIB(jpeg, jpeg_simple_progression,
|
||||
AC_DEFINE(HAVE_PROGRESSIVE_JPEG, 1, [Jpeg Progressive Saving Support.]),
|
||||
AC_MSG_WARN(JPEG library does not support progressive saving.))
|
||||
AC_MSG_CHECKING([[libjpeg version is 8 or greater]])
|
||||
AC_PREPROC_IFELSE([ AC_LANG_SOURCE(
|
||||
[[
|
||||
#include <stdio.h>
|
||||
#include <jpeglib.h>
|
||||
#if JPEG_LIB_VERSION < 80
|
||||
#error "wrong version"
|
||||
#endif
|
||||
int main(int c, char**v) { return 0; }
|
||||
]]) ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
have_libjpeg_80=yes],
|
||||
[AC_MSG_RESULT(no)
|
||||
have_libjpeg_80=no])
|
||||
|
||||
else
|
||||
AC_MSG_WARN(*** JPEG loader will not be built (JPEG header file not found) ***)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
|
||||
AC_MSG_ERROR([
|
||||
*** Checks for JPEG loader failed. You can build without it by passing
|
||||
*** --without-libjpeg to configure but some programs using GTK+ may
|
||||
*** not work properly])
|
||||
fi
|
||||
AC_SUBST(LIBJPEG)
|
||||
AM_CONDITIONAL(ENABLE_JPEG, test x$have_jpeg = xyes)
|
||||
AM_CONDITIONAL(HAVE_LIBJPEG_80, test "x$have_libjpeg_80" = xyes)
|
||||
|
||||
# ************************************
|
||||
# libXML2 (required for toolbareditor)
|
||||
# ************************************
|
||||
|
||||
LIBXML2_REQUIRED=2.0
|
||||
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= $LIBXML2_REQUIRED])
|
||||
|
||||
# ***************
|
||||
# RSVG (optional for scaling svg image)
|
||||
# ***************
|
||||
|
||||
LIBRSVG_REQUIRED=2.36.2
|
||||
|
||||
AC_ARG_WITH([librsvg], AC_HELP_STRING([--without-librsvg], [disable RSVG support]))
|
||||
have_rsvg=no
|
||||
if test x$with_librsvg != xno; then
|
||||
PKG_CHECK_MODULES(RSVG, librsvg-2.0 >= $LIBRSVG_REQUIRED, have_rsvg=yes, have_rsvg=no)
|
||||
fi
|
||||
if test "x$have_rsvg" = "xyes"; then
|
||||
AC_DEFINE(HAVE_RSVG, 1, [RSVG Support.])
|
||||
EOM_MODULES="$EOM_MODULES librsvg-2.0 >= $LIBRSVG_REQUIRED"
|
||||
else
|
||||
AC_WARN([LIBRSVG support disabled, svg files will not scale])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_RSVG], [test "x$have_rsvg" = "xyes"])
|
||||
|
||||
# ****************
|
||||
# CFLAGS/LIBS init
|
||||
# ****************
|
||||
|
||||
PKG_CHECK_MODULES(EOM, $EOM_MODULES)
|
||||
AC_SUBST(EOM_CFLAGS)
|
||||
AC_SUBST(EOM_LIBS)
|
||||
|
||||
# *******************************************************
|
||||
# libX11 (required for TotemScrSaver and Color Profiling)
|
||||
# *******************************************************
|
||||
|
||||
# Check GDK rendering target
|
||||
gdk_target_has_x11=`$PKG_CONFIG --variable=targets gdk-3.0 | grep x11`
|
||||
|
||||
if test "x$have_lcms" = "xyes" || test "$gdk_target_has_x11" != ""; then
|
||||
PKG_CHECK_MODULES(X11, [x11], have_x11=yes, have_x11=no)
|
||||
|
||||
if test "x$have_x11" != "xyes"; then
|
||||
# Fallback for X11 releases without .pc-files
|
||||
AC_PATH_XTRA
|
||||
if test x$no_x = xyes ; then
|
||||
AC_MSG_ERROR([X development libraries (libX11) not found])
|
||||
else
|
||||
X11_LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
|
||||
AC_SUBST(X11_LIBS)
|
||||
have_x11=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# *****
|
||||
# GSettings
|
||||
# *****
|
||||
|
||||
GLIB_GSETTINGS
|
||||
|
||||
AC_SEARCH_LIBS([floor],[m])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/Makefile
|
||||
man/Makefile
|
||||
jpegutils/Makefile
|
||||
cut-n-paste/Makefile
|
||||
cut-n-paste/toolbar-editor/Makefile
|
||||
help/Makefile
|
||||
po/Makefile.in
|
||||
data/Makefile
|
||||
data/eom.pc
|
||||
data/eom.desktop.in
|
||||
data/org.mate.eom.gschema.xml
|
||||
data/pixmaps/Makefile
|
||||
data/icons/Makefile
|
||||
data/icons/16x16/Makefile
|
||||
data/icons/22x22/Makefile
|
||||
data/icons/24x24/Makefile
|
||||
data/icons/32x32/Makefile
|
||||
data/icons/48x48/Makefile
|
||||
data/icons/scalable/Makefile
|
||||
doc/Makefile
|
||||
doc/reference/Makefile
|
||||
doc/reference/version.xml
|
||||
doc/reference/eom-docs.sgml
|
||||
plugins/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
echo "
|
||||
Configure summary:
|
||||
|
||||
Source code location .......: ${srcdir}
|
||||
Compiler ...................: ${CC}
|
||||
Extra Compiler Warnings ....: ${WARN_CFLAGS}
|
||||
|
||||
EXIF support ...............: ${have_exif}
|
||||
XMP support ................: ${have_exempi}
|
||||
JPEG support ...............: ${have_jpeg}
|
||||
RSVG support ...............: ${have_rsvg}
|
||||
Colour management support ..: ${have_lcms}
|
||||
GObject Introspection.......: ${have_introspection}
|
||||
"
|
||||
@@ -0,0 +1,541 @@
|
||||
/* Eye Of Mate - Thumbnailing functions
|
||||
*
|
||||
* Copyright (C) 2000-2008 The Free Software Foundation
|
||||
*
|
||||
* Author: Lucas Rocha <lucasr@gnome.org>
|
||||
*
|
||||
* Based on eel code (eel/eel-graphic-effects.c) by:
|
||||
* - Andy Hertzfeld <andy@eazel.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* We must define MATE_DESKTOP_USE_UNSTABLE_API to be able
|
||||
to use MateDesktopThumbnail */
|
||||
#ifndef MATE_DESKTOP_USE_UNSTABLE_API
|
||||
#define MATE_DESKTOP_USE_UNSTABLE_API
|
||||
#endif
|
||||
#include <libmate-desktop/mate-desktop-thumbnail.h>
|
||||
|
||||
#include "eom-thumbnail.h"
|
||||
#include "eom-list-store.h"
|
||||
#include "eom-debug.h"
|
||||
|
||||
#define EOM_THUMB_ERROR eom_thumb_error_quark ()
|
||||
|
||||
static MateDesktopThumbnailFactory *factory = NULL;
|
||||
static GdkPixbuf *frame = NULL;
|
||||
|
||||
typedef enum {
|
||||
EOM_THUMB_ERROR_VFS,
|
||||
EOM_THUMB_ERROR_GENERIC,
|
||||
EOM_THUMB_ERROR_UNKNOWN
|
||||
} EomThumbError;
|
||||
|
||||
typedef struct {
|
||||
char *uri_str;
|
||||
char *thumb_path;
|
||||
time_t mtime;
|
||||
char *mime_type;
|
||||
gboolean thumb_exists;
|
||||
gboolean failed_thumb_exists;
|
||||
gboolean can_read;
|
||||
} EomThumbData;
|
||||
|
||||
static GQuark
|
||||
eom_thumb_error_quark (void)
|
||||
{
|
||||
static GQuark q = 0;
|
||||
if (q == 0)
|
||||
q = g_quark_from_static_string ("eom-thumb-error-quark");
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
static void
|
||||
set_vfs_error (GError **error, GError *ioerror)
|
||||
{
|
||||
g_set_error (error,
|
||||
EOM_THUMB_ERROR,
|
||||
EOM_THUMB_ERROR_VFS,
|
||||
"%s", ioerror ? ioerror->message : "VFS error making a thumbnail");
|
||||
}
|
||||
|
||||
static void
|
||||
set_thumb_error (GError **error, int error_id, const char *string)
|
||||
{
|
||||
g_set_error (error,
|
||||
EOM_THUMB_ERROR,
|
||||
error_id,
|
||||
"%s", string);
|
||||
}
|
||||
|
||||
static GdkPixbuf*
|
||||
get_valid_thumbnail (EomThumbData *data, GError **error)
|
||||
{
|
||||
GdkPixbuf *thumb = NULL;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
/* does a thumbnail under the path exists? */
|
||||
if (data->thumb_exists) {
|
||||
thumb = gdk_pixbuf_new_from_file (data->thumb_path, error);
|
||||
|
||||
/* is this thumbnail file up to date? */
|
||||
if (thumb != NULL && !mate_desktop_thumbnail_is_valid (thumb, data->uri_str, data->mtime)) {
|
||||
g_object_unref (thumb);
|
||||
thumb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
create_thumbnail_from_pixbuf (EomThumbData *data,
|
||||
GdkPixbuf *pixbuf,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *thumb;
|
||||
gint width, height;
|
||||
gfloat perc;
|
||||
|
||||
g_assert (factory != NULL);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
|
||||
perc = CLAMP (128.0/(MAX (width, height)), 0, 1);
|
||||
|
||||
thumb = mate_desktop_thumbnail_scale_down_pixbuf (pixbuf,
|
||||
width*perc,
|
||||
height*perc);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
static void
|
||||
eom_thumb_data_free (EomThumbData *data)
|
||||
{
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
g_free (data->thumb_path);
|
||||
g_free (data->mime_type);
|
||||
g_free (data->uri_str);
|
||||
|
||||
g_slice_free (EomThumbData, data);
|
||||
}
|
||||
|
||||
static EomThumbData*
|
||||
eom_thumb_data_new (GFile *file, GError **error)
|
||||
{
|
||||
EomThumbData *data;
|
||||
GFileInfo *file_info;
|
||||
GError *ioerror = NULL;
|
||||
|
||||
g_return_val_if_fail (file != NULL, NULL);
|
||||
g_return_val_if_fail (error != NULL && *error == NULL, NULL);
|
||||
|
||||
data = g_slice_new0 (EomThumbData);
|
||||
|
||||
data->uri_str = g_file_get_uri (file);
|
||||
data->thumb_path = mate_desktop_thumbnail_path_for_uri (data->uri_str, MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
|
||||
file_info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
|
||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
|
||||
0, NULL, &ioerror);
|
||||
if (file_info == NULL)
|
||||
{
|
||||
set_vfs_error (error, ioerror);
|
||||
g_clear_error (&ioerror);
|
||||
}
|
||||
|
||||
if (*error == NULL) {
|
||||
/* if available, copy data */
|
||||
data->mtime = g_file_info_get_attribute_uint64 (file_info,
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||
data->mime_type = g_strdup (g_file_info_get_content_type (file_info));
|
||||
|
||||
data->thumb_exists = (g_file_info_get_attribute_byte_string (file_info,
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH) != NULL);
|
||||
data->failed_thumb_exists = g_file_info_get_attribute_boolean (file_info,
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
|
||||
data->can_read = TRUE;
|
||||
if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) {
|
||||
data->can_read = g_file_info_get_attribute_boolean (file_info,
|
||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
|
||||
}
|
||||
}
|
||||
else {
|
||||
eom_thumb_data_free (data);
|
||||
data = NULL;
|
||||
g_clear_error (&ioerror);
|
||||
}
|
||||
|
||||
g_object_unref (file_info);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_frame_row (GdkPixbuf *frame_image,
|
||||
gint target_width,
|
||||
gint source_width,
|
||||
gint source_v_position,
|
||||
gint dest_v_position,
|
||||
GdkPixbuf *result_pixbuf,
|
||||
gint left_offset,
|
||||
gint height)
|
||||
{
|
||||
gint remaining_width, h_offset, slab_width;
|
||||
|
||||
remaining_width = target_width;
|
||||
h_offset = 0;
|
||||
|
||||
while (remaining_width > 0) {
|
||||
slab_width = remaining_width > source_width ?
|
||||
source_width : remaining_width;
|
||||
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
left_offset,
|
||||
source_v_position,
|
||||
slab_width,
|
||||
height,
|
||||
result_pixbuf,
|
||||
left_offset + h_offset,
|
||||
dest_v_position);
|
||||
|
||||
remaining_width -= slab_width;
|
||||
h_offset += slab_width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_frame_column (GdkPixbuf *frame_image,
|
||||
gint target_height,
|
||||
gint source_height,
|
||||
gint source_h_position,
|
||||
gint dest_h_position,
|
||||
GdkPixbuf *result_pixbuf,
|
||||
gint top_offset,
|
||||
gint width)
|
||||
{
|
||||
gint remaining_height, v_offset, slab_height;
|
||||
|
||||
remaining_height = target_height;
|
||||
v_offset = 0;
|
||||
|
||||
while (remaining_height > 0) {
|
||||
slab_height = remaining_height > source_height ?
|
||||
source_height : remaining_height;
|
||||
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
source_h_position,
|
||||
top_offset,
|
||||
width,
|
||||
slab_height,
|
||||
result_pixbuf,
|
||||
dest_h_position,
|
||||
top_offset + v_offset);
|
||||
|
||||
remaining_height -= slab_height;
|
||||
v_offset += slab_height;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
eom_thumbnail_stretch_frame_image (GdkPixbuf *frame_image,
|
||||
gint left_offset,
|
||||
gint top_offset,
|
||||
gint right_offset,
|
||||
gint bottom_offset,
|
||||
gint dest_width,
|
||||
gint dest_height,
|
||||
gboolean fill_flag)
|
||||
{
|
||||
GdkPixbuf *result_pixbuf;
|
||||
gint frame_width, frame_height;
|
||||
gint target_width, target_frame_width;
|
||||
gint target_height, target_frame_height;
|
||||
|
||||
frame_width = gdk_pixbuf_get_width (frame_image);
|
||||
frame_height = gdk_pixbuf_get_height (frame_image);
|
||||
|
||||
if (fill_flag) {
|
||||
result_pixbuf = gdk_pixbuf_scale_simple (frame_image,
|
||||
dest_width,
|
||||
dest_height,
|
||||
GDK_INTERP_NEAREST);
|
||||
} else {
|
||||
result_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
||||
TRUE,
|
||||
8,
|
||||
dest_width,
|
||||
dest_height);
|
||||
|
||||
/* Clear pixbuf to fully opaque white */
|
||||
gdk_pixbuf_fill (result_pixbuf, 0xffffffff);
|
||||
}
|
||||
|
||||
target_width = dest_width - left_offset - right_offset;
|
||||
target_frame_width = frame_width - left_offset - right_offset;
|
||||
|
||||
target_height = dest_height - top_offset - bottom_offset;
|
||||
target_frame_height = frame_height - top_offset - bottom_offset;
|
||||
|
||||
/* Draw the left top corner and top row */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
0, 0,
|
||||
left_offset,
|
||||
top_offset,
|
||||
result_pixbuf,
|
||||
0, 0);
|
||||
|
||||
draw_frame_row (frame_image,
|
||||
target_width,
|
||||
target_frame_width,
|
||||
0, 0,
|
||||
result_pixbuf,
|
||||
left_offset,
|
||||
top_offset);
|
||||
|
||||
/* Draw the right top corner and left column */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
frame_width - right_offset,
|
||||
0,
|
||||
right_offset,
|
||||
top_offset,
|
||||
result_pixbuf,
|
||||
dest_width - right_offset,
|
||||
0);
|
||||
|
||||
draw_frame_column (frame_image,
|
||||
target_height,
|
||||
target_frame_height,
|
||||
0, 0,
|
||||
result_pixbuf,
|
||||
top_offset,
|
||||
left_offset);
|
||||
|
||||
/* Draw the bottom right corner and bottom row */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
frame_width - right_offset,
|
||||
frame_height - bottom_offset,
|
||||
right_offset,
|
||||
bottom_offset,
|
||||
result_pixbuf,
|
||||
dest_width - right_offset,
|
||||
dest_height - bottom_offset);
|
||||
|
||||
draw_frame_row (frame_image,
|
||||
target_width,
|
||||
target_frame_width,
|
||||
frame_height - bottom_offset,
|
||||
dest_height - bottom_offset,
|
||||
result_pixbuf,
|
||||
left_offset, bottom_offset);
|
||||
|
||||
/* Draw the bottom left corner and the right column */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
0,
|
||||
frame_height - bottom_offset,
|
||||
left_offset,
|
||||
bottom_offset,
|
||||
result_pixbuf,
|
||||
0,
|
||||
dest_height - bottom_offset);
|
||||
|
||||
draw_frame_column (frame_image,
|
||||
target_height,
|
||||
target_frame_height,
|
||||
frame_width - right_offset,
|
||||
dest_width - right_offset,
|
||||
result_pixbuf, top_offset,
|
||||
right_offset);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* eom_thumbnail_add_frame:
|
||||
* @thumbnail: a #GdkPixbuf
|
||||
*
|
||||
* Adds a frame to @thumbnail
|
||||
*
|
||||
* Returns: (transfer full): a new #GdkPixbuf, storing @thumbnail nicely framed.
|
||||
**/
|
||||
GdkPixbuf *
|
||||
eom_thumbnail_add_frame (GdkPixbuf *thumbnail)
|
||||
{
|
||||
GdkPixbuf *result_pixbuf;
|
||||
gint source_width, source_height;
|
||||
gint dest_width, dest_height;
|
||||
|
||||
source_width = gdk_pixbuf_get_width (thumbnail);
|
||||
source_height = gdk_pixbuf_get_height (thumbnail);
|
||||
|
||||
dest_width = source_width + 9;
|
||||
dest_height = source_height + 9;
|
||||
|
||||
result_pixbuf = eom_thumbnail_stretch_frame_image (frame,
|
||||
3, 3, 6, 6,
|
||||
dest_width,
|
||||
dest_height,
|
||||
FALSE);
|
||||
|
||||
gdk_pixbuf_copy_area (thumbnail,
|
||||
0, 0,
|
||||
source_width,
|
||||
source_height,
|
||||
result_pixbuf,
|
||||
3, 3);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* eom_thumbnail_fit_to_size:
|
||||
* @thumbnail: a #GdkPixbuf
|
||||
* @dimension: the maximum width or height desired
|
||||
*
|
||||
* Ensures a pixbuf fits a given @dimension
|
||||
*
|
||||
* Returns: (transfer full): a new #GdkPixbuf
|
||||
**/
|
||||
GdkPixbuf *
|
||||
eom_thumbnail_fit_to_size (GdkPixbuf *thumbnail, gint dimension)
|
||||
{
|
||||
gint width, height;
|
||||
|
||||
width = gdk_pixbuf_get_width (thumbnail);
|
||||
height = gdk_pixbuf_get_height (thumbnail);
|
||||
|
||||
if (width > dimension || height > dimension) {
|
||||
GdkPixbuf *result_pixbuf;
|
||||
gfloat factor;
|
||||
|
||||
if (width > height) {
|
||||
factor = (gfloat) dimension / (gfloat) width;
|
||||
} else {
|
||||
factor = (gfloat) dimension / (gfloat) height;
|
||||
}
|
||||
|
||||
width = MAX (width * factor, 1);
|
||||
height = MAX (height * factor, 1);
|
||||
|
||||
result_pixbuf = mate_desktop_thumbnail_scale_down_pixbuf (thumbnail, width, height);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
return gdk_pixbuf_copy (thumbnail);
|
||||
}
|
||||
|
||||
/**
|
||||
* eom_thumbnail_load:
|
||||
* @image: a #EomImage
|
||||
* @error: location to store the error ocurring or %NULL to ignore
|
||||
*
|
||||
* Loads the thumbnail for @image. In case of error, %NULL is returned
|
||||
* and @error is set.
|
||||
*
|
||||
* Returns: (transfer full): a new #GdkPixbuf with the thumbnail for
|
||||
* @image or %NULL in case of error.
|
||||
**/
|
||||
GdkPixbuf*
|
||||
eom_thumbnail_load (EomImage *image, GError **error)
|
||||
{
|
||||
GdkPixbuf *thumb = NULL;
|
||||
GFile *file;
|
||||
EomThumbData *data;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
g_return_val_if_fail (image != NULL, NULL);
|
||||
g_return_val_if_fail (error != NULL && *error == NULL, NULL);
|
||||
|
||||
file = eom_image_get_file (image);
|
||||
data = eom_thumb_data_new (file, error);
|
||||
g_object_unref (file);
|
||||
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!data->can_read ||
|
||||
(data->failed_thumb_exists && mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory, data->uri_str, data->mtime))) {
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: bad permissions or valid failed thumbnail present",data->uri_str);
|
||||
set_thumb_error (error, EOM_THUMB_ERROR_GENERIC, "Thumbnail creation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check if there is already a valid cached thumbnail */
|
||||
thumb = get_valid_thumbnail (data, error);
|
||||
|
||||
if (thumb != NULL) {
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: loaded from cache",data->uri_str);
|
||||
} else if (mate_desktop_thumbnail_factory_can_thumbnail (factory, data->uri_str, data->mime_type, data->mtime)) {
|
||||
/* Only use the image pixbuf when it is up to date. */
|
||||
if (!eom_image_is_file_changed (image))
|
||||
pixbuf = eom_image_get_pixbuf (image);
|
||||
|
||||
if (pixbuf != NULL) {
|
||||
/* generate a thumbnail from the in-memory image,
|
||||
if we have already loaded the image */
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: creating from pixbuf",data->uri_str);
|
||||
thumb = create_thumbnail_from_pixbuf (data, pixbuf, error);
|
||||
g_object_unref (pixbuf);
|
||||
} else {
|
||||
/* generate a thumbnail from the file */
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: creating from file",data->uri_str);
|
||||
thumb = mate_desktop_thumbnail_factory_generate_thumbnail (factory, data->uri_str, data->mime_type);
|
||||
}
|
||||
|
||||
if (thumb != NULL) {
|
||||
/* Save the new thumbnail */
|
||||
mate_desktop_thumbnail_factory_save_thumbnail (factory, thumb, data->uri_str, data->mtime);
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: normal thumbnail saved",data->uri_str);
|
||||
} else {
|
||||
/* Save a failed thumbnail, to stop further thumbnail attempts */
|
||||
mate_desktop_thumbnail_factory_create_failed_thumbnail (factory, data->uri_str, data->mtime);
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: failed thumbnail saved",data->uri_str);
|
||||
set_thumb_error (error, EOM_THUMB_ERROR_GENERIC, "Thumbnail creation failed");
|
||||
}
|
||||
}
|
||||
|
||||
eom_thumb_data_free (data);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
void
|
||||
eom_thumbnail_init (void)
|
||||
{
|
||||
if (factory == NULL) {
|
||||
factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
}
|
||||
|
||||
if (frame == NULL) {
|
||||
frame = gdk_pixbuf_new_from_resource (
|
||||
"/org/mate/eom/ui/pixmaps/thumbnail-frame.png",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
AC_PREREQ(2.59)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
m4_define(gdk-pixbuf_minver, 2.36.5)
|
||||
m4_define(eom_major_version, 1)
|
||||
m4_define(eom_minor_version, 22)
|
||||
m4_define(eom_micro_version, 2)
|
||||
m4_define(eom_version, eom_major_version.eom_minor_version.eom_micro_version)
|
||||
|
||||
AC_INIT([eom], eom_version, [http://www.mate-desktop.org], [eom])
|
||||
AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-xz check-news])
|
||||
|
||||
# Support silencing the build output if supported (automake-1.11+)
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_DEFINE(EOM_MAJOR_VERSION, eom_major_version, [EOM major version])
|
||||
AC_SUBST(EOM_MAJOR_VERSION, eom_major_version)
|
||||
AC_DEFINE(EOM_MINOR_VERSION, eom_minor_version, [EOM minor version])
|
||||
AC_SUBST(EOM_MINOR_VERSION, eom_minor_version)
|
||||
AC_DEFINE(EOM_MICRO_VERSION, eom_micro_version, [EOM micro version])
|
||||
AC_SUBST(EOM_MICRO_VERSION, eom_micro_version)
|
||||
|
||||
EOM_API_VERSION=2.20
|
||||
AC_SUBST(EOM_API_VERSION)
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_SUBST(GDKPIXBUF_REQUIRED, [gdk-pixbuf_minver])
|
||||
MATE_COMMON_INIT
|
||||
MATE_MAINTAINER_MODE_DEFINES
|
||||
MATE_COMPILE_WARNINGS
|
||||
MATE_DEBUG_CHECK
|
||||
|
||||
# Disable building static archives by default
|
||||
AC_DISABLE_STATIC
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
|
||||
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
|
||||
AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
|
||||
|
||||
GTK_DOC_CHECK(1.9)
|
||||
|
||||
AC_CHECK_FUNCS(strptime)
|
||||
|
||||
# ****************************************************************
|
||||
# Support for nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) (optional)
|
||||
# ****************************************************************
|
||||
AC_MSG_CHECKING([for _NL_MEASUREMENT_MEASUREMENT])
|
||||
AC_TRY_LINK([#include <langinfo.h>], [
|
||||
char c;
|
||||
c = *((unsigned char *) nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
|
||||
], have_langinfo_measurement=yes, have_langinfo_measurement=no)
|
||||
AC_MSG_RESULT($have_langinfo_measurement)
|
||||
if test "$have_langinfo_measurement" = "yes"; then
|
||||
AC_DEFINE([HAVE__NL_MEASUREMENT_MEASUREMENT], [1],
|
||||
[Define if _NL_MEASUREMENT_MEASUREMENT is available])
|
||||
fi
|
||||
|
||||
# ***********
|
||||
# Translation
|
||||
# ***********
|
||||
|
||||
AM_GLIB_GNU_GETTEXT
|
||||
IT_PROG_INTLTOOL([0.50.1])
|
||||
|
||||
GETTEXT_PACKAGE=AC_PACKAGE_NAME
|
||||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package.])
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
|
||||
# ***************
|
||||
# mate-doc-utils
|
||||
# ***************
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
YELP_HELP_INIT
|
||||
|
||||
# **********
|
||||
# MATE Libs
|
||||
# **********
|
||||
|
||||
GLIB_REQUIRED=2.52.0
|
||||
GIO_REQUIRED=2.50.0
|
||||
GTK_REQUIRED=3.22.0
|
||||
MATE_DESKTOP_REQUIRED=1.17.0
|
||||
GDKPIXBUF_REQUIRED=2.30.0
|
||||
SHARED_MIME_INFO_REQUIRED=0.20
|
||||
EXEMPI_REQUIRED=1.99.5
|
||||
LIBPEAS_REQUIRED=1.8.0
|
||||
|
||||
PKG_CHECK_MODULES(GMODULE, gmodule-2.0, [GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
|
||||
EOM_MODULES="gtk+-3.0 >= $GTK_REQUIRED \
|
||||
gdk-pixbuf-2.0 >= gdk-pixbuf_minver
|
||||
glib-2.0 >= $GLIB_REQUIRED \
|
||||
$GMODULE_ADD \
|
||||
gio-2.0 >= $GLIB_REQUIRED \
|
||||
gio-unix-2.0 >= $GLIB_REQUIRED \
|
||||
gthread-2.0 >= $GLIB_REQUIRED \
|
||||
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED \
|
||||
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED \
|
||||
gio-2.0 >= $GIO_REQUIRED \
|
||||
gtk+-unix-print-3.0 >= $GTK_REQUIRED \
|
||||
shared-mime-info >= $SHARED_MIME_INFO_REQUIRED \
|
||||
libpeas-1.0 >= $LIBPEAS_REQUIRED \
|
||||
libpeas-gtk-1.0 >= $LIBPEAS_REQUIRED"
|
||||
|
||||
# Introspection
|
||||
GOBJECT_INTROSPECTION_CHECK([0.9.3])
|
||||
|
||||
if test "$found_introspection" = "yes"; then
|
||||
have_introspection=yes
|
||||
AC_DEFINE([HAVE_INTROSPECTION], [1], [Define to enable GObject Introspection])
|
||||
else
|
||||
have_introspection=no
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$have_introspection" = xyes)
|
||||
|
||||
# ***************
|
||||
# ZLIB (required)
|
||||
# ***************
|
||||
|
||||
have_zlib=yes
|
||||
AC_CHECK_HEADERS([zlib.h],
|
||||
[AC_CHECK_LIB([z], [inflate],
|
||||
[AC_CHECK_LIB([z], [crc32], [], [have_zlib=no])],
|
||||
[have_zlib=no])],
|
||||
[have_zlib=no])
|
||||
|
||||
if test x$have_zlib = xno; then
|
||||
AC_MSG_ERROR([No sufficient zlib library found on your system.])
|
||||
fi
|
||||
|
||||
# ***************
|
||||
# EXIF (optional)
|
||||
# ***************
|
||||
|
||||
LIBEXIF_REQUIRED=0.6.14
|
||||
|
||||
AC_ARG_WITH([libexif], AC_HELP_STRING([--without-libexif], [disable EXIF support]))
|
||||
have_exif=no
|
||||
if test x$with_libexif != xno; then
|
||||
PKG_CHECK_MODULES(EXIF, libexif >= $LIBEXIF_REQUIRED, have_exif=yes, have_exif=no)
|
||||
fi
|
||||
if test "x$have_exif" = "xyes"; then
|
||||
AC_DEFINE(HAVE_EXIF, 1, [EXIF Support.])
|
||||
EOM_MODULES="$EOM_MODULES libexif >= $LIBEXIF_REQUIRED"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_EXIF], [test "x$have_exif" = "xyes"])
|
||||
|
||||
# *********************
|
||||
# Little CMS (optional)
|
||||
# *********************
|
||||
|
||||
AC_ARG_WITH([cms], AC_HELP_STRING([--without-cms], [disable colour management support]))
|
||||
have_lcms=no
|
||||
if test x$with_cms != xno; then
|
||||
PKG_CHECK_MODULES(LCMS, lcms2, have_lcms=yes, have_lcms=no)
|
||||
fi
|
||||
if test "x$have_lcms" = "xyes"; then
|
||||
AC_DEFINE(HAVE_LCMS, 1, [Little CMS Support.])
|
||||
EOM_MODULES="$EOM_MODULES lcms2"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_LCMS], [test "x$have_lcms" = "xyes"])
|
||||
|
||||
# *********************
|
||||
# Exempi (optional)
|
||||
# *********************
|
||||
AC_ARG_WITH(xmp, AC_HELP_STRING([--without-xmp], [disable special XMP support]))
|
||||
have_exempi=no
|
||||
if test x$with_xmp != xno; then
|
||||
PKG_CHECK_MODULES(EXEMPI, exempi-2.0 >= $EXEMPI_REQUIRED, have_exempi=yes, have_exempi=no)
|
||||
fi
|
||||
if test "x$have_exempi" = "xyes"; then
|
||||
AC_DEFINE(HAVE_EXEMPI,1, [XMP support.])
|
||||
EOM_MODULES="$EOM_MODULES exempi-2.0 >= $EXEMPI_REQUIRED"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_EXEMPI], [test "x$have_exempi" = "xyes"])
|
||||
|
||||
# Build EXIF-related documentation if we really have support for it
|
||||
if test "x$have_exif" = "xyes" || test "x$have_exempi" = "xyes"; then
|
||||
EOM_DOC_EXIF_START=""
|
||||
EOM_DOC_EXIF_STOP=""
|
||||
else
|
||||
EOM_DOC_EXIF_START="<!--"
|
||||
EOM_DOC_EXIF_STOP="-->"
|
||||
fi
|
||||
|
||||
AC_SUBST([EOM_DOC_EXIF_START])
|
||||
AC_SUBST([EOM_DOC_EXIF_STOP])
|
||||
|
||||
# ********************
|
||||
# Jpeg (semi-optional)
|
||||
# ********************
|
||||
|
||||
AC_ARG_WITH(libjpeg, AC_HELP_STRING([--without-libjpeg], [disable special JPEG support]))
|
||||
have_jpeg=no
|
||||
have_libjpeg_80=no
|
||||
if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
|
||||
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
|
||||
have_jpeg=yes,
|
||||
have_jpeg=no
|
||||
AC_MSG_WARN(*** JPEG loader will not be built (JPEG library not found) ***))
|
||||
if test "$have_jpeg" = yes; then
|
||||
AC_MSG_CHECKING([for jpeglib.h])
|
||||
AC_TRY_CPP(
|
||||
[#include <stdio.h>
|
||||
#undef PACKAGE
|
||||
#undef VERSION
|
||||
#undef HAVE_STDLIB_H
|
||||
#include <jpeglib.h>],
|
||||
have_jpeg=yes,
|
||||
have_jpeg=no)
|
||||
AC_MSG_RESULT($have_jpeg)
|
||||
if test "$have_jpeg" = yes; then
|
||||
LIBJPEG='-ljpeg'
|
||||
AC_DEFINE(HAVE_JPEG, 1, [Jpeg Support.])
|
||||
AC_DEFINE(HAVE_LIBJPEG, 1, [libjpeg is Present.])
|
||||
AC_CHECK_LIB(jpeg, jpeg_simple_progression,
|
||||
AC_DEFINE(HAVE_PROGRESSIVE_JPEG, 1, [Jpeg Progressive Saving Support.]),
|
||||
AC_MSG_WARN(JPEG library does not support progressive saving.))
|
||||
AC_MSG_CHECKING([[libjpeg version is 8 or greater]])
|
||||
AC_PREPROC_IFELSE([ AC_LANG_SOURCE(
|
||||
[[
|
||||
#include <stdio.h>
|
||||
#include <jpeglib.h>
|
||||
#if JPEG_LIB_VERSION < 80
|
||||
#error "wrong version"
|
||||
#endif
|
||||
int main(int c, char**v) { return 0; }
|
||||
]]) ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
have_libjpeg_80=yes],
|
||||
[AC_MSG_RESULT(no)
|
||||
have_libjpeg_80=no])
|
||||
|
||||
else
|
||||
AC_MSG_WARN(*** JPEG loader will not be built (JPEG header file not found) ***)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
|
||||
AC_MSG_ERROR([
|
||||
*** Checks for JPEG loader failed. You can build without it by passing
|
||||
*** --without-libjpeg to configure but some programs using GTK+ may
|
||||
*** not work properly])
|
||||
fi
|
||||
AC_SUBST(LIBJPEG)
|
||||
AM_CONDITIONAL(ENABLE_JPEG, test x$have_jpeg = xyes)
|
||||
AM_CONDITIONAL(HAVE_LIBJPEG_80, test "x$have_libjpeg_80" = xyes)
|
||||
|
||||
# ************************************
|
||||
# libXML2 (required for toolbareditor)
|
||||
# ************************************
|
||||
|
||||
LIBXML2_REQUIRED=2.0
|
||||
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= $LIBXML2_REQUIRED])
|
||||
|
||||
# ***************
|
||||
# RSVG (optional for scaling svg image)
|
||||
# ***************
|
||||
|
||||
LIBRSVG_REQUIRED=2.36.2
|
||||
|
||||
AC_ARG_WITH([librsvg], AC_HELP_STRING([--without-librsvg], [disable RSVG support]))
|
||||
have_rsvg=no
|
||||
if test x$with_librsvg != xno; then
|
||||
PKG_CHECK_MODULES(RSVG, librsvg-2.0 >= $LIBRSVG_REQUIRED, have_rsvg=yes, have_rsvg=no)
|
||||
fi
|
||||
if test "x$have_rsvg" = "xyes"; then
|
||||
AC_DEFINE(HAVE_RSVG, 1, [RSVG Support.])
|
||||
EOM_MODULES="$EOM_MODULES librsvg-2.0 >= $LIBRSVG_REQUIRED"
|
||||
else
|
||||
AC_WARN([LIBRSVG support disabled, svg files will not scale])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_RSVG], [test "x$have_rsvg" = "xyes"])
|
||||
|
||||
# ****************
|
||||
# CFLAGS/LIBS init
|
||||
# ****************
|
||||
|
||||
PKG_CHECK_MODULES(EOM, $EOM_MODULES)
|
||||
AC_SUBST(EOM_CFLAGS)
|
||||
AC_SUBST(EOM_LIBS)
|
||||
|
||||
# *******************************************************
|
||||
# libX11 (required for TotemScrSaver and Color Profiling)
|
||||
# *******************************************************
|
||||
|
||||
# Check GDK rendering target
|
||||
gdk_target_has_x11=`$PKG_CONFIG --variable=targets gdk-3.0 | grep x11`
|
||||
|
||||
if test "x$have_lcms" = "xyes" || test "$gdk_target_has_x11" != ""; then
|
||||
PKG_CHECK_MODULES(X11, [x11], have_x11=yes, have_x11=no)
|
||||
|
||||
if test "x$have_x11" != "xyes"; then
|
||||
# Fallback for X11 releases without .pc-files
|
||||
AC_PATH_XTRA
|
||||
if test x$no_x = xyes ; then
|
||||
AC_MSG_ERROR([X development libraries (libX11) not found])
|
||||
else
|
||||
X11_LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
|
||||
AC_SUBST(X11_LIBS)
|
||||
have_x11=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# *****
|
||||
# GSettings
|
||||
# *****
|
||||
|
||||
GLIB_GSETTINGS
|
||||
|
||||
AC_SEARCH_LIBS([floor],[m])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/Makefile
|
||||
man/Makefile
|
||||
jpegutils/Makefile
|
||||
cut-n-paste/Makefile
|
||||
cut-n-paste/toolbar-editor/Makefile
|
||||
help/Makefile
|
||||
po/Makefile.in
|
||||
data/Makefile
|
||||
data/eom.pc
|
||||
data/eom.desktop.in
|
||||
data/org.mate.eom.gschema.xml
|
||||
data/pixmaps/Makefile
|
||||
data/icons/Makefile
|
||||
data/icons/16x16/Makefile
|
||||
data/icons/22x22/Makefile
|
||||
data/icons/24x24/Makefile
|
||||
data/icons/32x32/Makefile
|
||||
data/icons/48x48/Makefile
|
||||
data/icons/scalable/Makefile
|
||||
doc/Makefile
|
||||
doc/reference/Makefile
|
||||
doc/reference/version.xml
|
||||
doc/reference/eom-docs.sgml
|
||||
plugins/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
echo "
|
||||
Configure summary:
|
||||
|
||||
Source code location .......: ${srcdir}
|
||||
Compiler ...................: ${CC}
|
||||
Extra Compiler Warnings ....: ${WARN_CFLAGS}
|
||||
|
||||
EXIF support ...............: ${have_exif}
|
||||
XMP support ................: ${have_exempi}
|
||||
JPEG support ...............: ${have_jpeg}
|
||||
RSVG support ...............: ${have_rsvg}
|
||||
Colour management support ..: ${have_lcms}
|
||||
GObject Introspection.......: ${have_introspection}
|
||||
"
|
||||
@@ -0,0 +1,542 @@
|
||||
/* Eye Of Mate - Thumbnailing functions
|
||||
*
|
||||
* Copyright (C) 2000-2008 The Free Software Foundation
|
||||
*
|
||||
* Author: Lucas Rocha <lucasr@gnome.org>
|
||||
*
|
||||
* Based on eel code (eel/eel-graphic-effects.c) by:
|
||||
* - Andy Hertzfeld <andy@eazel.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* We must define MATE_DESKTOP_USE_UNSTABLE_API to be able
|
||||
to use MateDesktopThumbnail */
|
||||
#ifndef MATE_DESKTOP_USE_UNSTABLE_API
|
||||
#define MATE_DESKTOP_USE_UNSTABLE_API
|
||||
#endif
|
||||
#include <libmate-desktop/mate-desktop-thumbnail.h>
|
||||
|
||||
#include "eom-thumbnail.h"
|
||||
#include "eom-list-store.h"
|
||||
#include "eom-debug.h"
|
||||
|
||||
#define EOM_THUMB_ERROR eom_thumb_error_quark ()
|
||||
|
||||
static MateDesktopThumbnailFactory *factory = NULL;
|
||||
static GdkPixbuf *frame = NULL;
|
||||
|
||||
typedef enum {
|
||||
EOM_THUMB_ERROR_VFS,
|
||||
EOM_THUMB_ERROR_GENERIC,
|
||||
EOM_THUMB_ERROR_UNKNOWN
|
||||
} EomThumbError;
|
||||
|
||||
typedef struct {
|
||||
char *uri_str;
|
||||
char *thumb_path;
|
||||
time_t mtime;
|
||||
char *mime_type;
|
||||
gboolean thumb_exists;
|
||||
gboolean failed_thumb_exists;
|
||||
gboolean can_read;
|
||||
} EomThumbData;
|
||||
|
||||
static GQuark
|
||||
eom_thumb_error_quark (void)
|
||||
{
|
||||
static GQuark q = 0;
|
||||
if (q == 0)
|
||||
q = g_quark_from_static_string ("eom-thumb-error-quark");
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
static void
|
||||
set_vfs_error (GError **error, GError *ioerror)
|
||||
{
|
||||
g_set_error (error,
|
||||
EOM_THUMB_ERROR,
|
||||
EOM_THUMB_ERROR_VFS,
|
||||
"%s", ioerror ? ioerror->message : "VFS error making a thumbnail");
|
||||
}
|
||||
|
||||
static void
|
||||
set_thumb_error (GError **error, int error_id, const char *string)
|
||||
{
|
||||
g_set_error (error,
|
||||
EOM_THUMB_ERROR,
|
||||
error_id,
|
||||
"%s", string);
|
||||
}
|
||||
|
||||
static GdkPixbuf*
|
||||
get_valid_thumbnail (EomThumbData *data, GError **error)
|
||||
{
|
||||
GdkPixbuf *thumb = NULL;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
/* does a thumbnail under the path exists? */
|
||||
if (data->thumb_exists) {
|
||||
thumb = gdk_pixbuf_new_from_file (data->thumb_path, error);
|
||||
|
||||
/* is this thumbnail file up to date? */
|
||||
if (thumb != NULL && !mate_desktop_thumbnail_is_valid (thumb, data->uri_str, data->mtime)) {
|
||||
g_object_unref (thumb);
|
||||
thumb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
create_thumbnail_from_pixbuf (EomThumbData *data,
|
||||
GdkPixbuf *pixbuf,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *thumb;
|
||||
gint width, height;
|
||||
gfloat perc;
|
||||
|
||||
g_assert (factory != NULL);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
|
||||
perc = CLAMP (128.0/(MAX (width, height)), 0, 1);
|
||||
|
||||
thumb = gdk_pixbuf_scale_simple (pixbuf,
|
||||
width*perc,
|
||||
height*perc,
|
||||
GDK_INTERP_HYPER);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
static void
|
||||
eom_thumb_data_free (EomThumbData *data)
|
||||
{
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
g_free (data->thumb_path);
|
||||
g_free (data->mime_type);
|
||||
g_free (data->uri_str);
|
||||
|
||||
g_slice_free (EomThumbData, data);
|
||||
}
|
||||
|
||||
static EomThumbData*
|
||||
eom_thumb_data_new (GFile *file, GError **error)
|
||||
{
|
||||
EomThumbData *data;
|
||||
GFileInfo *file_info;
|
||||
GError *ioerror = NULL;
|
||||
|
||||
g_return_val_if_fail (file != NULL, NULL);
|
||||
g_return_val_if_fail (error != NULL && *error == NULL, NULL);
|
||||
|
||||
data = g_slice_new0 (EomThumbData);
|
||||
|
||||
data->uri_str = g_file_get_uri (file);
|
||||
data->thumb_path = mate_desktop_thumbnail_path_for_uri (data->uri_str, MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
|
||||
file_info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
|
||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
|
||||
0, NULL, &ioerror);
|
||||
if (file_info == NULL)
|
||||
{
|
||||
set_vfs_error (error, ioerror);
|
||||
g_clear_error (&ioerror);
|
||||
}
|
||||
|
||||
if (*error == NULL) {
|
||||
/* if available, copy data */
|
||||
data->mtime = g_file_info_get_attribute_uint64 (file_info,
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||
data->mime_type = g_strdup (g_file_info_get_content_type (file_info));
|
||||
|
||||
data->thumb_exists = (g_file_info_get_attribute_byte_string (file_info,
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH) != NULL);
|
||||
data->failed_thumb_exists = g_file_info_get_attribute_boolean (file_info,
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
|
||||
data->can_read = TRUE;
|
||||
if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) {
|
||||
data->can_read = g_file_info_get_attribute_boolean (file_info,
|
||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
|
||||
}
|
||||
}
|
||||
else {
|
||||
eom_thumb_data_free (data);
|
||||
data = NULL;
|
||||
g_clear_error (&ioerror);
|
||||
}
|
||||
|
||||
g_object_unref (file_info);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_frame_row (GdkPixbuf *frame_image,
|
||||
gint target_width,
|
||||
gint source_width,
|
||||
gint source_v_position,
|
||||
gint dest_v_position,
|
||||
GdkPixbuf *result_pixbuf,
|
||||
gint left_offset,
|
||||
gint height)
|
||||
{
|
||||
gint remaining_width, h_offset, slab_width;
|
||||
|
||||
remaining_width = target_width;
|
||||
h_offset = 0;
|
||||
|
||||
while (remaining_width > 0) {
|
||||
slab_width = remaining_width > source_width ?
|
||||
source_width : remaining_width;
|
||||
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
left_offset,
|
||||
source_v_position,
|
||||
slab_width,
|
||||
height,
|
||||
result_pixbuf,
|
||||
left_offset + h_offset,
|
||||
dest_v_position);
|
||||
|
||||
remaining_width -= slab_width;
|
||||
h_offset += slab_width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_frame_column (GdkPixbuf *frame_image,
|
||||
gint target_height,
|
||||
gint source_height,
|
||||
gint source_h_position,
|
||||
gint dest_h_position,
|
||||
GdkPixbuf *result_pixbuf,
|
||||
gint top_offset,
|
||||
gint width)
|
||||
{
|
||||
gint remaining_height, v_offset, slab_height;
|
||||
|
||||
remaining_height = target_height;
|
||||
v_offset = 0;
|
||||
|
||||
while (remaining_height > 0) {
|
||||
slab_height = remaining_height > source_height ?
|
||||
source_height : remaining_height;
|
||||
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
source_h_position,
|
||||
top_offset,
|
||||
width,
|
||||
slab_height,
|
||||
result_pixbuf,
|
||||
dest_h_position,
|
||||
top_offset + v_offset);
|
||||
|
||||
remaining_height -= slab_height;
|
||||
v_offset += slab_height;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
eom_thumbnail_stretch_frame_image (GdkPixbuf *frame_image,
|
||||
gint left_offset,
|
||||
gint top_offset,
|
||||
gint right_offset,
|
||||
gint bottom_offset,
|
||||
gint dest_width,
|
||||
gint dest_height,
|
||||
gboolean fill_flag)
|
||||
{
|
||||
GdkPixbuf *result_pixbuf;
|
||||
gint frame_width, frame_height;
|
||||
gint target_width, target_frame_width;
|
||||
gint target_height, target_frame_height;
|
||||
|
||||
frame_width = gdk_pixbuf_get_width (frame_image);
|
||||
frame_height = gdk_pixbuf_get_height (frame_image);
|
||||
|
||||
if (fill_flag) {
|
||||
result_pixbuf = gdk_pixbuf_scale_simple (frame_image,
|
||||
dest_width,
|
||||
dest_height,
|
||||
GDK_INTERP_NEAREST);
|
||||
} else {
|
||||
result_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
||||
TRUE,
|
||||
8,
|
||||
dest_width,
|
||||
dest_height);
|
||||
|
||||
/* Clear pixbuf to fully opaque white */
|
||||
gdk_pixbuf_fill (result_pixbuf, 0xffffffff);
|
||||
}
|
||||
|
||||
target_width = dest_width - left_offset - right_offset;
|
||||
target_frame_width = frame_width - left_offset - right_offset;
|
||||
|
||||
target_height = dest_height - top_offset - bottom_offset;
|
||||
target_frame_height = frame_height - top_offset - bottom_offset;
|
||||
|
||||
/* Draw the left top corner and top row */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
0, 0,
|
||||
left_offset,
|
||||
top_offset,
|
||||
result_pixbuf,
|
||||
0, 0);
|
||||
|
||||
draw_frame_row (frame_image,
|
||||
target_width,
|
||||
target_frame_width,
|
||||
0, 0,
|
||||
result_pixbuf,
|
||||
left_offset,
|
||||
top_offset);
|
||||
|
||||
/* Draw the right top corner and left column */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
frame_width - right_offset,
|
||||
0,
|
||||
right_offset,
|
||||
top_offset,
|
||||
result_pixbuf,
|
||||
dest_width - right_offset,
|
||||
0);
|
||||
|
||||
draw_frame_column (frame_image,
|
||||
target_height,
|
||||
target_frame_height,
|
||||
0, 0,
|
||||
result_pixbuf,
|
||||
top_offset,
|
||||
left_offset);
|
||||
|
||||
/* Draw the bottom right corner and bottom row */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
frame_width - right_offset,
|
||||
frame_height - bottom_offset,
|
||||
right_offset,
|
||||
bottom_offset,
|
||||
result_pixbuf,
|
||||
dest_width - right_offset,
|
||||
dest_height - bottom_offset);
|
||||
|
||||
draw_frame_row (frame_image,
|
||||
target_width,
|
||||
target_frame_width,
|
||||
frame_height - bottom_offset,
|
||||
dest_height - bottom_offset,
|
||||
result_pixbuf,
|
||||
left_offset, bottom_offset);
|
||||
|
||||
/* Draw the bottom left corner and the right column */
|
||||
gdk_pixbuf_copy_area (frame_image,
|
||||
0,
|
||||
frame_height - bottom_offset,
|
||||
left_offset,
|
||||
bottom_offset,
|
||||
result_pixbuf,
|
||||
0,
|
||||
dest_height - bottom_offset);
|
||||
|
||||
draw_frame_column (frame_image,
|
||||
target_height,
|
||||
target_frame_height,
|
||||
frame_width - right_offset,
|
||||
dest_width - right_offset,
|
||||
result_pixbuf, top_offset,
|
||||
right_offset);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* eom_thumbnail_add_frame:
|
||||
* @thumbnail: a #GdkPixbuf
|
||||
*
|
||||
* Adds a frame to @thumbnail
|
||||
*
|
||||
* Returns: (transfer full): a new #GdkPixbuf, storing @thumbnail nicely framed.
|
||||
**/
|
||||
GdkPixbuf *
|
||||
eom_thumbnail_add_frame (GdkPixbuf *thumbnail)
|
||||
{
|
||||
GdkPixbuf *result_pixbuf;
|
||||
gint source_width, source_height;
|
||||
gint dest_width, dest_height;
|
||||
|
||||
source_width = gdk_pixbuf_get_width (thumbnail);
|
||||
source_height = gdk_pixbuf_get_height (thumbnail);
|
||||
|
||||
dest_width = source_width + 9;
|
||||
dest_height = source_height + 9;
|
||||
|
||||
result_pixbuf = eom_thumbnail_stretch_frame_image (frame,
|
||||
3, 3, 6, 6,
|
||||
dest_width,
|
||||
dest_height,
|
||||
FALSE);
|
||||
|
||||
gdk_pixbuf_copy_area (thumbnail,
|
||||
0, 0,
|
||||
source_width,
|
||||
source_height,
|
||||
result_pixbuf,
|
||||
3, 3);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* eom_thumbnail_fit_to_size:
|
||||
* @thumbnail: a #GdkPixbuf
|
||||
* @dimension: the maximum width or height desired
|
||||
*
|
||||
* Ensures a pixbuf fits a given @dimension
|
||||
*
|
||||
* Returns: (transfer full): a new #GdkPixbuf
|
||||
**/
|
||||
GdkPixbuf *
|
||||
eom_thumbnail_fit_to_size (GdkPixbuf *thumbnail, gint dimension)
|
||||
{
|
||||
gint width, height;
|
||||
|
||||
width = gdk_pixbuf_get_width (thumbnail);
|
||||
height = gdk_pixbuf_get_height (thumbnail);
|
||||
|
||||
if (width > dimension || height > dimension) {
|
||||
GdkPixbuf *result_pixbuf;
|
||||
gfloat factor;
|
||||
|
||||
if (width > height) {
|
||||
factor = (gfloat) dimension / (gfloat) width;
|
||||
} else {
|
||||
factor = (gfloat) dimension / (gfloat) height;
|
||||
}
|
||||
|
||||
width = MAX (width * factor, 1);
|
||||
height = MAX (height * factor, 1);
|
||||
|
||||
result_pixbuf = gdk_pixbuf_scale_simple (thumbnail, width, height, GDK_INTERP_HYPER);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
return gdk_pixbuf_copy (thumbnail);
|
||||
}
|
||||
|
||||
/**
|
||||
* eom_thumbnail_load:
|
||||
* @image: a #EomImage
|
||||
* @error: location to store the error ocurring or %NULL to ignore
|
||||
*
|
||||
* Loads the thumbnail for @image. In case of error, %NULL is returned
|
||||
* and @error is set.
|
||||
*
|
||||
* Returns: (transfer full): a new #GdkPixbuf with the thumbnail for
|
||||
* @image or %NULL in case of error.
|
||||
**/
|
||||
GdkPixbuf*
|
||||
eom_thumbnail_load (EomImage *image, GError **error)
|
||||
{
|
||||
GdkPixbuf *thumb = NULL;
|
||||
GFile *file;
|
||||
EomThumbData *data;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
g_return_val_if_fail (image != NULL, NULL);
|
||||
g_return_val_if_fail (error != NULL && *error == NULL, NULL);
|
||||
|
||||
file = eom_image_get_file (image);
|
||||
data = eom_thumb_data_new (file, error);
|
||||
g_object_unref (file);
|
||||
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!data->can_read ||
|
||||
(data->failed_thumb_exists && mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory, data->uri_str, data->mtime))) {
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: bad permissions or valid failed thumbnail present",data->uri_str);
|
||||
set_thumb_error (error, EOM_THUMB_ERROR_GENERIC, "Thumbnail creation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check if there is already a valid cached thumbnail */
|
||||
thumb = get_valid_thumbnail (data, error);
|
||||
|
||||
if (thumb != NULL) {
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: loaded from cache",data->uri_str);
|
||||
} else if (mate_desktop_thumbnail_factory_can_thumbnail (factory, data->uri_str, data->mime_type, data->mtime)) {
|
||||
/* Only use the image pixbuf when it is up to date. */
|
||||
if (!eom_image_is_file_changed (image))
|
||||
pixbuf = eom_image_get_pixbuf (image);
|
||||
|
||||
if (pixbuf != NULL) {
|
||||
/* generate a thumbnail from the in-memory image,
|
||||
if we have already loaded the image */
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: creating from pixbuf",data->uri_str);
|
||||
thumb = create_thumbnail_from_pixbuf (data, pixbuf, error);
|
||||
g_object_unref (pixbuf);
|
||||
} else {
|
||||
/* generate a thumbnail from the file */
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: creating from file",data->uri_str);
|
||||
thumb = mate_desktop_thumbnail_factory_generate_thumbnail (factory, data->uri_str, data->mime_type);
|
||||
}
|
||||
|
||||
if (thumb != NULL) {
|
||||
/* Save the new thumbnail */
|
||||
mate_desktop_thumbnail_factory_save_thumbnail (factory, thumb, data->uri_str, data->mtime);
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: normal thumbnail saved",data->uri_str);
|
||||
} else {
|
||||
/* Save a failed thumbnail, to stop further thumbnail attempts */
|
||||
mate_desktop_thumbnail_factory_create_failed_thumbnail (factory, data->uri_str, data->mtime);
|
||||
eom_debug_message (DEBUG_THUMBNAIL, "%s: failed thumbnail saved",data->uri_str);
|
||||
set_thumb_error (error, EOM_THUMB_ERROR_GENERIC, "Thumbnail creation failed");
|
||||
}
|
||||
}
|
||||
|
||||
eom_thumb_data_free (data);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
void
|
||||
eom_thumbnail_init (void)
|
||||
{
|
||||
if (factory == NULL) {
|
||||
factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
}
|
||||
|
||||
if (frame == NULL) {
|
||||
frame = gdk_pixbuf_new_from_resource (
|
||||
"/org/mate/eom/ui/pixmaps/thumbnail-frame.png",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
diff -Nuar a/configure.ac b/configure.ac
|
||||
--- a/configure.ac 2019-09-18 16:05:00.000000000 +0300
|
||||
+++ b/configure.ac 2020-02-19 10:35:23.874694686 +0300
|
||||
@@ -1,6 +1,7 @@
|
||||
AC_PREREQ(2.59)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
+m4_define(gdk-pixbuf_minver, 2.36.5)
|
||||
m4_define(eom_major_version, 1)
|
||||
m4_define(eom_minor_version, 22)
|
||||
m4_define(eom_micro_version, 2)
|
||||
@@ -26,6 +27,7 @@
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
+AC_SUBST(GDKPIXBUF_REQUIRED, [gdk-pixbuf_minver])
|
||||
MATE_COMMON_INIT
|
||||
MATE_MAINTAINER_MODE_DEFINES
|
||||
MATE_COMPILE_WARNINGS
|
||||
@@ -96,6 +98,7 @@
|
||||
|
||||
PKG_CHECK_MODULES(GMODULE, gmodule-2.0, [GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
|
||||
EOM_MODULES="gtk+-3.0 >= $GTK_REQUIRED \
|
||||
+ gdk-pixbuf-2.0 >= gdk-pixbuf_minver
|
||||
glib-2.0 >= $GLIB_REQUIRED \
|
||||
$GMODULE_ADD \
|
||||
gio-2.0 >= $GLIB_REQUIRED \
|
||||
diff -Nuar a/src/eom-thumbnail.c b/src/eom-thumbnail.c
|
||||
--- a/src/eom-thumbnail.c 2019-09-18 16:05:00.000000000 +0300
|
||||
+++ b/src/eom-thumbnail.c 2020-02-19 10:42:44.560728013 +0300
|
||||
@@ -123,9 +123,10 @@
|
||||
|
||||
perc = CLAMP (128.0/(MAX (width, height)), 0, 1);
|
||||
|
||||
- thumb = mate_desktop_thumbnail_scale_down_pixbuf (pixbuf,
|
||||
+ thumb = gdk_pixbuf_scale_simple (pixbuf,
|
||||
width*perc,
|
||||
- height*perc);
|
||||
+ height*perc,
|
||||
+ GDK_INTERP_HYPER);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
@@ -444,7 +445,7 @@
|
||||
width = MAX (width * factor, 1);
|
||||
height = MAX (height * factor, 1);
|
||||
|
||||
- result_pixbuf = mate_desktop_thumbnail_scale_down_pixbuf (thumbnail, width, height);
|
||||
+ result_pixbuf = gdk_pixbuf_scale_simple (thumbnail, width, height, GDK_INTERP_HYPER);
|
||||
|
||||
return result_pixbuf;
|
||||
}
|
||||
Reference in New Issue
Block a user