/*
* 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,
TEXT_INFO_FILENAME = 1 << 0,
TEXT_INFO_FILEDATE = 1 << 1,
TEXT_INFO_FILESIZE = 1 << 2,
- TEXT_INFO_DIMENSIONS = 1 << 3
+ TEXT_INFO_DIMENSIONS = 1 << 3,
+ 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
{
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;
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;
/* 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)
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]);
}
*/
-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;
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>
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)
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;
}
}
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;
}
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);
}
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);
}
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);
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);
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;
}
if (pipe_handler_data)
{
- printf("warning SIGPIPE handler already in use\n");
+ log_printf("warning SIGPIPE handler already in use\n");
return NULL;
}
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;
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)
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;
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);
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;
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);
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;
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);
}
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;
gint c;
guchar *p;
guchar bps_buf[3];
- gint ret;
+ gboolean ret;
if (!pixbuf) return TRUE;
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++)
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);
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.. */
+static gdouble convert_pango_dpi(gdouble points);
- 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");
-
- 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;
pe = pipe_handler_new();
- fprintf(f, "%%%%EOF\n");
+ g_fprintf(f, "%%%%EOF\n");
ret = !pipe_handler_check(pe);
pipe_handler_free(pe);
*-----------------------------------------------------------------------------
*/
-static gint print_job_rgb_page_new(PrintWindow *pw, gint page)
+static gboolean print_job_rgb_page_new(PrintWindow *pw, gint page)
{
gint total;
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;
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;
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,
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;
}
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;
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,
*-----------------------------------------------------------------------------
*/
-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;
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;
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;
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);
*-----------------------------------------------------------------------------
*/
-static gint print_job_page_new(PrintWindow *pw)
+static gboolean print_job_page_new(PrintWindow *pw)
{
switch (pw->job_format)
{
return FALSE;
}
-static gint print_job_page_done(PrintWindow *pw)
+static gboolean print_job_page_done(PrintWindow *pw)
{
switch (pw->job_format)
{
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;
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;
*-----------------------------------------------------------------------------
*/
-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)
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);
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)
{
- g_string_append(string, filename_from_path(path));
+ if (pw->text_fields & TEXT_INFO_FILEPATH)
+ g_string_append(string, path);
+ else
+ g_string_append(string, filename_from_path(path));
+ newline = TRUE;
+ }
+ else if (pw->text_fields & TEXT_INFO_FILEPATH)
+ {
+ gchar *dirname = g_path_get_dirname(path);
+
+ g_string_append_printf(string, "%s%s", dirname, G_DIR_SEPARATOR_S);
+ g_free(dirname);
newline = TRUE;
}
if (pw->text_fields & TEXT_INFO_DIMENSIONS)
{
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;
}
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);
}
{
PrintWindow *pw = data;
GdkPixbuf *pixbuf;
- gint success = TRUE;
+ gboolean success = TRUE;
pixbuf = image_loader_get_pixbuf(il);
if (pixbuf)
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);
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);
}
}
-static gint print_job_render_image(PrintWindow *pw)
+static gboolean print_job_render_image(PrintWindow *pw)
{
FileData *fd = NULL;
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;
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)
{
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);
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)
{
}
}
-static gint print_job_render_proof(PrintWindow *pw)
+static gboolean print_job_render_proof(PrintWindow *pw)
{
FileData *fd = NULL;
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;
static void print_job_render(PrintWindow *pw)
{
gdouble proof_w, proof_h;
- gint finished;
+ gboolean finished;
pw->proof_position = 0;
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;
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)
{
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);
}
{
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;
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);
{
RenderFormat format;
- switch(pw->output)
+ switch (pw->output)
{
case PRINT_OUTPUT_RGB_FILE:
format = RENDER_FORMAT_RGB;
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)
*/
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++;
}
{
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;
{
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);
}
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);
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;
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)
{
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);
}
+static void print_text_cb_path(GtkWidget *widget, gpointer data)
+{
+ PrintWindow *pw = data;
+ gboolean active;
+
+ active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ print_text_field_set(pw, TEXT_INFO_FILEPATH, active);
+}
+
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);
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);
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);
pref_checkbox_new(group, _("Name"), (pw->text_fields & TEXT_INFO_FILENAME),
G_CALLBACK(print_text_cb_name), pw);
+ pref_checkbox_new(group, _("Path"), (pw->text_fields & TEXT_INFO_FILEPATH),
+ G_CALLBACK(print_text_cb_path), pw);
pref_checkbox_new(group, _("Date"), (pw->text_fields & TEXT_INFO_FILEDATE),
G_CALLBACK(print_text_cb_date), pw);
pref_checkbox_new(group, _("Size"), (pw->text_fields & TEXT_INFO_FILESIZE),
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);
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,
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);
gtk_widget_show(pw->notebook);
gtk_widget_show(pw->dialog->dialog);
}
-
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */