[gthumb] allow to print a modified image



commit 533fe3c79303c914bec6920a1d5a9e4f22e7ea6d
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Aug 28 13:52:05 2010 +0200

    allow to print a modified image
    
    [bug #595654]

 extensions/image_print/actions.c                  |   21 +++++++++-
 extensions/image_print/gth-image-print-job.c      |   17 ++++++--
 extensions/image_print/gth-image-print-job.h      |    2 +
 extensions/image_print/gth-load-image-info-task.c |   45 +++++++++++++-------
 4 files changed, 64 insertions(+), 21 deletions(-)
---
diff --git a/extensions/image_print/actions.c b/extensions/image_print/actions.c
index 3a01985..c807736 100644
--- a/extensions/image_print/actions.c
+++ b/extensions/image_print/actions.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #include <glib/gi18n.h>
 #include <gthumb.h>
+#include <extensions/image_viewer/gth-image-viewer-page.h>
 #include "gth-image-print-job.h"
 
 
@@ -36,10 +37,28 @@ gth_browser_activate_action_file_print (GtkAction  *action,
 	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
 	file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
 	if (file_list != NULL) {
+		GdkPixbuf        *current_image;
+		GtkWidget        *viewer_page;
 		GthImagePrintJob *print_job;
 		GError           *error = NULL;
 
-		print_job = gth_image_print_job_new (file_list, &error);
+		current_image = NULL;
+
+		viewer_page = gth_browser_get_viewer_page (browser);
+		if ((gth_main_extension_is_active ("image_viewer"))
+		    && (viewer_page != NULL)
+		    && GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
+		{
+			GtkWidget *viewer;
+
+			viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+			current_image = gth_image_viewer_get_current_pixbuf (GTH_IMAGE_VIEWER (viewer));
+		}
+
+		print_job = gth_image_print_job_new (file_list,
+						     gth_browser_get_current_file (browser),
+						     current_image,
+						     &error);
 		if (print_job != NULL)
 			gth_image_print_job_run (print_job,
 						 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
diff --git a/extensions/image_print/gth-image-print-job.c b/extensions/image_print/gth-image-print-job.c
index 269795a..ba192a3 100644
--- a/extensions/image_print/gth-image-print-job.c
+++ b/extensions/image_print/gth-image-print-job.c
@@ -1506,8 +1506,10 @@ print_operation_done_cb (GtkPrintOperation       *operation,
 
 
 GthImagePrintJob *
-gth_image_print_job_new (GList   *file_data_list,
-			 GError **error)
+gth_image_print_job_new (GList        *file_data_list,
+			 GthFileData  *current,
+			 GdkPixbuf    *current_image,
+			 GError      **error)
 {
 	GthImagePrintJob *self;
 	GList            *scan;
@@ -1520,8 +1522,15 @@ gth_image_print_job_new (GList   *file_data_list,
 	for (scan = file_data_list, n = 0; scan; scan = scan->next) {
 		GthFileData *file_data = scan->data;
 
-		if (_g_mime_type_is_image (gth_file_data_get_mime_type (file_data)))
-			self->priv->images[n++] = gth_image_info_new (file_data);
+		if (_g_mime_type_is_image (gth_file_data_get_mime_type (file_data))) {
+			GthImageInfo *image_info;
+
+			image_info = gth_image_info_new (file_data);
+			if ((current_image != NULL) && g_file_equal (file_data->file, current->file))
+				gth_image_info_set_pixbuf (image_info, current_image);
+
+			self->priv->images[n++] = image_info;
+		}
 	}
 	self->priv->images[n] = NULL;
 	self->priv->n_images = n;
diff --git a/extensions/image_print/gth-image-print-job.h b/extensions/image_print/gth-image-print-job.h
index a774da0..2ad7ebc 100644
--- a/extensions/image_print/gth-image-print-job.h
+++ b/extensions/image_print/gth-image-print-job.h
@@ -49,6 +49,8 @@ struct _GthImagePrintJobClass {
 
 GType              gth_image_print_job_get_type (void);
 GthImagePrintJob * gth_image_print_job_new      (GList                    *file_data_list,
+						 GthFileData              *current,
+						 GdkPixbuf                *current_image,
 						 GError                  **error);
 void               gth_image_print_job_run      (GthImagePrintJob         *self,
 						 GtkPrintOperationAction   action,
diff --git a/extensions/image_print/gth-load-image-info-task.c b/extensions/image_print/gth-load-image-info-task.c
index 3dab6c6..f7fd3f5 100644
--- a/extensions/image_print/gth-load-image-info-task.c
+++ b/extensions/image_print/gth-load-image-info-task.c
@@ -81,6 +81,28 @@ metadata_ready_cb (GList    *files,
 
 
 static void
+continue_loading_image (GthLoadImageInfoTask *self)
+{
+	if (strcmp (self->priv->attributes, "") != 0) {
+		GthImageInfo *image_info;
+		GList        *files;
+
+		image_info = self->priv->images[self->priv->current];
+		files = g_list_prepend (NULL, image_info->file_data);
+		_g_query_metadata_async (files,
+					 self->priv->attributes,
+					 gth_task_get_cancellable (GTH_TASK (self)),
+					 metadata_ready_cb,
+					 self);
+
+		g_list_free (files);
+	}
+	else
+		load_next_image (self);
+}
+
+
+static void
 image_loader_ready_cb (GthImageLoader *loader,
 		       GError         *error,
 		       gpointer        user_data)
@@ -102,20 +124,7 @@ image_loader_ready_cb (GthImageLoader *loader,
 	if (pixbuf != NULL)
 		gth_image_info_set_pixbuf (image_info, pixbuf);
 
-	if (strcmp (self->priv->attributes, "") != 0) {
-		GList *files;
-
-		files = g_list_prepend (NULL, image_info->file_data);
-		_g_query_metadata_async (files,
-					 self->priv->attributes,
-					 gth_task_get_cancellable (GTH_TASK (self)),
-					 metadata_ready_cb,
-					 self);
-
-		g_list_free (files);
-	}
-	else
-		load_next_image (self);
+	continue_loading_image (self);
 }
 
 
@@ -140,8 +149,12 @@ load_current_image (GthLoadImageInfoTask *self)
 			   FALSE,
 			   ((double) self->priv->current + 0.5) / self->priv->n_images);
 
-	gth_image_loader_set_file_data (self->priv->loader, image_info->file_data);
-	gth_image_loader_load (self->priv->loader);
+	if (image_info->pixbuf == NULL) {
+		gth_image_loader_set_file_data (self->priv->loader, image_info->file_data);
+		gth_image_loader_load (self->priv->loader);
+	}
+	else
+		call_when_idle ((DataFunc) continue_loading_image, self);
 
 	g_free (details);
 }



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