[gimp/alxsa-soft-proofing-menu] Hopefully fixed image simulation's overwriting



commit 66b256812742d11b5a8a683ba1ecfd51b96077fa
Author: Alx Sa <cmyk student gmail com>
Date:   Wed Aug 17 02:10:20 2022 +0000

    Hopefully fixed image simulation's overwriting

 app/display/gimpstatusbar.c | 61 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 49 insertions(+), 12 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index f24561fee4..8766dba8c6 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -145,6 +145,7 @@ static void     gimp_statusbar_shell_image_changed(GimpStatusbar     *statusbar,
 static void     gimp_statusbar_shell_image_simulation_changed
                                                   (GimpImage        *image,
                                                    GimpStatusbar     *statusbar);
+
 static gboolean gimp_statusbar_rotate_pressed     (GtkWidget         *event_box,
                                                    GdkEvent          *event,
                                                    GimpStatusbar     *statusbar);
@@ -969,20 +970,28 @@ gimp_statusbar_soft_proof_profile_changed (GtkComboBox   *combo,
                                            GimpStatusbar *statusbar)
 {
   GimpImage        *image;
+  GimpColorConfig  *color_config;
   GFile            *file;
   GimpColorProfile *simulation_profile = NULL;
 
   g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
 
-  image = gimp_display_get_image (statusbar->shell->display);
+  image = statusbar->image;
+  color_config = gimp_display_shell_get_color_config (statusbar->shell);
   file =
     gimp_color_profile_combo_box_get_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo));
 
   if (file)
-    simulation_profile = gimp_color_profile_new_from_file (file, NULL);
-  g_object_unref (file);
+    {
+      simulation_profile = gimp_color_profile_new_from_file (file, NULL);
+      g_object_unref (file);
+    }
+
+  if (image)
+    gimp_image_set_simulation_profile (image, simulation_profile);
 
-  gimp_image_set_simulation_profile (image, simulation_profile);
+  gimp_statusbar_shell_color_config_notify (G_OBJECT (color_config), NULL,
+                                            statusbar);
 }
 
 static void
@@ -990,12 +999,15 @@ gimp_statusbar_soft_proof_rendering_intent_changed (GtkComboBox   *combo,
                                                     GimpStatusbar *statusbar)
 {
   GimpImage                *image;
+  GimpColorConfig          *color_config;
   GimpColorRenderingIntent  intent;
   GimpColorRenderingIntent  active;
 
   g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
 
-  image = gimp_display_get_image (statusbar->shell->display);
+  image = statusbar->image;
+  color_config = gimp_display_shell_get_color_config (statusbar->shell);
+
   if (image)
     {
       intent = gimp_image_get_simulation_intent (image);
@@ -1007,20 +1019,26 @@ gimp_statusbar_soft_proof_rendering_intent_changed (GtkComboBox   *combo,
           gimp_image_set_simulation_intent (image, active);
           gimp_image_flush (image);
         }
-  }
+    }
+
+  gimp_statusbar_shell_color_config_notify (G_OBJECT (color_config), NULL,
+                                            statusbar);
 }
 
 static void
 gimp_statusbar_soft_proof_bpc_toggled (GtkWidget     *button,
                                        GimpStatusbar *statusbar)
 {
-  GimpImage *image;
-  gboolean   bpc_enabled;
-  gboolean   active;
+  GimpImage       *image;
+  GimpColorConfig *color_config;
+  gboolean         bpc_enabled;
+  gboolean         active;
 
   g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
 
-  image = gimp_display_get_image (statusbar->shell->display);
+  image = statusbar->image;
+  color_config = gimp_display_shell_get_color_config (statusbar->shell);
+
   if (image)
     {
       bpc_enabled = gimp_image_get_simulation_bpc (image);
@@ -1032,6 +1050,9 @@ gimp_statusbar_soft_proof_bpc_toggled (GtkWidget     *button,
           gimp_image_flush (image);
         }
     }
+
+  gimp_statusbar_shell_color_config_notify (G_OBJECT (color_config), NULL,
+                                            statusbar);
 }
 
 static void
@@ -1094,6 +1115,10 @@ static gboolean gimp_statusbar_soft_proof_popover_shown (GtkWidget      *button,
       if (bevent->button == 1 &&
           gtk_widget_get_sensitive (statusbar->soft_proof_button))
         {
+          /* Since a GtkEventBox now covers the toggle so we can't click it,
+           * directly, we have to flip the toggle ourselves before we call
+           * the soft-proof button so it produces the right result
+           */
           gboolean active =
             gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (statusbar->soft_proof_button));
           gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (statusbar->soft_proof_button),
@@ -1210,6 +1235,18 @@ gimp_statusbar_set_shell (GimpStatusbar    *statusbar,
                                               statusbar);
     }
 
+  if (statusbar->gimp)
+    {
+      GimpContext *context;
+
+      context = gimp_get_user_context (statusbar->gimp);
+
+      g_signal_handlers_disconnect_by_func (context,
+                                            gimp_statusbar_shell_image_changed,
+                                            statusbar);
+      gimp_statusbar_shell_set_image (statusbar, NULL);
+    }
+
   statusbar->shell = shell;
 
   g_signal_connect_object (statusbar->shell, "scaled",
@@ -1230,8 +1267,8 @@ gimp_statusbar_set_shell (GimpStatusbar    *statusbar,
   statusbar->gimp = gimp_display_get_gimp (statusbar->shell->display);
   if (statusbar->gimp)
     {
-      GimpContext    *context;
-      GimpImage      *image;
+      GimpContext *context;
+      GimpImage   *image;
 
       context = gimp_get_user_context (statusbar->gimp);
       image   = gimp_context_get_image (context);


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