Commit 03f7f419 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

fixed visualization of animated gifs

parent 0fe23f3e
......@@ -250,13 +250,13 @@ apply_cb (gpointer user_data)
cairo_fill (cr);
cairo_destroy (cr);
gth_image_viewer_set_image (preview, self->priv->destination, -1, -1);
gth_image_viewer_set_surface (preview, self->priv->destination, -1, -1);
cairo_surface_destroy (preview_surface);
sharpen_data_free (sharpen_data);
}
else
gth_image_viewer_set_image (preview, self->priv->source, -1, -1);
gth_image_viewer_set_surface (preview, self->priv->source, -1, -1);
return FALSE;
}
......@@ -324,7 +324,7 @@ gth_file_tool_sharpen_get_options (GthFileTool *base)
gth_image_viewer_set_zoom_change (GTH_IMAGE_VIEWER (self->priv->preview), GTH_ZOOM_CHANGE_KEEP_PREV);
gth_image_viewer_set_zoom (GTH_IMAGE_VIEWER (self->priv->preview), 1.0);
gth_image_viewer_enable_zoom_with_keys (GTH_IMAGE_VIEWER (self->priv->preview), FALSE);
gth_image_viewer_set_image (GTH_IMAGE_VIEWER (self->priv->preview), self->priv->source, -1, -1);
gth_image_viewer_set_surface (GTH_IMAGE_VIEWER (self->priv->preview), self->priv->source, -1, -1);
image_navigator = gth_image_navigator_new (GTH_IMAGE_VIEWER (self->priv->preview));
gtk_widget_show_all (image_navigator);
gtk_box_pack_start (GTK_BOX (GET_WIDGET ("preview_hbox")), image_navigator, TRUE, TRUE, 0);
......
......@@ -293,8 +293,6 @@ image_preloader_requested_ready_cb (GthImagePreloader *preloader,
GError *error,
GthImageViewerPage *self)
{
cairo_surface_t *surface;
if (! _g_file_equal (requested->file, self->priv->file_data->file))
return;
......@@ -305,12 +303,10 @@ image_preloader_requested_ready_cb (GthImagePreloader *preloader,
gth_viewer_page_focus (GTH_VIEWER_PAGE (self));
surface = gth_image_get_cairo_surface (image);
gth_image_viewer_set_image (GTH_IMAGE_VIEWER (self->priv->viewer),
surface,
image,
original_width,
original_height);
cairo_surface_destroy (surface);
if (self->priv->shrink_wrap)
gth_image_viewer_page_shrink_wrap (self, TRUE);
......@@ -1143,7 +1139,7 @@ _gth_image_viewer_page_set_image (GthImageViewerPage *self,
int height;
char *size;
gth_image_viewer_set_image (GTH_IMAGE_VIEWER (self->priv->viewer), image, -1, -1);
gth_image_viewer_set_surface (GTH_IMAGE_VIEWER (self->priv->viewer), image, -1, -1);
file_data = gth_browser_get_current_file (GTH_BROWSER (self->priv->browser));
......
......@@ -1680,17 +1680,17 @@ gth_image_viewer_set_pixbuf (GthImageViewer *self,
g_return_if_fail (self != NULL);
image = _cairo_image_surface_create_from_pixbuf (pixbuf);
gth_image_viewer_set_image (self, image, original_width, original_height);
gth_image_viewer_set_surface (self, image, original_width, original_height);
cairo_surface_destroy (image);
}
void
gth_image_viewer_set_image (GthImageViewer *self,
cairo_surface_t *image,
int original_width,
int original_height)
gth_image_viewer_set_surface (GthImageViewer *self,
cairo_surface_t *surface,
int original_width,
int original_height)
{
g_return_if_fail (self != NULL);
......@@ -1699,7 +1699,7 @@ gth_image_viewer_set_image (GthImageViewer *self,
_g_clear_object (&self->priv->animation);
_g_clear_object (&self->priv->iter);
self->priv->surface = cairo_surface_reference (image);
self->priv->surface = cairo_surface_reference (surface);
self->priv->is_void = (self->priv->surface == NULL);
self->priv->is_animation = FALSE;
_gth_image_viewer_set_original_size (self, original_width, original_height);
......@@ -1708,6 +1708,31 @@ gth_image_viewer_set_image (GthImageViewer *self,
}
void
gth_image_viewer_set_image (GthImageViewer *viewer,
GthImage *image,
int original_width,
int original_height)
{
if (gth_image_is_animation (image)) {
GdkPixbufAnimation *animation;
animation = gth_image_get_pixbuf_animation (image);
gth_image_viewer_set_animation (viewer, animation, original_width, original_height);
g_object_unref (animation);
}
else {
cairo_surface_t *surface;
surface = gth_image_get_cairo_surface (image);
gth_image_viewer_set_surface (viewer, surface, original_width, original_height);
cairo_surface_destroy (surface);
}
}
void
gth_image_viewer_set_void (GthImageViewer *self)
{
......
......@@ -24,6 +24,7 @@
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gth-image.h"
#include "gth-image-viewer-tool.h"
G_BEGIN_DECLS
......@@ -161,8 +162,12 @@ void gth_image_viewer_set_pixbuf (GthImageViewer *vi
GdkPixbuf *pixbuf,
int original_width,
int original_height);
void gth_image_viewer_set_surface (GthImageViewer *viewer,
cairo_surface_t *surface,
int original_width,
int original_height);
void gth_image_viewer_set_image (GthImageViewer *viewer,
cairo_surface_t *image,
GthImage *image,
int original_width,
int original_height);
void gth_image_viewer_set_better_quality (GthImageViewer *viewer,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment