[gimp] Issue #3025 - "File/New" doesn't honor "precision" choice ...



commit 033082dd9a0850a86c1b0b76187afd4725df4e9f
Author: Ell <ell_se yahoo com>
Date:   Sun Mar 31 14:54:30 2019 -0400

    Issue #3025 - "File/New" doesn't honor "precision" choice ...
    
    ... for "Edit/Preferences/Default Image"
    
    In GimpTemplateEditor, don't use gimp_prop_enum_combo_box_new() for
    the "Precision" combo-box, and rather synchronize the combo-box and
    the template manually, since we only want to update the "Gamma"
    combo-box according to the precision when it changes through the
    UI, and not when the template's precision otherwise changes.
    
    This fixes an issue where we'd always set the default gamma value
    when resetting the editor's template, overwriting the template's
    original gamma value.

 app/widgets/gimptemplateeditor.c | 47 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 65e3191438..ab16be20bb 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -31,6 +31,8 @@
 
 #include "config/gimpcoreconfig.h"
 
+#include "gegl/gimp-babl.h"
+
 #include "core/gimp.h"
 #include "core/gimptemplate.h"
 
@@ -71,6 +73,7 @@ struct _GimpTemplateEditorPrivate
   GtkWidget     *more_label;
   GtkWidget     *resolution_se;
   GtkWidget     *chain_button;
+  GtkWidget     *precision_combo;
   GtkWidget     *profile_combo;
 };
 
@@ -157,6 +160,7 @@ gimp_template_editor_constructed (GObject *object)
   GtkWidget                 *scrolled_window;
   GtkWidget                 *text_view;
   GtkTextBuffer             *text_buffer;
+  GtkListStore              *store;
   GList                     *focus_chain = NULL;
   gchar                     *text;
   gint                       row;
@@ -387,15 +391,28 @@ gimp_template_editor_constructed (GObject *object)
                             _("Color _space:"), 0.0, 0.5,
                             combo, 1);
 
-  combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
-                                        "component-type",
-                                        GIMP_COMPONENT_TYPE_U8,
-                                        GIMP_COMPONENT_TYPE_FLOAT);
+  /* construct the precision combo manually, instead of using
+   * gimp_prop_enum_combo_box_new(), so that we only reset the gamma combo when
+   * the precision is changed through the ui.  see issue #3025.
+   */
+  store = gimp_enum_store_new_with_range (GIMP_TYPE_COMPONENT_TYPE,
+                                          GIMP_COMPONENT_TYPE_U8,
+                                          GIMP_COMPONENT_TYPE_FLOAT);
+
+  private->precision_combo = g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
+                                           "model", store,
+                                           NULL);
+  g_object_unref (store);
+
   gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
                             _("_Precision:"), 0.0, 0.5,
-                            combo, 1);
+                            private->precision_combo, 1);
 
-  g_signal_connect (combo, "changed",
+  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->precision_combo),
+                                 gimp_babl_component_type (
+                                   gimp_template_get_precision (template)));
+
+  g_signal_connect (private->precision_combo, "changed",
                     G_CALLBACK (gimp_template_editor_precision_changed),
                     editor);
 
@@ -617,6 +634,10 @@ gimp_template_editor_precision_changed (GtkWidget          *widget,
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
                                  (gint *) &component_type);
 
+  g_object_set (private->template,
+                "component-type", component_type,
+                NULL);
+
   /* when changing this logic, also change the same switch()
    * in convert-precision-dialog.c
    */
@@ -738,6 +759,20 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
                                           gimp_template_get_resolution_y (template),
                                           FALSE);
         }
+      else if (! strcmp (param_spec->name, "component-type"))
+        {
+          g_signal_handlers_block_by_func (private->precision_combo,
+                                           gimp_template_editor_precision_changed,
+                                           editor);
+
+          gimp_int_combo_box_set_active (
+            GIMP_INT_COMBO_BOX (private->precision_combo),
+            gimp_babl_component_type (gimp_template_get_precision (template)));
+
+          g_signal_handlers_unblock_by_func (private->precision_combo,
+                                             gimp_template_editor_precision_changed,
+                                             editor);
+        }
     }
 
 #ifdef ENABLE_MEMSIZE_LABEL


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