[gthumb] flip: use a GthImageViewerTask to load the original image



commit 996de67aa87ea929f55c0fe7ad2893dead44d450
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Sep 21 15:23:11 2013 +0200

    flip: use a GthImageViewerTask to load the original image

 extensions/file_tools/gth-file-tool-flip.c |   49 +++++++++++++++++++--------
 1 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-flip.c b/extensions/file_tools/gth-file-tool-flip.c
index c4b8ab7..357b33b 100644
--- a/extensions/file_tools/gth-file-tool-flip.c
+++ b/extensions/file_tools/gth-file-tool-flip.c
@@ -22,36 +22,55 @@
 #include <config.h>
 #include <math.h>
 #include <gthumb.h>
-#include <extensions/image_viewer/gth-image-viewer-page.h>
+#include <extensions/image_viewer/image-viewer.h>
 #include "gth-file-tool-flip.h"
 
 
 G_DEFINE_TYPE (GthFileToolFlip, gth_file_tool_flip, GTH_TYPE_FILE_TOOL)
 
 
+static gpointer
+flip_exec (GthAsyncTask *task,
+          gpointer      user_data)
+{
+       cairo_surface_t *source;
+       cairo_surface_t *destination;
+
+       source = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
+       destination = _cairo_image_surface_transform (source, GTH_TRANSFORM_FLIP_V);
+       gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), destination);
+
+       cairo_surface_destroy (destination);
+       cairo_surface_destroy (source);
+
+       return NULL;
+}
+
+
 static void
 gth_file_tool_flip_activate (GthFileTool *base)
 {
-       GtkWidget       *window;
-       GtkWidget       *viewer_page;
-       GtkWidget       *viewer;
-       cairo_surface_t *old_image;
-       cairo_surface_t *new_image;
+       GtkWidget *window;
+       GtkWidget *viewer_page;
+       GthTask   *task;
 
        window = gth_file_tool_get_window (base);
        viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
        if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
                return;
 
-       viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
-       old_image = gth_image_viewer_get_current_image (GTH_IMAGE_VIEWER (viewer));
-       if (old_image == NULL)
-               return;
-
-       new_image = _cairo_image_surface_transform (old_image, GTH_TRANSFORM_FLIP_V);
-       gth_image_viewer_page_set_image (GTH_IMAGE_VIEWER_PAGE (viewer_page), new_image, TRUE);
-
-       cairo_surface_destroy (new_image);
+       task = gth_image_viewer_task_new (GTH_IMAGE_VIEWER_PAGE (viewer_page),
+                                         _("Applying changes"),
+                                         NULL,
+                                         flip_exec,
+                                         NULL,
+                                         NULL,
+                                         NULL);
+       g_signal_connect (task,
+                         "completed",
+                         G_CALLBACK (gth_image_viewer_task_set_destination),
+                         NULL);
+       gth_browser_exec_task (GTH_BROWSER (window), task, FALSE);
 }
 
 


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