Merge lp:~attente/gdk-pixbuf/gicon-upstream into lp:ubuntu/saucy/gdk-pixbuf

Proposed by William Hua
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~attente/gdk-pixbuf/gicon-upstream
Merge into: lp:ubuntu/saucy/gdk-pixbuf
Diff against target: 2540 lines (+2389/-8)
13 files modified
.pc/applied-patches (+1/-0)
.pc/gicon-serialization-support.patch/configure.ac (+1057/-0)
.pc/gicon-serialization-support.patch/gdk-pixbuf/gdk-pixbuf.c (+892/-0)
.pc/gicon-serialization-support.patch/tests/Makefile.am (+30/-0)
configure.ac (+1/-1)
debian/changelog (+7/-0)
debian/control (+2/-2)
debian/control.in (+2/-2)
debian/patches/gicon-serialization-support.patch (+229/-0)
debian/patches/series (+1/-0)
gdk-pixbuf/gdk-pixbuf.c (+102/-2)
tests/Makefile.am (+5/-1)
tests/pixbuf-icon-serialize.c (+60/-0)
To merge this branch: bzr merge lp:~attente/gdk-pixbuf/gicon-upstream
Reviewer Review Type Date Requested Status
Sebastien Bacher Needs Information
Ubuntu branches Pending
Review via email: mp+162431@code.launchpad.net

Commit message

* debian/patches/gicon-serialization-support.patch:
  - Add upstream's GdkPixbuf serialization support.

Description of the change

Take upstream's update of GdkPixbuf to implement the GLoadableIcon interface. Requires https://code.launchpad.net/~attente/glib/gicon-upstream/+merge/162430.

To post a comment you must log in.
55. By Sebastien Bacher

* Resynchronize on Debian, remaining changes:
* debian/control.in:
  - B-D on libtiff5-dev | libtiff-dev instead of libtiff-dev, as we
    have made this transition ahead of Debian.

56. By Sebastien Bacher

* Resynchronize on Debian, remaining changes:
* debian/control.in:
  - B-D on libtiff5-dev | libtiff-dev instead of libtiff-dev, as we
    have made this transition ahead of Debian.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work, the patch require glib 2.36 and the debian/control 2.34 ... should that be bumped to 2.34? Did you try it with glib 2.37.0 which landed this week? out of the glib requirement issue it should be fine to upload to the ppa for some testing and then to ubuntu

review: Needs Information
58. By William Hua

Depend on GLib 2.37 for GIcon changes.

Revision history for this message
William Hua (attente) wrote :

Thanks, I bumped the GLib version number required, so we should be good now. I'm running it on my system against 2.37 and everything is working fine.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, I've renamed the patch to append "git-" (which we use as a convention to indicator it's an upstream git backport, makes easier to figure out it can be dropped later), added the git description to the patch and uploaded to Ubuntu

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.pc/applied-patches'
--- .pc/applied-patches 1970-01-01 00:00:00 +0000
+++ .pc/applied-patches 2013-05-17 06:11:25 +0000
@@ -0,0 +1,1 @@
1gicon-serialization-support.patch
02
=== removed file '.pc/applied-patches'
=== added directory '.pc/gicon-serialization-support.patch'
=== added file '.pc/gicon-serialization-support.patch/configure.ac'
--- .pc/gicon-serialization-support.patch/configure.ac 1970-01-01 00:00:00 +0000
+++ .pc/gicon-serialization-support.patch/configure.ac 2013-05-17 06:11:25 +0000
@@ -0,0 +1,1057 @@
1# Process this file with autoconf to produce a configure script.
2AC_PREREQ([2.63])
3
4# Making point releases:
5# gdk_pixbuf_micro_version += 1;
6# gdk_pixbuf_interface_age += 1;
7# gdk_pixbuf_binary_age += 1;
8#
9# if any functions have been added, set gdk_pixbuf_interface_age to 0.
10#
11# if backwards compatibility has been broken:
12# gdk_pixbuf_major_version += 1;
13# gdk_pixbuf_interface_age = 0;
14# gdk_pixbuf_binary_age = 0;
15
16m4_define([gdk_pixbuf_major_version], [2])
17m4_define([gdk_pixbuf_minor_version], [28])
18m4_define([gdk_pixbuf_micro_version], [1])
19m4_define([gdk_pixbuf_interface_age], [1])
20m4_define([gdk_pixbuf_binary_age],
21 [m4_eval(100 * gdk_pixbuf_minor_version + gdk_pixbuf_micro_version)])
22m4_define([gdk_pixbuf_version],
23 [gdk_pixbuf_major_version.gdk_pixbuf_minor_version.gdk_pixbuf_micro_version])
24m4_define([gdk_pixbuf_api_version], [2.0])
25m4_define([gdk_pixbuf_binary_version], [2.10.0])
26
27
28# required versions of other packages
29m4_define([glib_required_version], [2.34.0])
30
31AC_INIT([gdk-pixbuf], [gdk_pixbuf_version],
32 [http://bugzilla.gnome.org/enter_bug.cgi?product=gdk-pixbuf],
33 [gdk-pixbuf])
34
35AC_CONFIG_HEADER([config.h])
36AC_CONFIG_SRCDIR([gdk-pixbuf/gdk-pixbuf.h])
37AC_CONFIG_MACRO_DIR([m4])
38
39# Save this value here, since automake will set cflags later
40cflags_set=${CFLAGS+set}
41
42AM_INIT_AUTOMAKE([1.11 foreign no-define -Wno-portability dist-xz no-dist-gzip tar-ustar])
43AM_MAINTAINER_MODE([enable])
44
45# Support silent build rules. Disable
46# by either passing --disable-silent-rules to configure or passing V=0
47# to make
48AM_SILENT_RULES([yes])
49
50#
51# For each of the libraries we build, we define the following
52# substituted variables:
53#
54# foo_PACKAGES: pkg-config packages this library requires
55# foo_EXTRA_LIBS: Libraries this module requires not pulled in by pkg-config
56# foo_EXTRA_CFLAGS: cflags this module requires not pulled in by pkg-config
57# foo_DEP_LIBS: All libraries this module requires
58# foo_DEP_CFLAGS: All cflags this module requires
59
60GDK_PIXBUF_MAJOR=gdk_pixbuf_major_version
61GDK_PIXBUF_MINOR=gdk_pixbuf_minor_version
62GDK_PIXBUF_MICRO=gdk_pixbuf_micro_version
63GDK_PIXBUF_VERSION=gdk_pixbuf_version
64GDK_PIXBUF_API_VERSION=gdk_pixbuf_api_version
65GDK_PIXBUF_BINARY_VERSION=gdk_pixbuf_binary_version
66AC_SUBST(GDK_PIXBUF_MAJOR)
67AC_SUBST(GDK_PIXBUF_MINOR)
68AC_SUBST(GDK_PIXBUF_MICRO)
69AC_SUBST(GDK_PIXBUF_VERSION)
70AC_SUBST(GDK_PIXBUF_API_VERSION)
71AC_SUBST(GDK_PIXBUF_BINARY_VERSION)
72
73# libtool versioning
74#LT_RELEASE=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION
75#LT_CURRENT=`expr $GTK_MICRO_VERSION - $GTK_INTERFACE_AGE`
76#LT_REVISION=$GTK_INTERFACE_AGE
77#LT_AGE=`expr $GTK_BINARY_AGE - $GTK_INTERFACE_AGE`
78#LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
79
80m4_define([lt_current], [m4_eval(100 * gdk_pixbuf_minor_version + gdk_pixbuf_micro_version - gdk_pixbuf_interface_age)])
81m4_define([lt_revision], [gdk_pixbuf_interface_age])
82m4_define([lt_age], [m4_eval(gdk_pixbuf_binary_age - gdk_pixbuf_interface_age)])
83LT_VERSION_INFO="lt_current:lt_revision:lt_age"
84LT_CURRENT_MINUS_AGE=m4_eval(lt_current - lt_age)
85AC_SUBST(LT_VERSION_INFO)
86AC_SUBST(LT_CURRENT_MINUS_AGE)
87
88# Checks for programs.
89AC_PROG_CC
90AC_PROG_CC_C_O
91AC_PROG_CC_STDC
92AC_PROG_INSTALL
93AC_PROG_MAKE_SET
94PKG_PROG_PKG_CONFIG
95
96AC_CANONICAL_HOST
97
98AC_ARG_ENABLE(gio-sniffing,
99 [AC_HELP_STRING([--enable-gio-sniffing=@<:@no/yes/auto@:>@],
100 [enable or disable gio sniffing [default=auto]])],,
101 [enable_gio_sniffing=auto])
102
103MATH_LIB=-lm
104AC_MSG_CHECKING([for native Win32])
105LIB_EXE_MACHINE_FLAG=X86
106EXE_MANIFEST_ARCHITECTURE=X86
107case "$host" in
108 *-*-mingw*)
109 os_win32=yes
110 gio_can_sniff=no
111 MATH_LIB=
112 case "$host" in
113 x86_64-*-*)
114 LIB_EXE_MACHINE_FLAG=X64
115 EXE_MANIFEST_ARCHITECTURE=AMD64
116 ;;
117 esac
118 ;;
119 *)
120 os_win32=no
121 ;;
122esac
123AC_MSG_RESULT([$os_win32])
124
125AC_SUBST(LIB_EXE_MACHINE_FLAG)
126AC_SUBST(EXE_MANIFEST_ARCHITECTURE)
127
128case $host in
129 *-*-linux*)
130 os_linux=yes
131 ;;
132esac
133
134if test "$os_win32" = "yes"; then
135 if test x$enable_static = xyes -o x$enable_static = x; then
136 AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
137 enable_static=no
138 fi
139 if test x$enable_shared = xno; then
140 AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
141 fi
142 enable_shared=yes
143fi
144
145dnl Initialize libtool
146LT_PREREQ([2.2.6])
147LT_INIT([disable-static win32-dll])
148# Create libtool early, because it's used in configure
149LT_OUTPUT
150
151# Make sure we use 64-bit versions of various file stuff.
152AC_SYS_LARGEFILE
153
154AM_PROG_AS
155AC_CHECK_TOOLS(NM, nm, nm)
156
157AC_MSG_CHECKING([for some Win32 platform])
158AS_CASE(["$host"],
159 [*-*-mingw*|*-*-cygwin*], [platform_win32=yes],
160 [platform_win32=no]
161)
162AC_MSG_RESULT([$platform_win32])
163AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
164
165AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
166AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
167AM_CONDITIONAL(OS_LINUX, test "$os_linux" = "yes")
168
169if test "$os_win32" = "yes"; then
170 AC_CHECK_TOOL(WINDRES, windres, no)
171 if test "$WINDRES" = no; then
172 AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.])
173 fi
174 AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
175fi
176AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)
177
178m4_define([debug_default],
179 m4_if(m4_eval(gdk_pixbuf_minor_version % 2), [1], [yes], [minimum]))
180
181dnl declare --enable-* args and collect ac_help strings
182AC_ARG_ENABLE(debug,
183 AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@],
184 [turn on debugging @<:@default=debug_default@:>@]),,
185 enable_debug=debug_default)
186AC_ARG_ENABLE(rebuilds,
187 [AC_HELP_STRING([--disable-rebuilds],
188 [disable all source autogeneration rules])],,
189 [enable_rebuilds=yes])
190
191AS_CASE([$enable_debug],
192 [yes],
193 [
194 test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
195 GDK_PIXBUF_DEBUG_FLAGS="-DG_ENABLE_DEBUG -DG_ERRORCHECK_MUTEXES"
196 ],
197
198 [no], [GDK_PIXBUF_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"],
199
200 [minimum], [GDK_PIXBUF_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"]
201)
202
203# Build time sanity check...
204AM_SANITY_CHECK
205
206changequote(,)dnl
207if test "x$GCC" = "xyes"; then
208 case " $CFLAGS " in
209 *[\ \ ]-Wall[\ \ ]*) ;;
210 *) CFLAGS="$CFLAGS -Wall" ;;
211 esac
212
213 if test "x$enable_ansi" = "xyes"; then
214 case " $CFLAGS " in
215 *[\ \ ]-ansi[\ \ ]*) ;;
216 *) CFLAGS="$CFLAGS -ansi" ;;
217 esac
218
219 case " $CFLAGS " in
220 *[\ \ ]-pedantic[\ \ ]*) ;;
221 *) CFLAGS="$CFLAGS -pedantic" ;;
222 esac
223 fi
224fi
225changequote([,])dnl
226
227CPPFLAGS="$CPPFLAGS -DG_DISABLE_SINGLE_INCLUDES"
228
229# Ensure MSVC-compatible struct packing convention is used when
230# compiling for Win32 with gcc.
231# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
232# gcc2 uses "-fnative-struct".
233if test x"$os_win32" = xyes; then
234 if test x"$GCC" = xyes; then
235 msnative_struct=''
236 AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
237 if test -z "$ac_cv_prog_CC"; then
238 our_gcc="$CC"
239 else
240 our_gcc="$ac_cv_prog_CC"
241 fi
242 case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
243 2.)
244 if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
245 msnative_struct='-fnative-struct'
246 fi
247 ;;
248 *)
249 if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
250 msnative_struct='-mms-bitfields'
251 fi
252 ;;
253 esac
254 if test x"$msnative_struct" = x ; then
255 AC_MSG_RESULT([no way])
256 AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
257 else
258 CFLAGS="$CFLAGS $msnative_struct"
259 AC_MSG_RESULT([${msnative_struct}])
260 fi
261 fi
262fi
263
264## Initial sanity check, done here so that users get told they
265## have the wrong dependencies as early in the process as possible.
266## Later on we actually use the cflags/libs from separate pkg-config
267## calls. Oh, also the later pkg-config calls don't include
268## the version requirements since those make the module lists
269## annoying to construct
270PKG_CHECK_MODULES(BASE_DEPENDENCIES, [glib-2.0 >= glib_required_version])
271
272if test "$os_win32" != yes; then
273 # libtool option to control which symbols are exported
274 # right now, symbols starting with _ are not exported
275 LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
276else
277 # We currently use .def files on Windows (for gdk-pixbuf, gdk and gtk)
278 LIBTOOL_EXPORT_OPTIONS=
279fi
280AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
281
282dnl ******************************************************
283dnl * See whether to include shared library dependencies *
284dnl ******************************************************
285
286AC_ARG_ENABLE(explicit-deps,
287 [AC_HELP_STRING([--enable-explicit-deps=@<:@yes/no/auto@:>@],
288 [use explicit dependencies in .pc files [default=auto]])],,
289 [enable_explicit_deps=auto])
290
291AC_MSG_CHECKING([Whether to write dependencies into .pc files])
292case $enable_explicit_deps in
293 auto)
294 export SED
295 deplibs_check_method=`(./libtool --config; echo 'eval echo \"$deplibs_check_method\"') | sh`
296 if test "x$deplibs_check_method" '!=' xpass_all || test "x$enable_static" = xyes ; then
297 enable_explicit_deps=yes
298 else
299 enable_explicit_deps=no
300 fi
301 ;;
302 yes|no)
303 ;;
304 *) AC_MSG_ERROR([Value given to --enable-explicit-deps must be one of yes, no or auto])
305 ;;
306esac
307AC_MSG_RESULT($enable_explicit_deps)
308
309AM_CONDITIONAL(DISABLE_EXPLICIT_DEPS, test $enable_explicit_deps = no)
310
311# define a MAINT-like variable REBUILD which is set if Perl
312# and awk are found, so autogenerated sources can be rebuilt
313
314AC_PATH_PROGS(PERL, perl5 perl)
315
316REBUILD=\#
317if test "x$enable_rebuilds" = "xyes" && \
318 test -n "$PERL" && \
319 $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 ; then
320 REBUILD=
321fi
322AC_SUBST(REBUILD)
323
324# sigsetjmp is a macro on some platforms, so AC_CHECK_FUNCS is not reliable
325AC_MSG_CHECKING(for sigsetjmp)
326AC_TRY_LINK([#include <setjmp.h>], [
327sigjmp_buf env;
328sigsetjmp(env, 0);
329], gtk_ok=yes, gtk_ok=no)
330AC_MSG_RESULT($gtk_ok)
331if test "$gtk_ok" = "yes"; then
332 AC_DEFINE(HAVE_SIGSETJMP, 1,
333 [Define to 1 if sigsetjmp is available])
334fi
335
336# i18n stuff
337AM_GNU_GETTEXT_VERSION([0.17])
338AM_GNU_GETTEXT([external])
339
340GETTEXT_PACKAGE="$PACKAGE"
341AC_SUBST(GETTEXT_PACKAGE)
342AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
343 [The prefix for our gettext translation domains.])
344
345dnl The DU4 header files don't provide library prototypes unless
346dnl -std1 is given to the native cc.
347AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
348
349gtk_save_LIBS=$LIBS
350LIBS="$LIBS -lm"
351AC_TRY_RUN([#include <math.h>
352 int main (void) { return (log(1) != log(1.)); }],
353 AC_MSG_RESULT(none needed),
354 gtk_save_CFLAGS="$CFLAGS"
355 CFLAGS="$CFLAGS -std1"
356 AC_TRY_RUN([#include <math.h>
357 int main (void) { return (log(1) != log(1.)); }],
358 AC_MSG_RESULT(-std1),
359 AC_MSG_RESULT()
360 CFLAGS="$gtk_save_CFLAGS"
361 AC_MSG_WARN(
362 [No ANSI prototypes found in library. (-std1 didn't work.)]),
363 true
364 ),
365 AC_MSG_RESULT(none needed)
366)
367LIBS=$gtk_save_LIBS
368
369AC_MSG_CHECKING(for the BeOS)
370case $host in
371 *-*-beos*)
372 AC_MSG_RESULT(yes)
373 MATH_LIB=
374 ;;
375 *)
376 AC_MSG_RESULT(no)
377 ;;
378esac
379
380AC_SUBST(MATH_LIB)
381#
382# see bug 162979
383#
384AC_MSG_CHECKING(for HP-UX)
385case $host_os in
386 hpux9* | hpux10* | hpux11*)
387 AC_MSG_RESULT(yes)
388 CFLAGS="$CFLAGS -DHPPEX -DSHMLINK"
389 ;;
390 *)
391 AC_MSG_RESULT(no)
392 ;;
393esac
394
395dnl NeXTStep cc seems to need this
396AC_MSG_CHECKING([for extra flags for POSIX compliance])
397AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
398 AC_MSG_RESULT(none needed),
399 gtk_save_CFLAGS="$CFLAGS"
400 CFLAGS="$CFLAGS -posix"
401 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
402 AC_MSG_RESULT(-posix),
403 AC_MSG_RESULT()
404 CFLAGS="$gtk_save_CFLAGS"
405 AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
406
407#
408# Run AM_PATH_GLIB_2_0 to make sure that GLib is installed and working
409#
410
411GLIB_PACKAGES="gobject-2.0 gio-2.0 gmodule-no-export-2.0"
412
413AM_PATH_GLIB_2_0(glib_required_version, :,
414 AC_MSG_ERROR([
415*** GLIB glib_required_version or better is required. The latest version of
416*** GLIB is always available from ftp://ftp.gtk.org/pub/gtk/.]),
417 gobject gmodule-no-export gthread)
418
419dnl
420dnl Check for bind_textdomain_codeset, including -lintl if GLib brings it in.
421dnl
422gtk_save_LIBS=$LIBS
423LIBS="$LIBS $GLIB_LIBS"
424AC_CHECK_FUNCS(bind_textdomain_codeset)
425LIBS=$gtk_save_LIBS
426
427AC_CHECK_HEADERS(unistd.h,
428 AC_DEFINE(HAVE_UNISTD_H, 1,
429 [Define to 1 if unistd.h is available]))
430
431saved_cflags="$CFLAGS"
432saved_ldflags="$LDFLAGS"
433
434
435# Checks for header files.
436AC_HEADER_STDC
437
438# Checks for typedefs, structures, and compiler characteristics.
439AC_C_CONST
440
441##################################################
442# Checks for gdk-pixbuf
443##################################################
444
445dnl ********************************************************
446dnl * See whether we need to load our modules as .la files *
447dnl ********************************************************
448
449use_la_modules=false
450case $host in
451 *-aix*) use_la_modules=true
452esac
453
454if $use_la_modules ; then
455 AC_DEFINE(USE_LA_MODULES, 1,
456 [Whether to load modules via .la files rather than directly])
457fi
458
459
460AC_MSG_CHECKING(whether to build gmodulized gdk-pixbuf)
461
462AC_ARG_ENABLE(modules,
463 [AC_HELP_STRING([--disable-modules],
464 [disable dynamic module loading])])
465
466dynworks=false
467deps=
468if test x$enable_modules = xno; then
469 AC_MSG_RESULT(no)
470else
471 AC_MSG_RESULT(yes)
472 AC_MSG_CHECKING(whether dynamic modules work)
473 ## for loop is to strip newline
474 tmp=`$PKG_CONFIG --variable=gmodule_supported gmodule-no-export-2.0`
475 for I in $tmp; do
476 dynworks=$I
477 done
478
479 dnl Now we check to see if our libtool supports shared lib deps
480 dnl (in a rather ugly way even)
481 if $dynworks; then
482 pixbuf_libtool_config="${CONFIG_SHELL-/bin/sh} ./libtool --config"
483 pixbuf_deplibs_check=`$pixbuf_libtool_config | \
484 grep '^[[a-z_]]*check[[a-z_]]*_method=[['\''"]]' | \
485 sed 's/.*[['\''"]]\(.*\)[['\''"]]$/\1/'`
486 if test "x$pixbuf_deplibs_check" = "xnone" || \
487 test "x$pixbuf_deplibs_check" = "xunknown" || \
488 test "x$pixbuf_deplibs_check" = "x"; then
489 dynworks=false
490 fi
491 fi
492
493 if $dynworks; then
494 AC_DEFINE(USE_GMODULE, 1,
495 [Define to 1 if gmodule works and should be used])
496 AC_MSG_RESULT(yes)
497 else
498 AC_MSG_RESULT(no)
499 fi
500fi
501
502dnl We allow people to disable image loaders explicitely, but if they don't we error
503dnl out so that people don't accidentally build without them.
504
505AC_ARG_WITH(libpng,
506 [AC_HELP_STRING([--without-libpng],
507 [disable PNG loader for gdk-pixbuf])])
508AC_ARG_WITH(libjpeg,
509 [AC_HELP_STRING([--without-libjpeg],
510 [disable JPEG loader for gdk-pixbuf])])
511AC_ARG_WITH(libtiff,
512 [AC_HELP_STRING([--without-libtiff],
513 [disable TIFF loader for gdk-pixbuf])])
514AC_ARG_WITH(libjasper,
515 [AC_HELP_STRING([--with-libjasper],
516 [enable JPEG2000 loader for gdk-pixbuf])])
517AC_ARG_WITH(gdiplus,
518 [AC_HELP_STRING([--without-gdiplus],
519 [disable GDI+ loaders for gdk-pixbuf on Windows])])
520
521AM_CONDITIONAL(BUILD_GDIPLUS_LOADERS, [ test x$os_win32 = xyes && test x$with_gdiplus != xno ])
522
523dnl Test for libtiff
524if test x$os_win32 = xno || test x$with_gdiplus = xno; then
525 if test x$with_libtiff != xno && test -z "$LIBTIFF"; then
526 AC_CHECK_LIB(tiff, TIFFReadRGBAImageOriented,
527 [AC_CHECK_HEADER(tiffio.h,
528 TIFF='tiff'; LIBTIFF='-ltiff',
529 AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
530 [AC_CHECK_LIB(tiff, TIFFWriteScanline,
531 [AC_CHECK_HEADER(tiffio.h,
532 TIFF='tiff'; LIBTIFF='-ltiff -ljpeg -lz',
533 AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
534 [AC_CHECK_LIB(tiff34, TIFFFlushData,
535 [AC_CHECK_HEADER(tiffio.h,
536 TIFF='tiff'; LIBTIFF='-ltiff34 -ljpeg -lz',
537 AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
538 AC_MSG_WARN(*** TIFF loader will not be built (TIFF library not found) ***), -ljpeg -lz -lm)], -ljpeg -lz -lm)], -lm)
539 fi
540
541 if test x$with_libtiff != xno && test -z "$LIBTIFF"; then
542 AC_MSG_ERROR([
543*** Checks for TIFF loader failed. You can build without it by passing
544*** --without-libtiff to configure but some programs using GTK+ may
545*** not work properly])
546 fi
547fi
548
549dnl Test for libjpeg
550if test x$os_win32 = xno || test x$with_gdiplus = xno; then
551 if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
552 AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
553 jpeg_ok=yes,
554 jpeg_ok=no
555 AC_MSG_WARN(*** JPEG loader will not be built (JPEG library not found) ***))
556 if test "$jpeg_ok" = yes; then
557 AC_MSG_CHECKING([for jpeglib.h])
558 AC_TRY_CPP(
559[#include <stdio.h>
560#undef PACKAGE
561#undef VERSION
562#undef HAVE_STDLIB_H
563#include <jpeglib.h>],
564 jpeg_ok=yes,
565 jpeg_ok=no)
566 AC_MSG_RESULT($jpeg_ok)
567 if test "$jpeg_ok" = yes; then
568 LIBJPEG='-ljpeg'
569 AC_CHECK_LIB(jpeg, jpeg_simple_progression,
570 AC_DEFINE(HAVE_PROGRESSIVE_JPEG, 1,
571 [Define to 1 is libjpeg supports progressive JPEG]),
572 AC_MSG_WARN(JPEG library does not support progressive saving.))
573 else
574 AC_MSG_WARN(*** JPEG loader will not be built (JPEG header file not found) ***)
575 fi
576 fi
577 fi
578
579 if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
580 AC_MSG_ERROR([
581*** Checks for JPEG loader failed. You can build without it by passing
582*** --without-libjpeg to configure but some programs using GTK+ may
583*** not work properly])
584 fi
585fi
586
587dnl Test for libpng
588 if test x$with_libpng != xno && test -z "$LIBPNG"; then
589 for l in libpng16 libpng15 libpng14 libpng12 libpng13 libpng10; do
590 AC_MSG_CHECKING(for $l)
591 if $PKG_CONFIG --exists $l ; then
592 AC_MSG_RESULT(yes)
593 PNG='png'
594 PNG_DEP_CFLAGS_PACKAGES=$l
595 LIBPNG=`$PKG_CONFIG --libs $l`
596 break
597 else
598 AC_MSG_RESULT(no)
599 fi
600 done
601 if test x$PNG != xpng; then
602 AC_MSG_RESULT(no)
603 AC_CHECK_LIB(png, png_read_info,
604 [AC_CHECK_HEADER(png.h,
605 png_ok=yes,
606 png_ok=no)],
607 AC_MSG_WARN(*** PNG loader will not be built (PNG library not found) ***), -lz -lm)
608 if test "$png_ok" = yes; then
609 AC_MSG_CHECKING([for png_structp in png.h])
610 AC_TRY_COMPILE([#include <png.h>],
611 [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
612 png_ok=yes,
613 png_ok=no)
614 AC_MSG_RESULT($png_ok)
615 if test "$png_ok" = yes; then
616 PNG='png'; LIBPNG='-lpng -lz'
617 else
618 AC_MSG_WARN(*** PNG loader will not be built (PNG library is too old) ***)
619 fi
620 else
621 AC_MSG_WARN(*** PNG loader will not be built (PNG header file not found) ***)
622 fi
623 fi
624 fi
625
626 if test x$with_libpng != xno && test -z "$LIBPNG"; then
627 AC_MSG_ERROR([
628*** Checks for PNG loader failed. You can build without it by passing
629*** --without-libpng to configure but many programs using GTK+ will
630*** not work properly. The PNG loader is also needed if you are compiling
631*** from Git.])
632 fi
633
634dnl Test for libjasper
635 if test x$with_libjasper = xyes && test -z "$LIBJASPER"; then
636 AC_CHECK_LIB(jasper, jas_init, LIBJASPER=-ljasper, [], -ljpeg -lm)
637 fi
638
639 if test x$with_libjasper = xyes && test -z "$LIBJASPER"; then
640 AC_MSG_ERROR([
641*** Checks for JPEG2000 loader failed. You can build without it by passing
642*** --without-libjasper to configure])
643 fi
644
645AC_SUBST(LIBTIFF)
646AC_SUBST(LIBJPEG)
647AC_SUBST(LIBPNG)
648AC_SUBST(LIBJASPER)
649
650AM_CONDITIONAL(BUILD_DYNAMIC_MODULES, $dynworks)
651
652#
653# Allow building some or all gdk-pixbuf loaders included
654#
655AC_MSG_CHECKING(pixbuf loaders to build)
656
657dnl due to an autoconf bug, commas in the first arg to
658dnl AC_HELP_STRING cause problems.
659dnl AC_HELP_STRING([--with-included-loaders=LOADER1 LOADER2 ...],
660dnl [build the specified loaders into gdk-pixbuf])
661AC_ARG_WITH(included_loaders,
662[ --with-included-loaders=LOADER1,LOADER2,...
663 build the specified loaders into gdk-pixbuf])
664
665if $dynworks; then
666 :
667else
668 ## if the option was specified, leave it; otherwise disable included loaders
669 if test x$with_included_loaders = xno; then
670 with_included_loaders=yes
671 fi
672fi
673
674# Use the traditional png loader instead of the GDI+ one on Windows,
675# because some important apps like GIMP need to read and write
676# arbitrary tEXt chunks which doesn't seem to be possible through GDI+
677
678all_loaders="ani,icns,pcx,ras,tga,png,pnm,wbmp,xbm,xpm,qtif"
679if test x$with_libjasper = xyes; then
680 all_loaders="$all_loaders,jasper"
681fi
682if test x$os_win32 = xyes && test x$with_gdiplus != xno; then
683 # Skip PNG, see comment above
684 gdip_formats="bmp emf gif ico jpeg tiff wmf"
685 for f in $gdip_formats; do
686 all_loaders="$all_loaders,gdip-$f"
687 done
688else
689 all_loaders="$all_loaders,bmp,gif,ico,jpeg,tiff"
690fi
691included_loaders=""
692# If no loaders specified, include all
693if test "x$with_included_loaders" = xyes ; then
694 included_loaders="$all_loaders"
695else
696 included_loaders="$with_included_loaders"
697fi
698
699AC_MSG_RESULT($included_loaders)
700
701INCLUDED_LOADER_OBJ=
702INCLUDED_LOADER_DEFINE=
703
704IFS="${IFS= }"; gtk_save_ifs="$IFS"; IFS=","
705for loader in $included_loaders; do
706 if echo "$all_loaders" | egrep "(^|,)$loader(\$|,)" > /dev/null; then
707 :
708 else
709 AC_MSG_ERROR([the specified loader $loader does not exist])
710 fi
711
712 loader_underscores=`echo $loader | sed -e 's/-/_/g'`
713 INCLUDED_LOADER_OBJ="$INCLUDED_LOADER_OBJ libstatic-pixbufloader-$loader.la"
714
715 # Don't bother defining separate -DINCLUDE_gdip_foo for each gdip-foo loader
716 case $loader in
717 gdip-*) ;;
718 *) INCLUDED_LOADER_DEFINE="$INCLUDED_LOADER_DEFINE -DINCLUDE_$loader_underscores";;
719 esac
720 eval INCLUDE_$loader_underscores=yes
721done
722
723# Just define one -DINCLUDE_gdiplus for all the gdip-foo loaders
724# (except gdip-png, which isn't built at all)
725if test x"$INCLUDE_gdip_ico" = xyes; then
726 INCLUDED_LOADER_DEFINE="$INCLUDED_LOADER_DEFINE -DINCLUDE_gdiplus"
727fi
728
729IFS="$gtk_save_ifs"
730AC_SUBST(INCLUDED_LOADER_OBJ)
731AC_SUBST(INCLUDED_LOADER_DEFINE)
732
733AM_CONDITIONAL(INCLUDE_PNG, [test x"$INCLUDE_png" = xyes])
734AM_CONDITIONAL(INCLUDE_BMP, [test x"$INCLUDE_bmp" = xyes])
735AM_CONDITIONAL(INCLUDE_WBMP, [test x"$INCLUDE_wbmp" = xyes])
736AM_CONDITIONAL(INCLUDE_GIF, [test x"$INCLUDE_gif" = xyes])
737AM_CONDITIONAL(INCLUDE_ICO, [test x"$INCLUDE_ico" = xyes])
738AM_CONDITIONAL(INCLUDE_ANI, [test x"$INCLUDE_ani" = xyes])
739AM_CONDITIONAL(INCLUDE_JPEG, [test x"$INCLUDE_jpeg" = xyes])
740AM_CONDITIONAL(INCLUDE_PNM, [test x"$INCLUDE_pnm" = xyes])
741AM_CONDITIONAL(INCLUDE_RAS, [test x"$INCLUDE_ras" = xyes])
742AM_CONDITIONAL(INCLUDE_TIFF, [test x"$INCLUDE_tiff" = xyes])
743AM_CONDITIONAL(INCLUDE_XPM, [test x"$INCLUDE_xpm" = xyes])
744AM_CONDITIONAL(INCLUDE_XBM, [test x"$INCLUDE_xbm" = xyes])
745AM_CONDITIONAL(INCLUDE_TGA, [test x"$INCLUDE_tga" = xyes])
746AM_CONDITIONAL(INCLUDE_PCX, [test x"$INCLUDE_pcx" = xyes])
747AM_CONDITIONAL(INCLUDE_ICNS, [test x"$INCLUDE_icns" = xyes])
748AM_CONDITIONAL(INCLUDE_JASPER, [test x"$INCLUDE_jasper" = xyes])
749AM_CONDITIONAL(INCLUDE_QTIF, [test x"$INCLUDE_qtif" = xyes])
750# As all GDI+ loaders are either built-in or not, arbitrarily just
751# check one of the variables here
752AM_CONDITIONAL(INCLUDE_GDIPLUS, [test x"$INCLUDE_gdip_ico" = xyes])
753
754if test x$enable_gio_sniffing = xauto && test x$gio_can_sniff = x; then
755 AC_MSG_CHECKING([if gio can sniff png])
756 gtk_save_LIBS="$LIBS"
757 gtk_save_CFLAGS="$CFLAGS"
758 LIBS="`$PKG_CONFIG --libs gio-2.0`"
759 CFLAGS="`$PKG_CONFIG --cflags gio-2.0`"
760 AC_RUN_IFELSE([AC_LANG_SOURCE([[
761 #include <gio/gio.h>
762 static const gsize data_size = 159;
763 static const guint8 data[] =
764 {
765 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
766 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
767 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde, 0x00, 0x00, 0x00,
768 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
769 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00,
770 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74,
771 0x49, 0x4d, 0x45, 0x07, 0xd8, 0x07, 0x0f, 0x10, 0x08, 0x15, 0x61, 0xd8,
772 0x35, 0x37, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f,
773 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
774 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57,
775 0x81, 0x0e, 0x17, 0x00, 0x00, 0x00, 0x0c, 0x49, 0x44, 0x41, 0x54, 0x08,
776 0xd7, 0x63, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x05, 0xfe, 0x02, 0xfe, 0xdc,
777 0xcc, 0x59, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
778 0x42, 0x60, 0x82
779 };
780 int
781 main (int argc, char **argv)
782 {
783 char *content_type;
784 char *image_png;
785 g_type_init ();
786 content_type = g_content_type_guess (NULL, data, data_size, NULL);
787 image_png = g_content_type_from_mime_type ("image/png");
788 return !!g_strcmp0 (content_type, image_png);
789 }]])],
790 [gio_can_sniff=yes
791 AC_DEFINE(GDK_PIXBUF_USE_GIO_MIME, 1, [Define if gio can sniff image data])],
792 [gio_can_sniff=no])
793 AC_MSG_RESULT($gio_can_sniff)
794 LIBS="$gtk_save_LIBS"
795 CFLAGS="$gtk_save_CFLAGS"
796else
797 if test x$enable_gio_sniffing = xyes; then
798 gio_can_sniff=yes
799 AC_DEFINE(GDK_PIXBUF_USE_GIO_MIME, 1, [Define if gio can sniff image data])
800 else
801 gio_can_sniff=no
802 fi
803fi
804
805AM_CONDITIONAL(HAVE_TIFF, test "x$LIBTIFF" != x)
806AM_CONDITIONAL(HAVE_PNG, test "x$LIBPNG" != x)
807AM_CONDITIONAL(HAVE_JPEG, test "x$LIBJPEG" != x)
808AM_CONDITIONAL(HAVE_JASPER, test "x$LIBJASPER" != x)
809
810if $dynworks ; then
811 STATIC_LIB_DEPS=
812 if echo "$included_loaders" | egrep '(^|,)tiff($|,)' > /dev/null; then
813 STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBTIFF"
814 fi
815 if echo "$included_loaders" | egrep '(^|,)jpeg($|,)' > /dev/null; then
816 STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBJPEG"
817 fi
818 if echo "$included_loaders" | egrep '(^|,)png($|,)' > /dev/null; then
819 if test -z $PNG_DEP_CFLAGS_PACKAGES; then
820 STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBPNG"
821 fi
822 fi
823 if echo "$included_loaders" | egrep '(^|,)jasper($|,)' > /dev/null; then
824 STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBJASPER"
825 fi
826else
827 STATIC_LIB_DEPS="$LIBTIFF $LIBJPEG $LIBPNG $LIBJASPER"
828fi
829
830# Checks to see whether we should include mediaLib
831# support.
832#
833AC_CHECK_HEADER(sys/systeminfo.h,
834 AC_DEFINE(HAVE_SYS_SYSTEMINFO_H, 1,
835 [Define to 1 if sys/systeminfo.h is available]))
836AC_CHECK_HEADER(sys/sysinfo.h,
837 AC_DEFINE(HAVE_SYS_SYSINFO_H, 1,
838 [Define to 1 if sys/sysinfo.h is available]))
839
840AC_MSG_CHECKING(for mediaLib 2.3)
841use_mlib25=no
842# Check for a mediaLib 2.3 function since that is what the GTK+ mediaLib
843# patch requires.
844AC_CHECK_LIB(mlib, mlib_ImageSetStruct, use_mlib=yes, use_mlib=no)
845if test $use_mlib = yes; then
846 AC_DEFINE(USE_MEDIALIB, 1,
847 [Define to 1 if medialib is available and should be used])
848 MEDIA_LIB=-lmlib
849
850 AC_MSG_CHECKING(for mediaLib 2.5)
851 # Check for a mediaLib 2.5 function since that is what is needed for
852 # gdk_rgb_convert integration.
853 AC_CHECK_LIB(mlib, mlib_VideoColorRGBint_to_BGRAint, use_mlib25=yes, use_mlib25=no)
854 if test $use_mlib25 = yes; then
855 AC_DEFINE(USE_MEDIALIB25, 1,
856 [Define to 1 if medialib 2.5 is available])
857 fi
858fi
859AM_CONDITIONAL(USE_MEDIALIB, test $use_mlib = yes)
860AM_CONDITIONAL(USE_MEDIALIB25, test $use_mlib25 = yes)
861
862# Checks to see if we should compile in MMX support (there will be
863# a runtime test when the code is actually run to see if it should
864# be used - this just checks if we can compile it.)
865#
866# This code is partially taken from Mesa
867#
868AC_MSG_CHECKING(for x86 platform)
869case $host_cpu in
870 i386|i486|i586|i686|i786|k6|k7)
871 use_x86_asm=yes
872 ;;
873 *)
874 use_x86_asm=no
875esac
876AC_MSG_RESULT($use_x86_asm)
877
878use_mmx_asm=no
879if test $use_x86_asm = yes; then
880 save_ac_ext=$ac_ext
881 ac_ext=S
882
883 AC_MSG_CHECKING(compiler support for MMX)
884 cp $srcdir/gdk-pixbuf/pixops/scale_line_22_33_mmx.S conftest.S
885 if AC_TRY_EVAL(ac_compile); then
886 use_mmx_asm=yes
887 fi
888
889 rm -rf conftest*
890
891 ac_ext=$save_ac_ext
892 if test $use_mmx_asm = yes; then
893 AC_DEFINE(USE_MMX, 1,
894 [Define to 1 if XXM is available and should be used])
895 AC_MSG_RESULT(yes)
896 else
897 AC_MSG_RESULT(no)
898 fi
899fi
900
901AM_CONDITIONAL(USE_MMX, test x$use_mmx_asm = xyes)
902
903REBUILD_PNGS=
904if test -z "$LIBPNG" && test x"$os_win32" = xno -o x$with_gdiplus = xno; then
905 REBUILD_PNGS=#
906fi
907
908dnl Look for a host system's gdk-pixbuf-csource if we are cross-compiling
909
910AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
911
912if test $cross_compiling = yes; then
913 AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, no)
914 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE, gtk-update-icon-cache, no)
915 if test x$GTK_UPDATE_ICON_CACHE = xno; then
916 REBUILD_PNGS=#
917 fi
918fi
919
920GDK_PIXBUF_PACKAGES="gmodule-no-export-2.0 gobject-2.0 gio-2.0"
921GDK_PIXBUF_EXTRA_LIBS="$STATIC_LIB_DEPS $MATH_LIB $MEDIA_LIB"
922GDK_PIXBUF_EXTRA_CFLAGS=
923GDK_PIXBUF_DEP_LIBS="`$PKG_CONFIG --libs $GDK_PIXBUF_PACKAGES $PNG_DEP_CFLAGS_PACKAGES` $GDK_PIXBUF_EXTRA_LIBS"
924GDK_PIXBUF_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PIXBUF_PACKAGES $PNG_DEP_CFLAGS_PACKAGES` $GDK_PIXBUF_EXTRA_CFLAGS"
925
926AC_SUBST(PNG_DEP_CFLAGS_PACKAGES)
927AC_SUBST(GDK_PIXBUF_PACKAGES)
928AC_SUBST(GDK_PIXBUF_EXTRA_LIBS)
929AC_SUBST(GDK_PIXBUF_EXTRA_CFLAGS)
930AC_SUBST(GDK_PIXBUF_DEP_LIBS)
931AC_SUBST(GDK_PIXBUF_DEP_CFLAGS)
932
933###############
934# Check for X11
935###############
936
937GDK_PIXBUF_XLIB_PACKAGES=
938GDK_PIXBUF_XLIB_EXTRA_CFLAGS=
939GDK_PIXBUF_XLIB_EXTRA_LIBS=
940
941AC_ARG_WITH(x11,
942 [AC_HELP_STRING([--with-x11],
943 [build X11 support])])
944
945if test x$with_x11 = xyes; then
946 AM_CONDITIONAL(USE_X11, true)
947 PKG_CHECK_MODULES(GDK_PIXBUF_XLIB_DEP, x11 gobject-2.0)
948else
949 AM_CONDITIONAL(USE_X11, false)
950fi
951
952################################################################
953# Strip -export-dynamic from the link lines of various libraries
954################################################################
955
956#
957# pkg-config --libs gmodule includes the "export_dynamic" flag,
958# but this flag is only meaningful for executables. For libraries
959# the effect is undefined; what it causes on Linux is that the
960# export list from -export-symbols-regex is ignored and everything
961# is exported
962#
963# We are using gmodule-no-export now, but I'm leaving the stripping
964# code in place for now, since pango and atk still require gmodule.
965export SED
966export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
967if test -n "$export_dynamic"; then
968 GDK_PIXBUF_DEP_LIBS=`echo $GDK_PIXBUF_DEP_LIBS | sed -e "s/$export_dynamic//"`
969fi
970
971##################################################
972# GObject introspection
973##################################################
974
975GOBJECT_INTROSPECTION_CHECK([0.9.3])
976
977##################################################
978# Checks for gtk-doc and docbook-tools
979##################################################
980
981GTK_DOC_CHECK([1.11], [--flavour=no-tmpl])
982
983AC_CHECK_PROG(DB2HTML, db2html, true, false)
984AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)
985
986AC_ARG_ENABLE(man,
987 [AC_HELP_STRING([--enable-man],
988 [regenerate man pages from Docbook [default=no]])],enable_man=yes,
989 enable_man=no)
990
991if test "${enable_man}" != no; then
992 dnl
993 dnl Check for xsltproc
994 dnl
995 AC_PATH_PROG([XSLTPROC], [xsltproc])
996 if test -z "$XSLTPROC"; then
997 enable_man=no
998 fi
999fi
1000
1001AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
1002
1003
1004##################################################
1005# Check for -Bsymbolic-functions linker flag used
1006# to avoid intra-library PLT jumps, if available.
1007##################################################
1008
1009AC_ARG_ENABLE(Bsymbolic,
1010 [AC_HELP_STRING([--disable-Bsymbolic],
1011 [avoid linking with -Bsymbolic])],,
1012 [SAVED_LDFLAGS="${LDFLAGS}"
1013 AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
1014 LDFLAGS=-Wl,-Bsymbolic-functions
1015 AC_TRY_LINK([], [int main (void) { return 0; }],
1016 AC_MSG_RESULT(yes)
1017 enable_Bsymbolic=yes,
1018 AC_MSG_RESULT(no)
1019 enable_Bsymbolic=no)
1020 LDFLAGS="${SAVED_LDFLAGS}"])
1021
1022if test "x${enable_Bsymbolic}" = "xyes"; then
1023 GDK_PIXBUF_LINK_FLAGS=-Wl,-Bsymbolic-functions
1024fi
1025
1026AC_SUBST(GDK_PIXBUF_LINK_FLAGS)
1027
1028
1029##################################################
1030# Output commands
1031##################################################
1032
1033AC_CONFIG_FILES([
1034Makefile
1035gdk-pixbuf-2.0.pc
1036gdk-pixbuf-2.0-uninstalled.pc
1037gdk-pixbuf/Makefile
1038gdk-pixbuf/gdk_pixbuf.rc
1039gdk-pixbuf/gdk-pixbuf-features.h
1040gdk-pixbuf/pixops/Makefile
1041build/Makefile
1042build/win32/Makefile
1043build/win32/vs9/Makefile
1044build/win32/vs10/Makefile
1045docs/Makefile
1046docs/reference/Makefile
1047docs/reference/gdk-pixbuf/Makefile
1048docs/reference/gdk-pixbuf/version.xml
1049po/Makefile.in
1050tests/Makefile
1051contrib/Makefile
1052contrib/gdk-pixbuf-xlib/Makefile
1053contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlib-2.0.pc
1054config.h.win32
1055])
1056
1057AC_OUTPUT
01058
=== added directory '.pc/gicon-serialization-support.patch/gdk-pixbuf'
=== added file '.pc/gicon-serialization-support.patch/gdk-pixbuf/gdk-pixbuf.c'
--- .pc/gicon-serialization-support.patch/gdk-pixbuf/gdk-pixbuf.c 1970-01-01 00:00:00 +0000
+++ .pc/gicon-serialization-support.patch/gdk-pixbuf/gdk-pixbuf.c 2013-05-17 06:11:25 +0000
@@ -0,0 +1,892 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2/* GdkPixbuf library - Basic memory management
3 *
4 * Copyright (C) 1999 The Free Software Foundation
5 *
6 * Authors: Mark Crichton <crichton@gimp.org>
7 * Miguel de Icaza <miguel@gnu.org>
8 * Federico Mena-Quintero <federico@gimp.org>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
24 */
25
26#include "config.h"
27
28#include <math.h>
29#include <stdlib.h>
30#include <string.h>
31
32#define GDK_PIXBUF_C_COMPILATION
33#include "gdk-pixbuf-private.h"
34#include "gdk-pixbuf-features.h"
35#include "gdk-pixbuf-enum-types.h"
36
37/* Include the marshallers */
38#include <glib-object.h>
39#include <gio/gio.h>
40#include "gdk-pixbuf-marshal.c"
41
42/**
43 * SECTION:creating
44 * @Short_description: Creating a pixbuf from image data that is already in memory.
45 * @Title: Image Data in Memory
46 * @See_also: gdk_pixbuf_finalize().
47 *
48 * The most basic way to create a pixbuf is to wrap an existing pixel
49 * buffer with a #GdkPixbuf structure. You can use the
50 * gdk_pixbuf_new_from_data() function to do this You need to specify
51 * the destroy notification function that will be called when the
52 * data buffer needs to be freed; this will happen when a #GdkPixbuf
53 * is finalized by the reference counting functions If you have a
54 * chunk of static data compiled into your application, you can pass
55 * in %NULL as the destroy notification function so that the data
56 * will not be freed.
57 *
58 *
59 * The gdk_pixbuf_new() function can be used as a convenience to
60 * create a pixbuf with an empty buffer. This is equivalent to
61 * allocating a data buffer using <function>malloc()</function> and
62 * then wrapping it with gdk_pixbuf_new_from_data(). The gdk_pixbuf_new()
63 * function will compute an optimal rowstride so that rendering can be
64 * performed with an efficient algorithm.
65 *
66 *
67 * As a special case, you can use the gdk_pixbuf_new_from_xpm_data()
68 * function to create a pixbuf from inline XPM image data.
69 *
70 *
71 * You can also copy an existing pixbuf with the gdk_pixbuf_copy()
72 * function. This is not the same as just doing a g_object_ref()
73 * on the old pixbuf; the copy function will actually duplicate the
74 * pixel data in memory and create a new #GdkPixbuf structure for it.
75 */
76
77/**
78 * SECTION:refcounting
79 * @Short_description: Functions for reference counting and memory management on pixbufs.
80 * @Title: Reference Counting and Memory Mangement
81 * @See_also: #GdkPixbuf, gdk_pixbuf_new_from_data().
82 *
83 * #GdkPixbuf structures are reference counted. This means that an
84 * application can share a single pixbuf among many parts of the
85 * code. When a piece of the program needs to keep a pointer to a
86 * pixbuf, it should add a reference to it by calling g_object_ref().
87 * When it no longer needs the pixbuf, it should subtract a reference
88 * by calling g_object_unref(). The pixbuf will be destroyed when
89 * its reference count drops to zero. Newly-created #GdkPixbuf
90 * structures start with a reference count of one.
91 *
92 *
93 * <note>
94 * As #GdkPixbuf is derived from #GObject now, gdk_pixbuf_ref() and
95 * gdk_pixbuf_unref() are deprecated in favour of g_object_ref()
96 * and g_object_unref () resp.
97 * </note>
98 *
99 * <emphasis>Finalizing</emphasis> a pixbuf means to free its pixel
100 * data and to free the #GdkPixbuf structure itself. Most of the
101 * library functions that create #GdkPixbuf structures create the
102 * pixel data by themselves and define the way it should be freed;
103 * you do not need to worry about those. The only function that lets
104 * you specify how to free the pixel data is
105 * gdk_pixbuf_new_from_data(). Since you pass it a pre-allocated
106 * pixel buffer, you must also specify a way to free that data. This
107 * is done with a function of type #GdkPixbufDestroyNotify. When a
108 * pixbuf created with gdk_pixbuf_new_from_data() is finalized, your
109 * destroy notification function will be called, and it is its
110 * responsibility to free the pixel array.
111 */
112
113static void gdk_pixbuf_finalize (GObject *object);
114static void gdk_pixbuf_set_property (GObject *object,
115 guint prop_id,
116 const GValue *value,
117 GParamSpec *pspec);
118static void gdk_pixbuf_get_property (GObject *object,
119 guint prop_id,
120 GValue *value,
121 GParamSpec *pspec);
122
123
0124
125enum
126{
127 PROP_0,
128 PROP_COLORSPACE,
129 PROP_N_CHANNELS,
130 PROP_HAS_ALPHA,
131 PROP_BITS_PER_SAMPLE,
132 PROP_WIDTH,
133 PROP_HEIGHT,
134 PROP_ROWSTRIDE,
135 PROP_PIXELS
136};
137
138static void gdk_pixbuf_icon_iface_init (GIconIface *iface);
139
140G_DEFINE_TYPE_WITH_CODE (GdkPixbuf, gdk_pixbuf, G_TYPE_OBJECT,
141 G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
142 gdk_pixbuf_icon_iface_init))
143
144static void
145gdk_pixbuf_init (GdkPixbuf *pixbuf)
146{
147}
148
149static void
150gdk_pixbuf_class_init (GdkPixbufClass *klass)
151{
152 GObjectClass *object_class = G_OBJECT_CLASS (klass);
153
154 object_class->finalize = gdk_pixbuf_finalize;
155 object_class->set_property = gdk_pixbuf_set_property;
156 object_class->get_property = gdk_pixbuf_get_property;
157
158#define PIXBUF_PARAM_FLAGS G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY|\
159 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
160 /**
161 * GdkPixbuf:n-channels:
162 *
163 * The number of samples per pixel.
164 * Currently, only 3 or 4 samples per pixel are supported.
165 */
166 g_object_class_install_property (object_class,
167 PROP_N_CHANNELS,
168 g_param_spec_int ("n-channels",
169 P_("Number of Channels"),
170 P_("The number of samples per pixel"),
171 0,
172 G_MAXINT,
173 3,
174 PIXBUF_PARAM_FLAGS));
175
176 g_object_class_install_property (object_class,
177 PROP_COLORSPACE,
178 g_param_spec_enum ("colorspace",
179 P_("Colorspace"),
180 P_("The colorspace in which the samples are interpreted"),
181 GDK_TYPE_COLORSPACE,
182 GDK_COLORSPACE_RGB,
183 PIXBUF_PARAM_FLAGS));
184
185 g_object_class_install_property (object_class,
186 PROP_HAS_ALPHA,
187 g_param_spec_boolean ("has-alpha",
188 P_("Has Alpha"),
189 P_("Whether the pixbuf has an alpha channel"),
190 FALSE,
191 PIXBUF_PARAM_FLAGS));
192
193 /**
194 * GdkPixbuf:bits-per-sample:
195 *
196 * The number of bits per sample.
197 * Currently only 8 bit per sample are supported.
198 */
199 g_object_class_install_property (object_class,
200 PROP_BITS_PER_SAMPLE,
201 g_param_spec_int ("bits-per-sample",
202 P_("Bits per Sample"),
203 P_("The number of bits per sample"),
204 1,
205 16,
206 8,
207 PIXBUF_PARAM_FLAGS));
208
209 g_object_class_install_property (object_class,
210 PROP_WIDTH,
211 g_param_spec_int ("width",
212 P_("Width"),
213 P_("The number of columns of the pixbuf"),
214 1,
215 G_MAXINT,
216 1,
217 PIXBUF_PARAM_FLAGS));
218
219 g_object_class_install_property (object_class,
220 PROP_HEIGHT,
221 g_param_spec_int ("height",
222 P_("Height"),
223 P_("The number of rows of the pixbuf"),
224 1,
225 G_MAXINT,
226 1,
227 PIXBUF_PARAM_FLAGS));
228
229 /**
230 * GdkPixbuf:rowstride:
231 *
232 * The number of bytes between the start of a row and
233 * the start of the next row. This number must (obviously)
234 * be at least as large as the width of the pixbuf.
235 */
236 g_object_class_install_property (object_class,
237 PROP_ROWSTRIDE,
238 g_param_spec_int ("rowstride",
239 P_("Rowstride"),
240 P_("The number of bytes between the start of a row and the start of the next row"),
241 1,
242 G_MAXINT,
243 1,
244 PIXBUF_PARAM_FLAGS));
245
246 g_object_class_install_property (object_class,
247 PROP_PIXELS,
248 g_param_spec_pointer ("pixels",
249 P_("Pixels"),
250 P_("A pointer to the pixel data of the pixbuf"),
251 PIXBUF_PARAM_FLAGS));
252}
253
254static void
255gdk_pixbuf_finalize (GObject *object)
256{
257 GdkPixbuf *pixbuf = GDK_PIXBUF (object);
258
259 if (pixbuf->destroy_fn)
260 (* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
261
262 G_OBJECT_CLASS (gdk_pixbuf_parent_class)->finalize (object);
263}
264
265
266/**
267 * gdk_pixbuf_ref: (skip)
268 * @pixbuf: A pixbuf.
269 *
270 * Adds a reference to a pixbuf.
271 *
272 * Return value: The same as the @pixbuf argument.
273 *
274 * Deprecated: 2.0: Use g_object_ref().
275 **/
276GdkPixbuf *
277gdk_pixbuf_ref (GdkPixbuf *pixbuf)
278{
279 return (GdkPixbuf *) g_object_ref (pixbuf);
280}
281
282/**
283 * gdk_pixbuf_unref: (skip)
284 * @pixbuf: A pixbuf.
285 *
286 * Removes a reference from a pixbuf.
287 *
288 * Deprecated: 2.0: Use g_object_unref().
289 **/
290void
291gdk_pixbuf_unref (GdkPixbuf *pixbuf)
292{
293 g_object_unref (pixbuf);
294}
295
296static void
297gdk_pixbuf_icon_iface_init (GIconIface *iface)
298{
299 iface->hash = (guint (*) (GIcon *)) g_direct_hash;
300 iface->equal = (gboolean (*) (GIcon *, GIcon *)) g_direct_equal;
301}
302
303/* Used as the destroy notification function for gdk_pixbuf_new() */
304static void
305free_buffer (guchar *pixels, gpointer data)
306{
307 g_free (pixels);
308}
309
310/**
311 * gdk_pixbuf_new:
312 * @colorspace: Color space for image
313 * @has_alpha: Whether the image should have transparency information
314 * @bits_per_sample: Number of bits per color sample
315 * @width: Width of image in pixels, must be > 0
316 * @height: Height of image in pixels, must be > 0
317 *
318 * Creates a new #GdkPixbuf structure and allocates a buffer for it. The
319 * buffer has an optimal rowstride. Note that the buffer is not cleared;
320 * you will have to fill it completely yourself.
321 *
322 * Return value: A newly-created #GdkPixbuf with a reference count of 1, or
323 * %NULL if not enough memory could be allocated for the image buffer.
324 **/
325GdkPixbuf *
326gdk_pixbuf_new (GdkColorspace colorspace,
327 gboolean has_alpha,
328 int bits_per_sample,
329 int width,
330 int height)
331{
332 guchar *buf;
333 int channels;
334 int rowstride;
335 gsize bytes;
336
337 g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
338 g_return_val_if_fail (bits_per_sample == 8, NULL);
339 g_return_val_if_fail (width > 0, NULL);
340 g_return_val_if_fail (height > 0, NULL);
341
342 channels = has_alpha ? 4 : 3;
343 rowstride = width * channels;
344 if (rowstride / channels != width || rowstride + 3 < 0) /* overflow */
345 return NULL;
346
347 /* Always align rows to 32-bit boundaries */
348 rowstride = (rowstride + 3) & ~3;
349
350 bytes = height * rowstride;
351 if (bytes / rowstride != height) /* overflow */
352 return NULL;
353
354 buf = g_try_malloc (bytes);
355 if (!buf)
356 return NULL;
357
358 return gdk_pixbuf_new_from_data (buf, colorspace, has_alpha, bits_per_sample,
359 width, height, rowstride,
360 free_buffer, NULL);
361}
362
363/**
364 * gdk_pixbuf_copy:
365 * @pixbuf: A pixbuf.
366 *
367 * Creates a new #GdkPixbuf with a copy of the information in the specified
368 * @pixbuf.
369 *
370 * Return value: (transfer full): A newly-created pixbuf with a reference count of 1, or %NULL if
371 * not enough memory could be allocated.
372 **/
373GdkPixbuf *
374gdk_pixbuf_copy (const GdkPixbuf *pixbuf)
375{
376 guchar *buf;
377 int size;
378
379 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
380
381 /* Calculate a semi-exact size. Here we copy with full rowstrides;
382 * maybe we should copy each row individually with the minimum
383 * rowstride?
384 */
385
386 size = gdk_pixbuf_get_byte_length (pixbuf);
387
388 buf = g_try_malloc (size * sizeof (guchar));
389 if (!buf)
390 return NULL;
391
392 memcpy (buf, pixbuf->pixels, size);
393
394 return gdk_pixbuf_new_from_data (buf,
395 pixbuf->colorspace, pixbuf->has_alpha,
396 pixbuf->bits_per_sample,
397 pixbuf->width, pixbuf->height,
398 pixbuf->rowstride,
399 free_buffer,
400 NULL);
401}
402
403/**
404 * gdk_pixbuf_new_subpixbuf:
405 * @src_pixbuf: a #GdkPixbuf
406 * @src_x: X coord in @src_pixbuf
407 * @src_y: Y coord in @src_pixbuf
408 * @width: width of region in @src_pixbuf
409 * @height: height of region in @src_pixbuf
410 *
411 * Creates a new pixbuf which represents a sub-region of
412 * @src_pixbuf. The new pixbuf shares its pixels with the
413 * original pixbuf, so writing to one affects both.
414 * The new pixbuf holds a reference to @src_pixbuf, so
415 * @src_pixbuf will not be finalized until the new pixbuf
416 * is finalized.
417 *
418 * Return value: (transfer full): a new pixbuf
419 **/
420GdkPixbuf*
421gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
422 int src_x,
423 int src_y,
424 int width,
425 int height)
426{
427 guchar *pixels;
428 GdkPixbuf *sub;
429
430 g_return_val_if_fail (GDK_IS_PIXBUF (src_pixbuf), NULL);
431 g_return_val_if_fail (src_x >= 0 && src_x + width <= src_pixbuf->width, NULL);
432 g_return_val_if_fail (src_y >= 0 && src_y + height <= src_pixbuf->height, NULL);
433
434 pixels = (gdk_pixbuf_get_pixels (src_pixbuf)
435 + src_y * src_pixbuf->rowstride
436 + src_x * src_pixbuf->n_channels);
437
438 sub = gdk_pixbuf_new_from_data (pixels,
439 src_pixbuf->colorspace,
440 src_pixbuf->has_alpha,
441 src_pixbuf->bits_per_sample,
442 width, height,
443 src_pixbuf->rowstride,
444 NULL, NULL);
445
446 /* Keep a reference to src_pixbuf */
447 g_object_ref (src_pixbuf);
448
449 g_object_set_qdata_full (G_OBJECT (sub),
450 g_quark_from_static_string ("gdk-pixbuf-subpixbuf-src"),
451 src_pixbuf,
452 (GDestroyNotify) g_object_unref);
453
454 return sub;
455}
456
457
1458
459
460/* Accessors */
461
462/**
463 * gdk_pixbuf_get_colorspace:
464 * @pixbuf: A pixbuf.
465 *
466 * Queries the color space of a pixbuf.
467 *
468 * Return value: Color space.
469 **/
470GdkColorspace
471gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf)
472{
473 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), GDK_COLORSPACE_RGB);
474
475 return pixbuf->colorspace;
476}
477
478/**
479 * gdk_pixbuf_get_n_channels:
480 * @pixbuf: A pixbuf.
481 *
482 * Queries the number of channels of a pixbuf.
483 *
484 * Return value: Number of channels.
485 **/
486int
487gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf)
488{
489 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
490
491 return pixbuf->n_channels;
492}
493
494/**
495 * gdk_pixbuf_get_has_alpha:
496 * @pixbuf: A pixbuf.
497 *
498 * Queries whether a pixbuf has an alpha channel (opacity information).
499 *
500 * Return value: %TRUE if it has an alpha channel, %FALSE otherwise.
501 **/
502gboolean
503gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf)
504{
505 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
506
507 return pixbuf->has_alpha ? TRUE : FALSE;
508}
509
510/**
511 * gdk_pixbuf_get_bits_per_sample:
512 * @pixbuf: A pixbuf.
513 *
514 * Queries the number of bits per color sample in a pixbuf.
515 *
516 * Return value: Number of bits per color sample.
517 **/
518int
519gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf)
520{
521 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
522
523 return pixbuf->bits_per_sample;
524}
525
526/**
527 * gdk_pixbuf_get_pixels:
528 * @pixbuf: A pixbuf.
529 *
530 * Queries a pointer to the pixel data of a pixbuf.
531 *
532 * Return value: (array): A pointer to the pixbuf's pixel data.
533 * Please see <xref linkend="image-data"/> for information about how
534 * the pixel data is stored in memory.
535 **/
536guchar *
537gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
538{
539 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
540
541 return pixbuf->pixels;
542}
543
544/**
545 * gdk_pixbuf_get_pixels_with_length:
546 * @pixbuf: A pixbuf.
547 * @length: (out): The length of the binary data.
548 *
549 * Queries a pointer to the pixel data of a pixbuf.
550 *
551 * Return value: (array length=length): A pointer to the pixbuf's
552 * pixel data. Please see <xref linkend="image-data"/>
553 * for information about how the pixel data is stored in
554 * memory.
555 *
556 * Rename to: gdk_pixbuf_get_pixels
557 *
558 * Since: 2.26
559 */
560guchar *
561gdk_pixbuf_get_pixels_with_length (const GdkPixbuf *pixbuf,
562 guint *length)
563{
564 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
565
566 if (length)
567 *length = gdk_pixbuf_get_byte_length (pixbuf);
568
569 return pixbuf->pixels;
570}
571
572/**
573 * gdk_pixbuf_get_width:
574 * @pixbuf: A pixbuf.
575 *
576 * Queries the width of a pixbuf.
577 *
578 * Return value: Width in pixels.
579 **/
580int
581gdk_pixbuf_get_width (const GdkPixbuf *pixbuf)
582{
583 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
584
585 return pixbuf->width;
586}
587
588/**
589 * gdk_pixbuf_get_height:
590 * @pixbuf: A pixbuf.
591 *
592 * Queries the height of a pixbuf.
593 *
594 * Return value: Height in pixels.
595 **/
596int
597gdk_pixbuf_get_height (const GdkPixbuf *pixbuf)
598{
599 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
600
601 return pixbuf->height;
602}
603
604/**
605 * gdk_pixbuf_get_rowstride:
606 * @pixbuf: A pixbuf.
607 *
608 * Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row
609 * and the start of the next row.
610 *
611 * Return value: Distance between row starts.
612 **/
613int
614gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf)
615{
616 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
617
618 return pixbuf->rowstride;
619}
620
621/**
622 * gdk_pixbuf_get_byte_length:
623 * @pixbuf: A pixbuf
624 *
625 * Returns the length of the pixel data, in bytes.
626 *
627 * Return value: The length of the pixel data.
628 *
629 * Since: 2.26
630 */
631gsize
632gdk_pixbuf_get_byte_length (const GdkPixbuf *pixbuf)
633{
634 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
635
636 return ((pixbuf->height - 1) * pixbuf->rowstride +
637 pixbuf->width * ((pixbuf->n_channels * pixbuf->bits_per_sample + 7) / 8));
638}
639
640
2641
642
643/* General initialization hooks */
644const guint gdk_pixbuf_major_version = GDK_PIXBUF_MAJOR;
645const guint gdk_pixbuf_minor_version = GDK_PIXBUF_MINOR;
646const guint gdk_pixbuf_micro_version = GDK_PIXBUF_MICRO;
647
648const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
649
650/* Error quark */
651GQuark
652gdk_pixbuf_error_quark (void)
653{
654 return g_quark_from_static_string ("gdk-pixbuf-error-quark");
655}
656
657/**
658 * gdk_pixbuf_fill:
659 * @pixbuf: a #GdkPixbuf
660 * @pixel: RGBA pixel to clear to
661 * (0xffffffff is opaque white, 0x00000000 transparent black)
662 *
663 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
664 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
665 * doesn't have an alpha channel.
666 *
667 **/
668void
669gdk_pixbuf_fill (GdkPixbuf *pixbuf,
670 guint32 pixel)
671{
672 guchar *pixels;
673 guint r, g, b, a;
674 guchar *p;
675 guint w, h;
676
677 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
678
679 if (pixbuf->width == 0 || pixbuf->height == 0)
680 return;
681
682 pixels = pixbuf->pixels;
683
684 r = (pixel & 0xff000000) >> 24;
685 g = (pixel & 0x00ff0000) >> 16;
686 b = (pixel & 0x0000ff00) >> 8;
687 a = (pixel & 0x000000ff);
688
689 h = pixbuf->height;
690
691 while (h--) {
692 w = pixbuf->width;
693 p = pixels;
694
695 switch (pixbuf->n_channels) {
696 case 3:
697 while (w--) {
698 p[0] = r;
699 p[1] = g;
700 p[2] = b;
701 p += 3;
702 }
703 break;
704 case 4:
705 while (w--) {
706 p[0] = r;
707 p[1] = g;
708 p[2] = b;
709 p[3] = a;
710 p += 4;
711 }
712 break;
713 default:
714 break;
715 }
716
717 pixels += pixbuf->rowstride;
718 }
719}
720
721
3722
723
724/**
725 * gdk_pixbuf_get_option:
726 * @pixbuf: a #GdkPixbuf
727 * @key: a nul-terminated string.
728 *
729 * Looks up @key in the list of options that may have been attached to the
730 * @pixbuf when it was loaded, or that may have been attached by another
731 * function using gdk_pixbuf_set_option().
732 *
733 * For instance, the ANI loader provides "Title" and "Artist" options.
734 * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot
735 * options for cursor definitions. The PNG loader provides the tEXt ancillary
736 * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
737 * return an "orientation" option string that corresponds to the embedded
738 * TIFF/Exif orientation tag (if present).
739 *
740 * Return value: the value associated with @key. This is a nul-terminated
741 * string that should not be freed or %NULL if @key was not found.
742 **/
743const gchar *
744gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
745 const gchar *key)
746{
747 gchar **options;
748 gint i;
749
750 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
751 g_return_val_if_fail (key != NULL, NULL);
752
753 options = g_object_get_qdata (G_OBJECT (pixbuf),
754 g_quark_from_static_string ("gdk_pixbuf_options"));
755 if (options) {
756 for (i = 0; options[2*i]; i++) {
757 if (strcmp (options[2*i], key) == 0)
758 return options[2*i+1];
759 }
760 }
761
762 return NULL;
763}
764
765/**
766 * gdk_pixbuf_set_option:
767 * @pixbuf: a #GdkPixbuf
768 * @key: a nul-terminated string.
769 * @value: a nul-terminated string.
770 *
771 * Attaches a key/value pair as an option to a #GdkPixbuf. If @key already
772 * exists in the list of options attached to @pixbuf, the new value is
773 * ignored and %FALSE is returned.
774 *
775 * Return value: %TRUE on success.
776 *
777 * Since: 2.2
778 **/
779gboolean
780gdk_pixbuf_set_option (GdkPixbuf *pixbuf,
781 const gchar *key,
782 const gchar *value)
783{
784 GQuark quark;
785 gchar **options;
786 gint n = 0;
787
788 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
789 g_return_val_if_fail (key != NULL, FALSE);
790 g_return_val_if_fail (value != NULL, FALSE);
791
792 quark = g_quark_from_static_string ("gdk_pixbuf_options");
793
794 options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
795
796 if (options) {
797 for (n = 0; options[2*n]; n++) {
798 if (strcmp (options[2*n], key) == 0)
799 return FALSE;
800 }
801
802 g_object_steal_qdata (G_OBJECT (pixbuf), quark);
803 options = g_renew (gchar *, options, 2*(n+1) + 1);
804 } else {
805 options = g_new (gchar *, 3);
806 }
807
808 options[2*n] = g_strdup (key);
809 options[2*n+1] = g_strdup (value);
810 options[2*n+2] = NULL;
811
812 g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
813 options, (GDestroyNotify) g_strfreev);
814
815 return TRUE;
816}
817
818static void
819gdk_pixbuf_set_property (GObject *object,
820 guint prop_id,
821 const GValue *value,
822 GParamSpec *pspec)
823{
824 GdkPixbuf *pixbuf = GDK_PIXBUF (object);
825
826 switch (prop_id)
827 {
828 case PROP_COLORSPACE:
829 pixbuf->colorspace = g_value_get_enum (value);
830 break;
831 case PROP_N_CHANNELS:
832 pixbuf->n_channels = g_value_get_int (value);
833 break;
834 case PROP_HAS_ALPHA:
835 pixbuf->has_alpha = g_value_get_boolean (value);
836 break;
837 case PROP_BITS_PER_SAMPLE:
838 pixbuf->bits_per_sample = g_value_get_int (value);
839 break;
840 case PROP_WIDTH:
841 pixbuf->width = g_value_get_int (value);
842 break;
843 case PROP_HEIGHT:
844 pixbuf->height = g_value_get_int (value);
845 break;
846 case PROP_ROWSTRIDE:
847 pixbuf->rowstride = g_value_get_int (value);
848 break;
849 case PROP_PIXELS:
850 pixbuf->pixels = (guchar *) g_value_get_pointer (value);
851 break;
852 default:
853 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
854 break;
855 }
856}
857
858static void
859gdk_pixbuf_get_property (GObject *object,
860 guint prop_id,
861 GValue *value,
862 GParamSpec *pspec)
863{
864 GdkPixbuf *pixbuf = GDK_PIXBUF (object);
865
866 switch (prop_id)
867 {
868 case PROP_COLORSPACE:
869 g_value_set_enum (value, gdk_pixbuf_get_colorspace (pixbuf));
870 break;
871 case PROP_N_CHANNELS:
872 g_value_set_int (value, gdk_pixbuf_get_n_channels (pixbuf));
873 break;
874 case PROP_HAS_ALPHA:
875 g_value_set_boolean (value, gdk_pixbuf_get_has_alpha (pixbuf));
876 break;
877 case PROP_BITS_PER_SAMPLE:
878 g_value_set_int (value, gdk_pixbuf_get_bits_per_sample (pixbuf));
879 break;
880 case PROP_WIDTH:
881 g_value_set_int (value, gdk_pixbuf_get_width (pixbuf));
882 break;
883 case PROP_HEIGHT:
884 g_value_set_int (value, gdk_pixbuf_get_height (pixbuf));
885 break;
886 case PROP_ROWSTRIDE:
887 g_value_set_int (value, gdk_pixbuf_get_rowstride (pixbuf));
888 break;
889 case PROP_PIXELS:
890 g_value_set_pointer (value, gdk_pixbuf_get_pixels (pixbuf));
891 break;
892 default:
893 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
894 break;
895 }
896}
4897
=== added directory '.pc/gicon-serialization-support.patch/tests'
=== added file '.pc/gicon-serialization-support.patch/tests/Makefile.am'
--- .pc/gicon-serialization-support.patch/tests/Makefile.am 1970-01-01 00:00:00 +0000
+++ .pc/gicon-serialization-support.patch/tests/Makefile.am 2013-05-17 06:11:25 +0000
@@ -0,0 +1,30 @@
1include $(top_srcdir)/Makefile.decl
2
3INCLUDES = \
4 -I$(top_srcdir) \
5 -I$(top_srcdir)/gdk-pixbuf \
6 $(GDK_PIXBUF_DEBUG_FLAGS) \
7 $(GDK_PIXBUF_DEP_CFLAGS)
8
9DEPS = \
10 $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GDK_PIXBUF_API_VERSION).la
11
12LDADDS = \
13 $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GDK_PIXBUF_API_VERSION).la \
14 $(GDK_PIXBUF_DEP_LIBS)
15
16noinst_PROGRAMS = \
17 pixbuf-read \
18 pixbuf-lowmem \
19 pixbuf-randomly-modified \
20 pixbuf-random \
21 pixbuf-threads
22
23pixbuf_read_LDADD = $(LDADDS)
24pixbuf_lowmem_LDADD = $(LDADDS)
25pixbuf_randomly_modified_LDADD = $(LDADDS)
26pixbuf_random_LDADD = $(LDADDS)
27pixbuf_threads_LDADD = $(LDADDS) $(GLIB_LIBS)
28
29
30-include $(top_srcdir)/git.mk
031
=== added file '.pc/gicon-serialization-support.patch/tests/pixbuf-icon-serialize.c'
=== modified file 'configure.ac'
--- configure.ac 2013-05-13 19:52:09 +0000
+++ configure.ac 2013-05-17 06:11:25 +0000
@@ -26,7 +26,7 @@
2626
2727
28# required versions of other packages28# required versions of other packages
29m4_define([glib_required_version], [2.34.0])29m4_define([glib_required_version], [2.37.0])
3030
31AC_INIT([gdk-pixbuf], [gdk_pixbuf_version],31AC_INIT([gdk-pixbuf], [gdk_pixbuf_version],
32 [http://bugzilla.gnome.org/enter_bug.cgi?product=gdk-pixbuf],32 [http://bugzilla.gnome.org/enter_bug.cgi?product=gdk-pixbuf],
3333
=== modified file 'debian/changelog'
--- debian/changelog 2013-05-13 19:52:09 +0000
+++ debian/changelog 2013-05-17 06:11:25 +0000
@@ -1,3 +1,10 @@
1gdk-pixbuf (2.28.1-1ubuntu2) UNRELEASED; urgency=low
2
3 * debian/patches/gicon-serialization-support.patch:
4 - Add upstream's GdkPixbuf serialization support.
5
6 -- William Hua <william.hua@canonical.com> Fri, 17 May 2013 00:11:11 -0400
7
1gdk-pixbuf (2.28.1-1ubuntu1) saucy; urgency=low8gdk-pixbuf (2.28.1-1ubuntu1) saucy; urgency=low
29
3 * Resynchronize on Debian, remaining changes:10 * Resynchronize on Debian, remaining changes:
411
=== modified file 'debian/control'
--- debian/control 2013-05-13 19:52:09 +0000
+++ debian/control 2013-05-17 06:11:25 +0000
@@ -12,7 +12,7 @@
12 debhelper (>= 9),12 debhelper (>= 9),
13 autotools-dev,13 autotools-dev,
14 gnome-pkg-tools (>= 0.10),14 gnome-pkg-tools (>= 0.10),
15 libglib2.0-dev (>= 2.34.0),15 libglib2.0-dev (>= 2.37.0),
16 libx11-dev,16 libx11-dev,
17 libpng-dev | libpng12-dev,17 libpng-dev | libpng12-dev,
18 libjpeg-dev,18 libjpeg-dev,
@@ -81,7 +81,7 @@
81 ${shlibs:Depends},81 ${shlibs:Depends},
82 libgdk-pixbuf2.0-0 (= ${binary:Version}),82 libgdk-pixbuf2.0-0 (= ${binary:Version}),
83 gir1.2-gdkpixbuf-2.0 (= ${binary:Version}),83 gir1.2-gdkpixbuf-2.0 (= ${binary:Version}),
84 libglib2.0-dev (>= 2.34.0),84 libglib2.0-dev (>= 2.37.0),
85 libx11-dev,85 libx11-dev,
86 libpng12-dev86 libpng12-dev
87Breaks: libgtk2.0-dev (<< 2.21.3),87Breaks: libgtk2.0-dev (<< 2.21.3),
8888
=== modified file 'debian/control.in'
--- debian/control.in 2013-05-13 19:52:09 +0000
+++ debian/control.in 2013-05-17 06:11:25 +0000
@@ -8,7 +8,7 @@
8 debhelper (>= 9),8 debhelper (>= 9),
9 autotools-dev,9 autotools-dev,
10 gnome-pkg-tools (>= 0.10),10 gnome-pkg-tools (>= 0.10),
11 libglib2.0-dev (>= 2.34.0),11 libglib2.0-dev (>= 2.37.0),
12 libx11-dev,12 libx11-dev,
13 libpng-dev | libpng12-dev,13 libpng-dev | libpng12-dev,
14 libjpeg-dev,14 libjpeg-dev,
@@ -77,7 +77,7 @@
77 ${shlibs:Depends},77 ${shlibs:Depends},
78 libgdk-pixbuf2.0-0 (= ${binary:Version}),78 libgdk-pixbuf2.0-0 (= ${binary:Version}),
79 gir1.2-gdkpixbuf-2.0 (= ${binary:Version}),79 gir1.2-gdkpixbuf-2.0 (= ${binary:Version}),
80 libglib2.0-dev (>= 2.34.0),80 libglib2.0-dev (>= 2.37.0),
81 libx11-dev,81 libx11-dev,
82 libpng12-dev82 libpng12-dev
83Breaks: libgtk2.0-dev (<< 2.21.3),83Breaks: libgtk2.0-dev (<< 2.21.3),
8484
=== added file 'debian/patches/gicon-serialization-support.patch'
--- debian/patches/gicon-serialization-support.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/gicon-serialization-support.patch 2013-05-17 06:11:25 +0000
@@ -0,0 +1,229 @@
1--- a/configure.ac
2+++ b/configure.ac
3@@ -26,7 +26,7 @@
4
5
6 # required versions of other packages
7-m4_define([glib_required_version], [2.34.0])
8+m4_define([glib_required_version], [2.37.0])
9
10 AC_INIT([gdk-pixbuf], [gdk_pixbuf_version],
11 [http://bugzilla.gnome.org/enter_bug.cgi?product=gdk-pixbuf],
12--- a/gdk-pixbuf/gdk-pixbuf.c
13+++ b/gdk-pixbuf/gdk-pixbuf.c
14@@ -135,10 +135,11 @@
15 };
16
17 static void gdk_pixbuf_icon_iface_init (GIconIface *iface);
18+static void gdk_pixbuf_loadable_icon_iface_init (GLoadableIconIface *iface);
19
20 G_DEFINE_TYPE_WITH_CODE (GdkPixbuf, gdk_pixbuf, G_TYPE_OBJECT,
21- G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
22- gdk_pixbuf_icon_iface_init))
23+ G_IMPLEMENT_INTERFACE (G_TYPE_ICON, gdk_pixbuf_icon_iface_init)
24+ G_IMPLEMENT_INTERFACE (G_TYPE_LOADABLE_ICON, gdk_pixbuf_loadable_icon_iface_init))
25
26 static void
27 gdk_pixbuf_init (GdkPixbuf *pixbuf)
28@@ -292,11 +293,110 @@
29 g_object_unref (pixbuf);
30 }
31
32+static GBytes *
33+gdk_pixbuf_make_bytes (GdkPixbuf *pixbuf,
34+ GError **error)
35+{
36+ gchar *buffer;
37+ gsize size;
38+
39+ if (!gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &size, "png", error, NULL))
40+ return NULL;
41+
42+ return g_bytes_new_take (buffer, size);
43+}
44+
45+static GVariant *
46+gdk_pixbuf_serialize (GIcon *icon)
47+{
48+ GError *error = NULL;
49+ GVariant *result;
50+ GBytes *bytes;
51+
52+ bytes = gdk_pixbuf_make_bytes (GDK_PIXBUF (icon), &error);
53+ if (!bytes)
54+ {
55+ g_critical ("Unable to serialise GdkPixbuf to png (via g_icon_serialize()): %s", error->message);
56+ g_error_free (error);
57+ return NULL;
58+ }
59+ result = g_variant_new_from_bytes (G_VARIANT_TYPE_BYTESTRING, bytes, TRUE);
60+ g_bytes_unref (bytes);
61+
62+ return g_variant_new ("(sv)", "bytes", result);
63+}
64+
65+static GInputStream *
66+gdk_pixbuf_load (GLoadableIcon *icon,
67+ int size,
68+ char **type,
69+ GCancellable *cancellable,
70+ GError **error)
71+{
72+ GInputStream *stream;
73+ GBytes *bytes;
74+
75+ bytes = gdk_pixbuf_make_bytes (GDK_PIXBUF (icon), error);
76+ if (!bytes)
77+ return NULL;
78+
79+ stream = g_memory_input_stream_new_from_bytes (bytes);
80+ g_bytes_unref (bytes);
81+
82+ if (type)
83+ *type = g_strdup ("image/png");
84+
85+ return stream;
86+}
87+
88+static void
89+gdk_pixbuf_load_async (GLoadableIcon *icon,
90+ int size,
91+ GCancellable *cancellable,
92+ GAsyncReadyCallback callback,
93+ gpointer user_data)
94+{
95+ GTask *task;
96+
97+ task = g_task_new (icon, cancellable, callback, user_data);
98+ g_task_return_pointer (task, icon, NULL);
99+ g_object_unref (task);
100+}
101+
102+static GInputStream *
103+gdk_pixbuf_load_finish (GLoadableIcon *icon,
104+ GAsyncResult *res,
105+ char **type,
106+ GError **error)
107+{
108+ g_return_val_if_fail (g_task_is_valid (res, icon), NULL);
109+
110+ if (!g_task_propagate_pointer (G_TASK (res), error))
111+ return NULL;
112+
113+ return gdk_pixbuf_load (icon, 0, type, NULL, error);
114+}
115+
116+static void
117+gdk_pixbuf_loadable_icon_iface_init (GLoadableIconIface *iface)
118+{
119+ iface->load = gdk_pixbuf_load;
120+
121+ /* In theory encoding a png could be time-consuming but we're talking
122+ * about icons here, so assume it's probably going to be OK and handle
123+ * the async variant of the call in-thread instead of having the
124+ * default implementation dispatch it to a worker.
125+ */
126+ iface->load_async = gdk_pixbuf_load_async;
127+ iface->load_finish = gdk_pixbuf_load_finish;
128+}
129+
130 static void
131 gdk_pixbuf_icon_iface_init (GIconIface *iface)
132 {
133 iface->hash = (guint (*) (GIcon *)) g_direct_hash;
134 iface->equal = (gboolean (*) (GIcon *, GIcon *)) g_direct_equal;
135+ iface->serialize = gdk_pixbuf_serialize;
136 }
137
138 /* Used as the destroy notification function for gdk_pixbuf_new() */
139--- a/tests/Makefile.am
140+++ b/tests/Makefile.am
141@@ -6,6 +6,8 @@
142 $(GDK_PIXBUF_DEBUG_FLAGS) \
143 $(GDK_PIXBUF_DEP_CFLAGS)
144
145+AM_CFLAGS = '-DABS_SRCDIR="$(abs_srcdir)"'
146+
147 DEPS = \
148 $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GDK_PIXBUF_API_VERSION).la
149
150@@ -18,13 +20,15 @@
151 pixbuf-lowmem \
152 pixbuf-randomly-modified \
153 pixbuf-random \
154- pixbuf-threads
155+ pixbuf-threads \
156+ pixbuf-icon-serialize
157
158 pixbuf_read_LDADD = $(LDADDS)
159 pixbuf_lowmem_LDADD = $(LDADDS)
160 pixbuf_randomly_modified_LDADD = $(LDADDS)
161 pixbuf_random_LDADD = $(LDADDS)
162 pixbuf_threads_LDADD = $(LDADDS) $(GLIB_LIBS)
163+pixbuf_icon_serialize_LDADD = $(LDADDS) $(GLIB_LIBS)
164
165
166 -include $(top_srcdir)/git.mk
167--- /dev/null
168+++ b/tests/pixbuf-icon-serialize.c
169@@ -0,0 +1,60 @@
170+#include "config.h"
171+#include "gdk-pixbuf/gdk-pixbuf.h"
172+#include <string.h>
173+#include <glib.h>
174+
175+static void
176+test_serialize (void)
177+{
178+ GError *error = NULL;
179+ GdkPixbuf *pixbuf;
180+ GdkPixbuf *pixbuf2;
181+ GVariant *data;
182+ GIcon *icon;
183+ GInputStream *stream;
184+
185+ pixbuf = gdk_pixbuf_new_from_file (ABS_SRCDIR "/test-image.png", &error);
186+ g_assert_no_error (error);
187+ g_assert (pixbuf != NULL);
188+
189+ /* turn it into a GVariant */
190+ data = g_icon_serialize (G_ICON (pixbuf));
191+
192+ /* back to a GIcon, but this will be a GBytesIcon, not GdkPixbuf */
193+ icon = g_icon_deserialize (data);
194+ g_assert (G_IS_BYTES_ICON (icon));
195+
196+ /* but since that is a GLoadableIcon, we can load it again */
197+ stream = g_loadable_icon_load (G_LOADABLE_ICON (icon), 0, NULL, NULL, &error);
198+ g_assert_no_error (error);
199+ pixbuf2 = gdk_pixbuf_new_from_stream (stream, NULL, &error);
200+ g_assert_no_error (error);
201+
202+ /* make sure that the pixels are the same.
203+ * our _serialize() uses png, so this should be perfect.
204+ */
205+ {
206+ guchar *pixels_a, *pixels_b;
207+ guint len_a, len_b;
208+ pixels_a = gdk_pixbuf_get_pixels_with_length (pixbuf, &len_a);
209+ pixels_b = gdk_pixbuf_get_pixels_with_length (pixbuf2, &len_b);
210+ g_assert (len_a == len_b);
211+ g_assert (memcmp (pixels_a, pixels_b, len_a) == 0);
212+ }
213+
214+ g_object_unref (pixbuf2);
215+ g_object_unref (pixbuf);
216+ g_object_unref (stream);
217+ g_variant_unref (data);
218+
219+}
220+
221+int
222+main (int argc, char **argv)
223+{
224+ g_test_init (&argc, &argv, NULL);
225+
226+ g_test_add_func ("/pixbuf/icon/serialize", test_serialize);
227+
228+ return g_test_run ();
229+}
0230
=== modified file 'debian/patches/series'
--- debian/patches/series 2013-05-07 19:03:11 +0000
+++ debian/patches/series 2013-05-17 06:11:25 +0000
@@ -0,0 +1,1 @@
1gicon-serialization-support.patch
02
=== modified file 'gdk-pixbuf/gdk-pixbuf.c'
--- gdk-pixbuf/gdk-pixbuf.c 2012-09-18 17:06:38 +0000
+++ gdk-pixbuf/gdk-pixbuf.c 2013-05-17 06:11:25 +0000
@@ -135,10 +135,11 @@
135};135};
136136
137static void gdk_pixbuf_icon_iface_init (GIconIface *iface);137static void gdk_pixbuf_icon_iface_init (GIconIface *iface);
138static void gdk_pixbuf_loadable_icon_iface_init (GLoadableIconIface *iface);
138139
139G_DEFINE_TYPE_WITH_CODE (GdkPixbuf, gdk_pixbuf, G_TYPE_OBJECT,140G_DEFINE_TYPE_WITH_CODE (GdkPixbuf, gdk_pixbuf, G_TYPE_OBJECT,
140 G_IMPLEMENT_INTERFACE (G_TYPE_ICON,141 G_IMPLEMENT_INTERFACE (G_TYPE_ICON, gdk_pixbuf_icon_iface_init)
141 gdk_pixbuf_icon_iface_init))142 G_IMPLEMENT_INTERFACE (G_TYPE_LOADABLE_ICON, gdk_pixbuf_loadable_icon_iface_init))
142143
143static void 144static void
144gdk_pixbuf_init (GdkPixbuf *pixbuf)145gdk_pixbuf_init (GdkPixbuf *pixbuf)
@@ -292,11 +293,110 @@
292 g_object_unref (pixbuf);293 g_object_unref (pixbuf);
293}294}
294295
296static GBytes *
297gdk_pixbuf_make_bytes (GdkPixbuf *pixbuf,
298 GError **error)
299{
300 gchar *buffer;
301 gsize size;
302
303 if (!gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &size, "png", error, NULL))
304 return NULL;
305
306 return g_bytes_new_take (buffer, size);
307}
308
309static GVariant *
310gdk_pixbuf_serialize (GIcon *icon)
311{
312 GError *error = NULL;
313 GVariant *result;
314 GBytes *bytes;
315
316 bytes = gdk_pixbuf_make_bytes (GDK_PIXBUF (icon), &error);
317 if (!bytes)
318 {
319 g_critical ("Unable to serialise GdkPixbuf to png (via g_icon_serialize()): %s", error->message);
320 g_error_free (error);
321 return NULL;
322 }
323 result = g_variant_new_from_bytes (G_VARIANT_TYPE_BYTESTRING, bytes, TRUE);
324 g_bytes_unref (bytes);
325
326 return g_variant_new ("(sv)", "bytes", result);
327}
328
329static GInputStream *
330gdk_pixbuf_load (GLoadableIcon *icon,
331 int size,
332 char **type,
333 GCancellable *cancellable,
334 GError **error)
335{
336 GInputStream *stream;
337 GBytes *bytes;
338
339 bytes = gdk_pixbuf_make_bytes (GDK_PIXBUF (icon), error);
340 if (!bytes)
341 return NULL;
342
343 stream = g_memory_input_stream_new_from_bytes (bytes);
344 g_bytes_unref (bytes);
345
346 if (type)
347 *type = g_strdup ("image/png");
348
349 return stream;
350}
351
352static void
353gdk_pixbuf_load_async (GLoadableIcon *icon,
354 int size,
355 GCancellable *cancellable,
356 GAsyncReadyCallback callback,
357 gpointer user_data)
358{
359 GTask *task;
360
361 task = g_task_new (icon, cancellable, callback, user_data);
362 g_task_return_pointer (task, icon, NULL);
363 g_object_unref (task);
364}
365
366static GInputStream *
367gdk_pixbuf_load_finish (GLoadableIcon *icon,
368 GAsyncResult *res,
369 char **type,
370 GError **error)
371{
372 g_return_val_if_fail (g_task_is_valid (res, icon), NULL);
373
374 if (!g_task_propagate_pointer (G_TASK (res), error))
375 return NULL;
376
377 return gdk_pixbuf_load (icon, 0, type, NULL, error);
378}
379
380static void
381gdk_pixbuf_loadable_icon_iface_init (GLoadableIconIface *iface)
382{
383 iface->load = gdk_pixbuf_load;
384
385 /* In theory encoding a png could be time-consuming but we're talking
386 * about icons here, so assume it's probably going to be OK and handle
387 * the async variant of the call in-thread instead of having the
388 * default implementation dispatch it to a worker.
389 */
390 iface->load_async = gdk_pixbuf_load_async;
391 iface->load_finish = gdk_pixbuf_load_finish;
392}
393
295static void394static void
296gdk_pixbuf_icon_iface_init (GIconIface *iface)395gdk_pixbuf_icon_iface_init (GIconIface *iface)
297{396{
298 iface->hash = (guint (*) (GIcon *)) g_direct_hash;397 iface->hash = (guint (*) (GIcon *)) g_direct_hash;
299 iface->equal = (gboolean (*) (GIcon *, GIcon *)) g_direct_equal;398 iface->equal = (gboolean (*) (GIcon *, GIcon *)) g_direct_equal;
399 iface->serialize = gdk_pixbuf_serialize;
300}400}
301401
302/* Used as the destroy notification function for gdk_pixbuf_new() */402/* Used as the destroy notification function for gdk_pixbuf_new() */
303403
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2010-07-23 11:26:25 +0000
+++ tests/Makefile.am 2013-05-17 06:11:25 +0000
@@ -6,6 +6,8 @@
6 $(GDK_PIXBUF_DEBUG_FLAGS) \6 $(GDK_PIXBUF_DEBUG_FLAGS) \
7 $(GDK_PIXBUF_DEP_CFLAGS)7 $(GDK_PIXBUF_DEP_CFLAGS)
88
9AM_CFLAGS = '-DABS_SRCDIR="$(abs_srcdir)"'
10
9DEPS = \11DEPS = \
10 $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GDK_PIXBUF_API_VERSION).la12 $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GDK_PIXBUF_API_VERSION).la
1113
@@ -18,13 +20,15 @@
18 pixbuf-lowmem \20 pixbuf-lowmem \
19 pixbuf-randomly-modified \21 pixbuf-randomly-modified \
20 pixbuf-random \22 pixbuf-random \
21 pixbuf-threads23 pixbuf-threads \
24 pixbuf-icon-serialize
2225
23pixbuf_read_LDADD = $(LDADDS)26pixbuf_read_LDADD = $(LDADDS)
24pixbuf_lowmem_LDADD = $(LDADDS)27pixbuf_lowmem_LDADD = $(LDADDS)
25pixbuf_randomly_modified_LDADD = $(LDADDS)28pixbuf_randomly_modified_LDADD = $(LDADDS)
26pixbuf_random_LDADD = $(LDADDS)29pixbuf_random_LDADD = $(LDADDS)
27pixbuf_threads_LDADD = $(LDADDS) $(GLIB_LIBS)30pixbuf_threads_LDADD = $(LDADDS) $(GLIB_LIBS)
31pixbuf_icon_serialize_LDADD = $(LDADDS) $(GLIB_LIBS)
2832
2933
30-include $(top_srcdir)/git.mk34-include $(top_srcdir)/git.mk
3135
=== added file 'tests/pixbuf-icon-serialize.c'
--- tests/pixbuf-icon-serialize.c 1970-01-01 00:00:00 +0000
+++ tests/pixbuf-icon-serialize.c 2013-05-17 06:11:25 +0000
@@ -0,0 +1,60 @@
1#include "config.h"
2#include "gdk-pixbuf/gdk-pixbuf.h"
3#include <string.h>
4#include <glib.h>
5
6static void
7test_serialize (void)
8{
9 GError *error = NULL;
10 GdkPixbuf *pixbuf;
11 GdkPixbuf *pixbuf2;
12 GVariant *data;
13 GIcon *icon;
14 GInputStream *stream;
15
16 pixbuf = gdk_pixbuf_new_from_file (ABS_SRCDIR "/test-image.png", &error);
17 g_assert_no_error (error);
18 g_assert (pixbuf != NULL);
19
20 /* turn it into a GVariant */
21 data = g_icon_serialize (G_ICON (pixbuf));
22
23 /* back to a GIcon, but this will be a GBytesIcon, not GdkPixbuf */
24 icon = g_icon_deserialize (data);
25 g_assert (G_IS_BYTES_ICON (icon));
26
27 /* but since that is a GLoadableIcon, we can load it again */
28 stream = g_loadable_icon_load (G_LOADABLE_ICON (icon), 0, NULL, NULL, &error);
29 g_assert_no_error (error);
30 pixbuf2 = gdk_pixbuf_new_from_stream (stream, NULL, &error);
31 g_assert_no_error (error);
32
33 /* make sure that the pixels are the same.
34 * our _serialize() uses png, so this should be perfect.
35 */
36 {
37 guchar *pixels_a, *pixels_b;
38 guint len_a, len_b;
39 pixels_a = gdk_pixbuf_get_pixels_with_length (pixbuf, &len_a);
40 pixels_b = gdk_pixbuf_get_pixels_with_length (pixbuf2, &len_b);
41 g_assert (len_a == len_b);
42 g_assert (memcmp (pixels_a, pixels_b, len_a) == 0);
43 }
44
45 g_object_unref (pixbuf2);
46 g_object_unref (pixbuf);
47 g_object_unref (stream);
48 g_variant_unref (data);
49
50}
51
52int
53main (int argc, char **argv)
54{
55 g_test_init (&argc, &argv, NULL);
56
57 g_test_add_func ("/pixbuf/icon/serialize", test_serialize);
58
59 return g_test_run ();
60}

Subscribers

People subscribed via source and target branches

to all changes: