[gimp/gimp-2-10] Issue #701 - Add the ability to embed the GIMP built-in sRGB profile...



commit 113829fd145b13895a882f852bb86f4b0def50d9
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 18 02:19:41 2018 +0200

    Issue #701 - Add the ability to embed the GIMP built-in sRGB profile...
    
    ...upon exporting an image
    
    Step 1: make it configurable just like "Export EXIF" etc.
    
    app, libgimp: add "export-color-profile" config option
    
    Add it to the preferences dialog, and pass it on to plug-ins in the
    GPConfig message. Add gimp_export_color_profile() to libgimp.
    
    Nothing uses this yet.
    
    (cherry picked from commit 8c9c09102135ca93a0da641f70f411149d10cedc)

 app/config/gimpcoreconfig.c          | 14 +++++++++++
 app/config/gimpcoreconfig.h          |  1 +
 app/config/gimprc-blurbs.h           |  3 +++
 app/dialogs/preferences-dialog.c     |  3 +++
 app/plug-in/gimppluginmanager-call.c |  2 +-
 libgimp/gimp.c                       | 22 +++++++++++++++---
 libgimp/gimp.def                     |  1 +
 libgimp/gimp.h                       | 45 ++++++++++++++++++------------------
 libgimpbase/gimpprotocol.c           |  5 ++--
 libgimpbase/gimpprotocol.h           |  4 ++--
 10 files changed, 70 insertions(+), 30 deletions(-)
---
diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c
index e1613462b3..f8c621053b 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -110,6 +110,7 @@ enum
   PROP_IMPORT_PROMOTE_DITHER,
   PROP_IMPORT_ADD_ALPHA,
   PROP_IMPORT_RAW_PLUG_IN,
+  PROP_EXPORT_COLOR_PROFILE,
   PROP_EXPORT_METADATA_EXIF,
   PROP_EXPORT_METADATA_XMP,
   PROP_EXPORT_METADATA_IPTC,
@@ -641,6 +642,13 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                          GIMP_PARAM_STATIC_STRINGS |
                          GIMP_CONFIG_PARAM_RESTART);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_COLOR_PROFILE,
+                            "export-color-profile",
+                            "Export Color Profile",
+                            EXPORT_COLOR_PROFILE_BLURB,
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_METADATA_EXIF,
                             "export-metadata-exif",
                             "Export Exif metadata",
@@ -967,6 +975,9 @@ gimp_core_config_set_property (GObject      *object,
       g_free (core_config->import_raw_plug_in);
       core_config->import_raw_plug_in = g_value_dup_string (value);
       break;
+    case PROP_EXPORT_COLOR_PROFILE:
+      core_config->export_color_profile = g_value_get_boolean (value);
+      break;
     case PROP_EXPORT_METADATA_EXIF:
       core_config->export_metadata_exif = g_value_get_boolean (value);
       break;
@@ -1166,6 +1177,9 @@ gimp_core_config_get_property (GObject    *object,
     case PROP_IMPORT_RAW_PLUG_IN:
       g_value_set_string (value, core_config->import_raw_plug_in);
       break;
+    case PROP_EXPORT_COLOR_PROFILE:
+      g_value_set_boolean (value, core_config->export_color_profile);
+      break;
     case PROP_EXPORT_METADATA_EXIF:
       g_value_set_boolean (value, core_config->export_metadata_exif);
       break;
diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h
index 9822863382..5a48f4bc90 100644
--- a/app/config/gimpcoreconfig.h
+++ b/app/config/gimpcoreconfig.h
@@ -95,6 +95,7 @@ struct _GimpCoreConfig
   gboolean                import_promote_dither;
   gboolean                import_add_alpha;
   gchar                  *import_raw_plug_in;
+  gboolean                export_color_profile;
   gboolean                export_metadata_exif;
   gboolean                export_metadata_xmp;
   gboolean                export_metadata_iptc;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 5cd0dd4973..8312d8ec60 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -204,6 +204,9 @@ _("Add an alpha channel to all layers of imported images.")
 #define IMPORT_RAW_PLUG_IN_BLURB \
 _("Which plug-in to use for importing raw digital camera files.")
 
+#define EXPORT_COLOR_PROFILE_BLURB \
+_("Export the image's color profile by default.")
+
 #define EXPORT_METADATA_EXIF_BLURB \
 _("Export Exif metadata by default.")
 
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index ab8fb88b24..0762de0904 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1484,6 +1484,9 @@ prefs_dialog_new (Gimp       *gimp,
   vbox2 = prefs_frame_new (_("Export Policies"),
                            GTK_CONTAINER (vbox), FALSE);
 
+  button = prefs_check_button_add (object, "export-color-profile",
+                                   _("Export the image's color profile by default"),
+                                   GTK_BOX (vbox2));
   button = prefs_check_button_add (object, "export-metadata-exif",
                                    _("Export Exif metadata by default when available"),
                                    GTK_BOX (vbox2));
diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c
index 0a4bb44da9..27e11e5409 100644
--- a/app/plug-in/gimppluginmanager-call.c
+++ b/app/plug-in/gimppluginmanager-call.c
@@ -209,10 +209,10 @@ gimp_plug_in_manager_call_run (GimpPlugInManager   *manager,
                                  gui_config->show_help_button);
       config.use_cpu_accel    = manager->gimp->use_cpu_accel;
       config.use_opencl       = gegl_config->use_opencl;
+      config.export_profile   = core_config->export_color_profile;
       config.export_exif      = core_config->export_metadata_exif;
       config.export_xmp       = core_config->export_metadata_xmp;
       config.export_iptc      = core_config->export_metadata_iptc;
-      config.install_cmap     = FALSE;
       config.show_tooltips    = gui_config->show_tooltips;
       config.min_colors       = 144;
       config.gdisp_ID         = display_ID;
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index a3e7529c44..1f8d62309f 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -214,9 +214,9 @@ static gint           _tile_height       = -1;
 static gint           _shm_ID            = -1;
 static guchar        *_shm_addr          = NULL;
 static const gdouble  _gamma_val         = 2.2;
-static gboolean       _install_cmap      = FALSE;
 static gboolean       _show_tool_tips    = TRUE;
 static gboolean       _show_help_button  = TRUE;
+static gboolean       _export_profile    = FALSE;
 static gboolean       _export_exif       = FALSE;
 static gboolean       _export_xmp        = FALSE;
 static gboolean       _export_iptc       = FALSE;
@@ -1393,7 +1393,7 @@ gimp_gamma (void)
 gboolean
 gimp_install_cmap (void)
 {
-  return _install_cmap;
+  return FALSE;
 }
 
 /**
@@ -1449,6 +1449,22 @@ gimp_show_help_button (void)
   return _show_help_button;
 }
 
+/**
+ * gimp_export_color_profile:
+ *
+ * Returns whether file plug-ins should default to exporting the
+ * image's color profile.
+ *
+ * Return value: TRUE if preferences are set to export the color profile.
+ *
+ * Since: 2.10.4
+ **/
+gboolean
+gimp_export_color_profile (void)
+{
+  return _export_profile;
+}
+
 /**
  * gimp_export_exif:
  *
@@ -2299,9 +2315,9 @@ gimp_config (GPConfig *config)
   _shm_ID           = config->shm_ID;
   _check_size       = config->check_size;
   _check_type       = config->check_type;
-  _install_cmap     = config->install_cmap     ? TRUE : FALSE;
   _show_tool_tips   = config->show_tooltips    ? TRUE : FALSE;
   _show_help_button = config->show_help_button ? TRUE : FALSE;
+  _export_profile   = config->export_profile   ? TRUE : FALSE;
   _export_exif      = config->export_exif      ? TRUE : FALSE;
   _export_xmp       = config->export_xmp       ? TRUE : FALSE;
   _export_iptc      = config->export_iptc      ? TRUE : FALSE;
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index d2a3d1fa19..79bb8b9b38 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -322,6 +322,7 @@ EXPORTS
        gimp_equalize
        gimp_eraser
        gimp_eraser_default
+       gimp_export_color_profile
        gimp_export_exif
        gimp_export_iptc
        gimp_export_xmp
diff --git a/libgimp/gimp.h b/libgimp/gimp.h
index ccc589c5f4..3b73ac474d 100644
--- a/libgimp/gimp.h
+++ b/libgimp/gimp.h
@@ -323,31 +323,32 @@ GimpPDBStatusType gimp_get_pdb_status   (void);
 
 /* Return various constants given by the GIMP core at plug-in config time.
  */
-guint          gimp_tile_width          (void) G_GNUC_CONST;
-guint          gimp_tile_height         (void) G_GNUC_CONST;
-gint           gimp_shm_ID              (void) G_GNUC_CONST;
-guchar       * gimp_shm_addr            (void) G_GNUC_CONST;
-gdouble        gimp_gamma               (void) G_GNUC_CONST;
-gboolean       gimp_show_tool_tips      (void) G_GNUC_CONST;
-gboolean       gimp_show_help_button    (void) G_GNUC_CONST;
-gboolean       gimp_export_exif         (void) G_GNUC_CONST;
-gboolean       gimp_export_xmp          (void) G_GNUC_CONST;
-gboolean       gimp_export_iptc         (void) G_GNUC_CONST;
-GimpCheckSize  gimp_check_size          (void) G_GNUC_CONST;
-GimpCheckType  gimp_check_type          (void) G_GNUC_CONST;
-gint32         gimp_default_display     (void) G_GNUC_CONST;
-const gchar  * gimp_wm_class            (void) G_GNUC_CONST;
-const gchar  * gimp_display_name        (void) G_GNUC_CONST;
-gint           gimp_monitor_number      (void) G_GNUC_CONST;
-guint32        gimp_user_time           (void) G_GNUC_CONST;
-const gchar  * gimp_icon_theme_dir      (void) G_GNUC_CONST;
-
-const gchar  * gimp_get_progname        (void) G_GNUC_CONST;
+guint          gimp_tile_width           (void) G_GNUC_CONST;
+guint          gimp_tile_height          (void) G_GNUC_CONST;
+gint           gimp_shm_ID               (void) G_GNUC_CONST;
+guchar       * gimp_shm_addr             (void) G_GNUC_CONST;
+gdouble        gimp_gamma                (void) G_GNUC_CONST;
+gboolean       gimp_show_tool_tips       (void) G_GNUC_CONST;
+gboolean       gimp_show_help_button     (void) G_GNUC_CONST;
+gboolean       gimp_export_color_profile (void) G_GNUC_CONST;
+gboolean       gimp_export_exif          (void) G_GNUC_CONST;
+gboolean       gimp_export_xmp           (void) G_GNUC_CONST;
+gboolean       gimp_export_iptc          (void) G_GNUC_CONST;
+GimpCheckSize  gimp_check_size           (void) G_GNUC_CONST;
+GimpCheckType  gimp_check_type           (void) G_GNUC_CONST;
+gint32         gimp_default_display      (void) G_GNUC_CONST;
+const gchar  * gimp_wm_class             (void) G_GNUC_CONST;
+const gchar  * gimp_display_name         (void) G_GNUC_CONST;
+gint           gimp_monitor_number       (void) G_GNUC_CONST;
+guint32        gimp_user_time            (void) G_GNUC_CONST;
+const gchar  * gimp_icon_theme_dir       (void) G_GNUC_CONST;
+
+const gchar  * gimp_get_progname         (void) G_GNUC_CONST;
 
 GIMP_DEPRECATED
-gboolean       gimp_install_cmap        (void) G_GNUC_CONST;
+gboolean       gimp_install_cmap         (void) G_GNUC_CONST;
 GIMP_DEPRECATED
-gint           gimp_min_colors          (void) G_GNUC_CONST;
+gint           gimp_min_colors           (void) G_GNUC_CONST;
 
 GIMP_DEPRECATED_FOR(gimp_get_parasite)
 GimpParasite * gimp_parasite_find       (const gchar        *name);
diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c
index a008e48a15..c76c67f037 100644
--- a/libgimpbase/gimpprotocol.c
+++ b/libgimpbase/gimpprotocol.c
@@ -516,7 +516,8 @@ _gp_config_read (GIOChannel      *channel,
                               user_data))
     goto cleanup;
   if (! _gimp_wire_read_int8 (channel,
-                              (guint8 *) &config->install_cmap, 1, user_data))
+                              (guint8 *) &config->export_profile, 1,
+                              user_data))
     goto cleanup;
   if (! _gimp_wire_read_int8 (channel,
                               (guint8 *) &config->show_tooltips, 1, user_data))
@@ -617,7 +618,7 @@ _gp_config_write (GIOChannel      *channel,
                                user_data))
     return;
   if (! _gimp_wire_write_int8 (channel,
-                               (const guint8 *) &config->install_cmap, 1,
+                               (const guint8 *) &config->export_profile, 1,
                                user_data))
     return;
   if (! _gimp_wire_write_int8 (channel,
diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h
index 326347a146..634e199152 100644
--- a/libgimpbase/gimpprotocol.h
+++ b/libgimpbase/gimpprotocol.h
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
 
 /* Increment every time the protocol changes
  */
-#define GIMP_PROTOCOL_VERSION  0x0017
+#define GIMP_PROTOCOL_VERSION  0x0018
 
 
 enum
@@ -73,7 +73,7 @@ struct _GPConfig
   gint8    export_exif;
   gint8    export_xmp;
   gint8    export_iptc;
-  gint8    install_cmap;
+  gint8    export_profile;
   gint8    show_tooltips;
   gint32   min_colors;
   gint32   gdisp_ID;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]