diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:23:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:23:22 +0000 |
commit | e42129241681dde7adae7d20697e7b421682fbb4 (patch) | |
tree | af1fe815a5e639e68e59fabd8395ec69458b3e5e /plug-ins/print | |
parent | Initial commit. (diff) | |
download | gimp-e42129241681dde7adae7d20697e7b421682fbb4.tar.xz gimp-e42129241681dde7adae7d20697e7b421682fbb4.zip |
Adding upstream version 2.10.22.upstream/2.10.22upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plug-ins/print')
-rw-r--r-- | plug-ins/print/Makefile.am | 62 | ||||
-rw-r--r-- | plug-ins/print/Makefile.in | 1037 | ||||
-rw-r--r-- | plug-ins/print/print-draw-page.c | 220 | ||||
-rw-r--r-- | plug-ins/print/print-draw-page.h | 20 | ||||
-rw-r--r-- | plug-ins/print/print-page-layout.c | 948 | ||||
-rw-r--r-- | plug-ins/print/print-page-layout.h | 20 | ||||
-rw-r--r-- | plug-ins/print/print-page-setup.c | 101 | ||||
-rw-r--r-- | plug-ins/print/print-page-setup.h | 27 | ||||
-rw-r--r-- | plug-ins/print/print-preview.c | 880 | ||||
-rw-r--r-- | plug-ins/print/print-preview.h | 60 | ||||
-rw-r--r-- | plug-ins/print/print-settings.c | 320 | ||||
-rw-r--r-- | plug-ins/print/print-settings.h | 19 | ||||
-rw-r--r-- | plug-ins/print/print-utils.c | 145 | ||||
-rw-r--r-- | plug-ins/print/print-utils.h | 26 | ||||
-rw-r--r-- | plug-ins/print/print.c | 503 | ||||
-rw-r--r-- | plug-ins/print/print.h | 56 |
16 files changed, 4444 insertions, 0 deletions
diff --git a/plug-ins/print/Makefile.am b/plug-ins/print/Makefile.am new file mode 100644 index 0000000..fed7f8e --- /dev/null +++ b/plug-ins/print/Makefile.am @@ -0,0 +1,62 @@ +## Process this file with automake to produce Makefile.in + +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la + +if OS_WIN32 +mwindows = -mwindows +endif + +if HAVE_WINDRES +include $(top_srcdir)/build/windows/gimprc-plug-ins.rule +print_RC = print.rc.o +endif + +AM_LDFLAGS = $(mwindows) + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +LDADD = \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEGL_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(print_RC) + +libexecdir = $(gimpplugindir)/plug-ins/print + +libexec_PROGRAMS = print + +EXTRA_PROGRAMS = print + +print_SOURCES = \ + print.c \ + print.h \ + print-draw-page.c \ + print-draw-page.h \ + print-page-layout.c \ + print-page-layout.h \ + print-page-setup.h \ + print-page-setup.c \ + print-preview.c \ + print-preview.h \ + print-settings.c \ + print-settings.h \ + print-utils.c \ + print-utils.h diff --git a/plug-ins/print/Makefile.in b/plug-ins/print/Makefile.in new file mode 100644 index 0000000..93db24f --- /dev/null +++ b/plug-ins/print/Makefile.in @@ -0,0 +1,1037 @@ +# Makefile.in generated by automake 1.16.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Version resources for Microsoft Windows + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +libexec_PROGRAMS = print$(EXEEXT) +EXTRA_PROGRAMS = print$(EXEEXT) +subdir = plug-ins/print +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/gtk-doc.m4 \ + $(top_srcdir)/m4macros/intltool.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/m4macros/alsa.m4 \ + $(top_srcdir)/m4macros/ax_compare_version.m4 \ + $(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4macros/ax_prog_cc_for_build.m4 \ + $(top_srcdir)/m4macros/ax_prog_perl_version.m4 \ + $(top_srcdir)/m4macros/detectcflags.m4 \ + $(top_srcdir)/m4macros/pythondev.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(libexecdir)" +PROGRAMS = $(libexec_PROGRAMS) +am_print_OBJECTS = print.$(OBJEXT) print-draw-page.$(OBJEXT) \ + print-page-layout.$(OBJEXT) print-page-setup.$(OBJEXT) \ + print-preview.$(OBJEXT) print-settings.$(OBJEXT) \ + print-utils.$(OBJEXT) +print_OBJECTS = $(am_print_OBJECTS) +print_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +print_DEPENDENCIES = $(libgimpui) $(libgimpwidgets) $(libgimpconfig) \ + $(libgimp) $(libgimpcolor) $(libgimpmath) $(libgimpbase) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(print_RC) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/print-draw-page.Po \ + ./$(DEPDIR)/print-page-layout.Po \ + ./$(DEPDIR)/print-page-setup.Po ./$(DEPDIR)/print-preview.Po \ + ./$(DEPDIR)/print-settings.Po ./$(DEPDIR)/print-utils.Po \ + ./$(DEPDIR)/print.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(print_SOURCES) +DIST_SOURCES = $(print_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build/windows/gimprc-plug-ins.rule \ + $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AA_LIBS = @AA_LIBS@ +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALL_LINGUAS = @ALL_LINGUAS@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +ALTIVEC_EXTRA_CFLAGS = @ALTIVEC_EXTRA_CFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPSTREAM_UTIL = @APPSTREAM_UTIL@ +AR = @AR@ +AS = @AS@ +ATK_CFLAGS = @ATK_CFLAGS@ +ATK_LIBS = @ATK_LIBS@ +ATK_REQUIRED_VERSION = @ATK_REQUIRED_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BABL_CFLAGS = @BABL_CFLAGS@ +BABL_LIBS = @BABL_LIBS@ +BABL_REQUIRED_VERSION = @BABL_REQUIRED_VERSION@ +BUG_REPORT_URL = @BUG_REPORT_URL@ +BUILD_EXEEXT = @BUILD_EXEEXT@ +BUILD_OBJEXT = @BUILD_OBJEXT@ +BZIP2_LIBS = @BZIP2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CAIRO_PDF_CFLAGS = @CAIRO_PDF_CFLAGS@ +CAIRO_PDF_LIBS = @CAIRO_PDF_LIBS@ +CAIRO_PDF_REQUIRED_VERSION = @CAIRO_PDF_REQUIRED_VERSION@ +CAIRO_REQUIRED_VERSION = @CAIRO_REQUIRED_VERSION@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CC_VERSION = @CC_VERSION@ +CFLAGS = @CFLAGS@ +CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DESKTOP_DATADIR = @DESKTOP_DATADIR@ +DESKTOP_FILE_VALIDATE = @DESKTOP_FILE_VALIDATE@ +DLLTOOL = @DLLTOOL@ +DOC_SHOOTER = @DOC_SHOOTER@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILE_AA = @FILE_AA@ +FILE_EXR = @FILE_EXR@ +FILE_HEIF = @FILE_HEIF@ +FILE_JP2_LOAD = @FILE_JP2_LOAD@ +FILE_MNG = @FILE_MNG@ +FILE_PDF_SAVE = @FILE_PDF_SAVE@ +FILE_PS = @FILE_PS@ +FILE_WMF = @FILE_WMF@ +FILE_XMC = @FILE_XMC@ +FILE_XPM = @FILE_XPM@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FONTCONFIG_REQUIRED_VERSION = @FONTCONFIG_REQUIRED_VERSION@ +FREETYPE2_REQUIRED_VERSION = @FREETYPE2_REQUIRED_VERSION@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GDBUS_CODEGEN = @GDBUS_CODEGEN@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_CSOURCE = @GDK_PIXBUF_CSOURCE@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GDK_PIXBUF_REQUIRED_VERSION = @GDK_PIXBUF_REQUIRED_VERSION@ +GEGL = @GEGL@ +GEGL_CFLAGS = @GEGL_CFLAGS@ +GEGL_LIBS = @GEGL_LIBS@ +GEGL_MAJOR_MINOR_VERSION = @GEGL_MAJOR_MINOR_VERSION@ +GEGL_REQUIRED_VERSION = @GEGL_REQUIRED_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GEXIV2_CFLAGS = @GEXIV2_CFLAGS@ +GEXIV2_LIBS = @GEXIV2_LIBS@ +GEXIV2_REQUIRED_VERSION = @GEXIV2_REQUIRED_VERSION@ +GIMP_API_VERSION = @GIMP_API_VERSION@ +GIMP_APP_VERSION = @GIMP_APP_VERSION@ +GIMP_BINARY_AGE = @GIMP_BINARY_AGE@ +GIMP_COMMAND = @GIMP_COMMAND@ +GIMP_DATA_VERSION = @GIMP_DATA_VERSION@ +GIMP_FULL_NAME = @GIMP_FULL_NAME@ +GIMP_INTERFACE_AGE = @GIMP_INTERFACE_AGE@ +GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@ +GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@ +GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@ +GIMP_MKENUMS = @GIMP_MKENUMS@ +GIMP_MODULES = @GIMP_MODULES@ +GIMP_PACKAGE_REVISION = @GIMP_PACKAGE_REVISION@ +GIMP_PKGCONFIG_VERSION = @GIMP_PKGCONFIG_VERSION@ +GIMP_PLUGINS = @GIMP_PLUGINS@ +GIMP_PLUGIN_VERSION = @GIMP_PLUGIN_VERSION@ +GIMP_REAL_VERSION = @GIMP_REAL_VERSION@ +GIMP_SYSCONF_VERSION = @GIMP_SYSCONF_VERSION@ +GIMP_TOOL_VERSION = @GIMP_TOOL_VERSION@ +GIMP_UNSTABLE = @GIMP_UNSTABLE@ +GIMP_USER_VERSION = @GIMP_USER_VERSION@ +GIMP_VERSION = @GIMP_VERSION@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GIO_UNIX_CFLAGS = @GIO_UNIX_CFLAGS@ +GIO_UNIX_LIBS = @GIO_UNIX_LIBS@ +GIO_WINDOWS_CFLAGS = @GIO_WINDOWS_CFLAGS@ +GIO_WINDOWS_LIBS = @GIO_WINDOWS_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@ +GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@ +GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +GREP = @GREP@ +GS_LIBS = @GS_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_MAC_INTEGRATION_CFLAGS = @GTK_MAC_INTEGRATION_CFLAGS@ +GTK_MAC_INTEGRATION_LIBS = @GTK_MAC_INTEGRATION_LIBS@ +GTK_REQUIRED_VERSION = @GTK_REQUIRED_VERSION@ +GTK_UPDATE_ICON_CACHE = @GTK_UPDATE_ICON_CACHE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@ +HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HARFBUZZ_REQUIRED_VERSION = @HARFBUZZ_REQUIRED_VERSION@ +HAVE_CXX14 = @HAVE_CXX14@ +HAVE_FINITE = @HAVE_FINITE@ +HAVE_ISFINITE = @HAVE_ISFINITE@ +HAVE_VFORK = @HAVE_VFORK@ +HOST_GLIB_COMPILE_RESOURCES = @HOST_GLIB_COMPILE_RESOURCES@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_REQUIRED_VERSION = @INTLTOOL_REQUIRED_VERSION@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +ISO_CODES_LOCALEDIR = @ISO_CODES_LOCALEDIR@ +ISO_CODES_LOCATION = @ISO_CODES_LOCATION@ +JPEG_LIBS = @JPEG_LIBS@ +JSON_GLIB_CFLAGS = @JSON_GLIB_CFLAGS@ +JSON_GLIB_LIBS = @JSON_GLIB_LIBS@ +LCMS_CFLAGS = @LCMS_CFLAGS@ +LCMS_LIBS = @LCMS_LIBS@ +LCMS_REQUIRED_VERSION = @LCMS_REQUIRED_VERSION@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ +LIBBACKTRACE_LIBS = @LIBBACKTRACE_LIBS@ +LIBHEIF_CFLAGS = @LIBHEIF_CFLAGS@ +LIBHEIF_LIBS = @LIBHEIF_LIBS@ +LIBHEIF_REQUIRED_VERSION = @LIBHEIF_REQUIRED_VERSION@ +LIBLZMA_REQUIRED_VERSION = @LIBLZMA_REQUIRED_VERSION@ +LIBMYPAINT_CFLAGS = @LIBMYPAINT_CFLAGS@ +LIBMYPAINT_LIBS = @LIBMYPAINT_LIBS@ +LIBMYPAINT_REQUIRED_VERSION = @LIBMYPAINT_REQUIRED_VERSION@ +LIBOBJS = @LIBOBJS@ +LIBPNG_REQUIRED_VERSION = @LIBPNG_REQUIRED_VERSION@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@ +LIBUNWIND_LIBS = @LIBUNWIND_LIBS@ +LIBUNWIND_REQUIRED_VERSION = @LIBUNWIND_REQUIRED_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LT_VERSION_INFO = @LT_VERSION_INFO@ +LZMA_CFLAGS = @LZMA_CFLAGS@ +LZMA_LIBS = @LZMA_LIBS@ +MAIL = @MAIL@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MIME_INFO_CFLAGS = @MIME_INFO_CFLAGS@ +MIME_INFO_LIBS = @MIME_INFO_LIBS@ +MIME_TYPES = @MIME_TYPES@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMX_EXTRA_CFLAGS = @MMX_EXTRA_CFLAGS@ +MNG_CFLAGS = @MNG_CFLAGS@ +MNG_LIBS = @MNG_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +MYPAINT_BRUSHES_CFLAGS = @MYPAINT_BRUSHES_CFLAGS@ +MYPAINT_BRUSHES_LIBS = @MYPAINT_BRUSHES_LIBS@ +NATIVE_GLIB_CFLAGS = @NATIVE_GLIB_CFLAGS@ +NATIVE_GLIB_LIBS = @NATIVE_GLIB_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENEXR_CFLAGS = @OPENEXR_CFLAGS@ +OPENEXR_LIBS = @OPENEXR_LIBS@ +OPENEXR_REQUIRED_VERSION = @OPENEXR_REQUIRED_VERSION@ +OPENJPEG_CFLAGS = @OPENJPEG_CFLAGS@ +OPENJPEG_LIBS = @OPENJPEG_LIBS@ +OPENJPEG_REQUIRED_VERSION = @OPENJPEG_REQUIRED_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PANGOCAIRO_CFLAGS = @PANGOCAIRO_CFLAGS@ +PANGOCAIRO_LIBS = @PANGOCAIRO_LIBS@ +PANGOCAIRO_REQUIRED_VERSION = @PANGOCAIRO_REQUIRED_VERSION@ +PATHSEP = @PATHSEP@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PERL_REQUIRED_VERSION = @PERL_REQUIRED_VERSION@ +PERL_VERSION = @PERL_VERSION@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PNG_CFLAGS = @PNG_CFLAGS@ +PNG_LIBS = @PNG_LIBS@ +POFILES = @POFILES@ +POPPLER_CFLAGS = @POPPLER_CFLAGS@ +POPPLER_DATA_CFLAGS = @POPPLER_DATA_CFLAGS@ +POPPLER_DATA_LIBS = @POPPLER_DATA_LIBS@ +POPPLER_DATA_REQUIRED_VERSION = @POPPLER_DATA_REQUIRED_VERSION@ +POPPLER_LIBS = @POPPLER_LIBS@ +POPPLER_REQUIRED_VERSION = @POPPLER_REQUIRED_VERSION@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PYBIN_PATH = @PYBIN_PATH@ +PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@ +PYCAIRO_LIBS = @PYCAIRO_LIBS@ +PYGIMP_EXTRA_CFLAGS = @PYGIMP_EXTRA_CFLAGS@ +PYGTK_CFLAGS = @PYGTK_CFLAGS@ +PYGTK_CODEGEN = @PYGTK_CODEGEN@ +PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ +PYGTK_LIBS = @PYGTK_LIBS@ +PYLINK_LIBS = @PYLINK_LIBS@ +PYTHON = @PYTHON@ +PYTHON2_REQUIRED_VERSION = @PYTHON2_REQUIRED_VERSION@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RSVG_REQUIRED_VERSION = @RSVG_REQUIRED_VERSION@ +RT_LIBS = @RT_LIBS@ +SCREENSHOT_LIBS = @SCREENSHOT_LIBS@ +SED = @SED@ +SENDMAIL = @SENDMAIL@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@ +SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@ +SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@ +STRIP = @STRIP@ +SVG_CFLAGS = @SVG_CFLAGS@ +SVG_LIBS = @SVG_LIBS@ +SYMPREFIX = @SYMPREFIX@ +TIFF_LIBS = @TIFF_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WEBKIT_CFLAGS = @WEBKIT_CFLAGS@ +WEBKIT_LIBS = @WEBKIT_LIBS@ +WEBKIT_REQUIRED_VERSION = @WEBKIT_REQUIRED_VERSION@ +WEBPDEMUX_CFLAGS = @WEBPDEMUX_CFLAGS@ +WEBPDEMUX_LIBS = @WEBPDEMUX_LIBS@ +WEBPMUX_CFLAGS = @WEBPMUX_CFLAGS@ +WEBPMUX_LIBS = @WEBPMUX_LIBS@ +WEBP_CFLAGS = @WEBP_CFLAGS@ +WEBP_LIBS = @WEBP_LIBS@ +WEBP_REQUIRED_VERSION = @WEBP_REQUIRED_VERSION@ +WEB_PAGE = @WEB_PAGE@ +WIN32_LARGE_ADDRESS_AWARE = @WIN32_LARGE_ADDRESS_AWARE@ +WINDRES = @WINDRES@ +WMF_CFLAGS = @WMF_CFLAGS@ +WMF_CONFIG = @WMF_CONFIG@ +WMF_LIBS = @WMF_LIBS@ +WMF_REQUIRED_VERSION = @WMF_REQUIRED_VERSION@ +XDG_EMAIL = @XDG_EMAIL@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_REQUIRED_VERSION = @XGETTEXT_REQUIRED_VERSION@ +XMC_CFLAGS = @XMC_CFLAGS@ +XMC_LIBS = @XMC_LIBS@ +XMKMF = @XMKMF@ +XMLLINT = @XMLLINT@ +XMU_LIBS = @XMU_LIBS@ +XPM_LIBS = @XPM_LIBS@ +XSLTPROC = @XSLTPROC@ +XVFB_RUN = @XVFB_RUN@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +Z_LIBS = @Z_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gimpdatadir = @gimpdatadir@ +gimpdir = @gimpdir@ +gimplocaledir = @gimplocaledir@ +gimpplugindir = @gimpplugindir@ +gimpsysconfdir = @gimpsysconfdir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = $(gimpplugindir)/plug-ins/print +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +manpage_gimpdir = @manpage_gimpdir@ +mkdir_p = @mkdir_p@ +ms_librarian = @ms_librarian@ +mypaint_brushes_dir = @mypaint_brushes_dir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la +@OS_WIN32_TRUE@mwindows = -mwindows +@HAVE_WINDRES_TRUE@GIMPPLUGINRC = $(top_builddir)/build/windows/gimp-plug-ins.rc +@HAVE_WINDRES_TRUE@print_RC = print.rc.o +AM_LDFLAGS = $(mwindows) +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +LDADD = \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEGL_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(print_RC) + +print_SOURCES = \ + print.c \ + print.h \ + print-draw-page.c \ + print-draw-page.h \ + print-page-layout.c \ + print-page-layout.h \ + print-page-setup.h \ + print-page-setup.c \ + print-preview.c \ + print-preview.h \ + print-settings.c \ + print-settings.h \ + print-utils.c \ + print-utils.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/print/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plug-ins/print/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; +$(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__empty): + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +print$(EXEEXT): $(print_OBJECTS) $(print_DEPENDENCIES) $(EXTRA_print_DEPENDENCIES) + @rm -f print$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(print_OBJECTS) $(print_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-draw-page.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-page-layout.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-page-setup.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-preview.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-settings.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-utils.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/print-draw-page.Po + -rm -f ./$(DEPDIR)/print-page-layout.Po + -rm -f ./$(DEPDIR)/print-page-setup.Po + -rm -f ./$(DEPDIR)/print-preview.Po + -rm -f ./$(DEPDIR)/print-settings.Po + -rm -f ./$(DEPDIR)/print-utils.Po + -rm -f ./$(DEPDIR)/print.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/print-draw-page.Po + -rm -f ./$(DEPDIR)/print-page-layout.Po + -rm -f ./$(DEPDIR)/print-page-setup.Po + -rm -f ./$(DEPDIR)/print-preview.Po + -rm -f ./$(DEPDIR)/print-settings.Po + -rm -f ./$(DEPDIR)/print-utils.Po + -rm -f ./$(DEPDIR)/print.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libexecPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libexecPROGRAMS clean-libtool \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libexecPROGRAMS \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-libexecPROGRAMS + +.PRECIOUS: Makefile + + +# `windres` seems a very stupid tool and it breaks with double shlashes +# in parameter paths. Strengthen the rule a little. +@HAVE_WINDRES_TRUE@%.rc.o: +@HAVE_WINDRES_TRUE@ $(WINDRES) --define ORIGINALFILENAME_STR="$*$(EXEEXT)" \ +@HAVE_WINDRES_TRUE@ --define INTERNALNAME_STR="$*" \ +@HAVE_WINDRES_TRUE@ --define TOP_SRCDIR="`echo $(top_srcdir) | sed 's*//*/*'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_srcdir)/app | sed 's%/\+%/%'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir)/app | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir) | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ $(GIMPPLUGINRC) $@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plug-ins/print/print-draw-page.c b/plug-ins/print/print-draw-page.c new file mode 100644 index 0000000..7fb0239 --- /dev/null +++ b/plug-ins/print/print-draw-page.c @@ -0,0 +1,220 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <string.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "print.h" +#include "print-draw-page.h" + +#include "libgimp/stdplugins-intl.h" + + +static cairo_surface_t * print_surface_from_drawable (gint32 drawable_ID, + GError **error); + +static void print_draw_crop_marks (GtkPrintContext *context, + gdouble x, + gdouble y, + gdouble w, + gdouble h); + +gboolean +print_draw_page (GtkPrintContext *context, + PrintData *data, + GError **error) +{ + cairo_t *cr = gtk_print_context_get_cairo_context (context); + cairo_surface_t *surface; + + surface = print_surface_from_drawable (data->drawable_id, error); + + if (surface) + { + gint width; + gint height; + gdouble scale_x; + gdouble scale_y; + + /* create a white rectangle covering the entire page, just + * to be safe; see bug #777233. + */ + cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0); + cairo_paint (cr); + + width = cairo_image_surface_get_width (surface); + height = cairo_image_surface_get_height (surface); + + scale_x = gtk_print_context_get_dpi_x (context) / data->xres; + scale_y = gtk_print_context_get_dpi_y (context) / data->yres; + + cairo_translate (cr, data->offset_x, data->offset_y); + + if (data->draw_crop_marks) + print_draw_crop_marks (context, + 0, 0, width * scale_x, height * scale_y); + + cairo_scale (cr, scale_x, scale_y); + cairo_rectangle (cr, 0, 0, width, height); + cairo_set_source_surface (cr, surface, 0, 0); + cairo_fill (cr); + + cairo_surface_destroy (surface); + + return TRUE; + } + + return FALSE; +} + +static cairo_surface_t * +print_surface_from_drawable (gint32 drawable_ID, + GError **error) +{ + GeglBuffer *buffer = gimp_drawable_get_buffer (drawable_ID); + const Babl *format; + cairo_surface_t *surface; + cairo_status_t status; + const gint width = gimp_drawable_width (drawable_ID); + const gint height = gimp_drawable_height (drawable_ID); + GeglBufferIterator *iter; + guchar *pixels; + gint stride; + guint count = 0; + guint done = 0; + + if (gimp_drawable_has_alpha (drawable_ID)) + format = babl_format ("cairo-ARGB32"); + else + format = babl_format ("cairo-RGB24"); + + surface = cairo_image_surface_create (gimp_drawable_has_alpha (drawable_ID) ? + CAIRO_FORMAT_ARGB32 : + CAIRO_FORMAT_RGB24, + width, height); + + status = cairo_surface_status (surface); + if (status != CAIRO_STATUS_SUCCESS) + { + switch (status) + { + case CAIRO_STATUS_INVALID_SIZE: + g_set_error_literal (error, + GIMP_PLUGIN_PRINT_ERROR, + GIMP_PLUGIN_PRINT_ERROR_FAILED, + _("Cannot handle the size (either width or height) of the image.")); + break; + default: + g_set_error (error, + GIMP_PLUGIN_PRINT_ERROR, + GIMP_PLUGIN_PRINT_ERROR_FAILED, + "Cairo error: %s", + cairo_status_to_string (status)); + break; + } + + return NULL; + } + + pixels = cairo_image_surface_get_data (surface); + stride = cairo_image_surface_get_stride (surface); + + iter = gegl_buffer_iterator_new (buffer, + GEGL_RECTANGLE (0, 0, width, height), 0, + format, + GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1); + + while (gegl_buffer_iterator_next (iter)) + { + const guchar *src = iter->items[0].data; + guchar *dest = pixels + iter->items[0].roi.y * stride + iter->items[0].roi.x * 4; + gint y; + + for (y = 0; y < iter->items[0].roi.height; y++) + { + memcpy (dest, src, iter->items[0].roi.width * 4); + + src += iter->items[0].roi.width * 4; + dest += stride; + } + + done += iter->items[0].roi.height * iter->items[0].roi.width; + + if (count++ % 16 == 0) + gimp_progress_update ((gdouble) done / (width * height)); + } + + g_object_unref (buffer); + + cairo_surface_mark_dirty (surface); + + gimp_progress_update (1.0); + + return surface; +} + +static void +print_draw_crop_marks (GtkPrintContext *context, + gdouble x, + gdouble y, + gdouble w, + gdouble h) +{ + cairo_t *cr = gtk_print_context_get_cairo_context (context); + gdouble len = MIN (gtk_print_context_get_width (context), + gtk_print_context_get_height (context)) / 20.0; + + /* upper left */ + + cairo_move_to (cr, x - len, y); + cairo_line_to (cr, x - len / 5, y); + + cairo_move_to (cr, x, y - len); + cairo_line_to (cr, x, y - len / 5); + + /* upper right */ + + cairo_move_to (cr, x + w + len / 5, y); + cairo_line_to (cr, x + w + len, y); + + cairo_move_to (cr, x + w, y - len); + cairo_line_to (cr, x + w, y - len / 5); + + /* lower left */ + + cairo_move_to (cr, x - len, y + h); + cairo_line_to (cr, x - len / 5, y + h); + + cairo_move_to (cr, x, y + h + len); + cairo_line_to (cr, x, y + h + len / 5); + + /* lower right */ + + cairo_move_to (cr, x + w + len / 5, y + h); + cairo_line_to (cr, x + w + len, y + h); + + cairo_move_to (cr, x + w, y + h + len); + cairo_line_to (cr, x + w, y + h + len / 5); + + cairo_set_source_rgb (cr, 0.5, 0.5, 0.5); + cairo_set_line_width (cr, 2); + cairo_stroke (cr); +} diff --git a/plug-ins/print/print-draw-page.h b/plug-ins/print/print-draw-page.h new file mode 100644 index 0000000..88f3968 --- /dev/null +++ b/plug-ins/print/print-draw-page.h @@ -0,0 +1,20 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +gboolean print_draw_page (GtkPrintContext *context, + PrintData *data, + GError **error); diff --git a/plug-ins/print/print-page-layout.c b/plug-ins/print/print-page-layout.c new file mode 100644 index 0000000..1fb91de --- /dev/null +++ b/plug-ins/print/print-page-layout.c @@ -0,0 +1,948 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <string.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "print.h" +#include "print-page-layout.h" +#include "print-preview.h" + +#include "libgimp/stdplugins-intl.h" + + +typedef struct +{ + PrintData *data; + gint image_width; + gint image_height; + GimpSizeEntry *size_entry; + GimpSizeEntry *resolution_entry; + GimpChainButton *chain; + GtkWidget *center_combo; + GtkWidget *area_label; + GtkWidget *preview; + GtkAdjustment *left_adj; + GtkAdjustment *right_adj; + GtkAdjustment *top_adj; + GtkAdjustment *bottom_adj; +} PrintSizeInfo; + +enum +{ + BOTTOM, + TOP, + RIGHT, + LEFT, + WIDTH, + HEIGHT +}; + + +static void print_page_setup_notify (GtkPrintOperation *operation); +static void update_custom_widget (GtkPrintOperation *operation, + GtkWidget *custom_widget, + GtkPageSetup *page_setup, + GtkPrintSettings *print_settings); + +static GtkWidget * print_size_frame (PrintData *data, + GtkSizeGroup *label_group, + GtkSizeGroup *entry_group); +static GtkWidget * print_offset_frame (PrintData *data, + GtkSizeGroup *label_group, + GtkSizeGroup *entry_group); + +static void print_size_info_update_offsets (void); +static void print_size_info_size_changed (GtkWidget *widget); +static void print_size_info_offset_max_changed (GtkAdjustment *adj, + gpointer data); +static void print_size_info_resolution_changed (GtkWidget *widget); +static void print_size_info_unit_changed (GtkWidget *widget); +static void print_size_info_preview_offset_changed + (GtkWidget *widget, + gdouble offset_x, + gdouble offset_y); +static void print_size_info_center_changed (GtkWidget *widget); +static void print_size_info_center_none (void); +static void print_size_info_use_full_page_toggled + (GtkWidget *widget); + +static void print_size_info_set_resolution (PrintSizeInfo *info, + gdouble xres, + gdouble yres); + + +static void print_size_info_set_page_setup (PrintSizeInfo *info); + +static void print_draw_crop_marks_toggled (GtkWidget *widget); + +static void print_resolution_load_defaults (PrintSizeInfo *info); + +static PrintSizeInfo info; + + +GtkWidget * +print_page_layout_gui (PrintData *data, + const gchar *help_id) +{ + GtkWidget *main_hbox; + GtkWidget *main_vbox; + GtkWidget *button; + GtkWidget *frame; + GtkPageSetup *setup; + GtkSizeGroup *label_group; + GtkSizeGroup *entry_group; + + memset (&info, 0, sizeof (PrintSizeInfo)); + + info.data = data; + info.image_width = gimp_drawable_width (data->drawable_id); + info.image_height = gimp_drawable_height (data->drawable_id); + + setup = gtk_print_operation_get_default_page_setup (data->operation); + if (! setup) + { + setup = gtk_page_setup_new (); + gtk_print_operation_set_default_page_setup (data->operation, setup); + } + + /* main hbox */ + main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12); + + /* main vbox */ + main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_box_pack_start (GTK_BOX (main_hbox), main_vbox, FALSE, FALSE, 0); + gtk_widget_show (main_vbox); + + label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + entry_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + + /* size entry area for the image's print size */ + + frame = print_size_frame (data, label_group, entry_group); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + /* offset entry area for the image's offset position */ + + frame = print_offset_frame (data, label_group, entry_group); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + g_object_unref (label_group); + g_object_unref (entry_group); + + button = gtk_check_button_new_with_mnemonic (_("Ignore Page _Margins")); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + data->use_full_page); + gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0); + g_signal_connect (button, "toggled", + G_CALLBACK (print_size_info_use_full_page_toggled), + NULL); + gtk_widget_show (button); + + /* crop marks toggle */ + button = gtk_check_button_new_with_mnemonic (_("_Draw Crop Marks")); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + data->draw_crop_marks); + gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0); + g_signal_connect (button, "toggled", + G_CALLBACK (print_draw_crop_marks_toggled), + NULL); + gtk_widget_show (button); + + /* preview */ + frame = gimp_frame_new (_("Preview")); + gtk_box_pack_start (GTK_BOX (main_hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + info.preview = print_preview_new (setup, data->drawable_id); + print_preview_set_use_full_page (PRINT_PREVIEW (info.preview), + data->use_full_page); + gtk_container_add (GTK_CONTAINER (frame), info.preview); + gtk_widget_show (info.preview); + + g_signal_connect (info.preview, "offsets-changed", + G_CALLBACK (print_size_info_preview_offset_changed), + NULL); + + print_size_info_set_page_setup (&info); + + g_signal_connect_object (data->operation, "notify::default-page-setup", + G_CALLBACK (print_page_setup_notify), + main_hbox, 0); + g_signal_connect_object (data->operation, "update-custom-widget", + G_CALLBACK (update_custom_widget), + main_hbox, 0); + + gimp_help_connect (main_hbox, gimp_standard_help_func, help_id, NULL); + + return main_hbox; +} + +static void +print_page_setup_notify (GtkPrintOperation *operation) +{ + GtkPageSetup *setup; + + setup = gtk_print_operation_get_default_page_setup (operation); + + print_size_info_set_page_setup (&info); + print_preview_set_page_setup (PRINT_PREVIEW (info.preview), setup); +} + +static void +update_custom_widget (GtkPrintOperation *operation, + GtkWidget *custom_widget, + GtkPageSetup *page_setup, + GtkPrintSettings *print_settings) +{ + gtk_print_operation_set_default_page_setup (operation, page_setup); +} + + +#define SB_WIDTH 8 + +static GtkWidget * +print_size_frame (PrintData *data, + GtkSizeGroup *label_group, + GtkSizeGroup *entry_group) +{ + GtkWidget *entry; + GtkWidget *height; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *chain; + GtkWidget *frame; + GtkWidget *label; + GtkWidget *button; + GtkAdjustment *adj; + gdouble image_width; + gdouble image_height; + + image_width = (info.image_width * + gimp_unit_get_factor (data->unit) / data->xres); + image_height = (info.image_height * + gimp_unit_get_factor (data->unit) / data->yres); + + frame = gimp_frame_new (_("Size")); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + /* the print size entry */ + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + entry = gimp_size_entry_new (1, data->unit, "%p", + FALSE, FALSE, FALSE, SB_WIDTH, + GIMP_SIZE_ENTRY_UPDATE_SIZE); + gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); + gtk_widget_show (entry); + + info.size_entry = GIMP_SIZE_ENTRY (entry); + + gtk_table_set_row_spacings (GTK_TABLE (entry), 2); + gtk_table_set_col_spacing (GTK_TABLE (entry), 0, 6); + gtk_table_set_col_spacing (GTK_TABLE (entry), 2, 6); + + adj = (GtkAdjustment *) gtk_adjustment_new (1, 1, 1, 1, 10, 0); + height = gimp_spin_button_new (adj, 1, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (height), TRUE); + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (height), NULL); + gtk_table_attach_defaults (GTK_TABLE (entry), height, 1, 2, 0, 1); + gtk_widget_show (height); + + gtk_size_group_add_widget (entry_group, height); + + gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), + _("_Width:"), 0, 0, 0.0); + label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), + _("_Height:"), 1, 0, 0.0); + + gtk_size_group_add_widget (label_group, label); + + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, + data->xres, FALSE); + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 1, + data->yres, FALSE); + + gimp_size_entry_set_value (GIMP_SIZE_ENTRY (entry), 0, image_width); + gimp_size_entry_set_value (GIMP_SIZE_ENTRY (entry), 1, image_height); + + /* the resolution entry */ + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + entry = gimp_size_entry_new (1, data->image_unit, + _("pixels/%a"), + FALSE, FALSE, FALSE, SB_WIDTH, + GIMP_SIZE_ENTRY_UPDATE_RESOLUTION); + gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); + gtk_widget_show (entry); + + info.resolution_entry = GIMP_SIZE_ENTRY (entry); + + gtk_table_set_row_spacings (GTK_TABLE (entry), 2); + gtk_table_set_col_spacing (GTK_TABLE (entry), 0, 6); + gtk_table_set_col_spacing (GTK_TABLE (entry), 2, 6); + + adj = (GtkAdjustment *) gtk_adjustment_new (1, 1, 1, 1, 10, 0); + height = gimp_spin_button_new (adj, 1, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (height), TRUE); + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (height), NULL); + gtk_table_attach_defaults (GTK_TABLE (entry), height, 1, 2, 0, 1); + gtk_widget_show (height); + + gtk_size_group_add_widget (entry_group, height); + + label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), + _("_X resolution:"), 0, 0, 0.0); + gtk_size_group_add_widget (label_group, label); + + label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), + _("_Y resolution:"), 1, 0, 0.0); + gtk_size_group_add_widget (label_group, label); + + button = gtk_button_new_with_mnemonic (_("_Load Defaults")); + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (print_resolution_load_defaults), + &info); + gtk_widget_show (button); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + + gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (entry), 0, + GIMP_MIN_RESOLUTION, + GIMP_MAX_RESOLUTION); + gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (entry), 1, + GIMP_MIN_RESOLUTION, + GIMP_MAX_RESOLUTION); + + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 0, data->xres); + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 1, data->yres); + + chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT); + if (ABS (data->xres - data->yres) < GIMP_MIN_RESOLUTION) + gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain), TRUE); + gtk_table_attach (GTK_TABLE (entry), chain, 2, 3, 0, 2, + GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (chain); + + info.chain = GIMP_CHAIN_BUTTON (chain); + + g_signal_connect (info.resolution_entry, "value-changed", + G_CALLBACK (print_size_info_resolution_changed), + NULL); + g_signal_connect (info.size_entry, "unit-changed", + G_CALLBACK (print_size_info_unit_changed), + NULL); + + return frame; +} + +static GtkWidget * +print_offset_frame (PrintData *data, + GtkSizeGroup *label_group, + GtkSizeGroup *entry_group) +{ + GtkWidget *entry; + GtkWidget *spinner; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *table; + GtkWidget *frame; + GtkWidget *label; + GtkWidget *combo; + + frame = gimp_frame_new (_("Position")); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + /* the offset entry */ + + entry = GTK_WIDGET (info.size_entry); + + table = gtk_table_new (4, 4, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 0); + gtk_table_set_col_spacing (GTK_TABLE (table), 1, 12); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); + + /* left */ + info.left_adj = (GtkAdjustment *) gtk_adjustment_new (1, 1, 1, 1, 10, 0); + spinner = gimp_spin_button_new (info.left_adj, 1, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE); + + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (spinner), NULL); + gtk_table_attach_defaults (GTK_TABLE (table), spinner, 1, 2, 0, 1); + gtk_widget_show (spinner); + + label = gtk_label_new_with_mnemonic (_("_Left:")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); + gtk_size_group_add_widget (label_group, label); + gtk_widget_show (label); + + /* right */ + info.right_adj = (GtkAdjustment *) gtk_adjustment_new (1, 1, 1, 1, 10, 0); + spinner = gimp_spin_button_new (info.right_adj, 1, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE); + + g_signal_connect (info.right_adj, "value-changed", + G_CALLBACK (print_size_info_offset_max_changed), + GINT_TO_POINTER (LEFT)); + + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (spinner), NULL); + gtk_table_attach_defaults (GTK_TABLE (table), spinner, 3, 4, 0, 1); + gtk_widget_show (spinner); + + label = gtk_label_new_with_mnemonic (_("_Right:")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1); + gtk_widget_show (label); + + /* top */ + info.top_adj = (GtkAdjustment *) gtk_adjustment_new (1, 1, 1, 1, 10, 0); + spinner = gimp_spin_button_new (info.top_adj, 1, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE); + + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (spinner), NULL); + gtk_table_attach_defaults (GTK_TABLE (table), spinner, 1, 2, 1, 2); + gtk_widget_show (spinner); + + label = gtk_label_new_with_mnemonic (_("_Top:")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); + gtk_size_group_add_widget (label_group, label); + gtk_widget_show (label); + + /* bottom */ + info.bottom_adj = (GtkAdjustment *) gtk_adjustment_new (1, 1, 1, 1, 10, 0); + spinner = gimp_spin_button_new (info.bottom_adj, 1, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE); + + g_signal_connect (info.bottom_adj, "value-changed", + G_CALLBACK (print_size_info_offset_max_changed), + GINT_TO_POINTER (TOP)); + + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (spinner), NULL); + gtk_table_attach_defaults (GTK_TABLE (table), spinner, 3, 4, 1, 2); + gtk_widget_show (spinner); + + label = gtk_label_new_with_mnemonic (_("_Bottom:")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 1, 2); + gtk_widget_show (label); + + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), LEFT, 72.0, FALSE); + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), RIGHT, 72.0, FALSE); + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), TOP, 72.0, FALSE); + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), BOTTOM, 72.0, FALSE); + + print_size_info_update_offsets (); + + g_signal_connect (info.size_entry, "value-changed", + G_CALLBACK (print_size_info_size_changed), + NULL); + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + label = gtk_label_new_with_mnemonic (_("C_enter:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_size_group_add_widget (label_group, label); + gtk_widget_show (label); + + /* if and how to center the image on the page */ + combo = gimp_int_combo_box_new (C_("center-mode", "None"), CENTER_NONE, + _("Horizontally"), CENTER_HORIZONTALLY, + _("Vertically"), CENTER_VERTICALLY, + _("Both"), CENTER_BOTH, + NULL); + gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); + gtk_widget_show (combo); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); + + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), + data->center, + G_CALLBACK (print_size_info_center_changed), + NULL); + + info.center_combo = combo; + + g_signal_connect (info.left_adj, "value-changed", + G_CALLBACK (print_size_info_center_none), + NULL); + g_signal_connect (info.right_adj, "value-changed", + G_CALLBACK (print_size_info_center_none), + NULL); + g_signal_connect (info.top_adj, "value-changed", + G_CALLBACK (print_size_info_center_none), + NULL); + g_signal_connect (info.bottom_adj, "value-changed", + G_CALLBACK (print_size_info_center_none), + NULL); + + return frame; +} + +static void +print_size_info_get_page_dimensions (PrintSizeInfo *info, + gdouble *page_width, + gdouble *page_height, + GtkUnit unit) +{ + GtkPageSetup *setup; + + setup = gtk_print_operation_get_default_page_setup (info->data->operation); + + if (info->data->use_full_page) + { + *page_width = gtk_page_setup_get_paper_width (setup, unit); + *page_height = gtk_page_setup_get_paper_height (setup, unit); + } + else + { + *page_width = gtk_page_setup_get_page_width (setup, unit); + *page_height = gtk_page_setup_get_page_height (setup, unit); + } + +} + +static void +gimp_size_info_get_max_offsets (gdouble *offset_x_max, + gdouble *offset_y_max) +{ + gdouble width; + gdouble height; + + print_size_info_get_page_dimensions (&info, &width, &height, GTK_UNIT_POINTS); + + *offset_x_max = width - 72.0 * info.image_width / info.data->xres; + *offset_x_max = MAX (0, *offset_x_max); + + *offset_y_max = height - 72.0 * info.image_height / info.data->yres; + *offset_y_max = MAX (0, *offset_y_max); +} + +static void +print_size_info_center_none_block (void) +{ + g_signal_handlers_block_by_func (info.left_adj, + print_size_info_center_none, NULL); + g_signal_handlers_block_by_func (info.right_adj, + print_size_info_center_none, NULL); + g_signal_handlers_block_by_func (info.top_adj, + print_size_info_center_none, NULL); + g_signal_handlers_block_by_func (info.bottom_adj, + print_size_info_center_none, NULL); +} + +static void +print_size_info_center_none_unblock (void) +{ + g_signal_handlers_unblock_by_func (info.left_adj, + print_size_info_center_none, NULL); + g_signal_handlers_unblock_by_func (info.right_adj, + print_size_info_center_none, NULL); + g_signal_handlers_unblock_by_func (info.top_adj, + print_size_info_center_none, NULL); + g_signal_handlers_unblock_by_func (info.bottom_adj, + print_size_info_center_none, NULL); +} + +static void +print_size_info_update_offsets (void) +{ + PrintData *data = info.data; + gdouble offset_x_max; + gdouble offset_y_max; + + gimp_size_info_get_max_offsets (&offset_x_max, &offset_y_max); + + g_signal_handlers_block_by_func (info.size_entry, + print_size_info_size_changed, NULL); + + print_size_info_center_none_block (); + + gimp_size_entry_set_refval_boundaries (info.size_entry, LEFT, + 0, offset_x_max); + gimp_size_entry_set_refval_boundaries (info.size_entry, RIGHT, + 0, offset_x_max); + gimp_size_entry_set_refval_boundaries (info.size_entry, TOP, + 0, offset_y_max); + gimp_size_entry_set_refval_boundaries (info.size_entry, BOTTOM, + 0, offset_y_max); + + switch (data->center) + { + case CENTER_NONE: + break; + + case CENTER_HORIZONTALLY: + data->offset_x = offset_x_max / 2.0; + break; + + case CENTER_VERTICALLY: + data->offset_y = offset_y_max / 2.0; + break; + + case CENTER_BOTH: + data->offset_x = offset_x_max / 2.0; + data->offset_y = offset_y_max / 2.0; + break; + } + + gimp_size_entry_set_refval (info.size_entry, LEFT, + data->offset_x); + gimp_size_entry_set_refval (info.size_entry, RIGHT, + offset_x_max - data->offset_x); + gimp_size_entry_set_refval (info.size_entry, TOP, + info.data->offset_y); + gimp_size_entry_set_refval (info.size_entry, BOTTOM, + offset_y_max - data->offset_y); + + print_size_info_center_none_unblock (); + + g_signal_handlers_unblock_by_func (info.size_entry, + print_size_info_size_changed, NULL); +} + +static void +print_size_info_center_changed (GtkWidget *combo) +{ + gint value; + + if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &value)) + { + info.data->center = value; + + print_size_info_update_offsets (); + + if (info.preview) + print_preview_set_image_offsets (PRINT_PREVIEW (info.preview), + info.data->offset_x, + info.data->offset_y); + } +} + +static void +print_size_info_center_none (void) +{ + /* return early if we are called from a unit change */ + if (gimp_size_entry_get_unit (info.size_entry) != info.data->unit) + return; + + info.data->center = CENTER_NONE; + + if (info.center_combo) + { + g_signal_handlers_block_by_func (info.center_combo, + print_size_info_center_changed, NULL); + + info.data->center = CENTER_NONE; + + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (info.center_combo), + info.data->center); + + g_signal_handlers_unblock_by_func (info.center_combo, + print_size_info_center_changed, NULL); + } +} + +static void +print_size_info_preview_offset_changed (GtkWidget *widget, + gdouble offset_x, + gdouble offset_y) +{ + print_size_info_center_none (); + + info.data->offset_x = offset_x; + info.data->offset_y = offset_y; + + print_size_info_update_offsets (); +} + +static void +print_size_info_size_changed (GtkWidget *widget) +{ + gdouble width; + gdouble height; + gdouble xres; + gdouble yres; + gdouble scale; + + scale = gimp_unit_get_factor (gimp_size_entry_get_unit (info.size_entry)); + + width = gimp_size_entry_get_value (info.size_entry, WIDTH); + height = gimp_size_entry_get_value (info.size_entry, HEIGHT); + + xres = scale * info.image_width / MAX (0.0001, width); + yres = scale * info.image_height / MAX (0.0001, height); + + print_size_info_set_resolution (&info, xres, yres); + + info.data->offset_x = gimp_size_entry_get_refval (info.size_entry, LEFT); + info.data->offset_y = gimp_size_entry_get_refval (info.size_entry, TOP); + + print_preview_set_image_offsets (PRINT_PREVIEW (info.preview), + info.data->offset_x, + info.data->offset_y); +} + +static void +print_size_info_offset_max_changed (GtkAdjustment *adj, + gpointer data) +{ + guint index = GPOINTER_TO_INT (data); + + /* return early if we are called from a unit change */ + if (gimp_size_entry_get_unit (info.size_entry) != info.data->unit) + return; + + g_signal_handlers_block_by_func (info.size_entry, + print_size_info_size_changed, NULL); + + gimp_size_entry_set_value (info.size_entry, index, + gtk_adjustment_get_upper (adj) - + gtk_adjustment_get_value (adj)); + + g_signal_handlers_unblock_by_func (info.size_entry, + print_size_info_size_changed, NULL); +} + +static void +print_size_info_resolution_changed (GtkWidget *widget) +{ + GimpSizeEntry *entry = info.resolution_entry; + gdouble xres = gimp_size_entry_get_refval (entry, 0); + gdouble yres = gimp_size_entry_get_refval (entry, 1); + + print_size_info_set_resolution (&info, xres, yres); +} + +static void +print_size_info_use_full_page_toggled (GtkWidget *widget) +{ + gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + info.data->use_full_page = active; + + print_size_info_set_page_setup (&info); + + print_preview_set_use_full_page (PRINT_PREVIEW(info.preview), active); +} + +static void +print_size_info_unit_changed (GtkWidget *widget) +{ + info.data->unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget)); + + print_size_info_set_page_setup (&info); +} + +static void +print_size_info_set_resolution (PrintSizeInfo *info, + gdouble xres, + gdouble yres) +{ + PrintData *data = info->data; + gdouble offset_x; + gdouble offset_y; + gdouble offset_x_max; + gdouble offset_y_max; + + if (info->chain && gimp_chain_button_get_active (info->chain)) + { + if (xres != data->xres) + yres = xres; + else + xres = yres; + } + + data->xres = xres; + data->yres = yres; + + g_signal_handlers_block_by_func (info->resolution_entry, + print_size_info_resolution_changed, + NULL); + + gimp_size_entry_set_refval (info->resolution_entry, 0, xres); + gimp_size_entry_set_refval (info->resolution_entry, 1, yres); + + g_signal_handlers_unblock_by_func (info->resolution_entry, + print_size_info_resolution_changed, + NULL); + + g_signal_handlers_block_by_func (info->size_entry, + print_size_info_size_changed, + NULL); + + gimp_size_entry_set_value (info->size_entry, WIDTH, + info->image_width * + gimp_unit_get_factor (data->unit) / xres); + gimp_size_entry_set_value (info->size_entry, HEIGHT, + info->image_height * + gimp_unit_get_factor (data->unit) / yres); + + g_signal_handlers_unblock_by_func (info->size_entry, + print_size_info_size_changed, + NULL); + + gimp_size_info_get_max_offsets (&offset_x_max, &offset_y_max); + + offset_x = gimp_size_entry_get_refval (info->size_entry, LEFT); + offset_y = gimp_size_entry_get_refval (info->size_entry, TOP); + + offset_x = CLAMP (offset_x, 0, offset_x_max); + offset_y = CLAMP (offset_y, 0, offset_y_max); + + data->offset_x = offset_x; + data->offset_y = offset_y; + + print_size_info_update_offsets (); + + print_preview_set_image_dpi (PRINT_PREVIEW (info->preview), + data->xres, data->yres); + print_preview_set_image_offsets (PRINT_PREVIEW (info->preview), + data->offset_x, data->offset_y); + print_preview_set_image_offsets_max (PRINT_PREVIEW (info->preview), + offset_x_max, offset_y_max); +} + +static void +print_size_info_set_page_setup (PrintSizeInfo *info) +{ + PrintData *data = info->data; + gdouble page_width; + gdouble page_height; + gdouble x; + gdouble y; + + print_size_info_get_page_dimensions (info, + &page_width, &page_height, + GTK_UNIT_INCH); + + page_width *= gimp_unit_get_factor (data->unit); + page_height *= gimp_unit_get_factor (data->unit); + + if (info->area_label) + { + gchar *format; + gchar *text; + + format = g_strdup_printf ("%%.%df x %%.%df %s", + gimp_unit_get_digits (data->unit), + gimp_unit_get_digits (data->unit), + gimp_unit_get_plural (data->unit)); + text = g_strdup_printf (format, page_width, page_height); + g_free (format); + + gtk_label_set_text (GTK_LABEL (info->area_label), text); + g_free (text); + } + + x = page_width; + y = page_height; + + if (info->chain && gimp_chain_button_get_active (info->chain)) + { + gdouble ratio_x = page_width / (gdouble) info->image_width; + gdouble ratio_y = page_height / (gdouble) info->image_height; + + if (ratio_x < ratio_y) + y = (gdouble) info->image_height * ratio_x; + else + x = (gdouble) info->image_width * ratio_y; + } + + gimp_size_entry_set_value_boundaries (info->size_entry, WIDTH, + page_width / 100.0, x); + gimp_size_entry_set_value_boundaries (info->size_entry, HEIGHT, + page_height / 100.0, y); + + print_size_info_get_page_dimensions (info, + &page_width, &page_height, + GTK_UNIT_POINTS); + + x = (gdouble) info->image_width / page_width * 72.0; + y = (gdouble) info->image_height / page_height * 72.0; + + if (info->chain && gimp_chain_button_get_active (info->chain)) + { + gdouble max = MAX (x, y); + + x = y = max; + } + + data->min_xres = x; + data->min_yres = y; + gimp_size_entry_set_refval_boundaries (info->resolution_entry, 0, + x, GIMP_MAX_RESOLUTION); + gimp_size_entry_set_refval_boundaries (info->resolution_entry, 1, + y, GIMP_MAX_RESOLUTION); +} + +static void +print_draw_crop_marks_toggled (GtkWidget *widget) +{ + gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + info.data->draw_crop_marks = active; +} + +static void +print_resolution_load_defaults (PrintSizeInfo *info) +{ + gdouble xres; + gdouble yres; + + gimp_image_get_resolution (info->data->image_id, &xres, &yres); + + gimp_size_entry_set_refval (info->resolution_entry, 0, xres); + gimp_size_entry_set_refval (info->resolution_entry, 1, yres); + print_size_info_resolution_changed (GTK_WIDGET (info->resolution_entry)); +} diff --git a/plug-ins/print/print-page-layout.h b/plug-ins/print/print-page-layout.h new file mode 100644 index 0000000..d01f777 --- /dev/null +++ b/plug-ins/print/print-page-layout.h @@ -0,0 +1,20 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +GtkWidget * print_page_layout_gui (PrintData *data, + const gchar *help_id); + diff --git a/plug-ins/print/print-page-setup.c b/plug-ins/print/print-page-setup.c new file mode 100644 index 0000000..f80e014 --- /dev/null +++ b/plug-ins/print/print-page-setup.c @@ -0,0 +1,101 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "print.h" +#include "print-page-setup.h" +#include "print-utils.h" + +#define PRINT_PAGE_SETUP_NAME "print-page-setup" + + +#ifndef EMBED_PAGE_SETUP +void +print_page_setup_dialog (GtkPrintOperation *operation) +{ + GtkPrintSettings *settings; + GtkPageSetup *setup; + + g_return_if_fail (GTK_IS_PRINT_OPERATION (operation)); + + setup = gtk_print_operation_get_default_page_setup (operation); + + settings = gtk_print_settings_new (); + setup = gtk_print_run_page_setup_dialog (NULL, setup, settings); + g_object_unref (settings); + + gtk_print_operation_set_default_page_setup (operation, setup); +} +#endif + +void +print_page_setup_load (GtkPrintOperation *operation, + gint32 image_ID) +{ + GKeyFile *key_file; + + g_return_if_fail (GTK_IS_PRINT_OPERATION (operation)); + + key_file = print_utils_key_file_load_from_parasite (image_ID, + PRINT_PAGE_SETUP_NAME); + + if (! key_file) + key_file = print_utils_key_file_load_from_rcfile (PRINT_PAGE_SETUP_NAME); + + if (key_file) + { + GtkPageSetup *setup; + + setup = gtk_page_setup_new_from_key_file (key_file, + PRINT_PAGE_SETUP_NAME, NULL); + + if (setup) + { + gtk_print_operation_set_default_page_setup (operation, setup); + g_object_unref (setup); + } + + g_key_file_free (key_file); + } +} + +void +print_page_setup_save (GtkPrintOperation *operation, + gint32 image_ID) +{ + GtkPageSetup *setup; + GKeyFile *key_file; + + g_return_if_fail (GTK_IS_PRINT_OPERATION (operation)); + + key_file = g_key_file_new (); + + setup = gtk_print_operation_get_default_page_setup (operation); + + gtk_page_setup_to_key_file (setup, key_file, PRINT_PAGE_SETUP_NAME); + + print_utils_key_file_save_as_parasite (key_file, + image_ID, PRINT_PAGE_SETUP_NAME); + print_utils_key_file_save_as_rcfile (key_file, + PRINT_PAGE_SETUP_NAME); + + g_key_file_free (key_file); +} diff --git a/plug-ins/print/print-page-setup.h b/plug-ins/print/print-page-setup.h new file mode 100644 index 0000000..8440e10 --- /dev/null +++ b/plug-ins/print/print-page-setup.h @@ -0,0 +1,27 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + + +#ifndef EMBED_PAGE_SETUP +void print_page_setup_dialog (GtkPrintOperation *operation); +#endif +void print_page_setup_load (GtkPrintOperation *operation, + gint32 image_ID); +void print_page_setup_save (GtkPrintOperation *operation, + gint32 image_ID); + + diff --git a/plug-ins/print/print-preview.c b/plug-ins/print/print-preview.c new file mode 100644 index 0000000..366a4c4 --- /dev/null +++ b/plug-ins/print/print-preview.c @@ -0,0 +1,880 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "print-preview.h" + + +enum +{ + OFFSETS_CHANGED, + LAST_SIGNAL +}; + + +#define SIZE_REQUEST 200 + + +struct _PrintPreview +{ + GtkEventBox parent_instance; + + GdkCursor *cursor; + + GtkPageSetup *page; + cairo_surface_t *thumbnail; + gboolean dragging; + gboolean inside; + + gint32 drawable_id; + + gdouble image_offset_x; + gdouble image_offset_y; + gdouble image_offset_x_max; + gdouble image_offset_y_max; + gdouble image_width; + gdouble image_height; + + gboolean use_full_page; + + /* for mouse drags */ + gdouble orig_offset_x; + gdouble orig_offset_y; + gint start_x; + gint start_y; +}; + +struct _PrintPreviewClass +{ + GtkEventBoxClass parent_class; + + void (* offsets_changed) (PrintPreview *print_preview, + gint offset_x, + gint offset_y); +}; + + +static void print_preview_finalize (GObject *object); + +static void print_preview_realize (GtkWidget *widget); +static void print_preview_unrealize (GtkWidget *widget); +static void print_preview_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void print_preview_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static gboolean print_preview_expose_event (GtkWidget *widget, + GdkEventExpose *event); +static gboolean print_preview_button_press_event (GtkWidget *widget, + GdkEventButton *event); +static gboolean print_preview_button_release_event (GtkWidget *widget, + GdkEventButton *event); +static gboolean print_preview_motion_notify_event (GtkWidget *widget, + GdkEventMotion *event); +static gboolean print_preview_leave_notify_event (GtkWidget *widget, + GdkEventCrossing *event); + +static gboolean print_preview_is_inside (PrintPreview *preview, + gdouble x, + gdouble y); +static void print_preview_set_inside (PrintPreview *preview, + gboolean inside); + +static gdouble print_preview_get_scale (PrintPreview *preview); + +static void print_preview_get_page_size (PrintPreview *preview, + gdouble *paper_width, + gdouble *paper_height); +static void print_preview_get_page_margins (PrintPreview *preview, + gdouble *left_margin, + gdouble *right_margin, + gdouble *top_margin, + gdouble *bottom_margin); +static cairo_surface_t * print_preview_get_thumbnail (gint32 drawable_id, + gint width, + gint height); + + +G_DEFINE_TYPE (PrintPreview, print_preview, GTK_TYPE_EVENT_BOX) + +#define parent_class print_preview_parent_class + +static guint print_preview_signals[LAST_SIGNAL] = { 0 }; + + +#define g_marshal_value_peek_double(v) (v)->data[0].v_double + +static void +marshal_VOID__DOUBLE_DOUBLE (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__DOUBLE_DOUBLE) (gpointer data1, + gdouble arg_1, + gdouble arg_2, + gpointer data2); + register GMarshalFunc_VOID__DOUBLE_DOUBLE callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + + callback = (GMarshalFunc_VOID__DOUBLE_DOUBLE) (marshal_data ? + marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_double (param_values + 1), + g_marshal_value_peek_double (param_values + 2), + data2); +} + +static void +print_preview_class_init (PrintPreviewClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + print_preview_signals[OFFSETS_CHANGED] = + g_signal_new ("offsets-changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (PrintPreviewClass, offsets_changed), + NULL, NULL, + marshal_VOID__DOUBLE_DOUBLE, + G_TYPE_NONE, 2, + G_TYPE_DOUBLE, + G_TYPE_DOUBLE); + + object_class->finalize = print_preview_finalize; + + widget_class->realize = print_preview_realize; + widget_class->unrealize = print_preview_unrealize; + widget_class->size_request = print_preview_size_request; + widget_class->size_allocate = print_preview_size_allocate; + widget_class->expose_event = print_preview_expose_event; + widget_class->button_press_event = print_preview_button_press_event; + widget_class->button_release_event = print_preview_button_release_event; + widget_class->motion_notify_event = print_preview_motion_notify_event; + widget_class->leave_notify_event = print_preview_leave_notify_event; + + klass->offsets_changed = NULL; +} + +static void +print_preview_init (PrintPreview *preview) +{ + gtk_event_box_set_visible_window (GTK_EVENT_BOX (preview), FALSE); + + gtk_widget_add_events (GTK_WIDGET (preview), + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK); +} + + +static void +print_preview_finalize (GObject *object) +{ + PrintPreview *preview = PRINT_PREVIEW (object); + + if (preview->thumbnail) + { + cairo_surface_destroy (preview->thumbnail); + preview->thumbnail = NULL; + } + + if (preview->page) + { + g_object_unref (preview->page); + preview->page = NULL; + } + + G_OBJECT_CLASS (print_preview_parent_class)->finalize (object); +} + +static void +print_preview_realize (GtkWidget *widget) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + GTK_WIDGET_CLASS (print_preview_parent_class)->realize (widget); + + preview->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), + GDK_HAND1); +} + +static void +print_preview_unrealize (GtkWidget *widget) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + if (preview->cursor) + gdk_cursor_unref (preview->cursor); + + GTK_WIDGET_CLASS (print_preview_parent_class)->unrealize (widget); +} + +static void +print_preview_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + gdouble paper_width; + gdouble paper_height; + gint border; + + border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1; + + print_preview_get_page_size (preview, &paper_width, &paper_height); + + if (paper_width > paper_height) + { + requisition->height = SIZE_REQUEST; + requisition->width = paper_width * SIZE_REQUEST / paper_height; + requisition->width = MIN (requisition->width, 2 * SIZE_REQUEST); + } + else + { + requisition->width = SIZE_REQUEST; + requisition->height = paper_height * SIZE_REQUEST / paper_width; + requisition->height = MIN (requisition->height, 2 * SIZE_REQUEST); + } + + requisition->width += 2 * border; + requisition->height += 2 * border; +} + +static void +print_preview_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + GTK_WIDGET_CLASS (print_preview_parent_class)->size_allocate (widget, + allocation); + + if (preview->thumbnail) + { + cairo_surface_destroy (preview->thumbnail); + preview->thumbnail = NULL; + } +} + +static gboolean +print_preview_button_press_event (GtkWidget *widget, + GdkEventButton *event) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + if (event->type == GDK_BUTTON_PRESS && event->button == 1 && preview->inside) + { + GdkCursor *cursor; + + cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), + GDK_FLEUR); + + if (gdk_pointer_grab (event->window, FALSE, + (GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK), + NULL, cursor, event->time) == GDK_GRAB_SUCCESS) + { + preview->orig_offset_x = preview->image_offset_x; + preview->orig_offset_y = preview->image_offset_y; + + preview->start_x = event->x; + preview->start_y = event->y; + + preview->dragging = TRUE; + } + + gdk_cursor_unref (cursor); + } + + return FALSE; +} + +static gboolean +print_preview_button_release_event (GtkWidget *widget, + GdkEventButton *event) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + if (preview->dragging) + { + gdk_display_pointer_ungrab (gtk_widget_get_display (widget), + event->time); + preview->dragging = FALSE; + + print_preview_set_inside (preview, + print_preview_is_inside (preview, + event->x, event->y)); + } + + return FALSE; +} + +static gboolean +print_preview_motion_notify_event (GtkWidget *widget, + GdkEventMotion *event) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + if (preview->dragging) + { + gdouble scale = print_preview_get_scale (preview); + gdouble offset_x; + gdouble offset_y; + + offset_x = (preview->orig_offset_x + + (event->x - preview->start_x) / scale); + offset_y = (preview->orig_offset_y + + (event->y - preview->start_y) / scale); + + offset_x = CLAMP (offset_x, 0, preview->image_offset_x_max); + offset_y = CLAMP (offset_y, 0, preview->image_offset_y_max); + + if (preview->image_offset_x != offset_x || + preview->image_offset_y != offset_y) + { + print_preview_set_image_offsets (preview, offset_x, offset_y); + + g_signal_emit (preview, + print_preview_signals[OFFSETS_CHANGED], 0, + preview->image_offset_x, + preview->image_offset_y); + } + } + else + { + print_preview_set_inside (preview, + print_preview_is_inside (preview, + event->x, event->y)); + } + + return FALSE; +} + +static gboolean +print_preview_leave_notify_event (GtkWidget *widget, + GdkEventCrossing *event) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + + if (event->mode == GDK_CROSSING_NORMAL) + print_preview_set_inside (preview, FALSE); + + return FALSE; +} + +static gboolean +print_preview_expose_event (GtkWidget *widget, + GdkEventExpose *event) +{ + PrintPreview *preview = PRINT_PREVIEW (widget); + GtkStyle *style = gtk_widget_get_style (widget); + GtkAllocation allocation; + cairo_t *cr; + gdouble paper_width; + gdouble paper_height; + gdouble left_margin; + gdouble right_margin; + gdouble top_margin; + gdouble bottom_margin; + gdouble scale; + gint border; + + gtk_widget_get_allocation (widget, &allocation); + + border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1; + + print_preview_get_page_size (preview, &paper_width, &paper_height); + print_preview_get_page_margins (preview, + &left_margin, &right_margin, + &top_margin, &bottom_margin); + + scale = print_preview_get_scale (preview); + + cr = gdk_cairo_create (gtk_widget_get_window (widget)); + + cairo_translate (cr, + allocation.x + border, + allocation.y + border); + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + { + gint width = allocation.width - 2 * border; + + cairo_translate (cr, width - scale * paper_width, 0); + } + + cairo_set_line_width (cr, 1.0); + + /* draw page background */ + cairo_rectangle (cr, 0, 0, scale * paper_width, scale * paper_height); + + gdk_cairo_set_source_color (cr, &style->black); + cairo_stroke_preserve (cr); + + gdk_cairo_set_source_color (cr, &style->white); + cairo_fill (cr); + + /* draw page_margins */ + cairo_rectangle (cr, + scale * left_margin, + scale * top_margin, + scale * (paper_width - left_margin - right_margin), + scale * (paper_height - top_margin - bottom_margin)); + + gdk_cairo_set_source_color (cr, &style->mid[gtk_widget_get_state (widget)]); + cairo_stroke (cr); + + cairo_translate (cr, + scale * (left_margin + preview->image_offset_x), + scale * (top_margin + preview->image_offset_y)); + + if (preview->dragging || preview->inside) + { + cairo_rectangle (cr, + 0, 0, + scale * preview->image_width, + scale * preview->image_height); + + gdk_cairo_set_source_color (cr, &style->black); + cairo_stroke (cr); + } + + if (preview->thumbnail == NULL && + gimp_item_is_valid (preview->drawable_id)) + { + preview->thumbnail = + print_preview_get_thumbnail (preview->drawable_id, + MIN (allocation.width, 1024), + MIN (allocation.height, 1024)); + } + + if (preview->thumbnail != NULL) + { + gdouble scale_x; + gdouble scale_y; + + scale_x = (preview->image_width / + cairo_image_surface_get_width (preview->thumbnail)); + scale_y = (preview->image_height / + cairo_image_surface_get_height (preview->thumbnail)); + + cairo_rectangle (cr, 0, 0, preview->image_width, preview->image_height); + + cairo_scale (cr, scale_x * scale, scale_y * scale); + + cairo_set_source_surface (cr, preview->thumbnail, 0, 0); + cairo_fill (cr); + } + + cairo_destroy (cr); + + return FALSE; +} + +/** + * print_preview_new: + * @page: page setup + * @drawable_id: the drawable to print + * + * Creates a new #PrintPreview widget. + * + * Return value: the new #PrintPreview widget. + **/ +GtkWidget * +print_preview_new (GtkPageSetup *page, + gint32 drawable_id) +{ + PrintPreview *preview; + + g_return_val_if_fail (GTK_IS_PAGE_SETUP (page), NULL); + + preview = g_object_new (PRINT_TYPE_PREVIEW, NULL); + + preview->drawable_id = drawable_id; + + print_preview_set_page_setup (preview, page); + + return GTK_WIDGET (preview); +} + +/** + * print_preview_set_image_dpi: + * @preview: a #PrintPreview. + * @xres: the X resolution + * @yres: the Y resolution + * + * Sets the resolution of the image/drawable displayed by the + * #PrintPreview. + **/ +void +print_preview_set_image_dpi (PrintPreview *preview, + gdouble xres, + gdouble yres) +{ + gdouble width; + gdouble height; + + g_return_if_fail (PRINT_IS_PREVIEW (preview)); + g_return_if_fail (xres > 0.0 && yres > 0.0); + + width = gimp_drawable_width (preview->drawable_id) * 72.0 / xres; + height = gimp_drawable_height (preview->drawable_id) * 72.0 / yres; + + if (width != preview->image_width || height != preview->image_height) + { + preview->image_width = width; + preview->image_height = height; + + gtk_widget_queue_draw (GTK_WIDGET (preview)); + } +} + +/** + * print_preview_set_page_setup: + * @preview: a #PrintPreview. + * @page: the page setup to use + * + * Sets the page setup to use by the #PrintPreview. + **/ +void +print_preview_set_page_setup (PrintPreview *preview, + GtkPageSetup *page) +{ + g_return_if_fail (PRINT_IS_PREVIEW (preview)); + g_return_if_fail (GTK_IS_PAGE_SETUP (page)); + + if (preview->page) + g_object_unref (preview->page); + + preview->page = gtk_page_setup_copy (page); + + gtk_widget_queue_resize (GTK_WIDGET (preview)); +} + +/** + * print_preview_set_image_offsets: + * @preview: a #PrintPreview. + * @offset_x: the X offset + * @offset_y: the Y offset + * + * Sets the offsets of the image/drawable displayed by the #PrintPreview. + * It does not emit the "offsets-changed" signal. + **/ +void +print_preview_set_image_offsets (PrintPreview *preview, + gdouble offset_x, + gdouble offset_y) +{ + g_return_if_fail (PRINT_IS_PREVIEW (preview)); + + preview->image_offset_x = offset_x; + preview->image_offset_y = offset_y; + + gtk_widget_queue_draw (GTK_WIDGET (preview)); +} + +/** + * print_preview_set_image_offsets_max: + * @preview: a #PrintPreview. + * @offset_x_max: the maximum X offset allowed + * @offset_y_max: the maximum Y offset allowed + * + * Sets the maximum offsets of the image/drawable displayed by the + * #PrintPreview. It does not emit the "offsets-changed" signal. + **/ +void +print_preview_set_image_offsets_max (PrintPreview *preview, + gdouble offset_x_max, + gdouble offset_y_max) +{ + g_return_if_fail (PRINT_IS_PREVIEW (preview)); + + preview->image_offset_x_max = offset_x_max; + preview->image_offset_y_max = offset_y_max; + + gtk_widget_queue_draw (GTK_WIDGET (preview)); +} + +/** + * print_preview_set_use_full_page: + * @preview: a #PrintPreview. + * @full_page: TRUE to ignore the page margins + * + * If @full_page is TRUE, the page margins are ignored and the full page + * can be used to setup printing. + **/ +void +print_preview_set_use_full_page (PrintPreview *preview, + gboolean full_page) +{ + g_return_if_fail (PRINT_IS_PREVIEW (preview)); + + preview->use_full_page = full_page; + + gtk_widget_queue_draw (GTK_WIDGET (preview)); +} + +static gboolean +print_preview_is_inside (PrintPreview *preview, + gdouble x, + gdouble y) +{ + GtkWidget *widget = GTK_WIDGET (preview); + GtkAllocation allocation; + gdouble left_margin; + gdouble right_margin; + gdouble top_margin; + gdouble bottom_margin; + gdouble scale; + gint border; + + gtk_widget_get_allocation (widget, &allocation); + + border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1; + + x -= border; + + scale = print_preview_get_scale (preview); + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + { + gdouble paper_width; + gdouble paper_height; + gint width = allocation.width - 2 * border; + + print_preview_get_page_size (preview, &paper_width, &paper_height); + + x -= width - scale * paper_width; + } + + print_preview_get_page_margins (preview, + &left_margin, &right_margin, + &top_margin, &bottom_margin); + + x = x / scale - left_margin; + y = y / scale - top_margin; + + return (x > preview->image_offset_x && + x < preview->image_offset_x + preview->image_width && + y > preview->image_offset_y && + y < preview->image_offset_y + preview->image_height); +} + +static void +print_preview_set_inside (PrintPreview *preview, + gboolean inside) +{ + if (inside != preview->inside) + { + GtkWidget *widget = GTK_WIDGET (preview); + + preview->inside = inside; + + if (gtk_widget_is_drawable (widget)) + gdk_window_set_cursor (gtk_widget_get_window (widget), + inside ? preview->cursor : NULL); + + gtk_widget_queue_draw (widget); + } +} + +static gdouble +print_preview_get_scale (PrintPreview *preview) +{ + GtkWidget *widget = GTK_WIDGET (preview); + GtkAllocation allocation; + gdouble paper_width; + gdouble paper_height; + gdouble scale_x; + gdouble scale_y; + gint border; + + gtk_widget_get_allocation (widget, &allocation); + + border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1; + + print_preview_get_page_size (preview, &paper_width, &paper_height); + + scale_x = (gdouble) (allocation.width - 2 * border) / paper_width; + scale_y = (gdouble) (allocation.height - 2 * border) / paper_height; + + return MIN (scale_x, scale_y); +} + +static void +print_preview_get_page_size (PrintPreview *preview, + gdouble *paper_width, + gdouble *paper_height) +{ + *paper_width = gtk_page_setup_get_paper_width (preview->page, + GTK_UNIT_POINTS); + *paper_height = gtk_page_setup_get_paper_height (preview->page, + GTK_UNIT_POINTS); +} + +static void +print_preview_get_page_margins (PrintPreview *preview, + gdouble *left_margin, + gdouble *right_margin, + gdouble *top_margin, + gdouble *bottom_margin) +{ + if (preview->use_full_page) + { + *left_margin = 0.0; + *right_margin = 0.0; + *top_margin = 0.0; + *bottom_margin = 0.0; + } + else + { + *left_margin = gtk_page_setup_get_left_margin (preview->page, + GTK_UNIT_POINTS); + *right_margin = gtk_page_setup_get_right_margin (preview->page, + GTK_UNIT_POINTS); + *top_margin = gtk_page_setup_get_top_margin (preview->page, + GTK_UNIT_POINTS); + *bottom_margin = gtk_page_setup_get_bottom_margin (preview->page, + GTK_UNIT_POINTS); + } +} + + +/* This thumbnail code should eventually end up in libgimpui. */ + +static cairo_surface_t * +print_preview_get_thumbnail (gint32 drawable_id, + gint width, + gint height) +{ + cairo_surface_t *surface; + cairo_format_t format; + guchar *data; + guchar *dest; + const guchar *src; + gint src_stride; + gint dest_stride; + gint y; + gint bpp; + + g_return_val_if_fail (width > 0 && width <= 1024, NULL); + g_return_val_if_fail (height > 0 && height <= 1024, NULL); + + data = gimp_drawable_get_thumbnail_data (drawable_id, + &width, &height, &bpp); + + switch (bpp) + { + case 1: + case 3: + format = CAIRO_FORMAT_RGB24; + break; + + case 2: + case 4: + format = CAIRO_FORMAT_ARGB32; + break; + + default: + g_assert_not_reached (); + break; + } + + surface = cairo_image_surface_create (format, width, height); + + src = data; + src_stride = width * bpp; + + dest = cairo_image_surface_get_data (surface); + dest_stride = cairo_image_surface_get_stride (surface); + + for (y = 0; y < height; y++) + { + const guchar *s = src; + guchar *d = dest; + gint w = width; + + switch (bpp) + { + case 1: + while (w--) + { + GIMP_CAIRO_RGB24_SET_PIXEL (d, s[0], s[0], s[0]); + s += 1; + d += 4; + } + break; + + case 2: + while (w--) + { + GIMP_CAIRO_ARGB32_SET_PIXEL (d, s[0], s[0], s[0], s[1]); + s += 2; + d += 4; + } + break; + + case 3: + while (w--) + { + GIMP_CAIRO_RGB24_SET_PIXEL (d, s[0], s[1], s[2]); + s += 3; + d += 4; + } + break; + + case 4: + while (w--) + { + GIMP_CAIRO_ARGB32_SET_PIXEL (d, s[0], s[1], s[2], s[3]); + s += 4; + d += 4; + } + break; + } + + src += src_stride; + dest += dest_stride; + } + + g_free (data); + + cairo_surface_mark_dirty (surface); + + return surface; +} diff --git a/plug-ins/print/print-preview.h b/plug-ins/print/print-preview.h new file mode 100644 index 0000000..dc4e172 --- /dev/null +++ b/plug-ins/print/print-preview.h @@ -0,0 +1,60 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __PRINT_PREVIEW_H__ +#define __PRINT_PREVIEW_H__ + +G_BEGIN_DECLS + + +#define PRINT_TYPE_PREVIEW (print_preview_get_type ()) +#define PRINT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PRINT_TYPE_PREVIEW, PrintPreview)) +#define PRINT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PRINT_TYPE_PREVIEW, PrintPreviewClass)) +#define PRINT_IS_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PRINT_TYPE_PREVIEW)) +#define PRINT_IS_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PRINT_TYPE_PREVIEW)) +#define PRINT_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PRINT_TYPE_PREVIEW, PrintPreviewClass)) + +typedef struct _PrintPreview PrintPreview; +typedef struct _PrintPreviewClass PrintPreviewClass; + + +GType print_preview_get_type (void) G_GNUC_CONST; + +GtkWidget * print_preview_new (GtkPageSetup *page, + gint32 drawable_id); + +void print_preview_set_image_dpi (PrintPreview *preview, + gdouble xres, + gdouble yres); + +void print_preview_set_page_setup (PrintPreview *preview, + GtkPageSetup *page); + +void print_preview_set_image_offsets (PrintPreview *preview, + gdouble offset_x, + gdouble offset_y); + +void print_preview_set_image_offsets_max (PrintPreview *preview, + gdouble offset_x_max, + gdouble offset_y_max); + +void print_preview_set_use_full_page (PrintPreview *preview, + gboolean full_page); + +G_END_DECLS + +#endif /* __PRINT_PREVIEW_H__ */ diff --git a/plug-ins/print/print-settings.c b/plug-ins/print/print-settings.c new file mode 100644 index 0000000..617282f --- /dev/null +++ b/plug-ins/print/print-settings.c @@ -0,0 +1,320 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "print.h" +#include "print-settings.h" +#include "print-utils.h" + + +#define PRINT_SETTINGS_MAJOR_VERSION 0 +#define PRINT_SETTINGS_MINOR_VERSION 4 + +#define PRINT_SETTINGS_NAME "print-settings" + + +static GKeyFile * print_settings_key_file_from_settings (PrintData *data); + +static void print_settings_add_to_key_file (const gchar *key, + const gchar *value, + gpointer data); + +static GKeyFile * print_settings_key_file_from_resource_file (void); + +static GKeyFile * print_settings_key_file_from_parasite (gint32 image_ID); + +static gboolean print_settings_load_from_key_file (PrintData *data, + GKeyFile *key_file); + +static gboolean print_settings_check_version (GKeyFile *key_file); + +/* + * set GtkPrintSettings from the contents of a "print-settings" + * image parasite, or, if none exists, from a resource + * file of the same name + */ +gboolean +print_settings_load (PrintData *data) +{ + GKeyFile *key_file = print_settings_key_file_from_parasite (data->image_id); + + if (! key_file) + key_file = print_settings_key_file_from_resource_file (); + + if (key_file) + { + print_settings_load_from_key_file (data, key_file); + g_key_file_free (key_file); + return TRUE; + } + + return FALSE; +} + +/* + * save all settings as a resource file "print-settings" + * and as an image parasite + */ +void +print_settings_save (PrintData *data) +{ + GKeyFile *key_file = print_settings_key_file_from_settings (data); + + /* image setup */ + if (gimp_image_is_valid (data->image_id)) + { + gdouble xres; + gdouble yres; + + gimp_image_get_resolution (data->image_id, &xres, &yres); + + g_key_file_set_integer (key_file, "image-setup", + "unit", data->unit); + /* Do not save the print resolution when it is the expected image + * resolution so that changing it (i.e. in "print size" dialog) + * is not overridden by any previous prints. + */ + if ((data->min_xres <= xres && ABS (xres - data->xres) > 0.1) || + (data->min_yres <= yres && ABS (yres - data->yres) > 0.1) || + (data->min_xres > xres && ABS (data->min_xres - data->xres) > 0.1) || + (data->min_yres > yres && ABS (data->min_yres - data->yres) > 0.1)) + { + g_key_file_set_double (key_file, "image-setup", + "x-resolution", data->xres); + g_key_file_set_double (key_file, "image-setup", + "y-resolution", data->yres); + } + g_key_file_set_double (key_file, "image-setup", + "x-offset", data->offset_x); + g_key_file_set_double (key_file, "image-setup", + "y-offset", data->offset_y); + g_key_file_set_integer (key_file, "image-setup", + "center-mode", data->center); + g_key_file_set_boolean (key_file, "image-setup", + "use-full-page", data->use_full_page); + g_key_file_set_boolean (key_file, "image-setup", + "crop-marks", data->draw_crop_marks); + + print_utils_key_file_save_as_parasite (key_file, + data->image_id, + PRINT_SETTINGS_NAME); + } + + /* some settings shouldn't be made persistent on a global level, + * so they are only stored in the image, not in the rcfile + */ + + g_key_file_remove_key (key_file, "image-setup", "x-resolution", NULL); + g_key_file_remove_key (key_file, "image-setup", "y-resolution", NULL); + g_key_file_remove_key (key_file, "image-setup", "x-offset", NULL); + g_key_file_remove_key (key_file, "image-setup", "y-offset", NULL); + + g_key_file_remove_key (key_file, PRINT_SETTINGS_NAME, "n-copies", NULL); + + print_utils_key_file_save_as_rcfile (key_file, PRINT_SETTINGS_NAME); + + g_key_file_free (key_file); +} + +/* + * serialize print settings into a GKeyFile + */ +static GKeyFile * +print_settings_key_file_from_settings (PrintData *data) +{ + GtkPrintOperation *operation = data->operation; + GtkPrintSettings *settings; + GKeyFile *key_file = g_key_file_new (); + + /* put version information into the file */ + g_key_file_set_integer (key_file, "meta", "major-version", + PRINT_SETTINGS_MAJOR_VERSION); + g_key_file_set_integer (key_file, "meta", "minor-version", + PRINT_SETTINGS_MINOR_VERSION); + + /* save the contents of the GtkPrintSettings for the operation */ + settings = gtk_print_operation_get_print_settings (operation); + + if (settings) + gtk_print_settings_foreach (settings, + print_settings_add_to_key_file, key_file); + + return key_file; +} + +/* + * callback used in gtk_print_settings_foreach loop + */ +static void +print_settings_add_to_key_file (const gchar *key, + const gchar *value, + gpointer data) +{ + GKeyFile *key_file = data; + + g_key_file_set_value (key_file, PRINT_SETTINGS_NAME, key, value); +} + +/* + * deserialize a "print-settings" resource file into a GKeyFile + */ +static GKeyFile * +print_settings_key_file_from_resource_file (void) +{ + GKeyFile *key_file; + + key_file = print_utils_key_file_load_from_rcfile (PRINT_SETTINGS_NAME); + + if (key_file && ! print_settings_check_version (key_file)) + { + g_key_file_free (key_file); + return NULL; + } + + return key_file; +} + +/* load information from an image parasite called "print-settings" + * return a GKeyFile containing the information if a valid parasite is found, + * NULL otherwise + */ +static GKeyFile * +print_settings_key_file_from_parasite (gint32 image_ID) +{ + GKeyFile *key_file; + + key_file = print_utils_key_file_load_from_parasite (image_ID, + PRINT_SETTINGS_NAME); + + if (key_file && ! print_settings_check_version (key_file)) + { + g_key_file_free (key_file); + return NULL; + } + + return key_file; +} + +static gboolean +print_settings_load_from_key_file (PrintData *data, + GKeyFile *key_file) +{ + GtkPrintOperation *operation = data->operation; + GtkPrintSettings *settings; + gchar **keys; + gsize n_keys; + gint i; + + settings = gtk_print_operation_get_print_settings (operation); + if (! settings) + settings = gtk_print_settings_new (); + + keys = g_key_file_get_keys (key_file, PRINT_SETTINGS_NAME, &n_keys, NULL); + + if (! keys) + return FALSE; + + for (i = 0; i < n_keys; i++) + { + gchar *value; + + value = g_key_file_get_value (key_file, + PRINT_SETTINGS_NAME, keys[i], NULL); + + if (value) + { + gtk_print_settings_set (settings, keys[i], value); + g_free (value); + } + } + + g_strfreev (keys); + + if (g_key_file_has_key (key_file, "image-setup", "unit", NULL)) + { + data->unit = g_key_file_get_integer (key_file, "image-setup", + "unit", NULL); + } + + if (g_key_file_has_key (key_file, "image-setup", "x-resolution", NULL) && + g_key_file_has_key (key_file, "image-setup", "y-resolution", NULL)) + { + data->xres = g_key_file_get_double (key_file, "image-setup", + "x-resolution", NULL); + data->yres = g_key_file_get_double (key_file, "image-setup", + "y-resolution", NULL); + } + + if (g_key_file_has_key (key_file, "image-setup", "x-offset", NULL) && + g_key_file_has_key (key_file, "image-setup", "y-offset", NULL)) + { + data->offset_x = g_key_file_get_double (key_file, "image-setup", + "x-offset", NULL); + data->offset_y = g_key_file_get_double (key_file, "image-setup", + "y-offset", NULL); + } + + if (g_key_file_has_key (key_file, "image-setup", "center-mode", NULL)) + { + data->center = g_key_file_get_integer (key_file, "image-setup", + "center-mode", NULL); + } + + if (g_key_file_has_key (key_file, "image-setup", "use-full-page", NULL)) + { + data->use_full_page = g_key_file_get_boolean (key_file, "image-setup", + "use-full-page", NULL); + } + + if (g_key_file_has_key (key_file, "image-setup", "crop-marks", NULL)) + { + data->draw_crop_marks = g_key_file_get_boolean (key_file, "image-setup", + "crop-marks", NULL); + } + + gtk_print_operation_set_print_settings (operation, settings); + + return TRUE; +} + +static gboolean +print_settings_check_version (GKeyFile *key_file) +{ + gint major_version; + gint minor_version; + + if (! g_key_file_has_group (key_file, "meta")) + return FALSE; + + major_version = g_key_file_get_integer (key_file, + "meta", "major-version", NULL); + + if (major_version != PRINT_SETTINGS_MAJOR_VERSION) + return FALSE; + + minor_version = g_key_file_get_integer (key_file, + "meta", "minor-version", NULL); + + if (minor_version != PRINT_SETTINGS_MINOR_VERSION) + return FALSE; + + return TRUE; +} diff --git a/plug-ins/print/print-settings.h b/plug-ins/print/print-settings.h new file mode 100644 index 0000000..0120f07 --- /dev/null +++ b/plug-ins/print/print-settings.h @@ -0,0 +1,19 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +gboolean print_settings_load (PrintData *data); +void print_settings_save (PrintData *data); diff --git a/plug-ins/print/print-utils.c b/plug-ins/print/print-utils.c new file mode 100644 index 0000000..a1b057b --- /dev/null +++ b/plug-ins/print/print-utils.c @@ -0,0 +1,145 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <libgimp/gimp.h> + +#include "print-utils.h" + + +GKeyFile * +print_utils_key_file_load_from_rcfile (const gchar *basename) +{ + GKeyFile *key_file; + gchar *filename; + + g_return_val_if_fail (basename != NULL, NULL); + + filename = g_build_filename (gimp_directory (), basename, NULL); + + key_file = g_key_file_new (); + + if (! g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL)) + { + g_key_file_free (key_file); + key_file = NULL; + } + + g_free (filename); + + return key_file; +} + +GKeyFile * +print_utils_key_file_load_from_parasite (gint32 image_ID, + const gchar *parasite_name) +{ + GimpParasite *parasite; + GKeyFile *key_file; + GError *error = NULL; + + g_return_val_if_fail (parasite_name != NULL, NULL); + + parasite = gimp_image_get_parasite (image_ID, parasite_name); + + if (! parasite) + return NULL; + + key_file = g_key_file_new (); + + if (! g_key_file_load_from_data (key_file, + gimp_parasite_data (parasite), + gimp_parasite_data_size (parasite), + G_KEY_FILE_NONE, &error)) + { + g_key_file_free (key_file); + gimp_parasite_free (parasite); + + g_warning ("Unable to create key file from image parasite '%s': %s", + parasite_name, error->message); + g_error_free (error); + return NULL; + } + + gimp_parasite_free (parasite); + + return key_file; +} + +void +print_utils_key_file_save_as_rcfile (GKeyFile *key_file, + const gchar *basename) +{ + gchar *filename; + gchar *contents; + gsize length; + GError *error = NULL; + + g_return_if_fail (basename != NULL); + + contents = g_key_file_to_data (key_file, &length, &error); + + if (! contents) + { + g_warning ("Unable to get contents of key file for '%s': %s", + basename, error->message); + g_error_free (error); + return; + } + + filename = g_build_filename (gimp_directory (), basename, NULL); + + if (! g_file_set_contents (filename, contents, length, &error)) + { + g_warning ("Unable to write settings to '%s': %s", + gimp_filename_to_utf8 (filename), error->message); + g_error_free (error); + } + + g_free (filename); + g_free (contents); +} + +void +print_utils_key_file_save_as_parasite (GKeyFile *key_file, + gint32 image_ID, + const gchar *parasite_name) +{ + GimpParasite *parasite; + gchar *contents; + gsize length; + GError *error = NULL; + + g_return_if_fail (parasite_name != NULL); + + contents = g_key_file_to_data (key_file, &length, &error); + + if (! contents) + { + g_warning ("Unable to get contents of key file for parasite '%s': %s", + parasite_name, error->message); + g_error_free (error); + return; + } + + parasite = gimp_parasite_new (parasite_name, 0, length, contents); + g_free (contents); + + gimp_image_attach_parasite (image_ID, parasite); + gimp_parasite_free (parasite); +} diff --git a/plug-ins/print/print-utils.h b/plug-ins/print/print-utils.h new file mode 100644 index 0000000..78aa12a --- /dev/null +++ b/plug-ins/print/print-utils.h @@ -0,0 +1,26 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +GKeyFile * print_utils_key_file_load_from_rcfile (const gchar *basename); +GKeyFile * print_utils_key_file_load_from_parasite (gint32 image_ID, + const gchar *parasite_name); + +void print_utils_key_file_save_as_rcfile (GKeyFile *key_file, + const gchar *basename); +void print_utils_key_file_save_as_parasite (GKeyFile *key_file, + gint32 image_ID, + const gchar *parasite_name); diff --git a/plug-ins/print/print.c b/plug-ins/print/print.c new file mode 100644 index 0000000..57b83ce --- /dev/null +++ b/plug-ins/print/print.c @@ -0,0 +1,503 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <string.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "print.h" +#include "print-settings.h" +#include "print-page-layout.h" +#include "print-page-setup.h" +#include "print-draw-page.h" + +#include "libgimp/stdplugins-intl.h" + + +#define PLUG_IN_BINARY "print" +#define PLUG_IN_ROLE "gimp-print" +#define PRINT_PROC_NAME "file-print-gtk" + +#ifndef EMBED_PAGE_SETUP +#define PAGE_SETUP_PROC_NAME "file-print-gtk-page-setup" +#define PRINT_TEMP_PROC_NAME "file-print-gtk-page-setup-notify-temp" +#endif + +G_DEFINE_QUARK (gimp-plugin-print-error-quark, gimp_plugin_print_error) + +static void query (void); +static void run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals); + +static GimpPDBStatusType print_image (gint32 image_ID, + gboolean interactive, + GError **error); +#ifndef EMBED_PAGE_SETUP +static GimpPDBStatusType page_setup (gint32 image_ID); +#endif + +static void print_show_error (const gchar *message); +static void print_operation_set_name (GtkPrintOperation *operation, + gint image_ID); + +static void begin_print (GtkPrintOperation *operation, + GtkPrintContext *context, + PrintData *data); +static void end_print (GtkPrintOperation *operation, + GtkPrintContext *context, + gint32 *layer_ID); +static void draw_page (GtkPrintOperation *print, + GtkPrintContext *context, + gint page_nr, + PrintData *data); + +static GtkWidget * create_custom_widget (GtkPrintOperation *operation, + PrintData *data); + +#ifndef EMBED_PAGE_SETUP +static gchar * print_temp_proc_name (gint32 image_ID); +static gchar * print_temp_proc_install (gint32 image_ID); + +/* Keep a reference to the current GtkPrintOperation + * for access by the temporary procedure. + */ +static GtkPrintOperation *print_operation = NULL; +#endif + + +const GimpPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ +}; + +MAIN () + +static void +query (void) +{ + static const GimpParamDef print_args[] = + { + { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0) }" }, + { GIMP_PDB_IMAGE, "image", "Image to print" } + }; + + gimp_install_procedure (PRINT_PROC_NAME, + N_("Print the image"), + "Print the image using the GTK+ Print API.", + "Bill Skaggs, Sven Neumann, Stefan Röllin", + "Bill Skaggs <weskaggs@primate.ucdavis.edu>", + "2006 - 2008", + N_("_Print..."), + "*", + GIMP_PLUGIN, + G_N_ELEMENTS (print_args), 0, + print_args, NULL); + + gimp_plugin_menu_register (PRINT_PROC_NAME, "<Image>/File/Send"); + gimp_plugin_icon_register (PRINT_PROC_NAME, GIMP_ICON_TYPE_ICON_NAME, + (const guint8 *) GIMP_ICON_DOCUMENT_PRINT); + +#ifndef EMBED_PAGE_SETUP + gimp_install_procedure (PAGE_SETUP_PROC_NAME, + N_("Adjust page size and orientation for printing"), + "Adjust page size and orientation for printing the " + "image using the GTK+ Print API.", + "Bill Skaggs, Sven Neumann, Stefan Röllin", + "Sven Neumann <sven@gimp.org>", + "2008", + N_("Page Set_up..."), + "*", + GIMP_PLUGIN, + G_N_ELEMENTS (print_args), 0, + print_args, NULL); + + gimp_plugin_menu_register (PAGE_SETUP_PROC_NAME, "<Image>/File/Send"); + gimp_plugin_icon_register (PAGE_SETUP_PROC_NAME, GIMP_ICON_TYPE_ICON_NAME, + (const guint8 *) GIMP_ICON_DOCUMENT_PAGE_SETUP); +#endif +} + +static void +run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[2]; + GimpRunMode run_mode; + GimpPDBStatusType status; + gint32 image_ID; + GError *error = NULL; + + INIT_I18N (); + gegl_init (NULL, NULL); + + run_mode = param[0].data.d_int32; + + *nreturn_vals = 1; + *return_vals = values; + + values[0].type = GIMP_PDB_STATUS; + values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; + + image_ID = param[1].data.d_int32; + + if (strcmp (name, PRINT_PROC_NAME) == 0) + { + status = print_image (image_ID, run_mode == GIMP_RUN_INTERACTIVE, &error); + + if (error && run_mode == GIMP_RUN_INTERACTIVE) + { + print_show_error (error->message); + } + } +#ifndef EMBED_PAGE_SETUP + else if (strcmp (name, PAGE_SETUP_PROC_NAME) == 0) + { + if (run_mode == GIMP_RUN_INTERACTIVE) + { + status = page_setup (image_ID); + } + else + { + status = GIMP_PDB_CALLING_ERROR; + } + } +#endif + else + { + status = GIMP_PDB_CALLING_ERROR; + } + + if (status != GIMP_PDB_SUCCESS && error) + { + *nreturn_vals = 2; + values[1].type = GIMP_PDB_STRING; + values[1].data.d_string = error->message; + } + + values[0].data.d_status = status; +} + +static GimpPDBStatusType +print_image (gint32 image_ID, + gboolean interactive, + GError **error) +{ + GtkPrintOperation *operation; + GtkPrintOperationResult result; + gint32 layer; + PrintData data; +#ifndef EMBED_PAGE_SETUP + gchar *temp_proc; +#endif + + /* create a print layer from the projection */ + layer = gimp_layer_new_from_visible (image_ID, image_ID, PRINT_PROC_NAME); + + operation = gtk_print_operation_new (); + + gtk_print_operation_set_n_pages (operation, 1); + print_operation_set_name (operation, image_ID); + + print_page_setup_load (operation, image_ID); + + /* fill in the PrintData struct */ + data.image_id = image_ID; + data.drawable_id = layer; + data.unit = gimp_get_default_unit (); + data.image_unit = gimp_image_get_unit (image_ID); + data.offset_x = 0; + data.offset_y = 0; + data.center = CENTER_BOTH; + data.use_full_page = FALSE; + data.draw_crop_marks = FALSE; + data.operation = operation; + + gimp_image_get_resolution (image_ID, &data.xres, &data.yres); + + print_settings_load (&data); + + gtk_print_operation_set_unit (operation, GTK_UNIT_PIXEL); + + g_signal_connect (operation, "begin-print", + G_CALLBACK (begin_print), + &data); + g_signal_connect (operation, "draw-page", + G_CALLBACK (draw_page), + &data); + g_signal_connect (operation, "end-print", + G_CALLBACK (end_print), + &layer); + +#ifndef EMBED_PAGE_SETUP + print_operation = operation; + temp_proc = print_temp_proc_install (image_ID); + gimp_extension_enable (); +#endif + + if (interactive) + { + gimp_ui_init (PLUG_IN_BINARY, FALSE); + + g_signal_connect_swapped (operation, "end-print", + G_CALLBACK (print_settings_save), + &data); + + g_signal_connect (operation, "create-custom-widget", + G_CALLBACK (create_custom_widget), + &data); + + gtk_print_operation_set_custom_tab_label (operation, _("Image Settings")); + +#ifdef EMBED_PAGE_SETUP + gtk_print_operation_set_embed_page_setup (operation, TRUE); +#endif + + result = gtk_print_operation_run (operation, + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, + NULL, error); + + if (result == GTK_PRINT_OPERATION_RESULT_APPLY || + result == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS) + { + print_page_setup_save (operation, image_ID); + } + } + else + { + result = gtk_print_operation_run (operation, + GTK_PRINT_OPERATION_ACTION_PRINT, + NULL, error); + } + +#ifndef EMBED_PAGE_SETUP + gimp_uninstall_temp_proc (temp_proc); + g_free (temp_proc); + print_operation = NULL; +#endif + + g_object_unref (operation); + + if (gimp_item_is_valid (layer)) + gimp_item_delete (layer); + + switch (result) + { + case GTK_PRINT_OPERATION_RESULT_APPLY: + case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: + return GIMP_PDB_SUCCESS; + + case GTK_PRINT_OPERATION_RESULT_CANCEL: + return GIMP_PDB_CANCEL; + + case GTK_PRINT_OPERATION_RESULT_ERROR: + return GIMP_PDB_EXECUTION_ERROR; + } + + return GIMP_PDB_EXECUTION_ERROR; +} + +#ifndef EMBED_PAGE_SETUP +static GimpPDBStatusType +page_setup (gint32 image_ID) +{ + GtkPrintOperation *operation; + GimpParam *return_vals; + gchar *name; + gint n_return_vals; + + gimp_ui_init (PLUG_IN_BINARY, FALSE); + + operation = gtk_print_operation_new (); + + print_page_setup_load (operation, image_ID); + print_page_setup_dialog (operation); + print_page_setup_save (operation, image_ID); + + g_object_unref (operation); + + /* now notify a running print procedure about this change */ + name = print_temp_proc_name (image_ID); + + /* we don't want the core to show an error message if the + * temporary procedure does not exist + */ + gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN); + + return_vals = gimp_run_procedure (name, + &n_return_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + gimp_destroy_params (return_vals, n_return_vals); + + g_free (name); + + return GIMP_PDB_SUCCESS; +} +#endif + +static void +print_show_error (const gchar *message) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "%s", + _("An error occurred while trying to print:")); + + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s", message); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} + +static void +print_operation_set_name (GtkPrintOperation *operation, + gint image_ID) +{ + gchar *name = gimp_image_get_name (image_ID); + + gtk_print_operation_set_job_name (operation, name); + + g_free (name); +} + +static void +begin_print (GtkPrintOperation *operation, + GtkPrintContext *context, + PrintData *data) +{ + gtk_print_operation_set_use_full_page (operation, data->use_full_page); + + gimp_progress_init (_("Printing")); +} + +static void +end_print (GtkPrintOperation *operation, + GtkPrintContext *context, + gint32 *layer_ID) +{ + /* we don't need the print layer any longer, delete it */ + if (gimp_item_is_valid (*layer_ID)) + { + gimp_item_delete (*layer_ID); + *layer_ID = -1; + } + + gimp_progress_end (); + + /* generate events to solve the problems described in bug #466928 */ + g_timeout_add_seconds (1, (GSourceFunc) gtk_true, NULL); +} + +static void +draw_page (GtkPrintOperation *operation, + GtkPrintContext *context, + gint page_nr, + PrintData *data) +{ + GError *error = NULL; + + if (print_draw_page (context, data, &error)) + { + gimp_progress_update (1.0); + } + else + { + print_show_error (error->message); + g_error_free (error); + } +} + + +/* + * This callback creates a "custom" widget that gets inserted into the + * print operation dialog. + */ +static GtkWidget * +create_custom_widget (GtkPrintOperation *operation, + PrintData *data) +{ + return print_page_layout_gui (data, PRINT_PROC_NAME); +} + +#ifndef EMBED_PAGE_SETUP +static void +print_temp_proc_run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[1]; + + values[0].type = GIMP_PDB_STATUS; + values[0].data.d_status = GIMP_PDB_SUCCESS; + + *nreturn_vals = 1; + *return_vals = values; + + if (print_operation && nparams == 1) + print_page_setup_load (print_operation, param[0].data.d_int32); +} + +static gchar * +print_temp_proc_name (gint32 image_ID) +{ + return g_strdup_printf (PRINT_TEMP_PROC_NAME "-%d", image_ID); +} + +static gchar * +print_temp_proc_install (gint32 image_ID) +{ + static const GimpParamDef args[] = + { + { GIMP_PDB_IMAGE, "image", "Image to print" } + }; + + gchar *name = print_temp_proc_name (image_ID); + + gimp_install_temp_proc (name, + "DON'T USE THIS ONE", + "Temporary procedure to notify the Print plug-in " + "about changes to the Page Setup.", + "Sven Neumann", + "Sven Neumann", + "2008", + NULL, + "", + GIMP_TEMPORARY, + G_N_ELEMENTS (args), 0, args, NULL, + print_temp_proc_run); + + return name; +} +#endif diff --git a/plug-ins/print/print.h b/plug-ins/print/print.h new file mode 100644 index 0000000..7a863e4 --- /dev/null +++ b/plug-ins/print/print.h @@ -0,0 +1,56 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 3 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, see <https://www.gnu.org/licenses/>. + */ + + +#ifndef G_OS_WIN32 +#define EMBED_PAGE_SETUP 1 +#endif + +#define GIMP_PLUGIN_PRINT_ERROR gimp_plugin_print_error_quark () + +typedef enum +{ + GIMP_PLUGIN_PRINT_ERROR_FAILED +} GimpPluginPrintError; + +GQuark gimp_plugin_print_error_quark (void); + +typedef enum +{ + CENTER_NONE = 0, + CENTER_HORIZONTALLY = 1, + CENTER_VERTICALLY = 2, + CENTER_BOTH = 3 +} PrintCenterMode; + +typedef struct +{ + gint32 image_id; + gint32 drawable_id; + GimpUnit unit; + gdouble xres; + gdouble yres; + gdouble min_xres; + gdouble min_yres; + GimpUnit image_unit; + gdouble offset_x; + gdouble offset_y; + PrintCenterMode center; + gboolean use_full_page; + gboolean draw_crop_marks; + GtkPrintOperation *operation; +} PrintData; |