[gimp/pippin/linear-is-the-new-black: 10/10] png: add a combo-box for specifying png variant



commit 8208c8a5b89fb1096e839ccab304f9f33bba1c84
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Dec 30 14:07:05 2016 +0100

    png: add a combo-box for specifying png variant

 plug-ins/common/file-png.c      |   39 ++++++++++++++++++++++-
 plug-ins/ui/plug-in-file-png.ui |   67 ++++++++++++++++++++++++++-------------
 2 files changed, 83 insertions(+), 23 deletions(-)
---
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index 6efb7f1..4d52d2f 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -77,6 +77,18 @@
  * Structures...
  */
 
+typedef enum _PngExportformat {
+  PNG_FORMAT_AUTO = 0,
+  PNG_FORMAT_RGB8,
+  PNG_FORMAT_GRAY8,
+  PNG_FORMAT_RGBA8,
+  PNG_FORMAT_GRAYA8,
+  PNG_FORMAT_RGB16,
+  PNG_FORMAT_GRAY16,
+  PNG_FORMAT_RGBA16,
+  PNG_FORMAT_GRAYA16
+} PngExportFormat;
+
 typedef struct
 {
   gboolean  interlaced;
@@ -92,6 +104,7 @@ typedef struct
   gboolean  save_xmp;
   gboolean  save_iptc;
   gboolean  save_thumbnail;
+  PngExportFormat export_format;
 }
 PngSaveVals;
 
@@ -106,6 +119,7 @@ typedef struct
   GtkWidget *phys;
   GtkWidget *time;
   GtkWidget *comment;
+  GtkWidget *pixelformat;
   GtkWidget *save_transp_pixels;
   GtkAdjustment *compression_level;
   GtkWidget *save_exif;
@@ -201,7 +215,8 @@ static const PngSaveVals defaults =
   TRUE,                /* save exif       */
   TRUE,                /* save xmp        */
   TRUE,                /* save iptc        */
-  TRUE                 /* save thumbnail  */
+  TRUE,                /* save thumbnail  */
+  PNG_FORMAT_AUTO
 };
 
 static PngSaveVals pngvals;
@@ -2233,6 +2248,13 @@ toggle_button_init (GtkBuilder  *builder,
   return toggle;
 }
 
+static void pixformat_changed (GtkWidget *widget,
+                                   void      *foo)
+{
+  PngExportFormat *ep = foo;
+  *ep = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+}
+
 static gboolean
 save_dialog (gint32    image_ID,
              gboolean  alpha)
@@ -2332,6 +2354,21 @@ save_dialog (gint32    image_ID,
                     G_CALLBACK (gimp_int_adjustment_update),
                     &pngvals.compression_level);
 
+  /* Compression level scale */
+  pg.pixelformat =
+    GTK_WIDGET (gtk_builder_get_object (builder, "pixelformat-combo"));
+  gtk_combo_box_set_active (GTK_COMBO_BOX (pg.pixelformat), pngvals.export_format);
+  g_signal_connect (pg.pixelformat, "changed",
+                    G_CALLBACK (pixformat_changed),
+                    &pngvals.export_format);
+
+#if 0
+  gtk_adjustment_set_value (pg.compression_level, pngvals.compression_level);
+  g_signal_connect (pg.compression_level, "value-changed",
+                    G_CALLBACK (gimp_int_adjustment_update),
+                    &pngvals.compression_level);
+#endif
+
   /* Load/save defaults buttons */
   g_signal_connect_swapped (gtk_builder_get_object (builder, "load-defaults"),
                             "clicked",
diff --git a/plug-ins/ui/plug-in-file-png.ui b/plug-ins/ui/plug-in-file-png.ui
index 9fcbd68..5736ca5 100644
--- a/plug-ins/ui/plug-in-file-png.ui
+++ b/plug-ins/ui/plug-in-file-png.ui
@@ -12,7 +12,7 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="border_width">12</property>
-    <property name="n_rows">11</property>
+    <property name="n_rows">12</property>
     <property name="n_columns">3</property>
     <property name="column_spacing">6</property>
     <property name="row_spacing">6</property>
@@ -143,21 +143,6 @@
       </packing>
     </child>
     <child>
-      <object class="GtkLabel" id="compression-level-label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="xalign">0</property>
-        <property name="label" translatable="yes">Co_mpression level:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">compression-level-spin</property>
-      </object>
-      <packing>
-        <property name="top_attach">8</property>
-        <property name="bottom_attach">9</property>
-        <property name="x_options"/>
-      </packing>
-    </child>
-    <child>
       <object class="GtkHScale" id="compression-level-scale">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
@@ -167,8 +152,8 @@
       <packing>
         <property name="left_attach">1</property>
         <property name="right_attach">2</property>
-        <property name="top_attach">8</property>
-        <property name="bottom_attach">9</property>
+        <property name="top_attach">9</property>
+        <property name="bottom_attach">10</property>
       </packing>
     </child>
     <child>
@@ -186,8 +171,8 @@
       <packing>
         <property name="left_attach">2</property>
         <property name="right_attach">3</property>
-        <property name="top_attach">8</property>
-        <property name="bottom_attach">9</property>
+        <property name="top_attach">9</property>
+        <property name="bottom_attach">10</property>
         <property name="x_options"/>
       </packing>
     </child>
@@ -228,8 +213,8 @@
       </object>
       <packing>
         <property name="right_attach">3</property>
-        <property name="top_attach">10</property>
-        <property name="bottom_attach">11</property>
+        <property name="top_attach">11</property>
+        <property name="bottom_attach">12</property>
       </packing>
     </child>
     <child>
@@ -316,8 +301,46 @@
       </object>
       <packing>
         <property name="right_attach">3</property>
+        <property name="top_attach">10</property>
+        <property name="bottom_attach">11</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="compression-level-label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Co_mpression level:</property>
+        <property name="use_underline">True</property>
+        <property name="mnemonic_widget">compression-level-spin</property>
+        <property name="xalign">0</property>
+      </object>
+      <packing>
         <property name="top_attach">9</property>
         <property name="bottom_attach">10</property>
+        <property name="x_options"/>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkComboBoxText" id="pixelformat-combo">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <items>
+          <item translatable="yes">automatic pixelformat</item>
+          <item translatable="yes">8bpc RGB</item>
+          <item translatable="yes">8bpc GRAY</item>
+          <item translatable="yes">8bpc RGBA</item>
+          <item translatable="yes">8bpc GRAYA</item>
+          <item translatable="yes">16bpc RGB</item>
+          <item translatable="yes">16bpc GRAY</item>
+          <item translatable="yes">16bpc RGBA</item>
+          <item translatable="yes">16bpc GRAYA</item>
+        </items>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="right_attach">3</property>
+        <property name="top_attach">8</property>
+        <property name="bottom_attach">9</property>
       </packing>
     </child>
   </object>


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