[gthumb] image viewer: added a common callback to set the modified image



commit 4938b9faee0e264edb2b835d0a9c17ee8ebbc5a9
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Sep 21 15:07:03 2013 +0200

    image viewer: added a common callback to set the modified image

 .../file_tools/gth-file-tool-adjust-contrast.c     |   34 +------------------
 extensions/image_viewer/gth-image-viewer-task.c    |   25 ++++++++++++++
 extensions/image_viewer/gth-image-viewer-task.h    |    4 ++
 3 files changed, 31 insertions(+), 32 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-adjust-contrast.c 
b/extensions/file_tools/gth-file-tool-adjust-contrast.c
index 5d828d6..2e194a4 100644
--- a/extensions/file_tools/gth-file-tool-adjust-contrast.c
+++ b/extensions/file_tools/gth-file-tool-adjust-contrast.c
@@ -208,36 +208,6 @@ adjust_contrast_data_free (gpointer user_data)
 
 
 static void
-image_task_completed_cb (GthTask  *task,
-                        GError   *error,
-                        gpointer  user_data)
-{
-       GthFileTool     *base = user_data;
-       cairo_surface_t *destination;
-       GtkWidget       *window;
-       GtkWidget       *viewer_page;
-
-       if (error != NULL) {
-               g_object_unref (task);
-               return;
-       }
-
-       destination = gth_image_task_get_destination_surface (GTH_IMAGE_TASK (task));
-       if (destination == NULL) {
-               g_object_unref (task);
-               return;
-       }
-
-       window = gth_file_tool_get_window (base);
-       viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
-       gth_image_viewer_page_set_image (GTH_IMAGE_VIEWER_PAGE (viewer_page), destination, TRUE);
-
-       cairo_surface_destroy (destination);
-       g_object_unref (task);
-}
-
-
-static void
 gth_file_tool_adjust_contrast_activate (GthFileTool *base)
 {
        GtkWidget          *window;
@@ -264,8 +234,8 @@ gth_file_tool_adjust_contrast_activate (GthFileTool *base)
                                          adjust_contrast_data_free);
        g_signal_connect (task,
                          "completed",
-                         G_CALLBACK (image_task_completed_cb),
-                         base);
+                         G_CALLBACK (gth_image_viewer_task_set_destination),
+                         NULL);
        gth_browser_exec_task (GTH_BROWSER (window), task, FALSE);
 }
 
diff --git a/extensions/image_viewer/gth-image-viewer-task.c b/extensions/image_viewer/gth-image-viewer-task.c
index 19efa5a..1aaa98f 100644
--- a/extensions/image_viewer/gth-image-viewer-task.c
+++ b/extensions/image_viewer/gth-image-viewer-task.c
@@ -171,3 +171,28 @@ gth_image_viewer_task_set_load_original (GthImageViewerTask *self,
 {
        self->priv->load_original = load_original;
 }
+
+
+void
+gth_image_viewer_task_set_destination  (GthTask  *task,
+                                       GError   *error,
+                                       gpointer  user_data)
+{
+       cairo_surface_t *destination;
+
+       if (error != NULL) {
+               g_object_unref (task);
+               return;
+       }
+
+       destination = gth_image_task_get_destination_surface (GTH_IMAGE_TASK (task));
+       if (destination == NULL) {
+               g_object_unref (task);
+               return;
+       }
+
+       gth_image_viewer_page_set_image (GTH_IMAGE_VIEWER_TASK (task)->priv->viewer_page, destination, TRUE);
+
+       cairo_surface_destroy (destination);
+       g_object_unref (task);
+}
diff --git a/extensions/image_viewer/gth-image-viewer-task.h b/extensions/image_viewer/gth-image-viewer-task.h
index 480677d..c968dfc 100644
--- a/extensions/image_viewer/gth-image-viewer-task.h
+++ b/extensions/image_viewer/gth-image-viewer-task.h
@@ -57,6 +57,10 @@ GthTask *     gth_image_viewer_task_new                      (GthImageViewerPage     
*viewer_page,
                                                         GDestroyNotify          user_data_destroy_func);
 void         gth_image_viewer_task_set_load_original   (GthImageViewerTask     *self,
                                                         gboolean                load_original);
+void         gth_image_viewer_task_set_destination     (GthTask                *task,
+                                                        GError                 *error,
+                                                        gpointer                user_data);
+
 G_END_DECLS
 
 #endif /* GTH_IMAGE_VIEWER_TASK_H */


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