22 #include <glib/gstdio.h>
36 #define EV_IMAGE_GET_PRIVATE(object) \
37 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_IMAGE, EvImagePrivate))
46 if (image->priv->pixbuf) {
47 g_object_unref (image->priv->pixbuf);
48 image->priv->pixbuf = NULL;
51 if (image->priv->tmp_uri) {
54 filename = g_filename_from_uri (image->priv->tmp_uri, NULL, NULL);
57 g_free (image->priv->tmp_uri);
58 image->priv->tmp_uri = NULL;
61 (* G_OBJECT_CLASS (ev_image_parent_class)->finalize) (
object);
67 GObjectClass *g_object_class;
69 g_object_class = G_OBJECT_CLASS (klass);
71 g_type_class_add_private (g_object_class,
sizeof (
EvImagePrivate));
89 image->priv->page = page;
90 image->priv->id = img_id;
100 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
103 image->priv->pixbuf = g_object_ref (pixbuf);
113 return image->priv->page;
121 return image->priv->id;
134 g_return_val_if_fail (GDK_IS_PIXBUF (image->priv->pixbuf), NULL);
136 return image->priv->pixbuf;
143 GError *error = NULL;
144 gchar *filename = NULL;
148 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
150 if (image->priv->tmp_uri)
151 return image->priv->tmp_uri;
153 if ((fd =
ev_mkstemp (
"image.XXXXXX.png", &filename, &error)) == -1)
156 gdk_pixbuf_save (pixbuf, filename,
158 "compression",
"3", NULL);
162 image->priv->tmp_uri = g_filename_to_uri (filename, NULL, &error);
163 if (image->priv->tmp_uri == NULL)
168 return image->priv->tmp_uri;
174 g_warning (
"Error saving image: %s", error->message);
175 g_error_free (error);
186 return image->priv->tmp_uri;