[gthumb] roate left: load the original image using a GthImageViewerTask



commit 48a249d5c1159e3c38027fbf3c99dffc855e3623
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Sep 21 16:48:42 2013 +0200

    roate left: load the original image using a GthImageViewerTask

 extensions/file_tools/gth-file-tool-rotate-left.c |   49 ++++++++++++++------
 1 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-rotate-left.c 
b/extensions/file_tools/gth-file-tool-rotate-left.c
index dafbed1..0f62169 100644
--- a/extensions/file_tools/gth-file-tool-rotate-left.c
+++ b/extensions/file_tools/gth-file-tool-rotate-left.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-rotate-left.h"
 
 
 G_DEFINE_TYPE (GthFileToolRotateLeft, gth_file_tool_rotate_left, GTH_TYPE_FILE_TOOL)
 
 
+static gpointer
+rotate_left_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_ROTATE_270);
+       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_rotate_left_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_ROTATE_270);
-       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,
+                                         rotate_left_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]