Updating branch refs/heads/ristretto-0.0 to bac224cb1b66e10412b716087efc58bf3e95eb41 (commit) from c392e68978eb22be783cc51fb4dc5af083e21019 (commit)
commit bac224cb1b66e10412b716087efc58bf3e95eb41 Author: Stephan Arts <step...@xfce.org> Date: Wed May 20 00:06:28 2009 +0200 Scale image down to page-size ChangeLog | 4 ++++ src/main_window.c | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28898cb..77ac7a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-05-20 Stephan Arts <step...@xfce.org> + + * src/main_window.c: Scale the image down to page-size + 2009-05-17 Stephan Arts <step...@xfce.org> * src/main_window.c: Toggle printing-button sensitivity diff --git a/src/main_window.c b/src/main_window.c index 9534422..2a22df1 100644 --- a/src/main_window.c +++ b/src/main_window.c @@ -1189,7 +1189,10 @@ cb_rstto_main_window_print (GtkWidget *widget, RsttoMainWindow *window) gtk_print_settings_set_resolution (print_settings, 300); GtkPrintOperation *print_operation = gtk_print_operation_new (); + GtkPageSetup *page_setup = gtk_page_setup_new (); + gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); + gtk_print_operation_set_default_page_setup (print_operation, page_setup); gtk_print_operation_set_print_settings (print_operation, print_settings); g_object_set (print_operation, @@ -1210,11 +1213,28 @@ rstto_main_window_print_draw_page (GtkPrintOperation *operation, { RsttoImage *image = rstto_navigator_iter_get_image (window->priv->iter); GdkPixbuf *pixbuf = rstto_image_get_pixbuf (image); + gdouble w = gdk_pixbuf_get_width (pixbuf); + gdouble w1 = gtk_print_context_get_width (print_context); + gdouble h = gdk_pixbuf_get_height (pixbuf); + gdouble h1 = gtk_print_context_get_height (print_context); cairo_t *context = gtk_print_context_get_cairo_context (print_context); + cairo_translate (context, 0, 0); + /* Scale to page-width */ + if ((w1/w) < (h1/h)) + { + cairo_scale (context, w1/w, w1/w); + } + else + { + cairo_scale (context, h1/h, h1/h); + } + //cairo_rotate (context, 90 * 3.141592/180); gdk_cairo_set_source_pixbuf (context, pixbuf, 0, 0); - //cairo_scale (context, 1000, 1000); + + //cairo_rectangle (context, 0, 0, 200, 200); + cairo_paint (context); } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits