Ref #160: Replace print dialog by standard GTK dialog
authorColin Clark <colin.clark@cclark.uk>
Thu, 4 Oct 2018 15:16:25 +0000 (16:16 +0100)
committerColin Clark <colin.clark@cclark.uk>
Thu, 4 Oct 2018 15:16:25 +0000 (16:16 +0100)
https://github.com/BestImageViewer/geeqie/issues/160

Rotate to exif orientation

src/print.c

index 6506ac5..8032ac3 100644 (file)
 #include "main.h"
 #include "print.h"
 
+#include "exif.h"
 #include "filedata.h"
 #include "image-load.h"
+#include "pixbuf_util.h"
 #include "ui_misc.h"
 #include "ui_fileops.h"
 
@@ -527,6 +529,7 @@ static void draw_page(GtkPrintOperation *operation, GtkPrintContext *context,
        gdouble height_offset;
        GdkPixbuf *pixbuf;
        GdkPixbuf *pixbuf_scaled;
+       GdkPixbuf *rotated = NULL;
        PangoLayout *layout_image = NULL;
        PangoLayout *layout_page = NULL;
        PangoFontDescription *desc;
@@ -543,12 +546,18 @@ static void draw_page(GtkPrintOperation *operation, GtkPrintContext *context,
        GtkTextIter start, end;
        gchar *tmp;
 
+       fd = g_list_nth_data(pw->source_selection, page_nr);
+
        pixbuf = g_list_nth_data(pw->print_pixbuf_queue, page_nr);
+       if (fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
+               {
+               rotated = pixbuf_apply_orientation(pixbuf, fd->exif_orientation);
+               pixbuf = rotated;
+               }
+
        pixbuf_image_width = gdk_pixbuf_get_width(pixbuf);
        pixbuf_image_height = gdk_pixbuf_get_height(pixbuf);
 
-       fd = g_list_nth_data(pw->source_selection, page_nr);
-
        if (options->printer.show_image_text)
                {
                if (pw->text_fields & TEXT_INFO_FILENAME)
@@ -749,6 +758,7 @@ static void draw_page(GtkPrintOperation *operation, GtkPrintContext *context,
                }
 
        g_object_unref(pixbuf_scaled);
+       if (rotated) g_object_unref(rotated);
 
        return;
 }