[Xfce4-commits] <tumbler:master> Add TumblerColorspace enum, rename save_pixbuf() to save_image_data().

Jannis Pohlmann noreply at xfce.org
Wed Oct 21 00:34:02 CEST 2009


Updating branch refs/heads/master
         to 610f0964b759a26944bca705dad5061f1fe0ba04 (commit)
       from be9202b523a1854fa4824cd348ebae4462d7cfa5 (commit)

commit 610f0964b759a26944bca705dad5061f1fe0ba04
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Wed Oct 21 00:27:33 2009 +0200

    Add TumblerColorspace enum, rename save_pixbuf() to save_image_data().
    
    Also fixed the coding style here and there.

 plugins/font-thumbnailer/font-thumbnailer.c     |   26 +++++-----
 plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c |   26 +++++-----
 plugins/xdg-cache/xdg-cache-thumbnail.c         |   55 +++++++++++-----------
 tumbler/tumbler-enum-types.c                    |   21 +++++++++
 tumbler/tumbler-enum-types.h                    |    9 ++++
 tumbler/tumbler-thumbnail.c                     |   18 ++++----
 tumbler/tumbler-thumbnail.h                     |   56 ++++++++++++-----------
 7 files changed, 121 insertions(+), 90 deletions(-)

diff --git a/plugins/font-thumbnailer/font-thumbnailer.c b/plugins/font-thumbnailer/font-thumbnailer.c
index 95479c3..8908843 100644
--- a/plugins/font-thumbnailer/font-thumbnailer.c
+++ b/plugins/font-thumbnailer/font-thumbnailer.c
@@ -441,6 +441,7 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
 {
   TumblerThumbnailFlavor *flavors;
   TumblerThumbnailFlavor  flavor;
+  TumblerImageData        data;
   TumblerFileInfo        *info;
   FontThumbnailer        *font_thumbnailer = FONT_THUMBNAILER (thumbnailer);
   GHashTable             *pixbufs;
@@ -609,19 +610,18 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
             pixbuf = g_hash_table_lookup (pixbufs, GINT_TO_POINTER (flavor));
 
             /* if an image for this flavor was generated, save it now */
-            if (pixbuf != NULL) {
-              TumblerImageData data;
-
-              data.data            = gdk_pixbuf_get_pixels (pixbuf);
-              data.has_alpha       = gdk_pixbuf_get_has_alpha (pixbuf);
-              data.bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
-              data.width           = gdk_pixbuf_get_width (pixbuf);
-              data.height          = gdk_pixbuf_get_height (pixbuf);
-              data.rowstride       = gdk_pixbuf_get_rowstride (pixbuf);
-              data.colorspace      = (gint) gdk_pixbuf_get_colorspace (pixbuf);
-
-              tumbler_thumbnail_save_pixbuf (lp->data, &data, mtime, NULL, &error);
-            }
+            if (pixbuf != NULL) 
+              {
+                data.data = gdk_pixbuf_get_pixels (pixbuf);
+                data.has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+                data.bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
+                data.width = gdk_pixbuf_get_width (pixbuf);
+                data.height = gdk_pixbuf_get_height (pixbuf);
+                data.rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+                data.colorspace = (TumblerColorspace) gdk_pixbuf_get_colorspace (pixbuf);
+
+                tumbler_thumbnail_save_image_data (lp->data, &data, mtime, NULL, &error);
+              }
           }
     }
 
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
index e181a6e..c4caf2d 100644
--- a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
@@ -148,6 +148,7 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
   TumblerThumbnailFlavor *flavors;
   TumblerThumbnailFlavor  flavor;
   GFileInputStream       *stream;
+  TumblerImageData        data;
   TumblerFileInfo        *info;
   GHashTable             *pixbufs;
   GdkPixbuf              *source_pixbuf;
@@ -226,19 +227,18 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
             flavor = tumbler_thumbnail_get_flavor (lp->data);
             pixbuf = g_hash_table_lookup (pixbufs, GINT_TO_POINTER (flavor));
 
-            if (pixbuf != NULL) {
-              TumblerImageData data;
-
-              data.data            = gdk_pixbuf_get_pixels (pixbuf);
-              data.has_alpha       = gdk_pixbuf_get_has_alpha (pixbuf);
-              data.bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
-              data.width           = gdk_pixbuf_get_width (pixbuf);
-              data.height          = gdk_pixbuf_get_height (pixbuf);
-              data.rowstride       = gdk_pixbuf_get_rowstride (pixbuf);
-              data.colorspace      = (gint) gdk_pixbuf_get_colorspace (pixbuf);
-
-              tumbler_thumbnail_save_pixbuf (lp->data, &data, mtime, NULL, &error);
-            }
+            if (pixbuf != NULL) 
+              {
+                data.data = gdk_pixbuf_get_pixels (pixbuf);
+                data.has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+                data.bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
+                data.width = gdk_pixbuf_get_width (pixbuf);
+                data.height = gdk_pixbuf_get_height (pixbuf);
+                data.rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+                data.colorspace = (TumblerColorspace) gdk_pixbuf_get_colorspace (pixbuf);
+
+                tumbler_thumbnail_save_image_data (lp->data, &data, mtime, NULL, &error);
+              }
           }
     }
 
diff --git a/plugins/xdg-cache/xdg-cache-thumbnail.c b/plugins/xdg-cache/xdg-cache-thumbnail.c
index c8a0f6f..40100aa 100644
--- a/plugins/xdg-cache/xdg-cache-thumbnail.c
+++ b/plugins/xdg-cache/xdg-cache-thumbnail.c
@@ -50,27 +50,27 @@ enum
 
 
 
-static void     xdg_cache_thumbnail_thumbnail_init (TumblerThumbnailIface  *iface);
-static void     xdg_cache_thumbnail_finalize       (GObject                *object);
-static void     xdg_cache_thumbnail_get_property   (GObject                *object,
-                                                    guint                   prop_id,
-                                                    GValue                 *value,
-                                                    GParamSpec             *pspec);
-static void     xdg_cache_thumbnail_set_property   (GObject                *object,
-                                                    guint                   prop_id,
-                                                    const GValue           *value,
-                                                    GParamSpec             *pspec);
-static gboolean xdg_cache_thumbnail_load           (TumblerThumbnail       *thumbnail,
-                                                    GCancellable           *cancellable,
-                                                    GError                **error);
-static gboolean xdg_cache_thumbnail_needs_update   (TumblerThumbnail       *thumbnail,
-                                                    const gchar            *uri,
-                                                    guint64                 mtime);
-static gboolean xdg_cache_thumbnail_save_pixbuf    (TumblerThumbnail       *thumbnail,
-                                                    TumblerImageData       *data,
-                                                    guint64                 mtime,
-                                                    GCancellable           *cancellable,
-                                                    GError                **error);
+static void     xdg_cache_thumbnail_thumbnail_init  (TumblerThumbnailIface  *iface);
+static void     xdg_cache_thumbnail_finalize        (GObject                *object);
+static void     xdg_cache_thumbnail_get_property    (GObject                *object,
+                                                     guint                   prop_id,
+                                                     GValue                 *value,
+                                                     GParamSpec             *pspec);
+static void     xdg_cache_thumbnail_set_property    (GObject                *object,
+                                                     guint                   prop_id,
+                                                     const GValue           *value,
+                                                     GParamSpec             *pspec);
+static gboolean xdg_cache_thumbnail_load            (TumblerThumbnail       *thumbnail,
+                                                     GCancellable           *cancellable,
+                                                     GError                **error);
+static gboolean xdg_cache_thumbnail_needs_update    (TumblerThumbnail       *thumbnail,
+                                                     const gchar            *uri,
+                                                     guint64                 mtime);
+static gboolean xdg_cache_thumbnail_save_image_data (TumblerThumbnail       *thumbnail,
+                                                     TumblerImageData       *data,
+                                                     guint64                 mtime,
+                                                     GCancellable           *cancellable,
+                                                     GError                **error);
 
 
 
@@ -138,7 +138,7 @@ xdg_cache_thumbnail_thumbnail_init (TumblerThumbnailIface *iface)
 {
   iface->load = xdg_cache_thumbnail_load;
   iface->needs_update = xdg_cache_thumbnail_needs_update;
-  iface->save_pixbuf = xdg_cache_thumbnail_save_pixbuf;
+  iface->save_image_data = xdg_cache_thumbnail_save_image_data;
 }
 
 
@@ -288,11 +288,11 @@ xdg_cache_thumbnail_needs_update (TumblerThumbnail *thumbnail,
 
 
 static gboolean
-xdg_cache_thumbnail_save_pixbuf (TumblerThumbnail *thumbnail,
-                                 TumblerImageData *data,
-                                 guint64           mtime,
-                                 GCancellable     *cancellable,
-                                 GError          **error)
+xdg_cache_thumbnail_save_image_data (TumblerThumbnail *thumbnail,
+                                     TumblerImageData *data,
+                                     guint64           mtime,
+                                     GCancellable     *cancellable,
+                                     GError          **error)
 {
   XDGCacheThumbnail *cache_thumbnail = XDG_CACHE_THUMBNAIL (thumbnail);
   GFileOutputStream *stream;
@@ -317,7 +317,6 @@ xdg_cache_thumbnail_save_pixbuf (TumblerThumbnail *thumbnail,
   if (g_cancellable_set_error_if_cancelled (cancellable, error))
     return FALSE;
 
-  
   /* determine dimensions of the thumbnail pixbuf */
   width = data->width;
   height = data->height;
diff --git a/tumbler/tumbler-enum-types.c b/tumbler/tumbler-enum-types.c
index 19f4935..baba55f 100644
--- a/tumbler/tumbler-enum-types.c
+++ b/tumbler/tumbler-enum-types.c
@@ -80,3 +80,24 @@ tumbler_thumbnail_format_get_type (void)
 
   return type;
 }
+
+
+
+GType
+tumbler_colorspace_get_type (void)
+{
+  GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GEnumValue values[] = 
+      {
+        { TUMBLER_COLORSPACE_RGB, "TUMBLER_COLORSPACE_RGB", N_ ("RGB Colorspace"), },
+        { 0,                      NULL,                     NULL,                  },
+      };
+
+      type = g_enum_register_static ("TumblerColorspace", values);
+    }
+
+  return type;
+}
diff --git a/tumbler/tumbler-enum-types.h b/tumbler/tumbler-enum-types.h
index 962f981..ea784c3 100644
--- a/tumbler/tumbler-enum-types.h
+++ b/tumbler/tumbler-enum-types.h
@@ -51,6 +51,15 @@ typedef enum /*< enum >*/
 
 GType tumbler_thumbnail_format_get_type (void);
 
+#define TUMBLER_TYPE_COLORSPACE (tumbler_colorspace_get_type ())
+
+typedef enum /*< enum >*/
+{
+  TUMBLER_COLORSPACE_RGB,
+} TumblerColorspace;
+
+GType tumbler_colorspace_get_type (void);
+
 G_END_DECLS
 
 #endif /* !__TUMBLER_ENUM_TYPES_H__ */
diff --git a/tumbler/tumbler-thumbnail.c b/tumbler/tumbler-thumbnail.c
index a4736ce..ecefc51 100644
--- a/tumbler/tumbler-thumbnail.c
+++ b/tumbler/tumbler-thumbnail.c
@@ -118,20 +118,20 @@ tumbler_thumbnail_needs_update (TumblerThumbnail *thumbnail,
 
 
 gboolean
-tumbler_thumbnail_save_pixbuf (TumblerThumbnail *thumbnail,
-                               TumblerImageData *pixbuf,
-                               guint64           mtime,
-                               GCancellable     *cancellable,
-                               GError          **error)
+tumbler_thumbnail_save_image_data (TumblerThumbnail *thumbnail,
+                                   TumblerImageData *data,
+                                   guint64           mtime,
+                                   GCancellable     *cancellable,
+                                   GError          **error)
 {
   g_return_val_if_fail (TUMBLER_IS_THUMBNAIL (thumbnail), FALSE);
   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-  g_return_val_if_fail (TUMBLER_THUMBNAIL_GET_IFACE (thumbnail)->save_pixbuf != NULL, FALSE);
+  g_return_val_if_fail (TUMBLER_THUMBNAIL_GET_IFACE (thumbnail)->save_image_data != NULL, FALSE);
 
-  return (TUMBLER_THUMBNAIL_GET_IFACE (thumbnail)->save_pixbuf) (thumbnail, pixbuf, 
-                                                                 mtime, cancellable, 
-                                                                 error);
+  return (TUMBLER_THUMBNAIL_GET_IFACE (thumbnail)->save_image_data) (thumbnail, data, 
+                                                                     mtime, cancellable, 
+                                                                     error);
 }
 
 
diff --git a/tumbler/tumbler-thumbnail.h b/tumbler/tumbler-thumbnail.h
index f62db41..ed72b8f 100644
--- a/tumbler/tumbler-thumbnail.h
+++ b/tumbler/tumbler-thumbnail.h
@@ -37,18 +37,20 @@ G_BEGIN_DECLS
 #define TUMBLER_IS_THUMBNAIL(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUMBLER_TYPE_THUMBNAIL))
 #define TUMBLER_THUMBNAIL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TUMBLER_TYPE_THUMBNAIL, TumblerThumbnailIface))
 
+typedef struct _TumblerImageData      TumblerImageData;
 typedef struct _TumblerThumbnail      TumblerThumbnail;
 typedef struct _TumblerThumbnailIface TumblerThumbnailIface;
 
-typedef struct {
-  const guchar *data;
-  gboolean has_alpha;
-  gint bits_per_sample;
-  gint width;
-  gint height;
-  gint rowstride;
-  gint colorspace;
-} TumblerImageData;
+struct _TumblerImageData
+{
+  TumblerColorspace colorspace;
+  const guchar     *data;
+  gboolean          has_alpha;
+  gint              bits_per_sample;
+  gint              width;
+  gint              height;
+  gint              rowstride;
+};
 
 struct _TumblerThumbnailIface
 {
@@ -57,22 +59,22 @@ struct _TumblerThumbnailIface
   /* signals */
 
   /* virtual methods */
-  gboolean (*load)         (TumblerThumbnail *thumbnail,
-                            GCancellable     *cancellable,
-                            GError          **error);
-  gboolean (*needs_update) (TumblerThumbnail *thumbnail,
-                            const gchar      *uri,
-                            guint64           mtime);
-  gboolean (*save_pixbuf)  (TumblerThumbnail *thumbnail,
-                            TumblerImageData *pixbuf,
-                            guint64           mtime,
-                            GCancellable     *cancellable,
-                            GError          **error);
-  gboolean (*save_file)    (TumblerThumbnail *thumbnail,
-                            GFile            *file,
-                            guint64           mtime,
-                            GCancellable     *cancellable,
-                            GError          **error);
+  gboolean (*load)            (TumblerThumbnail *thumbnail,
+                               GCancellable     *cancellable,
+                               GError          **error);
+  gboolean (*needs_update)    (TumblerThumbnail *thumbnail,
+                               const gchar      *uri,
+                               guint64           mtime);
+  gboolean (*save_image_data) (TumblerThumbnail *thumbnail,
+                               TumblerImageData *data,
+                               guint64           mtime,
+                               GCancellable     *cancellable,
+                               GError          **error);
+  gboolean (*save_file)       (TumblerThumbnail *thumbnail,
+                               GFile            *file,
+                               guint64           mtime,
+                               GCancellable     *cancellable,
+                               GError          **error);
 };
 
 GType                   tumbler_thumbnail_get_type        (void) G_GNUC_CONST;
@@ -83,8 +85,8 @@ gboolean                tumbler_thumbnail_load            (TumblerThumbnail
 gboolean                tumbler_thumbnail_needs_update    (TumblerThumbnail      *thumbnail,
                                                            const gchar           *uri,
                                                            guint64                mtime);
-gboolean                tumbler_thumbnail_save_pixbuf     (TumblerThumbnail      *thumbnail,
-                                                           TumblerImageData      *pixbuf,
+gboolean                tumbler_thumbnail_save_image_data (TumblerThumbnail      *thumbnail,
+                                                           TumblerImageData      *data,
                                                            guint64                mtime,
                                                            GCancellable          *cancellable,
                                                            GError               **error);



More information about the Xfce4-commits mailing list