[gimp] app: move post-loading image import logic to new files file-import.[ch]
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move post-loading image import logic to new files file-import.[ch]
- Date: Fri, 17 Feb 2017 20:01:39 +0000 (UTC)
commit 5af2ecc8b18314690af8c4434e6e2d77e8b9804c
Author: Michael Natterer <mitch gimp org>
Date: Fri Feb 17 20:59:17 2017 +0100
app: move post-loading image import logic to new files file-import.[ch]
Profile import is no longer done for opened XCF files, only for
actual imports, otherwise this is only cleanup.
app/file/Makefile.am | 2 +
app/file/file-import.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++
app/file/file-import.h | 31 +++++++++++++++++
app/file/file-open.c | 41 ++---------------------
4 files changed, 121 insertions(+), 37 deletions(-)
---
diff --git a/app/file/Makefile.am b/app/file/Makefile.am
index 71bc528..90b107f 100644
--- a/app/file/Makefile.am
+++ b/app/file/Makefile.am
@@ -13,6 +13,8 @@ AM_CPPFLAGS = \
noinst_LIBRARIES = libappfile.a
libappfile_a_SOURCES = \
+ file-import.c \
+ file-import.h \
file-open.c \
file-open.h \
file-remote.c \
diff --git a/app/file/file-import.c b/app/file/file-import.c
new file mode 100644
index 0000000..f79b8af
--- /dev/null
+++ b/app/file/file-import.c
@@ -0,0 +1,84 @@
+/* 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 <http://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/gimpprogress.h"
+
+#include "file-import.h"
+
+
+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 &&
+ config->import_promote_float &&
+ gimp_image_get_base_type (image) != GIMP_INDEXED)
+ {
+ 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);
+ }
+ }
+ }
+
+ 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..ec38640
--- /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 <http://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
index 8aa9ec5..1939bcb 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -24,20 +24,15 @@
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
-#include "libgimpconfig/gimpconfig.h"
#include "core/core-types.h"
-#include "config/gimpcoreconfig.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-color-profile.h"
-#include "core/gimpimage-convert-precision.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimagefile.h"
@@ -50,6 +45,7 @@
#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"
@@ -279,40 +275,11 @@ file_open_image (Gimp *gimp,
{
gimp_image_undo_disable (image);
- if (run_mode == GIMP_RUN_INTERACTIVE &&
- gimp_image_get_base_type (image) != GIMP_INDEXED &&
- gimp->config->import_promote_float &&
- file_open_file_proc_is_import (file_proc))
- {
- 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 (gimp->config->import_promote_dither &&
- old_precision == GIMP_PRECISION_U8_GAMMA)
- {
- gimp_image_convert_dither_u8 (image, progress);
- }
- }
- }
-
- gimp_image_import_color_profile (image, context, progress,
- run_mode == GIMP_RUN_INTERACTIVE ?
- TRUE : FALSE);
-
if (file_open_file_proc_is_import (file_proc))
{
- /* 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);
+ file_import_image (image, context, file,
+ run_mode == GIMP_RUN_INTERACTIVE,
+ progress);
}
/* Enables undo again */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]