Trim trailing white spaces.
[geeqie.git] / src / print.c
index 393e6a0..25eb5cc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -232,7 +232,7 @@ struct _PrintWindow
        gdouble layout_width;
        gdouble layout_height;
 
-       gint layout_idle_id;
+       guint layout_idle_id; /* event source id */
 
        gdouble image_scale;
 
@@ -319,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)
@@ -570,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;
                }
 }
 
@@ -584,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;
 }
 
@@ -598,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);
                }
@@ -750,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);
@@ -1008,10 +1008,10 @@ static void pipe_handler_free(PipeError *pe)
        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)
@@ -1021,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;
 
@@ -1120,7 +1120,8 @@ static gint print_job_ps_init(PrintWindow *pw)
        g_fprintf(f, "%%%%Title:\n");
 
        /* setup page size, coordinates (do we really need this?) */
-#if 0
+       /* 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 */
@@ -1145,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;
@@ -1182,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;
@@ -1233,9 +1234,9 @@ static void print_job_ps_page_image_pixel(FILE *f, guchar *pix)
 
        g_fprintf(f, "%s", text);
 }
-static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
-                                   gdouble x, gdouble y, gdouble w, gdouble h,
-                                   gdouble offx, gdouble offy)
+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;
@@ -1248,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;
 
@@ -1335,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;
-
-       g_fprintf(f, "%f %f moveto\n", x, y);
-       g_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';
-
-               g_fprintf(f, "%s", text);
-
-               p++;
-               }
-
-       g_fprintf(f, ">\n");
-       g_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;
+static gdouble convert_pango_dpi(gdouble points);
 
-       g_fprintf(f, "newpath\n");
-
-       p = text;
-       while (p && *p != '\0')
-               {
-               p = ps_text_to_hex_array(f, p, x, y);
-               if (p && *p == '\n') p++;
-               y -= point_size;
-               }
-
-       g_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);
 
-       g_fprintf(f, "/Sans findfont\n");
-       g_fprintf(f, "%f scalefont\n", point_size);
-       g_fprintf(f, "setfont\n");
+       pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
+       pango_layout_set_text(layout, text, -1);
 
-       g_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;
@@ -1463,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;
 
@@ -1522,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;
 
@@ -1574,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;
@@ -1624,7 +1576,7 @@ static gdouble convert_pango_dpi(gdouble points)
 
                if (dpi < 25.0)
                        {
-                       static gint warned = FALSE;
+                       static gboolean warned = FALSE;
                        gdouble fallback_dpi = 96.0;
 
                        if (!warned)
@@ -1648,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;
@@ -1677,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,
@@ -1692,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;
@@ -1780,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;
@@ -1824,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;
@@ -1859,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);
@@ -1875,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)
                {
@@ -1890,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)
                {
@@ -1905,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;
 
@@ -1929,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;
 
@@ -1959,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)
@@ -2007,7 +1959,7 @@ 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"), "print_warning",
                                parent, TRUE, NULL, NULL);
@@ -2029,14 +1981,14 @@ 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;
 
@@ -2097,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)
@@ -2105,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);
@@ -2118,13 +2069,11 @@ 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.0)
@@ -2193,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;
 
@@ -2235,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)
                {
@@ -2250,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);
 
@@ -2257,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;
@@ -2344,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;
 
@@ -2377,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;
 
@@ -2434,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;
 
@@ -2457,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)
                {
@@ -2529,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);
                }
@@ -2607,7 +2557,7 @@ static void print_pref_store(PrintWindow *pw)
        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;
@@ -2708,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)
@@ -2733,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++;
                }
 
@@ -3021,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);
@@ -3046,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;
 
@@ -3173,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)
                {
@@ -3190,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);
@@ -3199,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);
@@ -3208,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);
@@ -3217,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);
@@ -3226,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);
@@ -3262,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
 }
 
 /*
@@ -3355,7 +3299,7 @@ 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_pref_int(PRINT_PREF_SOURCE, PRINT_SOURCE_SELECTION);