[gimp] plug-ins: use gimp_procedure_dialog_set_sensitive().



commit 2f46dfb354e3498d2fd02e80279a3943d44fbdbc
Author: Jehan <jehan girinstud io>
Date:   Tue Apr 6 21:52:33 2021 +0200

    plug-ins: use gimp_procedure_dialog_set_sensitive().
    
    In PNG, JPEG and TIFF export plug-ins which use the new API, use our new
    function to set widget sensitivity.
    
    Note that part of it is similar to commit 6a2910bd3b on `gimp-2-10`,
    making "Save GeoTIFF data" checkbox insensitive when there are no such
    data available (this feature was late on the main branch as we rushed
    for 2.10.24 release).

 plug-ins/common/file-png.c          |  7 +++----
 plug-ins/file-jpeg/jpeg-save.c      |  6 +++---
 plug-ins/file-tiff/file-tiff-save.c | 37 ++++++++++++++++++++++++++++---------
 3 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index 8863bcd04a..5260715d63 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -2306,10 +2306,9 @@ save_dialog (GimpImage     *image,
                                        "format", GIMP_INT_STORE (store));
   g_object_unref (store);
 
-  gtk_widget_set_sensitive (gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
-                                                              "save-transparent",
-                                                              G_TYPE_NONE),
-                            alpha);
+  gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
+                                       "save-transparent",
+                                       alpha, NULL, NULL, FALSE);
 
   gimp_save_procedure_dialog_add_metadata (GIMP_SAVE_PROCEDURE_DIALOG (dialog), "bkgd");
   gimp_save_procedure_dialog_add_metadata (GIMP_SAVE_PROCEDURE_DIALOG (dialog), "offs");
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index 96db28ece2..a5b835052a 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -800,9 +800,9 @@ save_dialog (GimpProcedure       *procedure,
                                            gimp_item_get_image (GIMP_ITEM (drawable)));
 
   /* custom quantization tables - now used also for original quality */
-  widget = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
-                                                                   "use-original-quality", G_TYPE_NONE);
-  gtk_widget_set_sensitive (widget, (orig_quality > 0));
+  gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
+                                       "use-original-quality",
+                                       (orig_quality > 0), NULL, NULL, FALSE);
 
   /* Quality as a GimpScaleEntry. */
   gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog), "quality", 100.0);
diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c
index 65ea349eb2..daea3f8501 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -1299,9 +1299,23 @@ save_dialog (GimpImage     *image,
   GtkWidget       *dialog;
   GtkListStore    *store;
   GtkWidget       *combo;
-  GtkWidget       *frame;
+  gchar          **parasites;
   GimpCompression  compression;
   gboolean         run;
+  gboolean         has_geotiff = FALSE;
+  gint             n_parasites;
+  gint             i;
+
+  parasites = gimp_image_get_parasite_list (image, &n_parasites);
+  for (i = 0; i < n_parasites; i++)
+    {
+      if (g_str_has_prefix (parasites[i], "Gimp_GeoTIFF_"))
+        {
+          has_geotiff = TRUE;
+          break;
+        }
+    }
+  g_strfreev (parasites);
 
   dialog = gimp_save_procedure_dialog_new (GIMP_SAVE_PROCEDURE (procedure),
                                            GIMP_PROCEDURE_CONFIG (config),
@@ -1327,25 +1341,30 @@ save_dialog (GimpImage     *image,
   combo_set_item_sensitive (combo, GIMP_COMPRESSION_CCITTFAX4, is_monochrome);
   combo_set_item_sensitive (combo, GIMP_COMPRESSION_JPEG,      ! is_indexed);
 
-  frame = gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
-                                            "layers-frame", "save-layers", FALSE,
-                                            "crop-layers");
+  gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
+                                    "layers-frame", "save-layers", FALSE,
+                                    "crop-layers");
   /* TODO: if single-layer TIFF, set the toggle insensitive and show it
    * as unchecked though I don't actually change the config value to
    * keep storing previously chosen value.
    * This used to be so before. We probably need to add some logics in
    * the GimpProcedureDialog generation for such case.
    */
-  gtk_widget_set_sensitive (frame, is_multi_layer);
+  gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
+                                       "layers-frame", is_multi_layer,
+                                       NULL, NULL, FALSE);
   /* TODO: same for "save-transparent-pixels", we probably want to show
    * it unchecked even though it doesn't matter for processing.
    */
-  gtk_widget_set_sensitive (gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
-                                                              "save-transparent-pixels",
-                                                              G_TYPE_NONE),
-                            has_alpha && ! is_indexed);
+  gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
+                                       "save-transparent-pixels",
+                                       has_alpha && ! is_indexed,
+                                       NULL, NULL, FALSE);
 
   gimp_save_procedure_dialog_add_metadata (GIMP_SAVE_PROCEDURE_DIALOG (dialog), "save-geotiff");
+  gimp_procedure_dialog_set_sensitive (GIMP_PROCEDURE_DIALOG (dialog),
+                                       "save-geotiff",
+                                       has_geotiff, NULL, NULL, FALSE);
 
   gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
                               "compression",


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