[gimp/alxsa-simulation-profile-new-image] Updating to new API



commit e72f508ab27d9705d8fb06618cc955bde148954e
Author: Alx Sa <cmyk student gmail com>
Date:   Sat Aug 13 21:12:28 2022 +0000

    Updating to new API

 app/core/gimpimage-new.c         | 19 +++++++---
 app/core/gimptemplate.c          | 81 +++++++++++++++++++++++++++++++++-------
 app/core/gimptemplate.h          |  3 ++
 app/dialogs/preferences-dialog.c | 11 ------
 app/widgets/gimptemplateeditor.c | 71 +++++++++++++++++++++++++++++++++--
 5 files changed, 151 insertions(+), 34 deletions(-)
---
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index b6ae7ceab5..2c89c15661 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -92,12 +92,14 @@ gimp_image_new_from_template (Gimp         *gimp,
                               GimpTemplate *template,
                               GimpContext  *context)
 {
-  GimpImage         *image;
-  GimpLayer         *layer;
-  GimpColorProfile  *profile;
-  gint               width, height;
-  gboolean           has_alpha;
-  const gchar       *comment;
+  GimpImage               *image;
+  GimpLayer               *layer;
+  GimpColorProfile        *profile;
+  GimpColorRenderingIntent intent;
+  gboolean                 bpc;
+  gint                     width, height;
+  gboolean                 has_alpha;
+  const gchar             *comment;
 
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
   g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
@@ -141,6 +143,11 @@ gimp_image_new_from_template (Gimp         *gimp,
   if (profile)
     g_object_unref (profile);
 
+  intent = gimp_template_get_simulation_intent (template);
+  gimp_image_set_simulation_intent (image, intent);
+  bpc = gimp_template_get_simulation_bpc (template);
+  gimp_image_set_simulation_bpc (image, bpc);
+
   width  = gimp_image_get_width (image);
   height = gimp_image_get_height (image);
 
diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index 58658eedac..148a40cf2e 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -60,6 +60,8 @@ enum
   PROP_TRC,
   PROP_COLOR_PROFILE,
   PROP_SIMULATION_PROFILE,
+  PROP_SIMULATION_BPC,
+  PROP_SIMULATION_INTENT,
   PROP_FILL_TYPE,
   PROP_COMMENT,
   PROP_FILENAME,
@@ -73,24 +75,26 @@ typedef struct _GimpTemplatePrivate GimpTemplatePrivate;
 
 struct _GimpTemplatePrivate
 {
-  gint               width;
-  gint               height;
-  GimpUnit           unit;
+  gint                     width;
+  gint                     height;
+  GimpUnit                 unit;
 
-  gdouble            xresolution;
-  gdouble            yresolution;
-  GimpUnit           resolution_unit;
+  gdouble                  xresolution;
+  gdouble                  yresolution;
+  GimpUnit                 resolution_unit;
 
-  GimpImageBaseType  base_type;
-  GimpPrecision      precision;
+  GimpImageBaseType        base_type;
+  GimpPrecision            precision;
 
-  GFile             *color_profile;
-  GFile             *simulation_profile;
+  GFile                   *color_profile;
+  GFile                   *simulation_profile;
+  GimpColorRenderingIntent simulation_intent;
+  gboolean                 simulation_bpc;
 
-  GimpFillType       fill_type;
+  GimpFillType             fill_type;
 
-  gchar             *comment;
-  gchar             *filename;
+  gchar                   *comment;
+  gchar                   *filename;
 
   guint64            initial_size;
 };
@@ -226,6 +230,21 @@ gimp_template_class_init (GimpTemplateClass *klass)
                            G_TYPE_FILE,
                            GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_ENUM (object_class, PROP_SIMULATION_INTENT,
+                         "simulation-intent",
+                         _("Simulation Rendering Intent"),
+                         NULL,
+                         GIMP_TYPE_COLOR_RENDERING_INTENT,
+                         GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
+                         GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SIMULATION_BPC,
+                            "simulation-bpc",
+                            _("Use Black Point Compensation for Simulation"),
+                            NULL,
+                            FALSE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_ENUM (object_class, PROP_FILL_TYPE,
                          "fill-type",
                          _("Fill type"),
@@ -332,6 +351,12 @@ gimp_template_set_property (GObject      *object,
         g_object_unref (private->simulation_profile);
       private->simulation_profile = g_value_dup_object (value);
       break;
+    case PROP_SIMULATION_INTENT:
+      private->simulation_intent = g_value_get_enum (value);
+      break;
+    case PROP_SIMULATION_BPC:
+      private->simulation_bpc = g_value_get_boolean (value);
+      break;
     case PROP_FILL_TYPE:
       private->fill_type = g_value_get_enum (value);
       break;
@@ -402,6 +427,12 @@ gimp_template_get_property (GObject    *object,
     case PROP_SIMULATION_PROFILE:
       g_value_set_object (value, private->simulation_profile);
       break;
+    case PROP_SIMULATION_INTENT:
+      g_value_set_enum (value, private->simulation_intent);
+      break;
+    case PROP_SIMULATION_BPC:
+      g_value_set_boolean (value, private->simulation_bpc);
+      break;
     case PROP_FILL_TYPE:
       g_value_set_enum (value, private->fill_type);
       break;
@@ -607,6 +638,30 @@ gimp_template_get_simulation_profile (GimpTemplate *template)
   return NULL;
 }
 
+GimpColorRenderingIntent
+gimp_template_get_simulation_intent (GimpTemplate *template)
+{
+  GimpTemplatePrivate *private;
+
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), FALSE);
+
+  private = GET_PRIVATE (template);
+
+  return private->simulation_intent;
+}
+
+gboolean
+gimp_template_get_simulation_bpc (GimpTemplate *template)
+{
+  GimpTemplatePrivate *private;
+
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), FALSE);
+
+  private = GET_PRIVATE (template);
+
+  return private->simulation_bpc;
+}
+
 GimpFillType
 gimp_template_get_fill_type (GimpTemplate *template)
 {
diff --git a/app/core/gimptemplate.h b/app/core/gimptemplate.h
index 81ed29e621..39ee4707e1 100644
--- a/app/core/gimptemplate.h
+++ b/app/core/gimptemplate.h
@@ -87,6 +87,9 @@ GimpPrecision       gimp_template_get_precision       (GimpTemplate *template);
 GimpColorProfile  * gimp_template_get_color_profile   (GimpTemplate *template);
 GimpColorProfile  * gimp_template_get_simulation_profile
                                                       (GimpTemplate *template);
+GimpColorRenderingIntent gimp_template_get_simulation_intent
+                                                      (GimpTemplate *template);
+gboolean            gimp_template_get_simulation_bpc  (GimpTemplate *template);
 
 GimpFillType        gimp_template_get_fill_type       (GimpTemplate *template);
 
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 0e06218ddb..656b8c7fe9 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1423,17 +1423,6 @@ prefs_dialog_new (Gimp       *gimp,
     grid = prefs_grid_new (GTK_CONTAINER (vbox2));
     row = 0;
 
-    prefs_enum_combo_box_add (color_config,
-                              "simulation-rendering-intent", 0, 0,
-                              _("Re_ndering intent:"),
-                              GTK_GRID (grid), row++, size_group);
-
-    button = gimp_prop_check_button_new (color_config,
-                                         "simulation-use-black-point-compensation",
-                                         _("Use black _point compensation"));
-    gtk_grid_attach (GTK_GRID (grid), button, 1, row, 1, 1);
-    row++;
-
     prefs_boolean_combo_box_add (color_config,
                                  "simulation-optimize",
                                  _("Speed"),
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 010f3dad49..503da98a7f 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -78,6 +78,8 @@ struct _GimpTemplateEditorPrivate
   GtkWidget     *precision_combo;
   GtkWidget     *profile_combo;
   GtkWidget     *simulation_profile_combo;
+  GtkWidget     *simulation_intent_combo;
+  GtkWidget     *simulation_bpc_toggle;
 };
 
 #define GET_PRIVATE(editor) \
@@ -97,6 +99,13 @@ static void    gimp_template_editor_get_property   (GObject            *object,
 
 static void gimp_template_editor_precision_changed (GtkWidget          *widget,
                                                     GimpTemplateEditor *editor);
+static void gimp_template_editor_simulation_intent_changed
+                                                   (GtkWidget          *widget,
+                                                    GimpTemplateEditor *editor);
+static void gimp_template_editor_simulation_bpc_toggled
+                                                   (GtkWidget          *widget,
+                                                    GimpTemplateEditor *editor);
+
 static void gimp_template_editor_aspect_callback   (GtkWidget          *widget,
                                                     GimpTemplateEditor *editor);
 static void gimp_template_editor_template_notify   (GimpTemplate       *template,
@@ -448,6 +457,31 @@ gimp_template_editor_constructed (GObject *object)
                             _("_Soft-proofing color profile:"), 0.0, 0.5,
                             private->simulation_profile_combo, 1);
 
+  private->simulation_intent_combo =
+    gimp_enum_combo_box_new (GIMP_TYPE_COLOR_RENDERING_INTENT);
+
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
+                            _("_Soft-proofing rendering intent:"), 0.0, 0.5,
+                            private->simulation_intent_combo, 1);
+
+  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->simulation_intent_combo),
+                                 GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
+
+  g_signal_connect (private->simulation_intent_combo, "changed",
+                    G_CALLBACK (gimp_template_editor_simulation_intent_changed),
+                    editor);
+
+  private->simulation_bpc_toggle =
+    gtk_check_button_new_with_mnemonic (_("_Use Black Point Compensation"));
+
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
+                            NULL, 0.0, 0.5,
+                            private->simulation_bpc_toggle, 1);
+
+  g_signal_connect (private->simulation_bpc_toggle, "toggled",
+                    G_CALLBACK (gimp_template_editor_simulation_bpc_toggled),
+                    editor);
+
   combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
                                         "fill-type",
                                         0, 0);
@@ -661,6 +695,35 @@ gimp_template_editor_precision_changed (GtkWidget          *widget,
                 NULL);
 }
 
+static void
+gimp_template_editor_simulation_intent_changed (GtkWidget          *widget,
+                                                GimpTemplateEditor *editor)
+{
+  GimpTemplateEditorPrivate *private = GET_PRIVATE (editor);
+  GimpColorRenderingIntent   intent;
+
+  gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
+                                 (gint *) &intent);
+
+  g_object_set (private->template,
+                "simulation-intent", intent,
+                NULL);
+}
+
+static void
+gimp_template_editor_simulation_bpc_toggled (GtkWidget          *widget,
+                                             GimpTemplateEditor *editor)
+{
+  GimpTemplateEditorPrivate *private = GET_PRIVATE (editor);
+  gboolean                   bpc     = FALSE;
+
+  bpc = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+  g_object_set (private->template,
+                "simulation-bpc", bpc,
+                NULL);
+}
+
 static void
 gimp_template_editor_set_pixels (GimpTemplateEditor *editor,
                                  GimpTemplate       *template)
@@ -811,10 +874,10 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
       ! strcmp (param_spec->name, "image-type") ||
       ! strcmp (param_spec->name, "precision"))
     {
-      GimpColorProfile *profile;
-      GtkListStore     *profile_store;
-      GFile            *file;
-      gchar            *path;
+      GimpColorProfile        *profile;
+      GtkListStore            *profile_store;
+      GFile                   *file;
+      gchar                   *path;
 
       file = gimp_directory_file ("profilerc", NULL);
       profile_store = gimp_color_profile_store_new (file);


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