[gdk-pixbuf] modules: implement is_option_supported() for builtin modules



commit 1883b720cf6cb59eacd85781422b2f092974a753
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 2 15:17:14 2016 -0400

    modules: implement is_option_supported() for builtin modules
    
    Follow-up to previous commit; implement the new API in the modules we
    ship that can save pixbufs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683371

 gdk-pixbuf/io-gdip-jpeg.c |   10 ++++++++++
 gdk-pixbuf/io-gdip-png.c  |   11 +++++++++++
 gdk-pixbuf/io-ico.c       |   12 ++++++++++++
 gdk-pixbuf/io-jpeg.c      |   11 +++++++++++
 gdk-pixbuf/io-png.c       |   14 ++++++++++++++
 gdk-pixbuf/io-tiff.c      |   14 ++++++++++++++
 6 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/gdk-pixbuf/io-gdip-jpeg.c b/gdk-pixbuf/io-gdip-jpeg.c
index 0f2db1d..73fa1f1 100644
--- a/gdk-pixbuf/io-gdip-jpeg.c
+++ b/gdk-pixbuf/io-gdip-jpeg.c
@@ -99,6 +99,15 @@ gdk_pixbuf__gdip_image_save_JPEG (FILE         *f,
   return gdk_pixbuf__gdip_image_save_JPEG_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, 
error);
 }
 
+static gboolean
+gdk_pixbuf__gdip_is_save_option_supported_JPEG (const gchar *option_key)
+{
+  if (g_strcmp0 (option_key, "quality") == 0)
+    return TRUE;
+
+  return FALSE;
+}
+
 #ifndef INCLUDE_gdiplus
 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
 #else
@@ -111,6 +120,7 @@ MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
 
   module->save_to_callback = gdk_pixbuf__gdip_image_save_JPEG_to_callback;
   module->save = gdk_pixbuf__gdip_image_save_JPEG; /* for gtk < 2.14, you need to implement both. otherwise 
gdk-pixbuf-queryloaders fails */
+  module->is_save_option_supported = gdk_pixbuf__gdip_is_save_option_supported_JPEG;
 }
 
 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
diff --git a/gdk-pixbuf/io-gdip-png.c b/gdk-pixbuf/io-gdip-png.c
index a54eeb4..f7e597a 100644
--- a/gdk-pixbuf/io-gdip-png.c
+++ b/gdk-pixbuf/io-gdip-png.c
@@ -95,6 +95,16 @@ gdk_pixbuf__gdip_image_save_PNG (FILE          *f,
   return gdk_pixbuf__gdip_image_save_PNG_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, 
error);
 }
 
+static gboolean
+gdk_pixbuf__gdip_is_save_option_supported_PNG (const gchar *option_key)
+{
+  if (g_strcmp0 (option_key, "compression") == 0 ||
+      strncmp (option_key, "tEXt::", 6) == 0)
+    return TRUE;
+
+  return FALSE;
+}
+
 #ifndef INCLUDE_gdip_png
 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
 #else
@@ -107,6 +117,7 @@ MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
 
   module->save_to_callback = gdk_pixbuf__gdip_image_save_PNG_to_callback;
   module->save = gdk_pixbuf__gdip_image_save_PNG; /* for gtk < 2.14, you need to implement both. otherwise 
gdk-pixbuf-queryloaders fails */
+  module->is_save_option_supported = gdk_pixbuf__gdip_is_save_option_supported_PNG;
 }
 
 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index 82d3e4e..797f6d1 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -1242,6 +1242,17 @@ gdk_pixbuf__ico_image_save (FILE          *f,
        return TRUE;
 }
 
+static gboolean
+gdk_pixbuf__ico_is_save_option_supported (const gchar *option_key)
+{
+        if (g_strcmp0 (option_key, "depth") == 0 ||
+            g_strcmp0 (option_key, "x_hot") == 0 ||
+            g_strcmp0 (option_key, "y_hot") == 0)
+                return TRUE;
+
+        return FALSE;
+}
+
 #ifndef INCLUDE_ico
 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
 #else
@@ -1254,6 +1265,7 @@ MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
        module->stop_load = gdk_pixbuf__ico_image_stop_load;
        module->load_increment = gdk_pixbuf__ico_image_load_increment;
         module->save = gdk_pixbuf__ico_image_save;
+        module->is_save_option_supported = gdk_pixbuf__ico_is_save_option_supported;
 }
 
 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index eb48aed..a2adff1 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -1537,6 +1537,16 @@ gdk_pixbuf__jpeg_image_save_to_callback (GdkPixbufSaveFunc   save_func,
                               TRUE, NULL, save_func, user_data);
 }
 
+static gboolean
+gdk_pixbuf__jpeg_is_save_option_supported (const gchar *option_key)
+{
+        if (g_strcmp0 (option_key, "quality") == 0 ||
+            g_strcmp0 (option_key, "icc-profile") == 0)
+                return TRUE;
+
+        return FALSE;
+}
+
 #ifndef INCLUDE_jpeg
 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
 #else
@@ -1551,6 +1561,7 @@ MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
        module->load_increment = gdk_pixbuf__jpeg_image_load_increment;
        module->save = gdk_pixbuf__jpeg_image_save;
        module->save_to_callback = gdk_pixbuf__jpeg_image_save_to_callback;
+        module->is_save_option_supported = gdk_pixbuf__jpeg_is_save_option_supported;
 }
 
 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index e5ab22b..bb198c9 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -1171,6 +1171,19 @@ gdk_pixbuf__png_image_save_to_callback (GdkPixbufSaveFunc   save_func,
                               TRUE, NULL, save_func, user_data);
 }
 
+static gboolean
+gdk_pixbuf__png_is_save_option_supported (const gchar *option_key)
+{
+        if (g_strcmp0 (option_key, "compression") == 0 ||
+            g_strcmp0 (option_key, "icc-profile") == 0 ||
+            g_strcmp0 (option_key, "x-dpi") == 0 ||
+            g_strcmp0 (option_key, "y-dpi") == 0 ||
+            strncmp (option_key, "tEXt::", 6) == 0)
+                return TRUE;
+
+        return FALSE;
+}
+
 #ifndef INCLUDE_png
 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
 #else
@@ -1185,6 +1198,7 @@ MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
         module->load_increment = gdk_pixbuf__png_image_load_increment;
         module->save = gdk_pixbuf__png_image_save;
         module->save_to_callback = gdk_pixbuf__png_image_save_to_callback;
+        module->is_save_option_supported = gdk_pixbuf__png_is_save_option_supported;
 }
 
 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c
index 78eb243..9ca0378 100644
--- a/gdk-pixbuf/io-tiff.c
+++ b/gdk-pixbuf/io-tiff.c
@@ -979,6 +979,19 @@ gdk_pixbuf__tiff_image_save (FILE          *f,
                                                         values, error);
 }
 
+static gboolean
+gdk_pixbuf__tiff_is_save_option_supported (const gchar *option_key)
+{
+        if (g_strcmp0 (option_key, "bits-per-sample") == 0 ||
+            g_strcmp0 (option_key, "compression") == 0 ||
+            g_strcmp0 (option_key, "icc-profile") == 0 ||
+            g_strcmp0 (option_key, "x-dpi") == 0 ||
+            g_strcmp0 (option_key, "y-dpi") == 0)
+                return TRUE;
+
+        return FALSE;
+}
+
 #ifndef INCLUDE_tiff
 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
 #else
@@ -993,6 +1006,7 @@ MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
         module->load_increment = gdk_pixbuf__tiff_image_load_increment;
         module->save = gdk_pixbuf__tiff_image_save;
         module->save_to_callback = gdk_pixbuf__tiff_image_save_to_callback;
+        module->is_save_option_supported = gdk_pixbuf__tiff_is_save_option_supported;
 }
 
 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)


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