[gthumb] rotate right: load the original image using a GthImageViewerTask
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] rotate right: load the original image using a GthImageViewerTask
- Date: Sat, 9 Nov 2013 19:58:11 +0000 (UTC)
commit 5a49ea2a4120c76479b130400d5f1251e0618960
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Sep 21 16:48:53 2013 +0200
rotate right: load the original image using a GthImageViewerTask
extensions/file_tools/gth-file-tool-rotate-right.c | 49 ++++++++++++++------
1 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-rotate-right.c
b/extensions/file_tools/gth-file-tool-rotate-right.c
index e1d12a7..ce03aa4 100644
--- a/extensions/file_tools/gth-file-tool-rotate-right.c
+++ b/extensions/file_tools/gth-file-tool-rotate-right.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-right.h"
G_DEFINE_TYPE (GthFileToolRotateRight, gth_file_tool_rotate_right, GTH_TYPE_FILE_TOOL)
+static gpointer
+rotate_right_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_90);
+ 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_right_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_90);
- 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_right_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]