[gimp/gimp-2-10] plug-ins: set the "Save GeoTIFF data" checkbox insensitive when…



commit 6a2910bd3b504fccfdc1c8443ca6a3e7e989e6d1
Author: Jehan <jehan girinstud io>
Date:   Sun Mar 28 19:13:03 2021 +0200

    plug-ins: set the "Save GeoTIFF data" checkbox insensitive when…
    
    … there are no such data available.
    No need to have people test and wonder what it changes when it makes no
    difference. Also adding a tooltip to make the "present on import"
    condition a bit more obvious (hopefully).
    
    This is only on `gimp-2-10` for now, for the 2.10.24 release. I will
    port this to `master` branch later.

 plug-ins/file-tiff/file-tiff-save.c | 19 ++++++++++++++++++-
 plug-ins/file-tiff/file-tiff-save.h |  1 +
 plug-ins/file-tiff/file-tiff.c      |  2 +-
 plug-ins/ui/plug-in-file-tiff.ui    |  1 +
 4 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c
index d536d58a47..555ae013f3 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -1200,6 +1200,7 @@ out:
 
 gboolean
 save_dialog (TiffSaveVals  *tsvals,
+             gint32         image,
              const gchar   *help_id,
              gboolean       has_alpha,
              gboolean       is_monochrome,
@@ -1217,7 +1218,22 @@ save_dialog (TiffSaveVals  *tsvals,
   GtkWidget   *cmp_jpeg;
   GtkBuilder  *builder;
   gchar       *ui_file;
+  gchar      **parasites;
   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_export_dialog_new (_("TIFF"), PLUG_IN_ROLE, help_id);
 
@@ -1320,7 +1336,8 @@ save_dialog (TiffSaveVals  *tsvals,
 
   toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-geotiff"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
-                                tsvals->save_geotiff);
+                                has_geotiff && tsvals->save_geotiff);
+  gtk_widget_set_sensitive (toggle, has_geotiff);;
   g_signal_connect (toggle, "toggled",
                     G_CALLBACK (gimp_toggle_button_update),
                     &tsvals->save_geotiff);
diff --git a/plug-ins/file-tiff/file-tiff-save.h b/plug-ins/file-tiff/file-tiff-save.h
index 9cb97b7465..32709e90e3 100644
--- a/plug-ins/file-tiff/file-tiff-save.h
+++ b/plug-ins/file-tiff/file-tiff-save.h
@@ -50,6 +50,7 @@ gboolean  save_image  (GFile                  *file,
                        GError                **error);
 
 gboolean  save_dialog (TiffSaveVals *tsvals,
+                       gint32        image,
                        const gchar  *help_id,
                        gboolean      has_alpha,
                        gboolean      is_monochrome,
diff --git a/plug-ins/file-tiff/file-tiff.c b/plug-ins/file-tiff/file-tiff.c
index f9034ef562..336a443907 100644
--- a/plug-ins/file-tiff/file-tiff.c
+++ b/plug-ins/file-tiff/file-tiff.c
@@ -318,7 +318,7 @@ run (const gchar      *name,
           gimp_parasite_free (parasite);
 
           /*  First acquire information with a dialog  */
-          if (! save_dialog (&tsvals,
+          if (! save_dialog (&tsvals, image,
                              SAVE_PROC,
                              gimp_drawable_has_alpha (drawable),
                              image_is_monochrome (image),
diff --git a/plug-ins/ui/plug-in-file-tiff.ui b/plug-ins/ui/plug-in-file-tiff.ui
index ede5c9a8b8..921107d00d 100644
--- a/plug-ins/ui/plug-in-file-tiff.ui
+++ b/plug-ins/ui/plug-in-file-tiff.ui
@@ -248,6 +248,7 @@
             <child>
               <object class="GtkCheckButton" id="save-geotiff">
                 <property name="label" translatable="yes">Save _GeoTIFF data</property>
+                <property name="tooltip_text" translatable="yes">Keep the GeoTIFF metadata if it was present 
on import</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>


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