diff options
Diffstat (limited to 'app/file')
-rw-r--r-- | app/file/Makefile.am | 26 | ||||
-rw-r--r-- | app/file/Makefile.in | 937 | ||||
-rw-r--r-- | app/file/file-import.c | 109 | ||||
-rw-r--r-- | app/file/file-import.h | 31 | ||||
-rw-r--r-- | app/file/file-open.c | 833 | ||||
-rw-r--r-- | app/file/file-open.h | 87 | ||||
-rw-r--r-- | app/file/file-remote.c | 401 | ||||
-rw-r--r-- | app/file/file-remote.h | 48 | ||||
-rw-r--r-- | app/file/file-save.c | 325 | ||||
-rw-r--r-- | app/file/file-save.h | 36 | ||||
-rw-r--r-- | app/file/file-utils.c | 249 | ||||
-rw-r--r-- | app/file/file-utils.h | 33 | ||||
-rw-r--r-- | app/file/gimp-file.h | 30 |
13 files changed, 3145 insertions, 0 deletions
diff --git a/app/file/Makefile.am b/app/file/Makefile.am new file mode 100644 index 0000000..90b107f --- /dev/null +++ b/app/file/Makefile.am @@ -0,0 +1,26 @@ +## Process this file with automake to produce Makefile.in + +AM_CPPFLAGS = \ + -DG_LOG_DOMAIN=\"Gimp-File\" \ + -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_builddir)/app \ + -I$(top_srcdir)/app \ + $(GEGL_CFLAGS) \ + $(GDK_PIXBUF_CFLAGS) \ + -I$(includedir) + +noinst_LIBRARIES = libappfile.a + +libappfile_a_SOURCES = \ + file-import.c \ + file-import.h \ + file-open.c \ + file-open.h \ + file-remote.c \ + file-remote.h \ + file-save.c \ + file-save.h \ + file-utils.c \ + file-utils.h \ + gimp-file.h diff --git a/app/file/Makefile.in b/app/file/Makefile.in new file mode 100644 index 0000000..a7e18ed --- /dev/null +++ b/app/file/Makefile.in @@ -0,0 +1,937 @@ +# 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@ + +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@ +subdir = app/file +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 = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libappfile_a_AR = $(AR) $(ARFLAGS) +libappfile_a_LIBADD = +am_libappfile_a_OBJECTS = file-import.$(OBJEXT) file-open.$(OBJEXT) \ + file-remote.$(OBJEXT) file-save.$(OBJEXT) file-utils.$(OBJEXT) +libappfile_a_OBJECTS = $(am_libappfile_a_OBJECTS) +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)/file-import.Po \ + ./$(DEPDIR)/file-open.Po ./$(DEPDIR)/file-remote.Po \ + ./$(DEPDIR)/file-save.Po ./$(DEPDIR)/file-utils.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +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 = +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 = $(libappfile_a_SOURCES) +DIST_SOURCES = $(libappfile_a_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)/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 = @libexecdir@ +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@ +AM_CPPFLAGS = \ + -DG_LOG_DOMAIN=\"Gimp-File\" \ + -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_builddir)/app \ + -I$(top_srcdir)/app \ + $(GEGL_CFLAGS) \ + $(GDK_PIXBUF_CFLAGS) \ + -I$(includedir) + +noinst_LIBRARIES = libappfile.a +libappfile_a_SOURCES = \ + file-import.c \ + file-import.h \ + file-open.c \ + file-open.h \ + file-remote.c \ + file-remote.h \ + file-save.c \ + file-save.h \ + file-utils.c \ + file-utils.h \ + gimp-file.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(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 app/file/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu app/file/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_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): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +libappfile.a: $(libappfile_a_OBJECTS) $(libappfile_a_DEPENDENCIES) $(EXTRA_libappfile_a_DEPENDENCIES) + $(AM_V_at)-rm -f libappfile.a + $(AM_V_AR)$(libappfile_a_AR) libappfile.a $(libappfile_a_OBJECTS) $(libappfile_a_LIBADD) + $(AM_V_at)$(RANLIB) libappfile.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-import.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-open.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-remote.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-save.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-utils.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 $(LIBRARIES) +installdirs: +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-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/file-import.Po + -rm -f ./$(DEPDIR)/file-open.Po + -rm -f ./$(DEPDIR)/file-remote.Po + -rm -f ./$(DEPDIR)/file-save.Po + -rm -f ./$(DEPDIR)/file-utils.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-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)/file-import.Po + -rm -f ./$(DEPDIR)/file-open.Po + -rm -f ./$(DEPDIR)/file-remote.Po + -rm -f ./$(DEPDIR)/file-save.Po + -rm -f ./$(DEPDIR)/file-utils.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: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-noinstLIBRARIES \ + 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-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 + +.PRECIOUS: Makefile + + +# 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/app/file/file-import.c b/app/file/file-import.c new file mode 100644 index 0000000..f5e9baf --- /dev/null +++ b/app/file/file-import.c @@ -0,0 +1,109 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * file-import.c + * + * 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 <gdk-pixbuf/gdk-pixbuf.h> +#include <gegl.h> + +#include "core/core-types.h" + +#include "config/gimpcoreconfig.h" + +#include "core/gimp.h" +#include "core/gimpcontext.h" +#include "core/gimpimage.h" +#include "core/gimpimage-color-profile.h" +#include "core/gimpimage-convert-precision.h" +#include "core/gimplayer.h" +#include "core/gimpprogress.h" + +#include "text/gimptextlayer.h" + +#include "file-import.h" + + +/* public functions */ + +void +file_import_image (GimpImage *image, + GimpContext *context, + GFile *file, + gboolean interactive, + GimpProgress *progress) +{ + GimpCoreConfig *config; + + g_return_if_fail (GIMP_IS_IMAGE (image)); + g_return_if_fail (GIMP_IS_CONTEXT (context)); + g_return_if_fail (G_IS_FILE (file)); + g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress)); + + config = image->gimp->config; + + if (interactive && gimp_image_get_base_type (image) != GIMP_INDEXED) + { + if (config->import_promote_float) + { + GimpPrecision old_precision = gimp_image_get_precision (image); + + if (old_precision != GIMP_PRECISION_FLOAT_LINEAR) + { + gimp_image_convert_precision (image, + GIMP_PRECISION_FLOAT_LINEAR, + GEGL_DITHER_NONE, + GEGL_DITHER_NONE, + GEGL_DITHER_NONE, + progress); + + if (config->import_promote_dither && + old_precision == GIMP_PRECISION_U8_GAMMA) + { + gimp_image_convert_dither_u8 (image, progress); + } + } + } + + if (config->import_add_alpha) + { + GList *layers = gimp_image_get_layer_list (image); + GList *list; + + for (list = layers; list; list = g_list_next (list)) + { + if (! gimp_viewable_get_children (list->data) && + ! gimp_item_is_text_layer (list->data) && + ! gimp_drawable_has_alpha (list->data)) + { + gimp_layer_add_alpha (list->data); + } + } + + g_list_free (layers); + } + } + + gimp_image_import_color_profile (image, context, progress, interactive); + + /* Remember the import source */ + gimp_image_set_imported_file (image, file); + + /* We shall treat this file as an Untitled file */ + gimp_image_set_file (image, NULL); +} diff --git a/app/file/file-import.h b/app/file/file-import.h new file mode 100644 index 0000000..d23eff6 --- /dev/null +++ b/app/file/file-import.h @@ -0,0 +1,31 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * file-import.h + * + * 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 __FILE_IMPORT_H__ +#define __FILE_IMPORT_H__ + + +void file_import_image (GimpImage *image, + GimpContext *context, + GFile *file, + gboolean interactive, + GimpProgress *progress); + + +#endif /* __FILE_IMPORT_H__ */ diff --git a/app/file/file-open.c b/app/file/file-open.c new file mode 100644 index 0000000..b3ae129 --- /dev/null +++ b/app/file/file-open.c @@ -0,0 +1,833 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis + * Copyright (C) 1997 Josh MacDonald + * + * file-open.c + * + * 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 <gdk-pixbuf/gdk-pixbuf.h> +#include <gegl.h> + +#include "libgimpbase/gimpbase.h" + +#include "core/core-types.h" + +#include "gegl/gimp-babl.h" + +#include "core/gimp.h" +#include "core/gimpcontext.h" +#include "core/gimpdocumentlist.h" +#include "core/gimpimage.h" +#include "core/gimpimage-merge.h" +#include "core/gimpimage-undo.h" +#include "core/gimpimagefile.h" +#include "core/gimplayer.h" +#include "core/gimpparamspecs.h" +#include "core/gimpprogress.h" + +#include "pdb/gimppdb.h" + +#include "plug-in/gimppluginmanager-file.h" +#include "plug-in/gimppluginprocedure.h" + +#include "file-import.h" +#include "file-open.h" +#include "file-remote.h" +#include "gimp-file.h" + +#include "gimp-intl.h" + + +static void file_open_sanitize_image (GimpImage *image, + gboolean as_new); +static void file_open_convert_items (GimpImage *dest_image, + const gchar *basename, + GList *items); +static GList * file_open_get_layers (GimpImage *image, + gboolean merge_visible, + gint *n_visible); +static gboolean file_open_file_proc_is_import (GimpPlugInProcedure *file_proc); + + +/* public functions */ + +GimpImage * +file_open_image (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + GFile *entered_file, + gboolean as_new, + GimpPlugInProcedure *file_proc, + GimpRunMode run_mode, + GimpPDBStatusType *status, + const gchar **mime_type, + GError **error) +{ + GimpValueArray *return_vals; + GimpImage *image = NULL; + GFile *local_file = NULL; + gchar *path = NULL; + gchar *entered_uri = NULL; + gboolean mounted = TRUE; + GError *my_error = NULL; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (G_IS_FILE (entered_file), NULL); + g_return_val_if_fail (status != NULL, NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + *status = GIMP_PDB_EXECUTION_ERROR; + + if (! g_file_is_native (file) && + ! file_remote_mount_file (gimp, file, progress, &my_error)) + { + if (my_error) + { + g_printerr ("%s: mounting remote volume failed, trying to download" + "the file: %s\n", + G_STRFUNC, my_error->message); + g_clear_error (&my_error); + + mounted = FALSE; + } + else + { + *status = GIMP_PDB_CANCEL; + + return NULL; + } + } + + /* FIXME enable these tests for remote files again, needs testing */ + if (g_file_is_native (file) && + g_file_query_exists (file, NULL)) + { + GFileInfo *info; + + info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_TYPE "," + G_FILE_ATTRIBUTE_ACCESS_CAN_READ, + G_FILE_QUERY_INFO_NONE, + NULL, error); + if (! info) + return NULL; + + if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR) + { + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Not a regular file")); + g_object_unref (info); + return NULL; + } + + if (! g_file_info_get_attribute_boolean (info, + G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) + { + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Permission denied")); + g_object_unref (info); + return NULL; + } + + g_object_unref (info); + } + + if (! file_proc) + file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager, + GIMP_FILE_PROCEDURE_GROUP_OPEN, + file, error); + + if (! file_proc || ! file_proc->handles_uri || ! mounted) + { + gchar *my_path = g_file_get_path (file); + + if (! my_path) + { + g_clear_error (error); + + local_file = file_remote_download_image (gimp, file, progress, + &my_error); + + if (! local_file) + { + if (my_error) + g_propagate_error (error, my_error); + else + *status = GIMP_PDB_CANCEL; + + return NULL; + } + + /* if we don't have a file proc yet, try again on the local + * file + */ + if (! file_proc) + file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager, + GIMP_FILE_PROCEDURE_GROUP_OPEN, + local_file, error); + } + + g_free (my_path); + } + + if (! file_proc) + { + if (local_file) + { + g_file_delete (local_file, NULL, NULL); + g_object_unref (local_file); + } + + return NULL; + } + + if (file_proc->handles_uri) + path = g_file_get_uri (local_file ? local_file : file); + else + path = g_file_get_path (local_file ? local_file : file); + + entered_uri = g_file_get_uri (entered_file); + + if (! entered_uri) + entered_uri = g_strdup (path); + + if (progress) + g_object_add_weak_pointer (G_OBJECT (progress), (gpointer) &progress); + + return_vals = + gimp_pdb_execute_procedure_by_name (gimp->pdb, + context, progress, error, + gimp_object_get_name (file_proc), + GIMP_TYPE_INT32, run_mode, + G_TYPE_STRING, path, + G_TYPE_STRING, entered_uri, + G_TYPE_NONE); + + if (progress) + g_object_remove_weak_pointer (G_OBJECT (progress), (gpointer) &progress); + + g_free (path); + g_free (entered_uri); + + *status = g_value_get_enum (gimp_value_array_index (return_vals, 0)); + + if (*status == GIMP_PDB_SUCCESS) + image = gimp_value_get_image (gimp_value_array_index (return_vals, 1), + gimp); + + if (local_file) + { + if (image) + gimp_image_set_file (image, file); + + g_file_delete (local_file, NULL, NULL); + g_object_unref (local_file); + } + + if (*status == GIMP_PDB_SUCCESS) + { + if (image) + { + /* Only set the load procedure if it hasn't already been set. */ + if (! gimp_image_get_load_proc (image)) + gimp_image_set_load_proc (image, file_proc); + + file_proc = gimp_image_get_load_proc (image); + + if (mime_type) + *mime_type = g_slist_nth_data (file_proc->mime_types_list, 0); + } + else + { + if (error && ! *error) + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("%s plug-in returned SUCCESS but did not " + "return an image"), + gimp_procedure_get_label (GIMP_PROCEDURE (file_proc))); + + *status = GIMP_PDB_EXECUTION_ERROR; + } + } + else if (*status != GIMP_PDB_CANCEL) + { + if (error && ! *error) + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("%s plug-in could not open image"), + gimp_procedure_get_label (GIMP_PROCEDURE (file_proc))); + } + + gimp_value_array_unref (return_vals); + + if (image) + { + gimp_image_undo_disable (image); + + if (file_open_file_proc_is_import (file_proc)) + { + file_import_image (image, context, file, + run_mode == GIMP_RUN_INTERACTIVE, + progress); + } + + /* Enables undo again */ + file_open_sanitize_image (image, as_new); + } + + return image; +} + +/** + * file_open_thumbnail: + * @gimp: + * @context: + * @progress: + * @file: an image file + * @size: requested size of the thumbnail + * @mime_type: return location for image MIME type + * @image_width: return location for image width + * @image_height: return location for image height + * @format: return location for image format (set to NULL if unknown) + * @num_layers: return location for number of layers + * (set to -1 if the number of layers is not known) + * @error: + * + * Attempts to load a thumbnail by using a registered thumbnail loader. + * + * Return value: the thumbnail image + */ +GimpImage * +file_open_thumbnail (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + gint size, + const gchar **mime_type, + gint *image_width, + gint *image_height, + const Babl **format, + gint *num_layers, + GError **error) +{ + GimpPlugInProcedure *file_proc; + GimpProcedure *procedure; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (mime_type != NULL, NULL); + g_return_val_if_fail (image_width != NULL, NULL); + g_return_val_if_fail (image_height != NULL, NULL); + g_return_val_if_fail (format != NULL, NULL); + g_return_val_if_fail (num_layers != NULL, NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + *image_width = 0; + *image_height = 0; + *format = NULL; + *num_layers = -1; + + file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager, + GIMP_FILE_PROCEDURE_GROUP_OPEN, + file, NULL); + + if (! file_proc || ! file_proc->thumb_loader) + return NULL; + + procedure = gimp_pdb_lookup_procedure (gimp->pdb, file_proc->thumb_loader); + + if (procedure && procedure->num_args >= 2 && procedure->num_values >= 1) + { + GimpPDBStatusType status; + GimpValueArray *return_vals; + GimpImage *image = NULL; + gchar *path = NULL; + + if (! file_proc->handles_uri) + path = g_file_get_path (file); + + if (! path) + path = g_file_get_uri (file); + + return_vals = + gimp_pdb_execute_procedure_by_name (gimp->pdb, + context, progress, error, + gimp_object_get_name (procedure), + G_TYPE_STRING, path, + GIMP_TYPE_INT32, size, + G_TYPE_NONE); + + g_free (path); + + status = g_value_get_enum (gimp_value_array_index (return_vals, 0)); + + if (status == GIMP_PDB_SUCCESS && + GIMP_VALUE_HOLDS_IMAGE_ID (gimp_value_array_index (return_vals, 1))) + { + image = gimp_value_get_image (gimp_value_array_index (return_vals, 1), + gimp); + + if (gimp_value_array_length (return_vals) >= 3 && + G_VALUE_HOLDS_INT (gimp_value_array_index (return_vals, 2)) && + G_VALUE_HOLDS_INT (gimp_value_array_index (return_vals, 3))) + { + *image_width = + MAX (0, g_value_get_int (gimp_value_array_index (return_vals, 2))); + + *image_height = + MAX (0, g_value_get_int (gimp_value_array_index (return_vals, 3))); + + if (gimp_value_array_length (return_vals) >= 5 && + G_VALUE_HOLDS_INT (gimp_value_array_index (return_vals, 4))) + { + gint value = g_value_get_int (gimp_value_array_index (return_vals, 4)); + + switch (value) + { + case GIMP_RGB_IMAGE: + *format = gimp_babl_format (GIMP_RGB, + GIMP_PRECISION_U8_GAMMA, + FALSE); + break; + + case GIMP_RGBA_IMAGE: + *format = gimp_babl_format (GIMP_RGB, + GIMP_PRECISION_U8_GAMMA, + TRUE); + break; + + case GIMP_GRAY_IMAGE: + *format = gimp_babl_format (GIMP_GRAY, + GIMP_PRECISION_U8_GAMMA, + FALSE); + break; + + case GIMP_GRAYA_IMAGE: + *format = gimp_babl_format (GIMP_GRAY, + GIMP_PRECISION_U8_GAMMA, + TRUE); + break; + + case GIMP_INDEXED_IMAGE: + case GIMP_INDEXEDA_IMAGE: + { + const Babl *rgb; + const Babl *rgba; + + babl_new_palette ("-gimp-indexed-format-dummy", + &rgb, &rgba); + + if (value == GIMP_INDEXED_IMAGE) + *format = rgb; + else + *format = rgba; + } + break; + + default: + break; + } + } + + if (gimp_value_array_length (return_vals) >= 6 && + G_VALUE_HOLDS_INT (gimp_value_array_index (return_vals, 5))) + { + *num_layers = + MAX (0, g_value_get_int (gimp_value_array_index (return_vals, 5))); + } + } + + if (image) + { + file_open_sanitize_image (image, FALSE); + + *mime_type = g_slist_nth_data (file_proc->mime_types_list, 0); + +#ifdef GIMP_UNSTABLE + g_printerr ("opened thumbnail at %d x %d\n", + gimp_image_get_width (image), + gimp_image_get_height (image)); +#endif + } + } + + gimp_value_array_unref (return_vals); + + return image; + } + + return NULL; +} + +GimpImage * +file_open_with_display (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + gboolean as_new, + GObject *screen, + gint monitor, + GimpPDBStatusType *status, + GError **error) +{ + return file_open_with_proc_and_display (gimp, context, progress, + file, file, as_new, NULL, + screen, monitor, + status, error); +} + +GimpImage * +file_open_with_proc_and_display (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + GFile *entered_file, + gboolean as_new, + GimpPlugInProcedure *file_proc, + GObject *screen, + gint monitor, + GimpPDBStatusType *status, + GError **error) +{ + GimpImage *image; + const gchar *mime_type = NULL; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (G_IS_FILE (entered_file), NULL); + g_return_val_if_fail (screen == NULL || G_IS_OBJECT (screen), NULL); + g_return_val_if_fail (status != NULL, NULL); + + image = file_open_image (gimp, context, progress, + file, + entered_file, + as_new, + file_proc, + GIMP_RUN_INTERACTIVE, + status, + &mime_type, + error); + + if (image) + { + /* If the file was imported we want to set the layer name to the + * file name. For now, assume that multi-layered imported images + * have named the layers already, so only rename the layer of + * single-layered imported files. Note that this will also + * rename already named layers from e.g. single-layered PSD + * files. To solve this properly, we would need new file plug-in + * API. + */ + if (! file_proc) + file_proc = gimp_image_get_load_proc (image); + + if (file_open_file_proc_is_import (file_proc) && + gimp_image_get_n_layers (image) == 1) + { + GimpObject *layer = gimp_image_get_layer_iter (image)->data; + gchar *basename; + + basename = g_path_get_basename (gimp_file_get_utf8_name (file)); + + gimp_item_rename (GIMP_ITEM (layer), basename, NULL); + gimp_image_undo_free (image); + gimp_image_clean_all (image); + + g_free (basename); + } + + if (gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0, + screen, monitor)) + { + /* the display owns the image now */ + g_object_unref (image); + } + + if (! as_new) + { + GimpDocumentList *documents = GIMP_DOCUMENT_LIST (gimp->documents); + GimpImagefile *imagefile; + GFile *any_file; + + imagefile = gimp_document_list_add_file (documents, file, mime_type); + + /* can only create a thumbnail if the passed file and the + * resulting image's file match. Use any_file() here so we + * create thumbnails for both XCF and imported images. + */ + any_file = gimp_image_get_any_file (image); + + if (any_file && g_file_equal (file, any_file)) + { + /* no need to save a thumbnail if there's a good one already */ + if (! gimp_imagefile_check_thumbnail (imagefile)) + { + gimp_imagefile_save_thumbnail (imagefile, mime_type, image, + NULL); + } + } + } + + /* announce that we opened this image */ + gimp_image_opened (image->gimp, file); + } + + return image; +} + +GList * +file_open_layers (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GimpImage *dest_image, + gboolean merge_visible, + GFile *file, + GimpRunMode run_mode, + GimpPlugInProcedure *file_proc, + GimpPDBStatusType *status, + GError **error) +{ + GimpImage *new_image; + GList *layers = NULL; + const gchar *mime_type = NULL; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); + g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (status != NULL, NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + new_image = file_open_image (gimp, context, progress, + file, file, FALSE, + file_proc, + run_mode, + status, &mime_type, error); + + if (new_image) + { + gint n_visible = 0; + + gimp_image_undo_disable (new_image); + + layers = file_open_get_layers (new_image, merge_visible, &n_visible); + + if (merge_visible && n_visible > 1) + { + GimpLayer *layer; + + g_list_free (layers); + + layer = gimp_image_merge_visible_layers (new_image, context, + GIMP_CLIP_TO_IMAGE, + FALSE, FALSE, + NULL); + + layers = g_list_prepend (NULL, layer); + } + + if (layers) + { + gchar *basename; + + basename = g_path_get_basename (gimp_file_get_utf8_name (file)); + file_open_convert_items (dest_image, basename, layers); + g_free (basename); + + gimp_document_list_add_file (GIMP_DOCUMENT_LIST (gimp->documents), + file, mime_type); + } + else + { + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Image doesn't contain any layers")); + *status = GIMP_PDB_EXECUTION_ERROR; + } + + g_object_unref (new_image); + } + + return g_list_reverse (layers); +} + + +/* This function is called for filenames passed on the command-line + * or from the D-Bus service. + */ +gboolean +file_open_from_command_line (Gimp *gimp, + GFile *file, + gboolean as_new, + GObject *screen, + gint monitor) + +{ + GimpImage *image; + GimpObject *display; + GimpPDBStatusType status; + gboolean success = FALSE; + GError *error = NULL; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); + g_return_val_if_fail (G_IS_FILE (file), FALSE); + g_return_val_if_fail (screen == NULL || G_IS_OBJECT (screen), FALSE); + + display = gimp_get_empty_display (gimp); + + /* show the progress in the last opened display, see bug #704896 */ + if (! display) + display = gimp_context_get_display (gimp_get_user_context (gimp)); + + if (display) + g_object_add_weak_pointer (G_OBJECT (display), (gpointer) &display); + + image = file_open_with_display (gimp, + gimp_get_user_context (gimp), + GIMP_PROGRESS (display), + file, as_new, + screen, monitor, + &status, &error); + + if (image) + { + success = TRUE; + + g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_FILE_KEY, + g_object_ref (file), + (GDestroyNotify) g_object_unref); + } + else if (status != GIMP_PDB_CANCEL && display) + { + gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, + _("Opening '%s' failed: %s"), + gimp_file_get_utf8_name (file), error->message); + g_clear_error (&error); + } + + if (display) + g_object_remove_weak_pointer (G_OBJECT (display), (gpointer) &display); + + return success; +} + + +/* private functions */ + +static void +file_open_sanitize_image (GimpImage *image, + gboolean as_new) +{ + if (as_new) + gimp_image_set_file (image, NULL); + + /* clear all undo steps */ + gimp_image_undo_free (image); + + /* make sure that undo is enabled */ + while (! gimp_image_undo_is_enabled (image)) + gimp_image_undo_thaw (image); + + /* Set the image to clean. Note that export dirtiness is not set to + * clean here; we can only consider export clean after the first + * export + */ + gimp_image_clean_all (image); + + /* Make sure the projection is completely constructed from valid + * layers, this is needed in case something triggers projection or + * image preview creation before all layers are loaded, see bug #767663. + */ + gimp_image_invalidate_all (image); + + /* Make sure all image states are up-to-date */ + gimp_image_flush (image); +} + +/* Converts items from one image to another */ +static void +file_open_convert_items (GimpImage *dest_image, + const gchar *basename, + GList *items) +{ + GList *list; + + for (list = items; list; list = g_list_next (list)) + { + GimpItem *src = list->data; + GimpItem *item; + + item = gimp_item_convert (src, dest_image, G_TYPE_FROM_INSTANCE (src)); + + if (g_list_length (items) == 1) + { + gimp_object_set_name (GIMP_OBJECT (item), basename); + } + else + { + gimp_object_set_name (GIMP_OBJECT (item), + gimp_object_get_name (src)); + } + + list->data = item; + } +} + +static GList * +file_open_get_layers (GimpImage *image, + gboolean merge_visible, + gint *n_visible) +{ + GList *iter = NULL; + GList *layers = NULL; + + for (iter = gimp_image_get_layer_iter (image); + iter; + iter = g_list_next (iter)) + { + GimpItem *item = iter->data; + + if (! merge_visible) + layers = g_list_prepend (layers, item); + + if (gimp_item_get_visible (item)) + { + if (n_visible) + (*n_visible)++; + + if (! layers) + layers = g_list_prepend (layers, item); + } + } + + return layers; +} + +static gboolean +file_open_file_proc_is_import (GimpPlugInProcedure *file_proc) +{ + return !(file_proc && + file_proc->mime_types && + strcmp (file_proc->mime_types, "image/x-xcf") == 0); +} diff --git a/app/file/file-open.h b/app/file/file-open.h new file mode 100644 index 0000000..361dd1f --- /dev/null +++ b/app/file/file-open.h @@ -0,0 +1,87 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * file-open.h + * + * 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 __FILE_OPEN_H__ +#define __FILE_OPEN_H__ + + +GimpImage * file_open_image (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + GFile *entered_file, + gboolean as_new, + GimpPlugInProcedure *file_proc, + GimpRunMode run_mode, + GimpPDBStatusType *status, + const gchar **mime_type, + GError **error); + +GimpImage * file_open_thumbnail (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + gint size, + const gchar **mime_type, + gint *image_width, + gint *image_height, + const Babl **format, + gint *num_layers, + GError **error); +GimpImage * file_open_with_display (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + gboolean as_new, + GObject *screen, + gint monitor, + GimpPDBStatusType *status, + GError **error); + +GimpImage * file_open_with_proc_and_display (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GFile *file, + GFile *entered_file, + gboolean as_new, + GimpPlugInProcedure *file_proc, + GObject *screen, + gint monitor, + GimpPDBStatusType *status, + GError **error); + +GList * file_open_layers (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + GimpImage *dest_image, + gboolean merge_visible, + GFile *file, + GimpRunMode run_mode, + GimpPlugInProcedure *file_proc, + GimpPDBStatusType *status, + GError **error); + +gboolean file_open_from_command_line (Gimp *gimp, + GFile *file, + gboolean as_new, + GObject *screen, + gint monitor); + + +#endif /* __FILE_OPEN_H__ */ diff --git a/app/file/file-remote.c b/app/file/file-remote.c new file mode 100644 index 0000000..498115a --- /dev/null +++ b/app/file/file-remote.c @@ -0,0 +1,401 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * file-remote.c + * Copyright (C) 2014 Michael Natterer <mitch@gimp.org> + * + * Based on: URI plug-in, GIO/GVfs backend + * Copyright (C) 2008 Sven Neumann <sven@gimp.org> + * + * 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 <gegl.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +#include "libgimpbase/gimpbase.h" + +#include "core/core-types.h" + +#include "core/gimp.h" +#include "core/gimpprogress.h" + +#include "file-remote.h" + +#include "gimp-intl.h" + + +typedef enum +{ + DOWNLOAD, + UPLOAD +} RemoteCopyMode; + +typedef struct +{ + GimpProgress *progress; + GCancellable *cancellable; + gboolean cancel; + GMainLoop *main_loop; + GError *error; +} RemoteMount; + +typedef struct +{ + RemoteCopyMode mode; + GimpProgress *progress; + GCancellable *cancellable; + gboolean cancel; + gint64 last_time; +} RemoteProgress; + + +static void file_remote_mount_volume_ready (GFile *file, + GAsyncResult *result, + RemoteMount *mount); +static void file_remote_mount_file_cancel (GimpProgress *progress, + RemoteMount *mount); + +static GFile * file_remote_get_temp_file (Gimp *gimp, + GFile *file); +static gboolean file_remote_copy_file (Gimp *gimp, + GFile *src_file, + GFile *dest_file, + RemoteCopyMode mode, + GimpProgress *progress, + GError **error); +static void file_remote_copy_file_cancel (GimpProgress *progress, + RemoteProgress *remote_progress); + +static void file_remote_progress_callback (goffset current_num_bytes, + goffset total_num_bytes, + gpointer user_data); + + +/* public functions */ + +gboolean +file_remote_mount_file (Gimp *gimp, + GFile *file, + GimpProgress *progress, + GError **error) +{ + GMountOperation *operation; + RemoteMount mount = { 0, }; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); + g_return_val_if_fail (G_IS_FILE (file), FALSE); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + mount.progress = progress; + mount.main_loop = g_main_loop_new (NULL, FALSE); + + operation = gimp_get_mount_operation (gimp, progress); + + if (progress) + { + gimp_progress_start (progress, TRUE, _("Mounting remote volume")); + + mount.cancellable = g_cancellable_new (); + + g_signal_connect (progress, "cancel", + G_CALLBACK (file_remote_mount_file_cancel), + &mount); + } + + g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE, + operation, mount.cancellable, + (GAsyncReadyCallback) file_remote_mount_volume_ready, + &mount); + + g_main_loop_run (mount.main_loop); + g_main_loop_unref (mount.main_loop); + + if (progress) + { + g_signal_handlers_disconnect_by_func (progress, + file_remote_mount_file_cancel, + &mount); + + g_object_unref (mount.cancellable); + + gimp_progress_end (progress); + } + + g_object_unref (operation); + + if (mount.error) + { + if (mount.error->domain != G_IO_ERROR || + mount.error->code != G_IO_ERROR_ALREADY_MOUNTED) + { + g_propagate_error (error, mount.error); + return FALSE; + } + else + { + g_clear_error (&mount.error); + } + } + + return TRUE; +} + +GFile * +file_remote_download_image (Gimp *gimp, + GFile *file, + GimpProgress *progress, + GError **error) +{ + GFile *local_file; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + local_file = file_remote_get_temp_file (gimp, file); + + if (! file_remote_copy_file (gimp, file, local_file, DOWNLOAD, + progress, error)) + { + g_object_unref (local_file); + return NULL; + } + + return local_file; +} + +GFile * +file_remote_upload_image_prepare (Gimp *gimp, + GFile *file, + GimpProgress *progress, + GError **error) +{ + GFile *local_file; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + local_file = file_remote_get_temp_file (gimp, file); + + return local_file; +} + +gboolean +file_remote_upload_image_finish (Gimp *gimp, + GFile *file, + GFile *local_file, + GimpProgress *progress, + GError **error) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); + g_return_val_if_fail (G_IS_FILE (file), FALSE); + g_return_val_if_fail (G_IS_FILE (local_file), FALSE); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (! file_remote_copy_file (gimp, local_file, file, UPLOAD, + progress, error)) + { + return FALSE; + } + + return TRUE; +} + + +/* private functions */ + +static void +file_remote_mount_volume_ready (GFile *file, + GAsyncResult *result, + RemoteMount *mount) +{ + g_file_mount_enclosing_volume_finish (file, result, &mount->error); + + g_main_loop_quit (mount->main_loop); +} + +static void +file_remote_mount_file_cancel (GimpProgress *progress, + RemoteMount *mount) +{ + mount->cancel = TRUE; + + g_cancellable_cancel (mount->cancellable); +} + +static GFile * +file_remote_get_temp_file (Gimp *gimp, + GFile *file) +{ + gchar *basename; + GFile *temp_file = NULL; + + basename = g_path_get_basename (gimp_file_get_utf8_name (file)); + + if (basename) + { + const gchar *ext = strchr (basename, '.'); + + if (ext && strlen (ext)) + temp_file = gimp_get_temp_file (gimp, ext + 1); + + g_free (basename); + } + + if (! temp_file) + temp_file = gimp_get_temp_file (gimp, "xxx"); + + return temp_file; +} + +static gboolean +file_remote_copy_file (Gimp *gimp, + GFile *src_file, + GFile *dest_file, + RemoteCopyMode mode, + GimpProgress *progress, + GError **error) +{ + RemoteProgress remote_progress = { 0, }; + gboolean success; + GError *my_error = NULL; + + remote_progress.mode = mode; + remote_progress.progress = progress; + + if (progress) + { + gimp_progress_start (progress, TRUE, _("Opening remote file")); + + remote_progress.cancellable = g_cancellable_new (); + + g_signal_connect (progress, "cancel", + G_CALLBACK (file_remote_copy_file_cancel), + &remote_progress); + + success = g_file_copy (src_file, dest_file, G_FILE_COPY_OVERWRITE, + remote_progress.cancellable, + file_remote_progress_callback, &remote_progress, + &my_error); + + g_signal_handlers_disconnect_by_func (progress, + file_remote_copy_file_cancel, + &remote_progress); + + g_object_unref (remote_progress.cancellable); + + gimp_progress_set_value (progress, 1.0); + gimp_progress_end (progress); + } + else + { + success = g_file_copy (src_file, dest_file, G_FILE_COPY_OVERWRITE, + NULL, NULL, NULL, + &my_error); + } + + return success; +} + +static void +file_remote_copy_file_cancel (GimpProgress *progress, + RemoteProgress *remote_progress) +{ + remote_progress->cancel = TRUE; + + g_cancellable_cancel (remote_progress->cancellable); +} + +static void +file_remote_progress_callback (goffset current_num_bytes, + goffset total_num_bytes, + gpointer user_data) +{ + RemoteProgress *progress = user_data; + gint64 now; + + /* update the progress only up to 10 times a second */ + now = g_get_monotonic_time (); + + if ((now - progress->last_time) / 1000 < 100) + return; + + progress->last_time = now; + + if (total_num_bytes > 0) + { + const gchar *format; + gchar *done = g_format_size (current_num_bytes); + gchar *total = g_format_size (total_num_bytes); + + switch (progress->mode) + { + case DOWNLOAD: + format = _("Downloading image (%s of %s)"); + break; + + case UPLOAD: + format = _("Uploading image (%s of %s)"); + break; + + default: + gimp_assert_not_reached (); + } + + gimp_progress_set_text (progress->progress, format, done, total); + g_free (total); + g_free (done); + + gimp_progress_set_value (progress->progress, + (gdouble) current_num_bytes / + (gdouble) total_num_bytes); + } + else + { + const gchar *format; + gchar *done = g_format_size (current_num_bytes); + + switch (progress->mode) + { + case DOWNLOAD: + format = _("Downloaded %s of image data"); + break; + + case UPLOAD: + format = _("Uploaded %s of image data"); + break; + + default: + gimp_assert_not_reached (); + } + + gimp_progress_set_text (progress->progress, format, done); + g_free (done); + + gimp_progress_pulse (progress->progress); + } + + while (! progress->cancel && g_main_context_pending (NULL)) + g_main_context_iteration (NULL, FALSE); +} diff --git a/app/file/file-remote.h b/app/file/file-remote.h new file mode 100644 index 0000000..e5f38cc --- /dev/null +++ b/app/file/file-remote.h @@ -0,0 +1,48 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * file-remote.h + * Copyright (C) 2014 Michael Natterer <mitch@gimp.org> + * + * Based on: URI plug-in, GIO/GVfs backend + * Copyright (C) 2008 Sven Neumann <sven@gimp.org> + * + * 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 __FILE_REMOTE_H__ +#define __FILE_REMOTE_H__ + + +gboolean file_remote_mount_file (Gimp *gimp, + GFile *file, + GimpProgress *progress, + GError **error); + +GFile * file_remote_download_image (Gimp *gimp, + GFile *file, + GimpProgress *progress, + GError **error); + +GFile * file_remote_upload_image_prepare (Gimp *gimp, + GFile *file, + GimpProgress *progress, + GError **error); +gboolean file_remote_upload_image_finish (Gimp *gimp, + GFile *file, + GFile *local_file, + GimpProgress *progress, + GError **error); + +#endif /* __FILE_REMOTE_H__ */ diff --git a/app/file/file-save.c b/app/file/file-save.c new file mode 100644 index 0000000..7fc2dfd --- /dev/null +++ b/app/file/file-save.c @@ -0,0 +1,325 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis + * Copyright (C) 1997 Josh MacDonald + * + * file-save.c + * + * 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 <gdk-pixbuf/gdk-pixbuf.h> +#include <gegl.h> + +#include "libgimpbase/gimpbase.h" + +#include "core/core-types.h" + +#include "config/gimpcoreconfig.h" + +#include "core/gimp.h" +#include "core/gimpcontext.h" +#include "core/gimpdocumentlist.h" +#include "core/gimpdrawable.h" +#include "core/gimpimage.h" +#include "core/gimpimagefile.h" +#include "core/gimpparamspecs.h" +#include "core/gimpprogress.h" + +#include "pdb/gimppdb.h" + +#include "plug-in/gimppluginprocedure.h" + +#include "file-remote.h" +#include "file-save.h" +#include "gimp-file.h" + +#include "gimp-intl.h" + + +/* public functions */ + +GimpPDBStatusType +file_save (Gimp *gimp, + GimpImage *image, + GimpProgress *progress, + GFile *file, + GimpPlugInProcedure *file_proc, + GimpRunMode run_mode, + gboolean change_saved_state, + gboolean export_backward, + gboolean export_forward, + GError **error) +{ + GimpDrawable *drawable; + GimpValueArray *return_vals; + GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR; + GFile *local_file = NULL; + gchar *path = NULL; + gchar *uri = NULL; + gboolean mounted = TRUE; + gint32 image_ID; + gint32 drawable_ID; + GError *my_error = NULL; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), GIMP_PDB_CALLING_ERROR); + g_return_val_if_fail (GIMP_IS_IMAGE (image), GIMP_PDB_CALLING_ERROR); + g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), + GIMP_PDB_CALLING_ERROR); + g_return_val_if_fail (G_IS_FILE (file), GIMP_PDB_CALLING_ERROR); + g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (file_proc), + GIMP_PDB_CALLING_ERROR); + g_return_val_if_fail ((export_backward && export_forward) == FALSE, + GIMP_PDB_CALLING_ERROR); + g_return_val_if_fail (error == NULL || *error == NULL, + GIMP_PDB_CALLING_ERROR); + + /* ref image and file, so they can't get deleted during save */ + g_object_ref (image); + g_object_ref (file); + + gimp_image_saving (image); + + drawable = gimp_image_get_active_drawable (image); + + if (! drawable) + { + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("There is no active layer to save")); + goto out; + } + + /* FIXME enable these tests for remote files again, needs testing */ + if (g_file_is_native (file) && + g_file_query_exists (file, NULL)) + { + GFileInfo *info; + + info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_TYPE "," + G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, + G_FILE_QUERY_INFO_NONE, + NULL, error); + if (! info) + { + /* extra paranoia */ + if (error && ! *error) + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Failed to get file information")); + goto out; + } + + if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR) + { + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Not a regular file")); + g_object_unref (info); + goto out; + } + + if (! g_file_info_get_attribute_boolean (info, + G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) + { + g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Permission denied")); + g_object_unref (info); + goto out; + } + + g_object_unref (info); + } + + if (! g_file_is_native (file) && + ! file_remote_mount_file (gimp, file, progress, &my_error)) + { + if (my_error) + { + g_printerr ("%s: mounting remote volume failed, trying to upload" + "the file: %s\n", + G_STRFUNC, my_error->message); + g_clear_error (&my_error); + + mounted = FALSE; + } + else + { + status = GIMP_PDB_CANCEL; + + goto out; + } + } + + if (! file_proc->handles_uri || ! mounted) + { + gchar *my_path = g_file_get_path (file); + + if (! my_path) + { + local_file = file_remote_upload_image_prepare (gimp, file, progress, + &my_error); + + if (! local_file) + { + if (my_error) + g_propagate_error (error, my_error); + else + status = GIMP_PDB_CANCEL; + + goto out; + } + + if (file_proc->handles_uri) + path = g_file_get_uri (local_file); + else + path = g_file_get_path (local_file); + } + + g_free (my_path); + } + + if (! path) + { + if (file_proc->handles_uri) + path = g_file_get_uri (file); + else + path = g_file_get_path (file); + } + + uri = g_file_get_uri (file); + + image_ID = gimp_image_get_ID (image); + drawable_ID = gimp_item_get_ID (GIMP_ITEM (drawable)); + + return_vals = + gimp_pdb_execute_procedure_by_name (image->gimp->pdb, + gimp_get_user_context (gimp), + progress, error, + gimp_object_get_name (file_proc), + GIMP_TYPE_INT32, run_mode, + GIMP_TYPE_IMAGE_ID, image_ID, + GIMP_TYPE_DRAWABLE_ID, drawable_ID, + G_TYPE_STRING, path, + G_TYPE_STRING, uri, + G_TYPE_NONE); + + status = g_value_get_enum (gimp_value_array_index (return_vals, 0)); + + gimp_value_array_unref (return_vals); + + if (local_file) + { + if (status == GIMP_PDB_SUCCESS) + { + GError *my_error = NULL; + + if (! file_remote_upload_image_finish (gimp, file, local_file, + progress, &my_error)) + { + status = GIMP_PDB_EXECUTION_ERROR; + + if (my_error) + g_propagate_error (error, my_error); + else + status = GIMP_PDB_CANCEL; + } + } + + g_file_delete (local_file, NULL, NULL); + g_object_unref (local_file); + } + + if (status == GIMP_PDB_SUCCESS) + { + GimpDocumentList *documents; + GimpImagefile *imagefile; + + if (change_saved_state) + { + gimp_image_set_file (image, file); + gimp_image_set_save_proc (image, file_proc); + + /* Forget the import source when we save. We interpret a + * save as that the user is not interested in being able + * to quickly export back to the original any longer + */ + gimp_image_set_imported_file (image, NULL); + + gimp_image_clean_all (image); + } + else if (export_backward) + { + /* We exported the image back to its imported source, + * change nothing about export/import flags, only set + * the export state to clean + */ + gimp_image_export_clean_all (image); + } + else if (export_forward) + { + /* Remember the last entered Export URI for the image. We + * only need to do this explicitly when exporting. It + * happens implicitly when saving since the GimpObject name + * of a GimpImage is the last-save URI + */ + gimp_image_set_exported_file (image, file); + gimp_image_set_export_proc (image, file_proc); + + /* An image can not be considered both exported and imported + * at the same time, so stop consider it as imported now + * that we consider it exported. + */ + gimp_image_set_imported_file (image, NULL); + + gimp_image_export_clean_all (image); + } + + if (export_backward || export_forward) + gimp_image_exported (image, file); + else + gimp_image_saved (image, file); + + documents = GIMP_DOCUMENT_LIST (image->gimp->documents); + + imagefile = gimp_document_list_add_file (documents, file, + g_slist_nth_data (file_proc->mime_types_list, 0)); + + /* only save a thumbnail if we are saving as XCF, see bug #25272 */ + if (GIMP_PROCEDURE (file_proc)->proc_type == GIMP_INTERNAL) + gimp_imagefile_save_thumbnail (imagefile, + g_slist_nth_data (file_proc->mime_types_list, 0), + image, + NULL); + } + else if (status != GIMP_PDB_CANCEL) + { + if (error && *error == NULL) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("%s plug-in could not save image"), + gimp_procedure_get_label (GIMP_PROCEDURE (file_proc))); + } + } + + gimp_image_flush (image); + + out: + g_object_unref (file); + g_object_unref (image); + + g_free (path); + g_free (uri); + + return status; +} diff --git a/app/file/file-save.h b/app/file/file-save.h new file mode 100644 index 0000000..fcfac0c --- /dev/null +++ b/app/file/file-save.h @@ -0,0 +1,36 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * file-save.h + * + * 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 __FILE_SAVE_H__ +#define __FILE_SAVE_H__ + + +GimpPDBStatusType file_save (Gimp *gimp, + GimpImage *image, + GimpProgress *progress, + GFile *file, + GimpPlugInProcedure *file_proc, + GimpRunMode run_mode, + gboolean change_saved_state, + gboolean export_backward, + gboolean export_forward, + GError **error); + + +#endif /* __FILE_SAVE_H__ */ diff --git a/app/file/file-utils.c b/app/file/file-utils.c new file mode 100644 index 0000000..230c1ef --- /dev/null +++ b/app/file/file-utils.c @@ -0,0 +1,249 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis + * Copyright (C) 1997 Josh MacDonald + * + * file-utils.c + * + * 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 <gegl.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +#include "libgimpbase/gimpbase.h" +#include "libgimpmath/gimpmath.h" +#include "libgimpthumb/gimpthumb.h" + +#include "core/core-types.h" + +#include "core/gimp.h" +#include "core/gimpimage.h" +#include "core/gimpimagefile.h" + +#include "plug-in/gimppluginmanager-file.h" + +#include "file-utils.h" + +#include "gimp-intl.h" + + +static gboolean +file_utils_filename_is_uri (const gchar *filename, + GError **error) +{ + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (strstr (filename, "://")) + { + gchar *scheme; + gchar *canon; + + scheme = g_strndup (filename, (strstr (filename, "://") - filename)); + canon = g_strdup (scheme); + + g_strcanon (canon, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "+-.", '-'); + + if (strcmp (scheme, canon) || ! g_ascii_isgraph (canon[0])) + { + g_set_error (error, G_FILE_ERROR, 0, + _("'%s:' is not a valid URI scheme"), scheme); + + g_free (scheme); + g_free (canon); + + return FALSE; + } + + g_free (scheme); + g_free (canon); + + if (! g_utf8_validate (filename, -1, NULL)) + { + g_set_error_literal (error, + G_CONVERT_ERROR, + G_CONVERT_ERROR_ILLEGAL_SEQUENCE, + _("Invalid character sequence in URI")); + return FALSE; + } + + return TRUE; + } + + return FALSE; +} + +GFile * +file_utils_filename_to_file (Gimp *gimp, + const gchar *filename, + GError **error) +{ + GFile *file; + gchar *absolute; + GError *temp_error = NULL; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (filename != NULL, NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + file = g_file_new_for_uri (filename); + + if (! file) + { + /* Despite the docs says it never fails, it actually can on Windows. + * See issue #3093 (and glib#1819). + */ + g_set_error_literal (error, + G_CONVERT_ERROR, + G_CONVERT_ERROR_ILLEGAL_SEQUENCE, + _("Invalid character sequence in URI")); + return NULL; + } + + /* check for prefixes like http or ftp */ + if (gimp_plug_in_manager_file_procedure_find_by_prefix (gimp->plug_in_manager, + GIMP_FILE_PROCEDURE_GROUP_OPEN, + file)) + { + if (g_utf8_validate (filename, -1, NULL)) + { + return file; + } + else + { + g_set_error_literal (error, + G_CONVERT_ERROR, + G_CONVERT_ERROR_ILLEGAL_SEQUENCE, + _("Invalid character sequence in URI")); + return NULL; + } + } + else if (file_utils_filename_is_uri (filename, &temp_error)) + { + return file; + } + else if (temp_error) + { + g_propagate_error (error, temp_error); + g_object_unref (file); + + return NULL; + } + + g_object_unref (file); + + if (! g_path_is_absolute (filename)) + { + gchar *current; + + current = g_get_current_dir (); + absolute = g_build_filename (current, filename, NULL); + g_free (current); + } + else + { + absolute = g_strdup (filename); + } + + file = g_file_new_for_path (absolute); + + g_free (absolute); + + return file; +} + +GdkPixbuf * +file_utils_load_thumbnail (const gchar *filename) +{ + GimpThumbnail *thumbnail = NULL; + GdkPixbuf *pixbuf = NULL; + gchar *uri; + + g_return_val_if_fail (filename != NULL, NULL); + + uri = g_filename_to_uri (filename, NULL, NULL); + + if (uri) + { + thumbnail = gimp_thumbnail_new (); + gimp_thumbnail_set_uri (thumbnail, uri); + + pixbuf = gimp_thumbnail_load_thumb (thumbnail, + (GimpThumbSize) GIMP_THUMBNAIL_SIZE_NORMAL, + NULL); + } + + g_free (uri); + + if (pixbuf) + { + gint width = gdk_pixbuf_get_width (pixbuf); + gint height = gdk_pixbuf_get_height (pixbuf); + + if (gdk_pixbuf_get_n_channels (pixbuf) != 3) + { + GdkPixbuf *tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, + width, height); + + gdk_pixbuf_composite_color (pixbuf, tmp, + 0, 0, width, height, 0, 0, 1.0, 1.0, + GDK_INTERP_NEAREST, 255, + 0, 0, GIMP_CHECK_SIZE_SM, + 0x66666666, 0x99999999); + + g_object_unref (pixbuf); + pixbuf = tmp; + } + } + + return pixbuf; +} + +gboolean +file_utils_save_thumbnail (GimpImage *image, + const gchar *filename) +{ + GFile *file; + gboolean success = FALSE; + + g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + + file = gimp_image_get_file (image); + + if (file) + { + gchar *image_uri = g_file_get_uri (file); + gchar *uri = g_filename_to_uri (filename, NULL, NULL); + + if (uri && image_uri && ! strcmp (uri, image_uri)) + { + GimpImagefile *imagefile; + + imagefile = gimp_imagefile_new (image->gimp, file); + success = gimp_imagefile_save_thumbnail (imagefile, NULL, image, + NULL); + g_object_unref (imagefile); + } + + g_free (image_uri); + g_free (uri); + } + + return success; +} diff --git a/app/file/file-utils.h b/app/file/file-utils.h new file mode 100644 index 0000000..02a30cc --- /dev/null +++ b/app/file/file-utils.h @@ -0,0 +1,33 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * file-utils.h + * + * 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 __FILE_UTILS_H__ +#define __FILE_UTILS_H__ + + +GFile * file_utils_filename_to_file (Gimp *gimp, + const gchar *filename, + GError **error); + +GdkPixbuf * file_utils_load_thumbnail (const gchar *filename); +gboolean file_utils_save_thumbnail (GimpImage *image, + const gchar *filename); + + +#endif /* __FILE_UTILS_H__ */ diff --git a/app/file/gimp-file.h b/app/file/gimp-file.h new file mode 100644 index 0000000..a18442f --- /dev/null +++ b/app/file/gimp-file.h @@ -0,0 +1,30 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimp-file.h + * Copyright (C) 2009 Martin Nordholts <martinn@src.gnome.org> + * + * 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 __GIMP_FILE_H__ +#define __GIMP_FILE_H__ + +/* Data keys for Gimp */ +#define GIMP_FILE_OPEN_LAST_FILE_KEY "gimp-file-open-last-file" +#define GIMP_FILE_SAVE_LAST_FILE_KEY "gimp-file-save-last-file" +#define GIMP_FILE_EXPORT_LAST_FILE_KEY "gimp-file-export-last-file" + + +#endif /* __GIMP_FILE_H__ */ |