]> Pileus Git - ~andy/gtk/blobdiff - gdk-pixbuf/io-wbmp.c
Require libtool-1.4, automake-1.4p1.
[~andy/gtk] / gdk-pixbuf / io-wbmp.c
index f8411ae2699de9ea67281ffef986470c0e4f90f3..1537d83d624eb36b8a5c7fc0fc4a47e7bb32f755 100644 (file)
@@ -62,21 +62,22 @@ struct wbmp_progressive_state {
   GdkPixbuf *pixbuf;   /* Our "target" */
 };
 
-gpointer
+static gpointer
 gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                  ModuleUpdatedNotifyFunc updated_func,
-                                 ModuleFrameDoneNotifyFunc frame_done_func,
-                                 ModuleAnimationDoneNotifyFunc
-                                 anim_done_func, gpointer user_data);
+                                  gpointer user_data,
+                                  GError **error);
 
-void gdk_pixbuf__wbmp_image_stop_load(gpointer data);
-gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
-                                              guint size);
+static gboolean gdk_pixbuf__wbmp_image_stop_load(gpointer data, GError **error);
+static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data,
+                                                      const guchar * buf,
+                                                      guint size,
+                                                      GError **error);
 
 
 /* Shared library entry point --> This should be removed when
    generic_image_load enters gdk-pixbuf-io. */
-GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f)
+static GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f, GError **error)
 {
        size_t length;
        char membuf[4096];
@@ -84,14 +85,19 @@ GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f)
 
        GdkPixbuf *pb;
 
-       State = gdk_pixbuf__wbmp_image_begin_load(NULL, NULL, NULL, NULL, NULL);
+       State = gdk_pixbuf__wbmp_image_begin_load(NULL, NULL, NULL,
+                                                  error);
 
+        if (State == NULL)
+          return NULL;
+        
        while (feof(f) == 0) {
                length = fread(membuf, 1, 4096, f);
                if (length > 0)
                  gdk_pixbuf__wbmp_image_load_increment(State,
                                                        membuf,
-                                                       length);
+                                                       length,
+                                                        error);
 
        }
        if (State->pixbuf != NULL)
@@ -99,7 +105,7 @@ GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f)
 
        pb = State->pixbuf;
 
-       gdk_pixbuf__wbmp_image_stop_load(State);
+       gdk_pixbuf__wbmp_image_stop_load(State, NULL);
        return pb;
 }
 
@@ -109,12 +115,11 @@ GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f)
  * return context (opaque to user)
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                                ModuleUpdatedNotifyFunc updated_func,
-                                ModuleFrameDoneNotifyFunc frame_done_func,
-                                ModuleAnimationDoneNotifyFunc
-                                anim_done_func, gpointer user_data)
+                                  ModuleUpdatedNotifyFunc updated_func,
+                                  gpointer user_data,
+                                  GError **error)
 {
        struct wbmp_progressive_state *context;
 
@@ -135,16 +140,23 @@ gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void gdk_pixbuf__wbmp_image_stop_load(gpointer data)
+static gboolean gdk_pixbuf__wbmp_image_stop_load(gpointer data,
+                                                 GError **error)
 {
        struct wbmp_progressive_state *context =
            (struct wbmp_progressive_state *) data;
 
-       g_return_if_fail(context != NULL);
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
+        
+       g_return_val_if_fail(context != NULL, TRUE);
        if (context->pixbuf)
          gdk_pixbuf_unref(context->pixbuf);
 
        g_free(context);
+
+        return TRUE;
 }
 
 static gboolean
@@ -220,8 +232,9 @@ get_mbi(struct wbmp_progressive_state *context, guchar **buf, guint *buf_size, i
  *
  * append image data onto inrecrementally built output image
  */
-gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
-                                             guint size)
+static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data,
+                                                      const guchar * buf,
+                                                      guint size, GError **error)
 {
        struct wbmp_progressive_state *context =
            (struct wbmp_progressive_state *) data;
@@ -268,7 +281,7 @@ gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
                    g_assert(context->pixbuf);
 
                    if(context->prepared_func)
-                     context->prepared_func(context->pixbuf, context->user_data);
+                     context->prepared_func(context->pixbuf, NULL, context->user_data);
                  }
              }
            else if(context->needmore)
@@ -316,3 +329,12 @@ gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
        else
          return context->needmore;
 }
+
+void
+gdk_pixbuf__wbmp_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__wbmp_image_load;
+  module->begin_load = gdk_pixbuf__wbmp_image_begin_load;
+  module->stop_load = gdk_pixbuf__wbmp_image_stop_load;
+  module->load_increment = gdk_pixbuf__wbmp_image_load_increment;
+}