Trim trailing white spaces.
[geeqie.git] / src / print.c
index 29fbafc..25eb5cc 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
  * This software comes with no warranty of any kind, use at your own risk!
  */
 
-
-#include "gqview.h"
+#include "main.h"
 #include "print.h"
 
-#include "filelist.h"
+#include "filedata.h"
 #include "image.h"
 #include "image-load.h"
 #include "pixbuf_util.h"
 #include "ui_spinner.h"
 #include "ui_tabcomp.h"
 
-
 #include <locale.h>
 #include <signal.h>
-
+#include <glib/gprintf.h>
 
 #define PRINT_LPR_COMMAND "lpr"
 #define PRINT_LPR_CUSTOM  "lpr -P %s"
 
 #define PRINT_PREF_PRINTERC    "custom_printer"
 
+#define PRINT_PREF_TEXT                        "text"
+#define PRINT_PREF_TEXTSIZE            "textsize"
+#define PRINT_PREF_TEXTCOLOR_R         "textcolor_r"
+#define PRINT_PREF_TEXTCOLOR_G         "textcolor_g"
+#define PRINT_PREF_TEXTCOLOR_B         "textcolor_b"
+
+#define PRINT_PREF_SOURCE              "source"
+#define PRINT_PREF_LAYOUT              "layout"
+
+#define PRINT_PREF_IMAGE_SCALE         "image_scale"
 
 typedef enum {
        PRINT_SOURCE_IMAGE = 0,
@@ -176,6 +185,22 @@ typedef enum {
        TEXT_INFO_FILEPATH = 1 << 4
 } TextInfo;
 
+typedef enum {
+       PAPER_UNIT_POINTS = 0,
+       PAPER_UNIT_MM,
+       PAPER_UNIT_CM,
+       PAPER_UNIT_INCH,
+       PAPER_UNIT_PICAS,
+       PAPER_UNIT_COUNT
+} PaperUnits;
+
+typedef enum {
+       PAPER_ORIENTATION_PORTRAIT = 0,
+       PAPER_ORIENTATION_LANDSCAPE,
+       PAPER_ORIENTATION_COUNT
+} PaperOrientation;
+
+
 typedef struct _PrintWindow PrintWindow;
 struct _PrintWindow
 {
@@ -207,9 +232,9 @@ struct _PrintWindow
        gdouble layout_width;
        gdouble layout_height;
 
-       gint layout_idle_id;
+       guint layout_idle_id; /* event source id */
 
-       gint image_scale;
+       gdouble image_scale;
 
        GtkWidget *image_scale_spin;
 
@@ -236,11 +261,11 @@ struct _PrintWindow
        GtkWidget *margin_top_spin;
        GtkWidget *margin_bottom_spin;
 
-       gint paper_units;
+       PaperUnits paper_units;
        gint paper_size;
        gdouble paper_width;
        gdouble paper_height;
-       gint paper_orientation;
+       PaperOrientation paper_orientation;
 
        gdouble margin_left;
        gdouble margin_right;
@@ -294,9 +319,9 @@ static void print_window_close(PrintWindow *pw);
 
 /* misc utils */
 
-static gint clip_region(gdouble x1, gdouble y1, gdouble w1, gdouble h1,
-                       gdouble x2, gdouble y2, gdouble w2, gdouble h2,
-                       gdouble *rx, gdouble *ry, gdouble *rw, gdouble *rh)
+static gboolean clip_region(gdouble x1, gdouble y1, gdouble w1, gdouble h1,
+                           gdouble x2, gdouble y2, gdouble w2, gdouble h2,
+                           gdouble *rx, gdouble *ry, gdouble *rw, gdouble *rh)
 {
        if (x2 + w2 <= x1 || x2 >= x1 + w1 ||
            y2 + h2 <= y1 || y2 >= y1 + h1)
@@ -315,7 +340,7 @@ static gint clip_region(gdouble x1, gdouble y1, gdouble w1, gdouble h1,
 
 static const gchar *print_output_name(PrintOutput output)
 {
-       if (output < 0 || output >= PRINT_OUTPUT_COUNT) return "";
+       if (output >= PRINT_OUTPUT_COUNT) return "";
 
        return _(print_output_text[output]);
 }
@@ -328,21 +353,6 @@ static const gchar *print_output_name(PrintOutput output)
  */
 
 
-typedef enum {
-       PAPER_UNIT_POINTS = 0,
-       PAPER_UNIT_MM,
-       PAPER_UNIT_CM,
-       PAPER_UNIT_INCH,
-       PAPER_UNIT_PICAS,
-       PAPER_UNIT_COUNT
-} PaperUnits;
-
-typedef enum {
-       PAPER_ORIENTATION_PORTRAIT = 0,
-       PAPER_ORIENTATION_LANDSCAPE,
-       PAPER_ORIENTATION_COUNT
-} PaperOrientation;
-
 typedef struct _PaperSize PaperSize;
 struct _PaperSize {
        gchar *description;
@@ -484,7 +494,7 @@ static gdouble print_paper_size_convert_units(gdouble value, PaperUnits src, Pap
 
 static PaperUnits paper_unit_default(void)
 {
-       const char *result;
+       const gchar *result;
 #if 0
        /* this is not used because it is not even slightly portable */
        #include <langinfo.h>
@@ -518,7 +528,7 @@ static gint print_layout_page_count(PrintWindow *pw);
 
 static gint print_preview_unit(gdouble points)
 {
-       return (int)(points / PRINT_PREVIEW_SCALE);
+       return (gint)(points / PRINT_PREVIEW_SCALE);
 }
 
 static void print_proof_size(PrintWindow *pw, gdouble *width, gdouble *height)
@@ -560,10 +570,10 @@ static void print_window_layout_status(PrintWindow *pw)
 
 static void print_window_layout_render_stop(PrintWindow *pw)
 {
-       if (pw->layout_idle_id != -1)
+       if (pw->layout_idle_id)
                {
                g_source_remove(pw->layout_idle_id);
-               pw->layout_idle_id = -1;
+               pw->layout_idle_id = 0;
                }
 }
 
@@ -574,7 +584,7 @@ static gboolean print_window_layout_render_idle(gpointer data)
        print_job_close(pw, FALSE);
        print_job_start(pw, RENDER_FORMAT_PREVIEW, 0);
 
-       pw->layout_idle_id = -1;
+       pw->layout_idle_id = 0;
        return FALSE;
 }
 
@@ -588,7 +598,7 @@ static void print_window_layout_render(PrintWindow *pw)
 
        print_window_layout_status(pw);
 
-       if (pw->layout_idle_id == -1)
+       if (!pw->layout_idle_id)
                {
                pw->layout_idle_id = g_idle_add(print_window_layout_render_idle, pw);
                }
@@ -625,7 +635,7 @@ static void print_window_layout_size(PrintWindow *pw)
            gdk_pixbuf_get_height(pixbuf) != sh)
                {
                pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, sw, sh);
-               image_change_pixbuf(pw->layout_image, pixbuf, 0.0);
+               image_change_pixbuf(pw->layout_image, pixbuf, 0.0, FALSE);
                g_object_unref(pixbuf);
                }
 
@@ -740,7 +750,7 @@ static GtkWidget *print_window_layout_setup(PrintWindow *pw, GtkWidget *box)
        vbox = pref_box_new(box, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
        group = pref_frame_new(vbox, TRUE, _("Preview"), GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
 
-       pw->layout_idle_id = -1;
+       pw->layout_idle_id = 0;
 
        pw->layout_image = image_new(FALSE);
        gtk_widget_set_size_request(pw->layout_image->widget, PRINT_DLG_PREVIEW_WIDTH, PRINT_DLG_PREVIEW_HEIGHT);
@@ -931,7 +941,7 @@ static GList *print_window_list_printers(void)
                while (*end != '\0' && *end != '\n' && *end != ' ' && *end != '\t') end++;
                *end = '\0';
                list = g_list_append(list, g_strdup(ptr));
-               if (debug) printf("adding printer: %s\n", ptr);
+               DEBUG_1("adding printer: %s", ptr);
                }
 
        pclose(p);
@@ -954,7 +964,7 @@ struct _PipeError {
 static sig_atomic_t pipe_handler_error = FALSE;
 static PipeError *pipe_handler_data = NULL;
 
-static void pipe_handler_sigpipe_cb(int fd)
+static void pipe_handler_sigpipe_cb(gint fd)
 {
        pipe_handler_error = TRUE;
 }
@@ -966,7 +976,7 @@ static PipeError *pipe_handler_new(void)
 
        if (pipe_handler_data)
                {
-               printf("warning SIGPIPE handler already in use\n");
+               log_printf("warning SIGPIPE handler already in use\n");
                return NULL;
                }
 
@@ -976,11 +986,11 @@ static PipeError *pipe_handler_new(void)
        pe->error = &pipe_handler_error;
 
        new_action.sa_handler = pipe_handler_sigpipe_cb;
-       sigemptyset (&new_action.sa_mask);
+       sigemptyset(&new_action.sa_mask);
        new_action.sa_flags = 0;
 
        /* setup our signal handler */
-       sigaction (SIGPIPE, &new_action, &pe->old_action);
+       sigaction(SIGPIPE, &new_action, &pe->old_action);
 
        pipe_handler_data = pe;
        return pe;
@@ -989,19 +999,19 @@ static PipeError *pipe_handler_new(void)
 static void pipe_handler_free(PipeError *pe)
 {
        if (!pe) return;
-       if (pe != pipe_handler_data) printf("warning SIGPIPE handler not closing same data\n");
+       if (pe != pipe_handler_data) log_printf("warning SIGPIPE handler not closing same data\n");
 
        /* restore the original signal handler */
-       sigaction (SIGPIPE, &pe->old_action, NULL);
+       sigaction(SIGPIPE, &pe->old_action, NULL);
 
        pipe_handler_data = NULL;
        g_free(pe);
 }
 
-static gint pipe_handler_check(PipeError *pe)
+static gboolean pipe_handler_check(PipeError *pe)
 {
        if (!pe) return FALSE;
-       return *pe->error;
+       return !!(*pe->error);
 }
 
 static FILE *print_job_ps_fd(PrintWindow *pw)
@@ -1011,14 +1021,14 @@ static FILE *print_job_ps_fd(PrintWindow *pw)
        return NULL;
 }
 
-static gint print_job_ps_init(PrintWindow *pw)
+static gboolean print_job_ps_init(PrintWindow *pw)
 {
        FILE *f;
        PipeError *pe;
        const gchar *cmd = NULL;
        const gchar *path = NULL;
        gchar *lc_pointer;
-       gint ret;
+       gboolean ret;
 
        if (pw->job_file != NULL || pw->job_pipe != NULL) return FALSE;
 
@@ -1096,29 +1106,30 @@ static gint print_job_ps_init(PrintWindow *pw)
        pe = pipe_handler_new();
 
        /* comments, etc. */
-       fprintf(f, "%%!PS-Adobe-3.0\n");
-       fprintf(f, "%%%%Creator: Geeqie Version %s\n", VERSION);
-       fprintf(f, "%%%%CreationDate: \n");
-       fprintf(f, "%%%%LanguageLevel 2\n");
-       fprintf(f, "%%%%DocumentMedia: \n");
-       fprintf(f, "%%%%Orientation: %s\n",
+       g_fprintf(f, "%%!PS-Adobe-3.0\n");
+       g_fprintf(f, "%%%%Creator: %s Version %s\n", GQ_APPNAME, VERSION);
+       g_fprintf(f, "%%%%CreationDate: \n");
+       g_fprintf(f, "%%%%LanguageLevel 2\n");
+       g_fprintf(f, "%%%%DocumentMedia: \n");
+       g_fprintf(f, "%%%%Orientation: %s\n",
                (pw->paper_orientation == PAPER_ORIENTATION_PORTRAIT) ? "Portrait" : "Landscape");
-       fprintf(f, "%%%%BoundingBox: %f %f %f %f\n",
+       g_fprintf(f, "%%%%BoundingBox: %f %f %f %f\n",
                0.0, 0.0, pw->paper_width, pw->paper_height);
-       fprintf(f, "%%%%Pages: %d\n", print_layout_page_count(pw));
-       fprintf(f, "%%%%PageOrder: Ascend\n");
-       fprintf(f, "%%%%Title:\n");
+       g_fprintf(f, "%%%%Pages: %d\n", print_layout_page_count(pw));
+       g_fprintf(f, "%%%%PageOrder: Ascend\n");
+       g_fprintf(f, "%%%%Title:\n");
 
        /* setup page size, coordinates (do we really need this?) */
-#if 0
-       fprintf(f, "<<\n");
-       fprintf(f, "/PageSize [%f %f]\n", pw->layout_width, pw->layout_height);
-       fprintf(f, "/ImagingBBox [%f %f %f %f]\n", /* l b r t */
+       /* enabled for 1.0beta2  https://bugzilla.redhat.com/222639 */
+#if 1
+       g_fprintf(f, "<<\n");
+       g_fprintf(f, "/PageSize [%f %f]\n", pw->layout_width, pw->layout_height);
+       g_fprintf(f, "/ImagingBBox [%f %f %f %f]\n", /* l b r t */
                pw->margin_left, pw->margin_bottom,
                pw->layout_width - pw->margin_right, pw->layout_height - pw->margin_top);
-       fprintf(f, "/Orientation %d\n",
+       g_fprintf(f, "/Orientation %d\n",
                (pw->paper_orientation == PAPER_ORIENTATION_PORTRAIT) ? 0 : 1);
-       fprintf(f, ">> setpagedevice\n");
+       g_fprintf(f, ">> setpagedevice\n");
 #endif
 
        ret = !pipe_handler_check(pe);
@@ -1135,12 +1146,12 @@ static gint print_job_ps_init(PrintWindow *pw)
        return ret;
 }
 
-static gint print_job_ps_page_new(PrintWindow *pw, gint page)
+static gboolean print_job_ps_page_new(PrintWindow *pw, gint page)
 {
        FILE *f;
        PipeError *pe;
        gchar *lc_pointer;
-       gint ret;
+       gboolean ret;
 
        f= print_job_ps_fd(pw);
        if (!f) return FALSE;
@@ -1150,12 +1161,12 @@ static gint print_job_ps_page_new(PrintWindow *pw, gint page)
 
        pe = pipe_handler_new();
 
-       fprintf(f, "%%%% page %d\n", page + 1);
+       g_fprintf(f, "%%%% page %d\n", page + 1);
 
        if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
                {
-               fprintf(f, "/pagelevel save def\n");
-               fprintf(f, "%d 0 translate 90 rotate\n", (gint)pw->layout_height);
+               g_fprintf(f, "/pagelevel save def\n");
+               g_fprintf(f, "%d 0 translate 90 rotate\n", (gint)pw->layout_height);
                }
 
        ret = !pipe_handler_check(pe);
@@ -1172,12 +1183,12 @@ static gint print_job_ps_page_new(PrintWindow *pw, gint page)
        return ret;
 }
 
-static gint print_job_ps_page_done(PrintWindow *pw)
+static gboolean print_job_ps_page_done(PrintWindow *pw)
 {
        FILE *f;
        PipeError *pe;
        gchar *lc_pointer;
-       gint ret;
+       gboolean ret;
 
        f = print_job_ps_fd(pw);
        if (!f) return FALSE;
@@ -1189,10 +1200,10 @@ static gint print_job_ps_page_done(PrintWindow *pw)
 
        if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
                {
-               fprintf(f, "pagelevel restore\n");
+               g_fprintf(f, "pagelevel restore\n");
                }
 
-       fprintf(f, "showpage\n");
+       g_fprintf(f, "showpage\n");
 
        ret = !pipe_handler_check(pe);
        pipe_handler_free(pe);
@@ -1221,11 +1232,11 @@ static void print_job_ps_page_image_pixel(FILE *f, guchar *pix)
                }
        text[6] = '\0';
 
-       fprintf(f, text);
-}                                                                                                                         
-static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
-                                   gdouble x, gdouble y, gdouble w, gdouble h,
-                                   gdouble offx, gdouble offy)
+       g_fprintf(f, "%s", text);
+}
+static gboolean print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
+                                       gdouble x, gdouble y, gdouble w, gdouble h,
+                                       gdouble offx, gdouble offy)
 {
        FILE *f;
        PipeError *pe;
@@ -1238,7 +1249,7 @@ static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
        gint c;
        guchar *p;
        guchar bps_buf[3];
-       gint ret;
+       gboolean ret;
 
        if (!pixbuf) return TRUE;
 
@@ -1272,13 +1283,13 @@ static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
 
        pe = pipe_handler_new();
 
-       fprintf(f, "gsave\n");
-       fprintf(f, "[%f 0 0 %f %f %f] concat\n", w, h, x, pw->layout_height - h - y);
-       fprintf(f, "/buf %d string def\n", sw * 3);
-       fprintf(f, "%d %d %d\n", sw, sh, 8);
-       fprintf(f, "[%d 0 0 -%d 0 %d]\n", sw, sh, sh);
-       fprintf(f, "{ currentfile buf readhexstring pop }\n");
-       fprintf(f, "false %d colorimage\n", 3);
+       g_fprintf(f, "gsave\n");
+       g_fprintf(f, "[%f 0 0 %f %f %f] concat\n", w, h, x, pw->layout_height - h - y);
+       g_fprintf(f, "/buf %d string def\n", sw * 3);
+       g_fprintf(f, "%d %d %d\n", sw, sh, 8);
+       g_fprintf(f, "[%d 0 0 -%d 0 %d]\n", sw, sh, sh);
+       g_fprintf(f, "{ currentfile buf readhexstring pop }\n");
+       g_fprintf(f, "false %d colorimage\n", 3);
 
        c = 0;
        for (j = 0; j < sh; j++)
@@ -1301,13 +1312,13 @@ static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
                        c++;
                        if (c > 11)
                                {
-                               fprintf(f, "\n");
+                               g_fprintf(f, "\n");
                                c = 0;
                                }
                        }
                }
-       if (c > 0) fprintf(f, "\n");
-       fprintf(f, "grestore\n");
+       if (c > 0) g_fprintf(f, "\n");
+       g_fprintf(f, "grestore\n");
 
        ret = !pipe_handler_check(pe);
        pipe_handler_free(pe);
@@ -1325,103 +1336,54 @@ static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
        return ret;
 }
 
-static const gchar *ps_text_to_hex_array(FILE *f, const gchar *text, gdouble x, gdouble y)
-{
-       static gchar hex_digits[] = "0123456789abcdef";
-       const gchar *p;
-
-       if (!text) return NULL;
-
-       fprintf(f, "%f %f moveto\n", x, y);
-       fprintf(f, "<");
-
-       /* fixme: convert utf8 to ascii or proper locale string.. */
-
-       p = text;
-       while (*p != '\0' && *p != '\n')
-               {
-               gchar text[3];
-
-               text[0] = hex_digits[*p >> 4];
-               text[1] = hex_digits[*p & 0xf];
-               text[2] = '\0';
-
-               fprintf(f, text);
-
-               p++;
-               }
-
-       fprintf(f, ">\n");
-       fprintf(f, "dup stringwidth pop 2 div neg 0 rmoveto show\n");
-
-       return p;
-}
-
-static void ps_text_parse(FILE *f, const gchar *text, gdouble x, gdouble y, gdouble point_size)
-{
-       const gchar *p;
-
-       if (!text) return;
-
-       fprintf(f, "newpath\n");
+static gdouble convert_pango_dpi(gdouble points);
 
-       p = text;
-       while (p && *p != '\0')
-               {
-               p = ps_text_to_hex_array(f, p, x, y);
-               if (p && *p == '\n') p++;
-               y -= point_size;
-               }
-
-       fprintf(f, "closepath\n");
-}
-
-static gint print_job_ps_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
-                                  gdouble x, gdouble y, gdouble width,
-                                  guint8 r, guint8 g, guint8 b)
+static gboolean print_job_ps_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
+                                      gdouble x, gdouble y, gdouble width,
+                                      guint8 r, guint8 g, guint8 b)
 {
-       FILE *f;
-       PipeError *pe;
-       gchar *lc_pointer;
-       gint ret;
-
-       if (!text) return TRUE;
-
-       f = print_job_ps_fd(pw);
-       if (!f) return FALSE;
+       PangoLayout *layout;
+       PangoFontDescription *desc;
+       GdkPixbuf *pixbuf;
+       gint lw, lh;
+       gboolean ret;
+       gdouble scale_to_max_dpi = (pw->max_dpi >= PRINT_PS_DPI_MIN) ? pw->max_dpi / 72.0 : 1200.0 / 72.0;
 
-       lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
-       setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
+       layout = gtk_widget_create_pango_layout(pw->dialog->dialog, NULL);
 
-       pe = pipe_handler_new();
+       desc = pango_font_description_new();
+       pango_font_description_set_size(desc, convert_pango_dpi(point_size) * PANGO_SCALE * scale_to_max_dpi);
+       pango_layout_set_font_description(layout, desc);
+       pango_font_description_free(desc);
 
-       fprintf(f, "/Sans findfont\n");
-       fprintf(f, "%f scalefont\n", point_size);
-       fprintf(f, "setfont\n");
+       pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
+       pango_layout_set_text(layout, text, -1);
 
-       fprintf(f, "%f %f %f setrgbcolor\n", (gdouble)r / 255.0, (gdouble)g / 255.0, (gdouble)b / 255.0);
-       ps_text_parse(f, text, x, pw->layout_height - y - point_size, point_size);
+       pango_layout_get_pixel_size(layout, &lw, &lh);
+       x = x - (gdouble)lw / 2.0 / scale_to_max_dpi;
 
-       ret = !pipe_handler_check(pe);
-       pipe_handler_free(pe);
+       pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, lw, lh);
+       gdk_pixbuf_fill(pixbuf, 0xffffffff);
+       pixbuf_draw_layout(pixbuf, layout, pw->dialog->dialog, 0, 0, r, g, b, 255);
+       g_object_unref(G_OBJECT(layout));
 
-       if (lc_pointer)
-               {
-               setlocale(LC_NUMERIC, lc_pointer);
-               g_free(lc_pointer);
-               }
+       ret = print_job_ps_page_image(pw, pixbuf, x, y,
+                                      /* do not allow rescaling of the pixbuf due to rounding errors */
+                                     ((gdouble)lw + 0.01) / scale_to_max_dpi,
+                                     ((gdouble)lh + 0.01) / scale_to_max_dpi,
+                                     0, 0);
 
-       if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
+       g_object_unref(G_OBJECT(pixbuf));
 
        return ret;
 }
 
-static gint print_job_ps_end(PrintWindow *pw)
+static gboolean print_job_ps_end(PrintWindow *pw)
 {
        FILE *f;
        PipeError *pe;
        gchar *lc_pointer;
-       gint ret;
+       gboolean ret;
 
        f = print_job_ps_fd(pw);
        if (!f) return FALSE;
@@ -1431,7 +1393,7 @@ static gint print_job_ps_end(PrintWindow *pw)
 
        pe = pipe_handler_new();
 
-       fprintf(f, "%%%%EOF\n");
+       g_fprintf(f, "%%%%EOF\n");
 
        ret = !pipe_handler_check(pe);
        pipe_handler_free(pe);
@@ -1453,7 +1415,7 @@ static gint print_job_ps_end(PrintWindow *pw)
  *-----------------------------------------------------------------------------
  */
 
-static gint print_job_rgb_page_new(PrintWindow *pw, gint page)
+static gboolean print_job_rgb_page_new(PrintWindow *pw, gint page)
 {
        gint total;
 
@@ -1512,10 +1474,10 @@ static gint print_job_rgb_page_new(PrintWindow *pw, gint page)
        return (pw->job_path != NULL);
 }
 
-static gint print_job_rgb_page_done(PrintWindow *pw)
+static gboolean print_job_rgb_page_done(PrintWindow *pw)
 {
        gchar *pathl;
-       gint ret = FALSE;
+       gboolean ret = FALSE;
 
        if (!pw->job_pixbuf) return FALSE;
 
@@ -1564,9 +1526,9 @@ static gint print_job_rgb_page_done(PrintWindow *pw)
        return ret;
 }
 
-static gint print_job_rgb_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
-                                    gdouble x, gdouble y, gdouble w, gdouble h,
-                                    gdouble offx, gdouble offy)
+static gboolean print_job_rgb_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
+                                        gdouble x, gdouble y, gdouble w, gdouble h,
+                                        gdouble offx, gdouble offy)
 {
        gdouble sw, sh;
        gdouble dw, dh;
@@ -1581,10 +1543,10 @@ static gint print_job_rgb_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
        dw = (gdouble)gdk_pixbuf_get_width(pw->job_pixbuf);
        dh = (gdouble)gdk_pixbuf_get_height(pw->job_pixbuf);
 
-        if (clip_region(x, y, w, h,
-                        0.0, 0.0, dw, dh,
-                        &rx, &ry, &rw, &rh))
-                {
+       if (clip_region(x, y, w, h,
+                       0.0, 0.0, dw, dh,
+                       &rx, &ry, &rw, &rh))
+               {
                gdk_pixbuf_composite(pixbuf, pw->job_pixbuf, rx, ry, rw, rh,
                                     x + offx, y + offy,
                                     w / sw, h / sh,
@@ -1607,25 +1569,25 @@ static gdouble convert_pango_dpi(gdouble points)
                klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
                if (g_object_class_find_property(klass, "gtk-xft-dpi"))
                        {
-                       int int_dpi;
+                       gint int_dpi;
                        g_object_get(settings, "gtk-xft-dpi", &int_dpi, NULL);
                        dpi = (gdouble)int_dpi / PANGO_SCALE;
                        }
 
                if (dpi < 25.0)
                        {
-                       static gint warned = FALSE;
+                       static gboolean warned = FALSE;
                        gdouble fallback_dpi = 96.0;
 
                        if (!warned)
                                {
                                if (dpi == 0.0)
                                        {
-                                       printf("pango dpi unknown, assuming %.0f\n", fallback_dpi);
+                                       log_printf("pango dpi unknown, assuming %.0f\n", fallback_dpi);
                                        }
                                else
                                        {
-                                       printf("pango dpi reported as %.0f ignored, assuming %.0f\n", dpi, fallback_dpi);
+                                       log_printf("pango dpi reported as %.0f ignored, assuming %.0f\n", dpi, fallback_dpi);
                                        }
                                warned = TRUE;
                                }
@@ -1638,9 +1600,9 @@ static gdouble convert_pango_dpi(gdouble points)
        return points * 72.0 / dpi;
 }
 
-static gint print_job_rgb_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
-                                   gdouble x, gdouble y, gdouble width,
-                                   guint8 r, guint8 g, guint8 b)
+static gboolean print_job_rgb_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
+                                       gdouble x, gdouble y, gdouble width,
+                                       guint8 r, guint8 g, guint8 b)
 {
        PangoLayout *layout;
        PangoFontDescription *desc;
@@ -1667,7 +1629,7 @@ static gint print_job_rgb_page_text(PrintWindow *pw, const gchar *text, gdouble
        return TRUE;
 }
 
-static gint print_job_rgb_init(PrintWindow *pw)
+static gboolean print_job_rgb_init(PrintWindow *pw)
 {
        if (pw->job_pixbuf) g_object_unref(pw->job_pixbuf);
        pw->job_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
@@ -1682,7 +1644,7 @@ static gint print_job_rgb_init(PrintWindow *pw)
  *-----------------------------------------------------------------------------
  */
 
-static gint print_job_preview_page_new(PrintWindow *pw, gint page)
+static gboolean print_job_preview_page_new(PrintWindow *pw, gint page)
 {
        GdkPixbuf *pixbuf;
        gint w, h;
@@ -1770,14 +1732,14 @@ static gint print_job_preview_page_new(PrintWindow *pw, gint page)
        return TRUE;
 }
 
-static gint print_job_preview_page_done(PrintWindow *pw)
+static gboolean print_job_preview_page_done(PrintWindow *pw)
 {
        return TRUE;
 }
 
-static gint print_job_preview_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
-                                        gdouble x, gdouble y, gdouble w, gdouble h,
-                                        gdouble offx, gdouble offy)
+static gboolean print_job_preview_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
+                                            gdouble x, gdouble y, gdouble w, gdouble h,
+                                            gdouble offx, gdouble offy)
 {
        gdouble sw, sh;
        gdouble dw, dh;
@@ -1814,9 +1776,9 @@ static gint print_job_preview_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
        return TRUE;
 }
 
-static gint print_job_preview_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
-                                       gdouble x, gdouble y, gdouble width,
-                                       guint8 r, guint8 g, guint8 b)
+static gboolean print_job_preview_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
+                                           gdouble x, gdouble y, gdouble width,
+                                           guint8 r, guint8 g, guint8 b)
 {
        PangoLayout *layout;
        PangoFontDescription *desc;
@@ -1849,7 +1811,7 @@ static gint print_job_preview_page_text(PrintWindow *pw, const gchar *text, gdou
        return TRUE;
 }
 
-static gint print_job_preview_init(PrintWindow *pw)
+static gboolean print_job_preview_init(PrintWindow *pw)
 {
        if (pw->job_pixbuf) g_object_unref(pw->job_pixbuf);
        pw->job_pixbuf = image_get_pixbuf(pw->layout_image);
@@ -1865,7 +1827,7 @@ static gint print_job_preview_init(PrintWindow *pw)
  *-----------------------------------------------------------------------------
  */
 
-static gint print_job_page_new(PrintWindow *pw)
+static gboolean print_job_page_new(PrintWindow *pw)
 {
        switch (pw->job_format)
                {
@@ -1880,7 +1842,7 @@ static gint print_job_page_new(PrintWindow *pw)
        return FALSE;
 }
 
-static gint print_job_page_done(PrintWindow *pw)
+static gboolean print_job_page_done(PrintWindow *pw)
 {
        switch (pw->job_format)
                {
@@ -1895,11 +1857,11 @@ static gint print_job_page_done(PrintWindow *pw)
        return FALSE;
 }
 
-static gint print_job_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
-                                gdouble x, gdouble y, gdouble w, gdouble h,
-                                gdouble offx, gdouble offy)
+static gboolean print_job_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
+                                    gdouble x, gdouble y, gdouble w, gdouble h,
+                                    gdouble offx, gdouble offy)
 {
-       gint success = FALSE;
+       gboolean success = FALSE;
 
        if (w <= 0.0 || h <= 0.0) return TRUE;
 
@@ -1919,11 +1881,11 @@ static gint print_job_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
        return success;
 }
 
-static gint print_job_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
-                               gdouble x, gdouble y, gdouble width,
-                               guint8 r, guint8 g, guint8 b)
+static gboolean print_job_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
+                                   gdouble x, gdouble y, gdouble width,
+                                   guint8 r, guint8 g, guint8 b)
 {
-       gint success = TRUE;
+       gboolean success = TRUE;
 
        if (!text) return TRUE;
 
@@ -1949,8 +1911,8 @@ static gint print_job_page_text(PrintWindow *pw, const gchar *text, gdouble poin
  *-----------------------------------------------------------------------------
  */
 
-static gint print_job_render_image(PrintWindow *pw);
-static gint print_job_render_proof(PrintWindow *pw);
+static gboolean print_job_render_image(PrintWindow *pw);
+static gboolean print_job_render_proof(PrintWindow *pw);
 
 
 static void print_job_status(PrintWindow *pw)
@@ -1997,9 +1959,9 @@ static void print_job_throw_error(PrintWindow *pw, const gchar *message)
        GtkWidget *label;
        gchar *buf;
 
-       if (GTK_WIDGET_VISIBLE(pw->dialog->dialog)) parent = pw->dialog->dialog;
+       if (gtk_widget_get_visible(pw->dialog->dialog)) parent = pw->dialog->dialog;
 
-       gd = generic_dialog_new(_("Printing error"), GQ_WMCLASS, "print_warning",
+       gd = generic_dialog_new(_("Printing error"), "print_warning",
                                parent, TRUE, NULL, NULL);
        generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, NULL, TRUE);
 
@@ -2019,19 +1981,19 @@ static void print_job_done(PrintWindow *pw)
        print_job_close(pw, FALSE);
 }
 
-static gint print_job_text_image(PrintWindow *pw, const gchar *path,
-                                gdouble x, gdouble y, gdouble width,
-                                gint sw, gint sh, gint proof)
+static gboolean print_job_text_image(PrintWindow *pw, const gchar *path,
+                                    gdouble x, gdouble y, gdouble width,
+                                    gint sw, gint sh, gint proof)
 {
        GString *string;
-       gint space = FALSE;
-       gint newline = FALSE;
-       gint ret;
+       gboolean space = FALSE;
+       gboolean newline = FALSE;
+       gboolean ret;
 
        if (pw->text_fields == 0) return TRUE;
 
        string = g_string_new("");
-       path = pw->job_loader->fd->path;
+       path = image_loader_get_fd(pw->job_loader)->path;
 
        if (pw->text_fields & TEXT_INFO_FILENAME)
                {
@@ -2060,7 +2022,7 @@ static gint print_job_text_image(PrintWindow *pw, const gchar *path,
                {
                if (newline)  g_string_append(string, "\n");
                if (space) g_string_append(string, " - ");
-               g_string_append(string, text_from_time(filetime(pw->job_loader->fd->path)));
+               g_string_append(string, text_from_time(filetime(image_loader_get_fd(pw->job_loader)->path)));
                newline = proof;
                space = !proof;
                }
@@ -2070,7 +2032,7 @@ static gint print_job_text_image(PrintWindow *pw, const gchar *path,
 
                if (newline)  g_string_append(string, "\n");
                if (space) g_string_append(string, " - ");
-               size = text_from_size_abrev(filesize(pw->job_loader->fd->path));
+               size = text_from_size_abrev(filesize(image_loader_get_fd(pw->job_loader)->path));
                g_string_append(string, size);
                g_free(size);
                }
@@ -2087,7 +2049,7 @@ static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
 {
        PrintWindow *pw = data;
        GdkPixbuf *pixbuf;
-       gint success = TRUE;
+       gboolean success = TRUE;
 
        pixbuf = image_loader_get_pixbuf(il);
        if (pixbuf)
@@ -2095,7 +2057,6 @@ static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
                gdouble sw, sh;
                gdouble dw, dh;
                gdouble x, y, w, h;
-               gdouble scale;
                gdouble offx, offy;
 
                sw = (gdouble)gdk_pixbuf_get_width(pixbuf);
@@ -2108,19 +2069,17 @@ static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
                        {
                        w = dw;
                        h = dw / sw * sh;
-                       scale = w / sw;
                        }
                else
                        {
                        h = dh;
                        w = dh / sh *sw;
-                       scale = h / sh;
                        }
 
-               if (pw->image_scale >= 5)
+               if (pw->image_scale >= 5.0)
                        {
-                       w = w * (gdouble)pw->image_scale / 100.0;
-                       h = h * (gdouble)pw->image_scale / 100.0;
+                       w = w * pw->image_scale / 100.0;
+                       h = h * pw->image_scale / 100.0;
                        }
 
                x = pw->margin_left + (dw / 2) - (w / 2);
@@ -2151,7 +2110,7 @@ static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
                y = y + h + PRINT_TEXT_PADDING;
 
                success = (success &&
-                          print_job_text_image(pw, pw->job_loader->fd->path, x, y, dw, sw, sh, FALSE));
+                          print_job_text_image(pw, image_loader_get_fd(pw->job_loader)->path, x, y, dw, sw, sh, FALSE));
                }
 
        image_loader_free(pw->job_loader);
@@ -2183,7 +2142,7 @@ static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
                }
 }
 
-static gint print_job_render_image(PrintWindow *pw)
+static gboolean print_job_render_image(PrintWindow *pw)
 {
        FileData *fd = NULL;
 
@@ -2207,7 +2166,8 @@ static gint print_job_render_image(PrintWindow *pw)
        if (!fd) return FALSE;
 
        pw->job_loader = image_loader_new(fd);
-       if (!image_loader_start(pw->job_loader, print_job_render_image_loader_done, pw))
+       g_signal_connect(G_OBJECT(pw->job_loader), "done", (GCallback)print_job_render_image_loader_done, pw);
+       if (!image_loader_start(pw->job_loader))
                {
                image_loader_free(pw->job_loader);
                pw->job_loader= NULL;
@@ -2224,8 +2184,7 @@ static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
        gdouble w, h;
        gdouble proof_w, proof_h;
        gdouble icon_w, icon_h;
-       gdouble scale;
-       gint success = TRUE;
+       gboolean success = TRUE;
 
        if (pw->proof_columns < 1 || pw->proof_rows < 1)
                {
@@ -2239,6 +2198,10 @@ static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
 
        pixbuf = image_loader_get_pixbuf(il);
 
+       if (options->image.exif_proof_rotate_enable == TRUE) {
+               pixbuf = pixbuf_apply_orientation(pixbuf, il->fd->exif_orientation);
+       }
+
        w = gdk_pixbuf_get_width(pixbuf);
        h = gdk_pixbuf_get_height(pixbuf);
 
@@ -2246,13 +2209,11 @@ static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
                {
                icon_w = pw->proof_width;
                icon_h = pw->proof_width / w * h;
-               scale = icon_w / w;
                }
        else
                {
                icon_h = pw->proof_height;
                icon_w = pw->proof_height / h * w;
-               scale = icon_h / h;
                }
 
        y = pw->proof_position / pw->proof_columns;
@@ -2271,8 +2232,8 @@ static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
        x = x + icon_w / 2;
        y = y + icon_h + (pw->proof_height - icon_h) / 2 + PRINT_TEXT_PADDING;
 
-       success = (success && 
-                  print_job_text_image(pw, pw->job_loader->fd->path, x, y, icon_w + PRINT_PROOF_MARGIN * 2, w, h, TRUE));
+       success = (success &&
+                  print_job_text_image(pw, image_loader_get_fd(pw->job_loader)->path, x, y, icon_w + PRINT_PROOF_MARGIN * 2, w, h, TRUE));
 
        if (!success)
                {
@@ -2333,7 +2294,7 @@ static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
                }
 }
 
-static gint print_job_render_proof(PrintWindow *pw)
+static gboolean print_job_render_proof(PrintWindow *pw)
 {
        FileData *fd = NULL;
 
@@ -2353,7 +2314,8 @@ static gint print_job_render_proof(PrintWindow *pw)
 
        image_loader_free(pw->job_loader);
        pw->job_loader = image_loader_new(fd);
-       if (!image_loader_start(pw->job_loader, print_job_render_proof_loader_done, pw))
+       g_signal_connect(G_OBJECT(pw->job_loader), "done", (GCallback)print_job_render_proof_loader_done, pw);
+       if (!image_loader_start(pw->job_loader))
                {
                image_loader_free(pw->job_loader);
                pw->job_loader = NULL;
@@ -2365,7 +2327,7 @@ static gint print_job_render_proof(PrintWindow *pw)
 static void print_job_render(PrintWindow *pw)
 {
        gdouble proof_w, proof_h;
-       gint finished;
+       gboolean finished;
 
        pw->proof_position = 0;
 
@@ -2422,9 +2384,9 @@ static void print_job_render(PrintWindow *pw)
        if (finished) print_job_done(pw);
 }
 
-static gint print_job_init(PrintWindow *pw)
+static gboolean print_job_init(PrintWindow *pw)
 {
-       gint success = FALSE;
+       gboolean success = FALSE;
 
        pw->job_page = 0;
 
@@ -2445,9 +2407,9 @@ static gint print_job_init(PrintWindow *pw)
        return success;
 }
 
-static gint print_job_finish(PrintWindow *pw)
+static gboolean print_job_finish(PrintWindow *pw)
 {
-       gint success = FALSE;
+       gboolean success = FALSE;
 
        switch (pw->job_format)
                {
@@ -2517,7 +2479,7 @@ static void print_job_close(PrintWindow *pw, gint error)
                pw->job_pixbuf = NULL;
                }
 
-       if (pw->dialog && !GTK_WIDGET_VISIBLE(pw->dialog->dialog))
+       if (pw->dialog && !gtk_widget_get_visible(pw->dialog->dialog))
                {
                g_idle_add_full(G_PRIORITY_HIGH_IDLE, print_job_close_finish_cb, pw, NULL);
                }
@@ -2582,9 +2544,20 @@ static void print_pref_store(PrintWindow *pw)
                {
                tab_completion_append_to_history(pw->path_entry, pw->output_path);
                }
+
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXT, pw->text_fields);
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTSIZE, pw->text_points);
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTCOLOR_R, pw->text_r);
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTCOLOR_G, pw->text_g);
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTCOLOR_B, pw->text_b);
+
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_SOURCE, pw->source);
+       pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_LAYOUT, pw->layout);
+
+       pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_IMAGE_SCALE, pw->image_scale);
 }
 
-static gint print_job_start(PrintWindow *pw, RenderFormat format, PrintOutput output)
+static gboolean print_job_start(PrintWindow *pw, RenderFormat format, PrintOutput output)
 {
        GtkWidget *hbox;
        GtkWidget *spinner;
@@ -2611,7 +2584,7 @@ static gint print_job_start(PrintWindow *pw, RenderFormat format, PrintOutput ou
 
        gtk_widget_hide(pw->dialog->dialog);
 
-       pw->job_dialog = file_util_gen_dlg(_("Print - Geeqie"), GQ_WMCLASS, "print_job_dialog",
+       pw->job_dialog = file_util_gen_dlg(_("Print"), "print_job_dialog",
                                           (GtkWidget *)gtk_window_get_transient_for(GTK_WINDOW(pw->dialog->dialog)), FALSE,
                                           print_job_cancel_cb, pw);
 
@@ -2656,7 +2629,7 @@ static void print_window_print_start(PrintWindow *pw)
 {
        RenderFormat format;
 
-       switch(pw->output)
+       switch (pw->output)
                {
                case PRINT_OUTPUT_RGB_FILE:
                        format = RENDER_FORMAT_RGB;
@@ -2685,11 +2658,11 @@ static GtkWidget *print_combo_menu(const gchar *text[], gint count, gint preferr
        GtkWidget *combo;
        gint i;
 
-       combo = gtk_combo_box_new_text();
+       combo = gtk_combo_box_text_new();
 
        for (i = 0 ; i < count; i++)
                {
-               gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(text[i]));
+               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _(text[i]));
                }
 
        if (preferred >= 0 && preferred < count)
@@ -2710,19 +2683,19 @@ static GtkWidget *print_combo_menu(const gchar *text[], gint count, gint preferr
  */
 
 static GtkWidget *print_paper_menu(GtkWidget *table, gint column, gint row,
-                                  gint preferred, GCallback func, gpointer data)
+                                  PaperOrientation preferred, GCallback func, gpointer data)
 {
        GtkWidget *combo;
        gint i;
 
        pref_table_label(table, column, row, (_("Format:")), 1.0);
 
-       combo = gtk_combo_box_new_text();
+       combo = gtk_combo_box_text_new();
 
        i = 0;
        while (print_paper_sizes[i].description)
                {
-               gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(print_paper_sizes[i].description));
+               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _(print_paper_sizes[i].description));
                i++;
                }
 
@@ -2805,7 +2778,7 @@ static void print_paper_units_set(PrintWindow *pw, PaperUnits units)
 {
        PaperUnits old_units;
 
-       if (units < 0 || units >= PAPER_UNIT_COUNT) return;
+       if (units >= PAPER_UNIT_COUNT) return;
 
        old_units = pw->paper_units;
        pw->paper_units = units;
@@ -2936,7 +2909,7 @@ static void print_image_scale_cb(GtkWidget *spin, gpointer data)
 {
        PrintWindow *pw = data;
 
-       pw->image_scale = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
+       pw->image_scale = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
 
        print_window_layout_set_size(pw, pw->paper_width, pw->paper_height);
 }
@@ -2998,7 +2971,7 @@ static void print_custom_entry_set(PrintWindow *pw, GtkWidget *combo)
                work = work->next;
 
                buf = g_strdup_printf(PRINT_LPR_CUSTOM, name);
-               gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf);
+               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), buf);
                g_free(buf);
                }
        string_list_free(list);
@@ -3023,9 +2996,9 @@ static void print_custom_entry_set(PrintWindow *pw, GtkWidget *combo)
 
 static void print_output_set(PrintWindow *pw, PrintOutput output)
 {
-       gint use_file = FALSE;
-       gint use_custom = FALSE;
-       gint use_format = FALSE;
+       gboolean use_file = FALSE;
+       gboolean use_custom = FALSE;
+       gboolean use_format = FALSE;
 
        pw->output = output;
 
@@ -3150,7 +3123,7 @@ static void print_output_dpi_cb(GtkWidget *combo, gpointer data)
        pw->max_dpi = (gdouble)n;
 }
 
-static void print_text_field_set(PrintWindow *pw, TextInfo field, gint active)
+static void print_text_field_set(PrintWindow *pw, TextInfo field, gboolean active)
 {
        if (active)
                {
@@ -3167,7 +3140,7 @@ static void print_text_field_set(PrintWindow *pw, TextInfo field, gint active)
 static void print_text_cb_name(GtkWidget *widget, gpointer data)
 {
        PrintWindow *pw = data;
-       gint active;
+       gboolean active;
 
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        print_text_field_set(pw, TEXT_INFO_FILENAME, active);
@@ -3176,7 +3149,7 @@ static void print_text_cb_name(GtkWidget *widget, gpointer data)
 static void print_text_cb_path(GtkWidget *widget, gpointer data)
 {
        PrintWindow *pw = data;
-       gint active;
+       gboolean active;
 
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        print_text_field_set(pw, TEXT_INFO_FILEPATH, active);
@@ -3185,7 +3158,7 @@ static void print_text_cb_path(GtkWidget *widget, gpointer data)
 static void print_text_cb_date(GtkWidget *widget, gpointer data)
 {
        PrintWindow *pw = data;
-       gint active;
+       gboolean active;
 
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        print_text_field_set(pw, TEXT_INFO_FILEDATE, active);
@@ -3194,7 +3167,7 @@ static void print_text_cb_date(GtkWidget *widget, gpointer data)
 static void print_text_cb_size(GtkWidget *widget, gpointer data)
 {
        PrintWindow *pw = data;
-       gint active;
+       gboolean active;
 
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        print_text_field_set(pw, TEXT_INFO_FILESIZE, active);
@@ -3203,7 +3176,7 @@ static void print_text_cb_size(GtkWidget *widget, gpointer data)
 static void print_text_cb_dims(GtkWidget *widget, gpointer data)
 {
        PrintWindow *pw = data;
-       gint active;
+       gboolean active;
 
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        print_text_field_set(pw, TEXT_INFO_DIMENSIONS, active);
@@ -3239,12 +3212,6 @@ static void print_text_menu(GtkWidget *box, PrintWindow *pw)
        pref_spin_new(group, _("Size:"), _("points"),
                      8.0, 100.0, 1.0, 0, pw->text_points,
                      G_CALLBACK(print_text_cb_points), pw);
-
-#if 0
-       button = color_selection_new();
-       gtk_box_pack_start(GTK_BOX(group), button, FALSE, FALSE, 0);
-       gtk_widget_show(button);
-#endif
 }
 
 /*
@@ -3332,12 +3299,14 @@ void print_window_new(FileData *fd, GList *selection, GList *list, GtkWidget *pa
        pw = g_new0(PrintWindow, 1);
 
        pw->source_fd = file_data_ref(fd);
-       pw->source_selection = selection;
+       pw->source_selection = file_data_process_groups_in_selection(selection, FALSE, NULL);
        pw->source_list = list;
 
-       pw->source = PRINT_SOURCE_SELECTION;
-       pw->layout = PRINT_LAYOUT_IMAGE;
-
+       pw->source = print_pref_int(PRINT_PREF_SOURCE, PRINT_SOURCE_SELECTION);
+       pw->layout = print_pref_int(PRINT_PREF_LAYOUT, PRINT_LAYOUT_IMAGE);
+       
+       pw->image_scale = print_pref_double(PRINT_PREF_IMAGE_SCALE, 100.0);
+       
        pw->output = print_pref_int(PRINT_PREF_OUTPUT, PRINT_OUTPUT_PS_LPR);
        pw->output_format = print_pref_int(PRINT_PREF_FORMAT, PRINT_FILE_JPG_NORMAL);
 
@@ -3361,18 +3330,20 @@ void print_window_new(FileData *fd, GList *selection, GList *list, GtkWidget *pa
        pw->proof_width = print_pref_double(PRINT_PREF_PROOF_WIDTH, PRINT_PROOF_DEFAULT_SIZE);
        pw->proof_height = print_pref_double(PRINT_PREF_PROOF_HEIGHT, PRINT_PROOF_DEFAULT_SIZE);
 
-       pw->text_fields = TEXT_INFO_FILENAME;
-       pw->text_points = 10;
-       pw->text_r = pw->text_g = pw->text_b = 0;
+       pw->text_fields = print_pref_int(PRINT_PREF_TEXT, TEXT_INFO_FILENAME);
+       pw->text_points = print_pref_int(PRINT_PREF_TEXTSIZE, 10);
+       pw->text_r = print_pref_int(PRINT_PREF_TEXTCOLOR_R, 0);
+       pw->text_g = print_pref_int(PRINT_PREF_TEXTCOLOR_G, 0);
+       pw->text_b = print_pref_int(PRINT_PREF_TEXTCOLOR_B, 0);
 
        pw->save_settings = print_pref_int(PRINT_PREF_SAVE, TRUE);
 
-       pw->dialog = file_util_gen_dlg(_("Print - Geeqie"), GQ_WMCLASS, "print_dialog",
+       pw->dialog = file_util_gen_dlg(_("Print"), "print_dialog",
                                       parent, FALSE,
                                       print_window_cancel_cb, pw);
 
-       geometry.min_width = 32;
-       geometry.min_height = 32;
+       geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
+       geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE;
        geometry.base_width = PRINT_DLG_WIDTH;
        geometry.base_height = PRINT_DLG_HEIGHT;
        gtk_window_set_geometry_hints(GTK_WINDOW(pw->dialog->dialog), NULL, &geometry,
@@ -3407,13 +3378,13 @@ void print_window_new(FileData *fd, GList *selection, GList *list, GtkWidget *pa
        table = pref_table_new(box, 2, 2, FALSE, FALSE);
 
        pw->image_scale_spin = pref_table_spin(table, 0, 0, _("Image size:"), "%",
-                                              5.0, 100.0, 1.0, 0, 100.0,
+                                              5.0, 100.0, 1.0, 0, pw->image_scale,
                                               G_CALLBACK(print_image_scale_cb), pw);
 
        label = pref_table_label(table, 0, 1, _("Proof size:"), 1.0);
        pw->proof_group = pref_table_box(table, 1, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
        pref_link_sensitivity(label, pw->proof_group);
-       
+
        pw->proof_width_spin = pref_spin_new(pw->proof_group, NULL, NULL,
                                             0.0, 50.0, 0.1, 3, 0.0,
                                             G_CALLBACK(print_proof_size_cb), pw);
@@ -3524,4 +3495,4 @@ void print_window_new(FileData *fd, GList *selection, GList *list, GtkWidget *pa
        gtk_widget_show(pw->notebook);
        gtk_widget_show(pw->dialog->dialog);
 }
-
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */