[Commits] [SCM] claws branch, master, updated. 3.9.3-97-g564bd91

colin at claws-mail.org colin at claws-mail.org
Fri Apr 25 11:45:51 CEST 2014


The branch master of project "claws" (Claws Mail) has been updated
       via  564bd916ef76d7ed91e76ae505221de1df214381 (commit)
      from  ad797671f663bcbabb05349bf7b29565b8d3e431 (commit)


- Log -----------------------------------------------------------------
commit 564bd916ef76d7ed91e76ae505221de1df214381
Author: Colin Leroy <colin at colino.net>
Date:   Fri Apr 25 11:45:37 2014 +0200

    Add avatar to the prints.

diff --git a/src/messageview.c b/src/messageview.c
index f822909..30cd460 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -2189,7 +2189,10 @@ static void print_mimeview(MimeView *mimeview, gint sel_start, gint sel_end, gin
 		mainwin = mainwindow_get_mainwindow();
 		printing_print(GTK_TEXT_VIEW(mimeview->textview->text),
 			       mainwin ? GTK_WINDOW(mainwin->window) : NULL,
-				sel_start, sel_end);
+				sel_start, sel_end,
+				(mimeview->textview->image 
+					? GTK_IMAGE(mimeview->textview->image)
+					: NULL));
 	}
 }
 
diff --git a/src/plugins/pdf_viewer/poppler_viewer.c b/src/plugins/pdf_viewer/poppler_viewer.c
index f1b6b1e..2f6e269 100644
--- a/src/plugins/pdf_viewer/poppler_viewer.c
+++ b/src/plugins/pdf_viewer/poppler_viewer.c
@@ -1657,7 +1657,7 @@ static void pdf_viewer_print(MimeViewer *mviewer)
 	pdf_renderer->cb_draw_page      = pdf_viewer_cb_draw_page;
 
 	printing_print_full(mainwin ? GTK_WINDOW(mainwin->window):NULL,
-			pdf_renderer, viewer->pdf_doc, -1, -1);
+			pdf_renderer, viewer->pdf_doc, -1, -1, NULL);
 	
 	g_free(pdf_renderer);
 }
diff --git a/src/printing.c b/src/printing.c
index f118b28..369f922 100644
--- a/src/printing.c
+++ b/src/printing.c
@@ -52,6 +52,7 @@ struct _PrintData {
 	gint img_cnt;
 	gdouble zoom;
 	gdouble ypos_line;
+	GtkImage *avatar;
 };
 
 typedef struct {
@@ -248,7 +249,7 @@ GtkPageSetup *printing_get_page_setup(void)
 }
 
 void printing_print_full(GtkWindow *parent, PrintRenderer *renderer, gpointer renderer_data, 
-			 gint sel_start, gint sel_end)
+			 gint sel_start, gint sel_end, GtkImage *avatar)
 {			 
 	GtkPrintOperation *op;
 	GtkPrintOperationResult res;
@@ -262,6 +263,7 @@ void printing_print_full(GtkWindow *parent, PrintRenderer *renderer, gpointer re
 	print_data->renderer_data = renderer_data;
 	print_data->sel_start = sel_start;
 	print_data->sel_end = sel_end;
+	print_data->avatar = GTK_IMAGE(g_object_ref(avatar));
 
 	print_data->zoom = 1.;
 
@@ -307,6 +309,8 @@ void printing_print_full(GtkWindow *parent, PrintRenderer *renderer, gpointer re
 	g_list_free(print_data->page_breaks);
 	if (print_data->layout)
 		g_object_unref(print_data->layout);
+	if (print_data->avatar)
+		g_object_unref(print_data->avatar);
 
 	g_free(print_data);
 
@@ -336,7 +340,7 @@ static gpointer printing_textview_get_data_to_print(gpointer data, gint sel_star
 	return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 }
 
-void printing_print(GtkTextView *text_view, GtkWindow *parent, gint sel_start, gint sel_end)
+void printing_print(GtkTextView *text_view, GtkWindow *parent, gint sel_start, gint sel_end, GtkImage *avatar)
 {
 	PrintRenderer *textview_renderer = g_new0(PrintRenderer, 1);
 	
@@ -345,7 +349,7 @@ void printing_print(GtkTextView *text_view, GtkWindow *parent, gint sel_start, g
 	textview_renderer->cb_begin_print    = printing_textview_cb_begin_print;
 	textview_renderer->cb_draw_page      = printing_textview_cb_draw_page;
 
-	printing_print_full(parent, textview_renderer, text_view, sel_start, sel_end);
+	printing_print_full(parent, textview_renderer, text_view, sel_start, sel_end, avatar);
 	
 	g_free(textview_renderer);
 }
@@ -1106,9 +1110,9 @@ static void printing_textview_cb_draw_page(GtkPrintOperation *op, GtkPrintContex
 			pango_layout_iter_get_line_extents(iter, NULL, &logical_rect);
 			baseline = pango_layout_iter_get_baseline(iter);
 
-			if (ii == start)
+			if (ii == start) {
 				start_pos = ((double)logical_rect.y) / PANGO_SCALE;
-
+			}
 			/* Draw header separator line */
 			if (ii == 0 && print_data->ypos_line >= 0) {
 				cairo_surface_t *surface;
@@ -1147,6 +1151,24 @@ static void printing_textview_cb_draw_page(GtkPrintOperation *op, GtkPrintContex
 		}
 		ii++;
 	} while(ii < end && (notlast = pango_layout_iter_next_line(iter)));
+
+	if (print_data->avatar && page_nr == 0) {
+		cairo_surface_t *surface;
+		GdkPixbuf *pixbuf = gtk_image_get_pixbuf(print_data->avatar);
+		gdouble startx, starty;
+		
+		startx = gtk_print_context_get_width(context)/print_data->zoom;
+		
+		startx -= ((double)gdk_pixbuf_get_width(pixbuf));
+
+		starty = start_pos;
+
+		surface = pixbuf_to_surface(pixbuf);
+		cairo_set_source_surface (cr, surface, startx, starty);
+		cairo_paint (cr);
+		cairo_surface_destroy (surface);
+	}
+
 	pango_layout_iter_free(iter);
 	debug_print("Sent page %d to printer\n", page_nr+1);
 }
diff --git a/src/printing.h b/src/printing.h
index 5865563..79a29f8 100644
--- a/src/printing.h
+++ b/src/printing.h
@@ -37,9 +37,9 @@ typedef struct _PrintRenderer {
 			     gpointer user_data);
 } PrintRenderer;
 
-void printing_print(GtkTextView*, GtkWindow*, gint, gint);
+void printing_print(GtkTextView*, GtkWindow*, gint, gint, GtkImage *avatar);
 void printing_print_full(GtkWindow *parent, PrintRenderer *renderer, gpointer renderer_data, 
-			 gint sel_start, gint sel_end);
+			 gint sel_start, gint sel_end, GtkImage *avatar);
 void printing_page_setup(GtkWindow*);
 gpointer printing_get_renderer_data(PrintData *print_data);
 gdouble  printing_get_zoom(PrintData *print_data);

-----------------------------------------------------------------------

Summary of changes:
 src/messageview.c                       |    5 ++++-
 src/plugins/pdf_viewer/poppler_viewer.c |    2 +-
 src/printing.c                          |   32 ++++++++++++++++++++++++++-----
 src/printing.h                          |    4 ++--
 4 files changed, 34 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list