71#include <glib/gstdio.h>
81 return _(
"print settings");
86 static const char *
v[] = {
"print", NULL};
118static const gchar *
_unit_names[] = { N_(
"mm"), N_(
"cm"), N_(
"inch"), NULL };
225 *n_digits = ceilf(log10f(1.0f /
units[unit]));
228 *incr = roundf(
units[unit] * 20.0f) / 20.0f;
232 *format = g_strdup_printf(
"%%.%df", *n_digits);
315 void *exif,
int exif_len, int32_t imgid,
int num,
int total,
dt_dev_pixelpipe_t *pipe,
316 const gboolean export_masks)
320 d->params->buf = (uint16_t *)malloc((
size_t)3 * (
d->bpp == 8?1:2) *
d->head.width *
d->head.height);
324 const uint8_t *in_ptr = (
const uint8_t *)in;
325 uint8_t *out_ptr = (uint8_t *)
d->params->buf;
326 for(
int y = 0; y <
d->head.height; y++)
328 for(
int x = 0;
x <
d->head.width;
x++, in_ptr += 4, out_ptr += 3)
329 memcpy(out_ptr, in_ptr, 3);
334 const uint16_t *in_ptr = (
const uint16_t *)in;
335 uint16_t *out_ptr = (uint16_t *)
d->params->buf;
336 for(
int y = 0; y <
d->head.height; y++)
338 for(
int x = 0;
x <
d->head.width;
x++, in_ptr += 4, out_ptr += 3)
339 memcpy(out_ptr, in_ptr, 6);
362 dat.
bpp = *params->p_icc_profile ? 16 : 8;
369 dt_control_log(_(
"processing `%s' for `%s'"), params->job_title, params->prt.printer.name);
371 const gboolean export_masks =
FALSE;
372 const gboolean is_scaling =
FALSE;
376 TRUE, is_scaling,
FALSE, NULL,
FALSE, export_masks, params->buf_icc_type,
377 params->buf_icc_profile, params->buf_icc_intent, NULL, NULL, 1, 1, NULL, NULL);
386 ¶ms->buf_icc_type,
387 params->buf_icc_profile);
388 if(*params->p_icc_profile)
395 dt_control_log(_(
"cannot open printer profile `%s'"), params->p_icc_profile);
396 fprintf(stderr,
"cannot open printer profile `%s'\n", params->p_icc_profile);
405 fprintf(stderr,
"error getting output profile for image %d\n", img->
imgid);
411 pprof->
profile, params->p_icc_intent, params->black_point_compensation))
413 dt_control_log(_(
"cannot apply printer profile `%s'"), params->p_icc_profile);
414 fprintf(stderr,
"cannot apply printer profile `%s'\n", params->p_icc_profile);
421 img->
buf = params->buf;
433 const int icc_id = 0;
450 const int resolution = params->prt.printer.resolution;
481 float x = 0.0f, y = 0.0f, swidth = 0.0f, sheight = 0.0f;
495 for(
int i=0;
i<9;
i++)
498 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps->
dtba[
i]), (
i == box->
alignment));
505 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_x),
x);
507 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_y), y);
509 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_width), swidth);
511 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_height), sheight);
546 for(
int k=0;
k<params->imgs.count;
k++)
560 g_strlcat(params->pdf_filename,
"/pf.XXXXXX.pdf",
sizeof(params->pdf_filename));
562 const gint fd = g_mkstemp(params->pdf_filename);
566 fprintf(stderr,
"failed to create temporary pdf for printing\n");
581 dt_print_file(imgid, params->pdf_filename, params->job_title, ¶ms->prt);
586 char tag[256] = { 0 };
588 snprintf (tag,
sizeof(tag),
"darktable|printed|%s", params->prt.printer.name);
591 for(
int k=0;
k<params->imgs.count;
k++)
627 gtk_widget_set_sensitive(ps->
del,
FALSE);
635 if(box_index == -1)
return;
649 gtk_widget_set_sensitive(ps->
del,
FALSE);
668 if(params->pdf_filename[0]) g_unlink(params->pdf_filename);
672 dt_free(params->buf_icc_profile);
673 dt_free(params->p_icc_profile);
719 memcpy(¶ms->imgs, &ps->
imgs,
sizeof(ps->
imgs));
726 params->job_title = g_strdup((gchar *)
res->data);
740 params->job_title = g_strdup(img->
filename);
744 gchar *message = g_strdup_printf(_(
"processing `%s' for `%s'"), params->job_title, params->prt.printer.name);
754 params->buf_icc_intent =
dt_conf_get_int(
"plugins/print/print/iccintent");
785 for(
const GList *papers = ps->
paper_list; papers; papers = g_list_next (papers))
810 for(
const GList *media = ps->
media_list; media; media = g_list_next (media))
917 gtk_label_set_text(GTK_LABEL(ps->
width),
value);
929 const float awidth = box_size.
width;
930 const float aheight = box_size.
height;
932 const double scale = (iwidth <= awidth)
936 value = g_strdup_printf(_(
"%3.2f (dpi:%d)"), scale,
940 gtk_label_set_text(GTK_LABEL(ps->
info),
value);
950 const double value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
962 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_bottom),
value);
963 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_left),
value);
964 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_right),
value);
979 const double value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
992 const double value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
1005 const double value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
1019 ps->
lock_activated = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
1029 const double value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ps->
b_top));
1030 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_bottom),
value);
1031 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_left),
value);
1032 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_right),
value);
1046 for(
int i=0;
i<9;
i++)
1051 if(GTK_WIDGET(ps->
dtba[
i]) == tb)
1053 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps->
dtba[
i]),
TRUE);
1056 else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps->
dtba[
i]),
FALSE);
1098 const float value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ps->
grid_size));
1114 if(unit < 0)
return;
1129 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_top), n_digits);
1130 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_bottom), n_digits);
1131 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_left), n_digits);
1132 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_right), n_digits);
1133 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_top), incr, 10.f*incr);
1134 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_bottom), incr, 10.f*incr);
1135 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_left), incr, 10.f*incr);
1136 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_right), incr, 10.f*incr);
1138 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_x), n_digits);
1139 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_y), n_digits);
1140 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_width), n_digits);
1141 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
b_height), n_digits);
1142 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_x), incr, 10.f*incr);
1143 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_y), incr, 10.f*incr);
1144 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_width), incr, 10.f*incr);
1145 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
b_height), incr, 10.f*incr);
1147 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(ps->
grid_size), n_digits);
1148 gtk_spin_button_set_increments(GTK_SPIN_BUTTON(ps->
grid_size), incr, 10.f*incr);
1153 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_top), margin_top *
units[ps->
unit]);
1154 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_bottom), margin_bottom *
units[ps->
unit]);
1155 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_left), margin_left *
units[ps->
unit]);
1156 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_right), margin_right *
units[ps->
unit]);
1159 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
grid_size), grid_size *
units[ps->
unit]);
1190 for(
const GList *prof = ps->
profiles; prof; prof = g_list_next(prof))
1215 for(
const GList *prof = ps->
profiles; prof; prof = g_list_next(prof))
1319 list = g_list_prepend(list, prof);
1326 list = g_list_prepend(list, prof);
1337 for(
size_t k = 0;
k < n_file_profiles;
k++)
1342 g_strlcpy(prof->
name, file_profiles[
k].
name,
sizeof(prof->
name));
1347 list = g_list_prepend(list, prof);
1351 return g_list_reverse(list);
1356 static int count = 0;
1362 g_signal_handlers_block_by_func(G_OBJECT(
d->printers), G_CALLBACK(
_printer_changed), NULL);
1366 if(!g_strcmp0(default_printer, printer->
name) || default_printer[0]==
'\0')
1374 g_signal_handlers_unblock_by_func(G_OBJECT(
d->printers), G_CALLBACK(
_printer_changed), NULL);
1402 const float dist = 20.0;
1408 if(fabsf(b->screen.x -
x) <
dist)
1411 if(fabsf(b->screen.y - y) <
dist)
1414 if(fabsf((b->screen.x + b->screen.width) -
x) <
dist)
1417 if(fabsf((b->screen.y + b->screen.height) - y) <
dist)
1437 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ps->
snap_grid)))
1440 const float step = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ps->
grid_size)) *
units[ps->
unit];
1451 if(fabsf(*
x - grid_pos) < diff) *
x = grid_pos;
1462 if(fabsf(*y - grid_pos) < diff) *y = grid_pos;
1490 const float coef = dx / b->screen.width;
1495 ps->
x1 = b->screen.x + dx;
1496 ps->
y1 = b->screen.y + dy;
1497 ps->
x2 = b->screen.x + b->screen.width + dx;
1498 ps->
y2 = b->screen.y + b->screen.height + dy;
1501 ps->
x1 = b->screen.x + dx;
1504 ps->
y1 = b->screen.y + dy;
1507 ps->
x2 = b->screen.x + b->screen.width + dx;
1510 ps->
y2 = b->screen.y + b->screen.height + dy;
1513 ps->
x1 = b->screen.x + dx;
1514 ps->
y1 = b->screen.y + (coef * b->screen.height);
1517 ps->
x2 = b->screen.x + b->screen.width + dx;
1518 ps->
y1 = b->screen.y - (coef * b->screen.height);
1521 ps->
x1 = b->screen.x + dx;
1522 ps->
y2 = b->screen.y + b->screen.height - (coef * b->screen.height);
1525 ps->
x2 = b->screen.x + b->screen.width + dx;
1526 ps->
y2 = b->screen.y + b->screen.height + (coef * b->screen.height);
1562 const float tmp = *a;
1575 gtk_widget_set_sensitive(ps->
del,
TRUE);
1595 const float dx = ps->
x2 - ps->
x1;
1596 const float dy = ps->
y2 - ps->
y1;
1628 ps->
x1 = ps->
x2 =
x;
1629 ps->
y1 = ps->
y2 = y;
1642 else if(ps->
selected != -1 && which == 1)
1647 ps->
x1 = b->screen.x;
1648 ps->
y1 = b->screen.y;
1649 ps->
x2 = b->screen.x + b->screen.width;
1650 ps->
y2 = b->screen.y + b->screen.height;
1659 else if(ps->
selected != -1 && which == 3)
1677 const int x1,
const int y1,
const int x2,
const int y2)
1682 const gboolean all = sel_controls ==
BOX_ALL;
1684 cairo_move_to(cr, x1, y1);
1685 cairo_set_line_width(cr, (all || sel_controls ==
BOX_LEFT) ? sel_width : std_width);
1686 cairo_line_to(cr, x1, y2);
1689 cairo_move_to(cr, x1, y2);
1690 cairo_set_line_width(cr, (all || sel_controls ==
BOX_BOTTOM) ? sel_width : std_width);
1691 cairo_line_to(cr, x2, y2);
1694 cairo_move_to(cr, x2, y2);
1695 cairo_set_line_width(cr, (all || sel_controls ==
BOX_RIGHT) ? sel_width : std_width);
1696 cairo_line_to(cr, x2, y1);
1699 cairo_move_to(cr, x2, y1);
1700 cairo_set_line_width(cr, (all || sel_controls ==
BOX_TOP) ? sel_width : std_width);
1701 cairo_line_to(cr, x1, y1);
1704 if(sel_controls == 0)
1707 cairo_set_dash(cr, dash, 2, 0);
1710 cairo_move_to(cr, x1, y1);
1711 cairo_line_to(cr, x2, y2);
1713 cairo_move_to(cr, x1, y2);
1714 cairo_line_to(cr, x2, y1);
1718 cairo_set_dash(cr, NULL, 0, 0);
1719 cairo_set_line_width(cr, sel_width);
1750 int32_t pointerx, int32_t pointery)
1758 const float step = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ps->
grid_size)) /
units[ps->
unit];
1761 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ps->
grid))
1765 cairo_set_source_rgba(cr, 1, .2, .2, 0.6);
1803 cairo_set_source_rgba(cr, 1, .2, .2, 0.6);
1804 cairo_set_dash(cr, NULL, 0, 0);
1812 cairo_set_source_rgba(cr, .4, .4, .4, 1.0);
1821 cairo_set_source_rgba(cr, .2, .2, .2, 1.0);
1830 float dx1, dy1, dx2, dy2, dwidth, dheight;
1831 float x1, y1, x2, y2;
1833 float pwidth, pheight;
1847 dwidth = fabsf(dx2 - dx1);
1848 dheight = fabsf(dy2 - dy1);
1863 dy2 = dy1 + dheight;
1871 cairo_set_source_rgba(cr, .4, .4, .4, 1.0);
1876 char dimensions[16];
1877 PangoLayout *layout;
1879 PangoFontDescription *desc = pango_font_description_copy_static(
dt_bauhaus_get_global()->pango_font_desc);
1880 pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
1881 pango_font_description_set_absolute_size(desc,
DT_PIXEL_APPLY_DPI(16) * PANGO_SCALE);
1882 layout = pango_cairo_create_layout(cr);
1883 pango_layout_set_font_description(layout, desc);
1892 yp = y1 + (y2 - y1 - text_h) * 0.5;
1896 snprintf(dimensions,
sizeof(dimensions),
precision, dx1);
1897 pango_layout_set_text(layout, dimensions, -1);
1898 pango_layout_get_pixel_extents(layout, NULL, &ext);
1900 if(xp < ps->imgs.screen.page.x + 3 * margin)
1902 xp = x1 + 2 * margin;
1905 yp =
MIN(y2 - text_h, yp + ext.width + 0.5 * text_h + margin * 3);
1907 cairo_set_source_rgba(cr, .7, .7, .7, .9);
1909 cairo_line_to(cr, x1, yp + text_h * 0.5);
1910 cairo_stroke_preserve(cr);
1911 cairo_set_source_rgba(cr, .5, .5, .5, .9);
1912 cairo_set_dash(cr, &dash, 1, dash);
1914 cairo_set_dash(cr, NULL, 0, 0);
1916 cairo_set_source_rgb(cr, .8, .8, .8);
1917 cairo_move_to(cr, xp, yp);
1918 pango_cairo_show_layout(cr, layout);
1924 pango_layout_set_text(layout, dimensions, -1);
1925 pango_layout_get_pixel_extents(layout, NULL, &ext);
1928 xp = x2 - ext.width - 2 * margin;
1929 cairo_set_source_rgba(cr, .7, .7, .7, .9);
1930 cairo_move_to(cr, x2, yp + text_h * 0.5);
1932 cairo_stroke_preserve(cr);
1933 cairo_set_source_rgba(cr, .5, .5, .5, .9);
1934 cairo_set_dash(cr, &dash, 1, dash);
1936 cairo_set_dash(cr, NULL, 0, 0);
1938 xp - margin, yp - margin);
1939 cairo_set_source_rgb(cr, .8, .8, .8);
1940 cairo_move_to(cr, xp, yp);
1941 pango_cairo_show_layout(cr, layout);
1944 xp = x1 + (x2 - x1 - text_h) * 0.5;
1948 snprintf(dimensions,
sizeof(dimensions),
precision, dy1);
1949 pango_layout_set_text(layout, dimensions, -1);
1950 pango_layout_get_pixel_extents(layout, NULL, &ext);
1952 if(yp < ps->imgs.screen.page.y + 3 * margin)
1954 xp =
MIN(x2 - text_h, xp + ext.width + 0.5 * text_h + margin * 3);
1955 yp = y1 + 2 * margin;
1957 cairo_set_source_rgba(cr, .7, .7, .7, .9);
1959 cairo_line_to(cr, xp + text_h * 0.5, y1);
1960 cairo_stroke_preserve(cr);
1961 cairo_set_source_rgba(cr, .5, .5, .5, .9);
1962 cairo_set_dash(cr, &dash, 1, dash);
1964 cairo_set_dash(cr, NULL, 0, 0);
1966 xp - margin, yp - margin);
1967 cairo_set_source_rgb(cr, .8, .8, .8);
1968 cairo_move_to(cr, xp + text_h * 0.5, yp + ext.width * 0.5);
1970 cairo_rotate(cr, -M_PI_2);
1971 cairo_rel_move_to(cr, -0.5 * ext.width, -0.5 * text_h);
1972 pango_cairo_update_layout(cr, layout);
1973 pango_cairo_show_layout(cr, layout);
1979 snprintf(dimensions,
sizeof(dimensions),
precision, pheight *
units[ps->
unit] - dy2);
1980 pango_layout_set_text(layout, dimensions, -1);
1981 pango_layout_get_pixel_extents(layout, NULL, &ext);
1984 yp = y2 - ext.width - 2 * margin;
1985 cairo_set_source_rgba(cr, .7, .7, .7, .9);
1986 cairo_move_to(cr, xp + text_h * 0.5, y2);
1988 cairo_stroke_preserve(cr);
1989 cairo_set_source_rgba(cr, .5, .5, .5, .9);
1990 cairo_set_dash(cr, &dash, 1, dash);
1992 cairo_set_dash(cr, NULL, 0, 0);
1994 xp - margin, yp - margin);
1995 cairo_set_source_rgb(cr, .8, .8, .8);
1996 cairo_move_to(cr, xp + text_h * 0.5, yp + ext.width * 0.5);
1998 cairo_rotate(cr, -M_PI_2);
1999 cairo_rel_move_to(cr, -0.5 * ext.width, -0.5 * text_h);
2000 pango_cairo_update_layout(cr, layout);
2001 pango_cairo_show_layout(cr, layout);
2006 snprintf(dimensions,
sizeof(dimensions),
precision, dwidth);
2007 pango_layout_set_text(layout, dimensions, -1);
2008 pango_layout_get_pixel_extents(layout, NULL, &ext);
2009 xp = (x1 + x2 - ext.width) * .5;
2010 if(y1 > text_h * 0.5 + margin)
2011 yp = y1 - text_h * 0.5;
2013 yp = y1 + text_h - 2 * margin;
2014 cairo_set_source_rgba(cr, .5, .5, .5, .9);
2016 xp - margin, yp - margin);
2017 cairo_set_source_rgb(cr, .8, .8, .8);
2018 cairo_move_to(cr, xp, yp);
2019 pango_cairo_show_layout(cr, layout);
2021 snprintf(dimensions,
sizeof(dimensions),
precision, dheight);
2022 pango_layout_set_text(layout, dimensions, -1);
2023 pango_layout_get_pixel_extents(layout, NULL, &ext);
2024 if(x1 > text_h * 0.5 + margin)
2025 xp = x1 - text_h * 0.5;
2027 xp = x1 + text_h - 2 * margin;
2028 yp = (y1 + y2) * .5;
2029 cairo_set_source_rgba(cr, .5, .5, .5, .9);
2031 xp - margin, yp - margin - 0.5 * ext.width);
2032 cairo_set_source_rgb(cr, .8, .8, .8);
2033 cairo_move_to(cr, xp + text_h * 0.5, yp);
2035 cairo_rotate(cr, -M_PI_2);
2036 cairo_rel_move_to(cr, -0.5 * ext.width, -0.5 * text_h);
2037 pango_cairo_update_layout(cr, layout);
2038 pango_cairo_show_layout(cr, layout);
2041 pango_font_description_free(desc);
2042 g_object_unref(layout);
2047 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps->
borderless),
TRUE);
2049 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps->
borderless),
FALSE);
2058 const float nv = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
2059 const float nv_mm = nv /
units[ps->
unit];
2077 const float nv = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
2078 const float nv_mm = nv /
units[ps->
unit];
2096 const float nv = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
2097 const float nv_mm = nv /
units[ps->
unit];
2115 const float nv = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
2116 const float nv_mm = nv /
units[ps->
unit];
2139 char *system_profile_dir = g_build_filename(datadir,
"color",
"out", NULL);
2140 char *user_profile_dir = g_build_filename(confdir,
"color",
"out", NULL);
2144 d->paper_list = NULL;
2145 d->media_list = NULL;
2147 d->width =
d->height = NULL;
2148 d->v_piccprofile = NULL;
2149 d->v_iccprofile = NULL;
2151 d->creation =
d->dragging =
FALSE;
2153 d->last_selected = -1;
2161 d->imgs.motion_over = -1;
2166 if(g_strcmp0(str, *
names) == 0)
2178 d->prt.page.margin_top =
_to_mm(
d, top_b);
2179 d->prt.page.margin_bottom =
_to_mm(
d, bottom_b);
2180 d->prt.page.margin_left =
_to_mm(
d, left_b);
2181 d->prt.page.margin_right =
_to_mm(
d, right_b);
2190 d->b_top = gtk_spin_button_new_with_range(0, 1000, incr);
2191 d->b_left = gtk_spin_button_new_with_range(0, 1000, incr);
2192 d->b_right = gtk_spin_button_new_with_range(0, 1000, incr);
2193 d->b_bottom = gtk_spin_button_new_with_range(0, 1000, incr);
2194 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_top), n_digits);
2195 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_bottom), n_digits);
2196 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_left), n_digits);
2197 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_right), n_digits);
2199 d->b_x = gtk_spin_button_new_with_range(0, 1000, incr);
2200 d->b_y = gtk_spin_button_new_with_range(0, 1000, incr);
2201 d->b_width = gtk_spin_button_new_with_range(0, 1000, incr);
2202 d->b_height = gtk_spin_button_new_with_range(0, 1000, incr);
2203 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_x), n_digits);
2204 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_y), n_digits);
2205 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_width), n_digits);
2206 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->b_height), n_digits);
2208 d->grid_size = gtk_spin_button_new_with_range(0, 100, incr);
2209 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(
d->grid_size), n_digits);
2211 gtk_entry_set_alignment(GTK_ENTRY(
d->b_top), 1);
2212 gtk_entry_set_alignment(GTK_ENTRY(
d->b_left), 1);
2213 gtk_entry_set_alignment(GTK_ENTRY(
d->b_right), 1);
2214 gtk_entry_set_alignment(GTK_ENTRY(
d->b_bottom), 1);
2216 gtk_entry_set_alignment(GTK_ENTRY(
d->b_x), 1);
2217 gtk_entry_set_alignment(GTK_ENTRY(
d->b_y), 1);
2218 gtk_entry_set_alignment(GTK_ENTRY(
d->b_width), 1);
2219 gtk_entry_set_alignment(GTK_ENTRY(
d->b_height), 1);
2221 gtk_entry_set_alignment(GTK_ENTRY(
d->grid_size), 1);
2234 gtk_box_pack_start(GTK_BOX(self->
widget),
d->printers,
TRUE,
TRUE, 0);
2235 g_signal_connect(G_OBJECT(
d->printers),
"value-changed", G_CALLBACK(
_printer_changed), self);
2243 g_signal_connect(G_OBJECT(
d->media),
"value-changed", G_CALLBACK(
_media_changed), self);
2244 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->media),
TRUE,
TRUE, 0);
2253 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->pprofile),
TRUE,
TRUE, 0);
2254 int printer_profile_type =
dt_conf_get_int(
"plugins/print/printer/icctype");
2260 for(
const GList *l =
d->profiles; l; l = g_list_next(l))
2268 if(prof->
type == printer_profile_type &&
2272 d->v_picctype = printer_profile_type;
2273 d->v_piccprofile = g_strdup(printer_profile);
2286 d->v_piccprofile = g_strdup(
"");
2291 char *
tooltip = g_strdup_printf(_(
"printer ICC profiles in %s or %s"), user_profile_dir, system_profile_dir);
2292 gtk_widget_set_tooltip_text(
d->pprofile,
tooltip);
2305 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->pintent),
TRUE,
TRUE, 0);
2311 d->prt.printer.intent =
d->v_pintent;
2313 d->black_point_compensation = gtk_check_button_new_with_label(_(
"black point compensation"));
2314 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->black_point_compensation),
TRUE,
FALSE, 0);
2315 g_signal_connect(
d->black_point_compensation,
"toggled", G_CALLBACK(
_printer_bpc_callback), (gpointer)self);
2317 d->v_black_point_compensation =
dt_conf_get_bool(
"plugins/print/print/black_point_compensation");
2318 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
d->black_point_compensation),
d->v_black_point_compensation);
2320 gtk_widget_set_tooltip_text(
d->black_point_compensation,
2321 _(
"activate black point compensation when applying the printer profile"));
2323 gtk_widget_set_sensitive(GTK_WIDGET(
d->black_point_compensation), combo_idx==0?
FALSE:
TRUE);
2335 g_signal_connect(G_OBJECT(
d->papers),
"value-changed", G_CALLBACK(
_paper_changed), self);
2336 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->papers),
TRUE,
TRUE, 0);
2344 g_signal_connect(G_OBJECT(
d->orientation),
"value-changed", G_CALLBACK(
_orientation_changed), self);
2346 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->orientation),
TRUE,
TRUE, 0);
2356 label = gtk_label_new(_(
"image width/height"));
2358 d->width = gtk_label_new(_(
"width"));
2359 gtk_box_pack_start(GTK_BOX(hboxdim), GTK_WIDGET(
d->width),
TRUE,
TRUE, 0);
2360 label = gtk_label_new(_(
" x "));
2361 gtk_box_pack_start(GTK_BOX(hboxdim), GTK_WIDGET(label),
TRUE,
TRUE, 0);
2362 d->height = gtk_label_new(_(
"height"));
2363 gtk_box_pack_start(GTK_BOX(hboxdim), GTK_WIDGET(
d->height),
TRUE,
TRUE, 0);
2368 label = gtk_label_new(_(
"scale factor"));
2370 d->info = gtk_label_new(
"1.0");
2371 gtk_box_pack_start(GTK_BOX(hboxinfo), GTK_WIDGET(
d->info),
TRUE,
TRUE, 0);
2372 gtk_widget_set_tooltip_text(hboxinfo,
2373 _(
"image scale factor from native printer DPI:\n"
2374 " < 1 means that it is downscaled (best quality)\n"
2375 " > 1 means that the image is upscaled\n"
2376 " a too large value may result in poor print quality"));
2380 GtkGrid *bds = GTK_GRID(gtk_grid_new());
2384 d->lock_activated =
FALSE;
2387 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->b_top), _(
"top margin"));
2388 gtk_grid_attach(bds, GTK_WIDGET(
d->b_top), 1, 0, 1, 1);
2391 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->b_left), _(
"left margin"));
2392 gtk_grid_attach(bds, GTK_WIDGET(
d->b_left), 0, 1, 1, 1);
2394 d->lock_button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label(_(
"lock")));
2395 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->lock_button), _(
"change all margins uniformly"));
2396 gtk_grid_attach(bds, GTK_WIDGET(
d->lock_button), 1, 1, 1, 1);
2399 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->b_right), _(
"right margin"));
2400 gtk_grid_attach(bds, GTK_WIDGET(
d->b_right), 2, 1, 1, 1);
2403 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->b_bottom), _(
"bottom margin"));
2404 gtk_grid_attach(bds, GTK_WIDGET(
d->b_bottom), 1, 2, 1, 1);
2406 gtk_widget_set_halign(GTK_WIDGET(bds), GTK_ALIGN_CENTER);
2407 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(bds),
TRUE,
TRUE, 0);
2409 gtk_spin_button_set_value(GTK_SPIN_BUTTON(
d->b_top), top_b);
2410 gtk_spin_button_set_value(GTK_SPIN_BUTTON(
d->b_bottom), bottom_b);
2411 gtk_spin_button_set_value(GTK_SPIN_BUTTON(
d->b_left), left_b);
2412 gtk_spin_button_set_value(GTK_SPIN_BUTTON(
d->b_right), right_b);
2414 g_signal_connect(G_OBJECT (
d->b_top),
"value-changed",
2416 g_signal_connect(G_OBJECT (
d->b_bottom),
"value-changed",
2418 g_signal_connect(G_OBJECT (
d->b_left),
"value-changed",
2420 g_signal_connect(G_OBJECT (
d->b_right),
"value-changed",
2422 g_signal_connect(G_OBJECT(
d->lock_button),
"toggled",
2425 gtk_widget_set_halign(GTK_WIDGET(hboxdim), GTK_ALIGN_CENTER);
2426 gtk_widget_set_halign(GTK_WIDGET(hboxinfo), GTK_ALIGN_CENTER);
2428 const gboolean lock_active =
dt_conf_get_bool(
"plugins/print/print/lock_borders");
2429 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
d->lock_button), lock_active);
2436 d->grid = gtk_check_button_new_with_label(_(
"display grid"));
2438 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(
d->grid),
TRUE,
TRUE, 0);
2439 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(
d->grid_size),
TRUE,
TRUE, 0);
2441 gtk_spin_button_set_value(GTK_SPIN_BUTTON(
d->grid_size),
2444 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox),
TRUE,
TRUE, 0);
2446 d->snap_grid = gtk_check_button_new_with_label(_(
"snap to grid"));
2447 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(
d->snap_grid),
TRUE,
TRUE, 0);
2449 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(vbox),
TRUE,
TRUE, 0);
2451 g_signal_connect(G_OBJECT(
d->grid_size),
"value-changed", G_CALLBACK(
_grid_size_changed), self);
2452 g_signal_connect(G_OBJECT(
d->grid),
"toggled", G_CALLBACK(
_grid_callback), self);
2456 d->borderless = gtk_check_button_new_with_label(_(
"borderless mode required"));
2457 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->borderless),
TRUE,
TRUE, 0);
2458 gtk_widget_set_tooltip_text(
d->borderless,
2459 _(
"indicates that the borderless mode should be activated\n"
2460 "in the printer driver because the selected margins are\n"
2461 "below the printer hardware margins"));
2462 gtk_widget_set_sensitive(
d->borderless,
FALSE);
2470 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(hboxdim),
TRUE,
TRUE, 0);
2471 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(hboxinfo),
TRUE,
TRUE, 0);
2476 GtkGrid *bat = GTK_GRID(gtk_grid_new());
2479 for(
int i=0;
i<9;
i++)
2483 gtk_grid_attach (GTK_GRID (bat), GTK_WIDGET (
d->dtba[
i]), (
i%3),
i/3, 1, 1);
2488 GtkWidget *label4 = gtk_label_new(_(
"alignment"));
2489 gtk_box_pack_start(GTK_BOX(hbox22),GTK_WIDGET(label4),
TRUE,
TRUE,0);
2490 gtk_box_pack_start(GTK_BOX(hbox22), GTK_WIDGET(bat),
TRUE,
TRUE, 0);
2491 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(hbox22),
TRUE,
TRUE, 0);
2498 GtkGrid *fitbut = GTK_GRID(gtk_grid_new());
2501 gtk_grid_set_column_homogeneous(fitbut,
TRUE);
2502 gtk_grid_set_row_homogeneous(fitbut,
TRUE);
2505 _(
"add a new image area on the page\n"
2506 "click and drag on the page to place the area\n"
2507 "drag&drop image from film strip on it"), 0, 0);
2510 _(
"delete the currently selected image area"), 0, 0);
2511 gtk_widget_set_sensitive(
d->del,
FALSE);
2514 _(
"remove all image areas from the page"), 0, 0);
2516 gtk_grid_attach(fitbut, GTK_WIDGET(bnew), 0, 0, 2, 1);
2517 gtk_grid_attach(fitbut, GTK_WIDGET(
d->del), 0, 1, 1, 1);
2518 gtk_grid_attach(fitbut, GTK_WIDGET(bclear), 1, 1, 1, 1);
2520 gtk_box_pack_start(GTK_BOX(mfitbox), GTK_WIDGET(fitbut),
TRUE,
TRUE, 0);
2521 gtk_box_pack_start(GTK_BOX(hfitbox), GTK_WIDGET(mfitbox),
TRUE,
TRUE, 0);
2529 gtk_widget_set_tooltip_text(
d->b_x, _(
"image area x origin (in current unit)"));
2530 gtk_entry_set_width_chars(GTK_ENTRY(
d->b_x), 5);
2533 gtk_widget_set_tooltip_text(
d->b_y, _(
"image area y origin (in current unit)"));
2534 gtk_entry_set_width_chars(GTK_ENTRY(
d->b_y), 5);
2536 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(
d->b_x),
TRUE,
TRUE, 0);
2537 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(
d->b_y),
TRUE,
TRUE, 0);
2539 gtk_box_pack_start(GTK_BOX(hfitbox), GTK_WIDGET(box),
TRUE,
TRUE, 0);
2544 gtk_widget_set_tooltip_text(
d->b_width, _(
"image area width (in current unit)"));
2545 gtk_entry_set_width_chars(GTK_ENTRY(
d->b_width), 5);
2548 gtk_widget_set_tooltip_text(
d->b_height, _(
"image area height (in current unit)"));
2549 gtk_entry_set_width_chars(GTK_ENTRY(
d->b_height), 5);
2551 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(
d->b_width),
TRUE,
TRUE, 0);
2552 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(
d->b_height),
TRUE,
TRUE, 0);
2554 gtk_box_pack_start(GTK_BOX(hfitbox), GTK_WIDGET(box),
TRUE,
TRUE, 0);
2556 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(hfitbox),
TRUE,
TRUE, 0);
2558 gtk_widget_add_events(
d->b_x, GDK_BUTTON_PRESS_MASK);
2559 gtk_widget_add_events(
d->b_y, GDK_BUTTON_PRESS_MASK);
2560 gtk_widget_add_events(
d->b_width, GDK_BUTTON_PRESS_MASK);
2561 gtk_widget_add_events(
d->b_height, GDK_BUTTON_PRESS_MASK);
2563 g_signal_connect(G_OBJECT(
d->b_x),
"value-changed", G_CALLBACK(
_x_changed), (gpointer)
d);
2564 g_signal_connect(G_OBJECT(
d->b_y),
"value-changed", G_CALLBACK(
_y_changed), (gpointer)
d);
2565 g_signal_connect(G_OBJECT(
d->b_width),
"value-changed", G_CALLBACK(
_width_changed), (gpointer)
d);
2566 g_signal_connect(G_OBJECT(
d->b_height),
"value-changed", G_CALLBACK(
_height_changed), (gpointer)
d);
2579 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->profile),
TRUE,
TRUE, 0);
2587 for(
const GList *l =
d->profiles; l; l = g_list_next(l))
2592 if(prof->
type == icctype
2596 d->v_icctype = icctype;
2597 d->v_iccprofile = g_strdup(iccprofile);
2608 d->v_iccprofile = g_strdup(
"");
2614 tooltip = g_strdup_printf(_(
"output ICC profiles in %s or %s"), user_profile_dir, system_profile_dir);
2615 gtk_widget_set_tooltip_text(
d->profile,
tooltip);
2618 g_signal_connect(G_OBJECT(
d->profile),
"value-changed", G_CALLBACK(
_profile_changed), (gpointer)self);
2630 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->intent),
TRUE,
TRUE, 0);
2634 g_signal_connect (G_OBJECT (
d->intent),
"value-changed", G_CALLBACK (
_intent_callback), (gpointer)self);
2645 combo_idx = -1;
n=0;
2647 for(
const GList *st_iter = styles; st_iter; st_iter = g_list_next(st_iter))
2652 if(g_strcmp0(style->
name,current_style)==0)
2655 d->v_style = g_strdup(current_style);
2661 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
d->style),
TRUE,
TRUE, 0);
2662 gtk_widget_set_tooltip_text(
d->style, _(
"temporary style to use while printing"));
2669 d->v_style = g_strdup(
"");
2674 g_signal_connect (G_OBJECT (
d->style),
"value-changed",
2682 d->print_button = GTK_BUTTON(button);
2683 gtk_box_pack_start(GTK_BOX(self->
widget), button,
TRUE,
TRUE, 0);
2695 const int old_version,
int *new_version,
size_t *new_size)
2697 if(old_version == 1)
2721 const char *buf = (
const char *)old_params;
2724 const char *printer = buf;
2725 const int32_t printer_len = strlen(printer) + 1;
2729 const char *paper = buf;
2730 const int32_t paper_len = strlen(paper) + 1;
2734 const int32_t landscape = *(int32_t *)buf;
2735 buf +=
sizeof(int32_t);
2738 const char *profile = buf;
2739 const int32_t profile_len = strlen(profile) + 1;
2743 const int32_t intent = *(int32_t *)buf;
2744 buf +=
sizeof(int32_t);
2747 const char *pprofile = buf;
2748 const int32_t pprofile_len = strlen(pprofile) + 1;
2749 buf += pprofile_len;
2756 const char *profile_filename =
"", *pprofile_filename =
"";
2758 if(*profile ==
'\0' || !g_strcmp0(profile,
"none"))
2762 else if(!g_strcmp0(profile,
"sRGB"))
2766 else if(!g_strcmp0(profile,
"adobergb"))
2773 profile_filename = &profile[1];
2777 if(*pprofile ==
'\0')
2781 else if(!g_strcmp0(pprofile,
"sRGB"))
2785 else if(!g_strcmp0(pprofile,
"adobergb"))
2792 pprofile_filename = &pprofile[1];
2795 const int32_t new_profile_len = strlen(profile_filename) + 1;
2796 const int32_t new_pprofile_len = strlen(pprofile_filename) + 1;
2799 size_t new_params_size = old_params_size - profile_len - pprofile_len;
2801 new_params_size += new_profile_len + new_pprofile_len;
2802 void *new_params = malloc(new_params_size);
2806 memcpy((uint8_t *)new_params + pos, printer, printer_len);
2809 memcpy((uint8_t *)new_params + pos, paper, paper_len);
2812 memcpy((uint8_t *)new_params + pos, &landscape,
sizeof(int32_t));
2813 pos +=
sizeof(int32_t);
2815 memcpy((uint8_t *)new_params + pos, &profile_type,
sizeof(int32_t));
2816 pos +=
sizeof(int32_t);
2818 memcpy((uint8_t *)new_params + pos, profile_filename, new_profile_len);
2819 pos += new_profile_len;
2821 memcpy((uint8_t *)new_params + pos, &intent,
sizeof(int32_t));
2822 pos +=
sizeof(int32_t);
2824 memcpy((uint8_t *)new_params + pos, &pprofile_type,
sizeof(int32_t));
2825 pos +=
sizeof(int32_t);
2827 memcpy((uint8_t *)new_params + pos, pprofile_filename, new_pprofile_len);
2828 pos += new_pprofile_len;
2830 memcpy((uint8_t *)new_params + pos, buf, old_params_size - ((
char *)buf - (
char *)old_params));
2832 *new_size = new_params_size;
2836 else if(old_version == 2)
2839 size_t new_params_size = old_params_size + 1;
2840 void *new_params = calloc(1, new_params_size);
2842 memcpy(new_params, old_params, old_params_size);
2844 ((
char *)new_params)[old_params_size] =
'\0';
2846 *new_size = new_params_size;
2850 else if(old_version == 3)
2853 size_t new_params_size = old_params_size +
sizeof(int32_t) + 4 *
sizeof(
float);
2854 void *new_params = calloc(1, new_params_size);
2856 memcpy(new_params, old_params, old_params_size);
2860 int32_t idx = old_params_size;
2861 *(int32_t *)((uint8_t *)new_params + idx) = 1;
2862 idx +=
sizeof(int32_t);
2863 *(
float *)((uint8_t *)new_params + idx) = 0.05f;
2864 idx +=
sizeof(float);
2865 *(
float *)((uint8_t *)new_params + idx) = 0.05f;
2866 idx +=
sizeof(float);
2867 *(
float *)((uint8_t *)new_params + idx) = 0.90f;
2868 idx +=
sizeof(float);
2869 *(
float *)((uint8_t *)new_params + idx) = 0.90f;
2872 *new_size = new_params_size;
2887 const char *buf = (
char *)params;
2890 const char *printer = buf;
2892 const int32_t printer_len = strlen(printer) + 1;
2895 const char *paper = buf;
2897 const int32_t paper_len = strlen(paper) + 1;
2900 const int32_t landscape = *(int32_t *)buf;
2901 buf +=
sizeof(int32_t);
2903 const int32_t f_profile_type = *(int32_t *)buf;
2904 buf +=
sizeof(int32_t);
2906 const char *f_profile = buf;
2908 const int32_t profile_len = strlen(f_profile) + 1;
2911 const int32_t intent = *(int32_t *)buf;
2912 buf +=
sizeof(int32_t);
2914 const int32_t f_pprofile_type = *(int32_t *)buf;
2915 buf +=
sizeof(int32_t);
2917 const char *f_pprofile = buf;
2919 const int32_t pprofile_len = strlen(f_pprofile) + 1;
2920 buf += pprofile_len;
2922 const int32_t pintent = *(int32_t *)buf;
2923 buf +=
sizeof(int32_t);
2925 const int32_t bpc = *(int32_t *)buf;
2926 buf +=
sizeof(int32_t);
2928 const char *style = buf;
2930 const int32_t style_len = strlen(style) + 1;
2934 buf +=
sizeof(int32_t);
2936 const double b_top = *(
double *)buf;
2939 const double b_bottom = *(
double *)buf;
2942 const double b_left = *(
double *)buf;
2945 const double b_right = *(
double *)buf;
2948 const int32_t alignment = *(int32_t *)buf;
2949 buf +=
sizeof(int32_t);
2951 const char *media = buf;
2953 const int32_t media_len = strlen(media) + 1;
2957 buf +=
sizeof(int32_t);
2962 buf +=
sizeof(float);
2964 buf +=
sizeof(float);
2966 buf +=
sizeof(float);
2968 buf +=
sizeof(float);
2972 if(
size != printer_len + paper_len + media_len + profile_len + pprofile_len + style_len + 8 *
sizeof(int32_t) + 4 *
sizeof(
double) +
sizeof(int32_t) + (ps->
imgs.
count * 4 *
sizeof(float)))
2976 if(printer[0] !=
'\0')
2979 if(paper[0] !=
'\0')
2982 if(media[0] !=
'\0')
2988 for(GList *iter = ps->
profiles; iter; iter = g_list_next(iter))
2991 if(f_profile_type ==
p->type && (f_profile_type !=
DT_COLORSPACE_FILE || !g_strcmp0(f_profile,
p->filename)))
3001 for(GList *iter = ps->
profiles; iter; iter = g_list_next(iter))
3004 if(f_pprofile_type ==
p->type && (f_pprofile_type !=
DT_COLORSPACE_FILE || !g_strcmp0(f_pprofile,
p->filename)))
3014 if(style[0] !=
'\0')
3017 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_top), b_top *
units[ps->
unit]);
3018 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_bottom), b_bottom *
units[ps->
unit]);
3019 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_left), b_left *
units[ps->
unit]);
3020 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_right), b_right *
units[ps->
unit]);
3022 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps->
dtba[alignment]),
TRUE);
3041 const int32_t style_mode = 0;
3050 const int32_t alignment = 0;
3053 const char *profile =
"", *pprofile =
"";
3054 for(GList *iter = ps->
profiles; iter; iter = g_list_next(iter))
3057 if(
p->pos == profile_pos)
3059 profile_type =
p->type;
3060 profile =
p->filename;
3062 if(
p->ppos == pprofile_pos)
3064 pprofile_type =
p->type;
3065 pprofile =
p->filename;
3075 const int32_t printer_len = strlen (printer) + 1;
3076 const int32_t paper_len = strlen (paper) + 1;
3077 const int32_t media_len = strlen (media) + 1;
3078 const int32_t profile_len = strlen (profile) + 1;
3079 const int32_t pprofile_len = strlen (pprofile) + 1;
3080 const int32_t style_len = strlen (style) + 1;
3083 *
size = printer_len + paper_len + media_len + profile_len + pprofile_len + style_len + 8 *
sizeof(int32_t) + 4 *
sizeof(
double) +
sizeof(int32_t) + (ps->
imgs.
count * 4 *
sizeof(
float));
3086 char *params = (
char *)malloc(*
size);
3090 memcpy(params+pos, printer, printer_len);
3092 memcpy(params+pos, paper, paper_len);
3094 memcpy(params+pos, &landscape,
sizeof(int32_t));
3095 pos +=
sizeof(int32_t);
3096 memcpy(params+pos, &profile_type,
sizeof(int32_t));
3097 pos +=
sizeof(int32_t);
3098 memcpy(params+pos, profile, profile_len);
3100 memcpy(params+pos, &intent,
sizeof(int32_t));
3101 pos +=
sizeof(int32_t);
3102 memcpy(params+pos, &pprofile_type,
sizeof(int32_t));
3103 pos +=
sizeof(int32_t);
3104 memcpy(params+pos, pprofile, pprofile_len);
3105 pos += pprofile_len;
3106 memcpy(params+pos, &pintent,
sizeof(int32_t));
3107 pos +=
sizeof(int32_t);
3108 memcpy(params+pos, &bpc,
sizeof(int32_t));
3109 pos +=
sizeof(int32_t);
3110 memcpy(params+pos, style, style_len);
3112 memcpy(params+pos, &style_mode,
sizeof(int32_t));
3113 pos +=
sizeof(int32_t);
3114 memcpy(params+pos, &b_top,
sizeof(
double));
3116 memcpy(params+pos, &b_bottom,
sizeof(
double));
3118 memcpy(params+pos, &b_left,
sizeof(
double));
3120 memcpy(params+pos, &b_right,
sizeof(
double));
3122 memcpy(params+pos, &alignment,
sizeof(int32_t));
3123 pos +=
sizeof(int32_t);
3124 memcpy(params+pos, media, media_len);
3128 memcpy(params+pos, &ps->
imgs.
count,
sizeof(int32_t));
3129 pos +=
sizeof(int32_t);
3133 memcpy(params+pos, &ps->
imgs.
box[
k].
pos.
x,
sizeof(
float));
3134 pos +=
sizeof(int32_t);
3135 memcpy(params+pos, &ps->
imgs.
box[
k].
pos.
y,
sizeof(
float));
3136 pos +=
sizeof(int32_t);
3138 pos +=
sizeof(int32_t);
3140 pos +=
sizeof(int32_t);
3143 g_assert(pos == *
size);
3179 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_top), 17 *
units[ps->
unit]);
3181 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_left), 17 *
units[ps->
unit]);
3182 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ps->
b_right), 17 *
units[ps->
unit]);
3193 gtk_widget_set_sensitive(GTK_WIDGET(ps->
pintent),
TRUE);
Handle default and user-set shortcuts (accelerators)
void dt_gui_add_help_link(GtkWidget *widget, char *link)
static double dist(double x1, double y1, double x2, double y2)
GtkWidget * dt_bauhaus_combobox_new_full(dt_bauhaus_t *bh, dt_gui_module_t *self, const char *label, const char *tip, int pos, GtkCallback callback, gpointer data, const char **texts)
void dt_bauhaus_combobox_clear(GtkWidget *widget)
int dt_bauhaus_combobox_get(GtkWidget *widget)
const char * dt_bauhaus_combobox_get_text(GtkWidget *widget)
void dt_bauhaus_combobox_set(GtkWidget *widget, const int pos)
void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *label)
GtkWidget * dt_bauhaus_combobox_new(dt_bauhaus_t *bh, dt_gui_module_t *self)
gboolean dt_bauhaus_combobox_set_from_text(GtkWidget *widget, const char *text)
void dt_bauhaus_combobox_add(GtkWidget *widget, const char *text)
const dt_colorspaces_color_profile_t * dt_colorspaces_get_profile(dt_colorspaces_color_profile_type_t type, const char *filename, dt_colorspaces_profile_role_t role)
Resolve a profile identity to its registered entry.
size_t dt_colorspaces_enumerate_profiles(const dt_colorspaces_profile_role_t role, dt_colorprofile_desc_t **out)
Ordered snapshot of every profile registered for one role.
The colour-profile module's API: which profiles exist, and how to apply one.
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
void dt_conf_set_bool(const char *name, int val)
int dt_conf_get_bool(const char *name)
void dt_conf_set_float(const char *name, float val)
float dt_conf_get_float(const char *name)
Float for name, clamped to its declared bounds.
gchar * dt_conf_get_string(const char *name)
Read the stored string for name as a private copy.
void dt_conf_set_int(const char *name, int val)
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
void dt_conf_set_string(const char *name, const char *val)
const char * dt_conf_get_string_const(const char *name)
Borrow the stored string for name without copying it.
dt_pdf_page_t * dt_pdf_add_page(dt_pdf_t *pdf, dt_pdf_image_t **images, int n_images)
dt_pdf_image_t * dt_pdf_add_image(dt_pdf_t *pdf, const unsigned char *image, int width, int height, int bpp, int icc_id, float border)
void dt_pdf_finish(dt_pdf_t *pdf, dt_pdf_page_t **pages, int n_pages)
dt_pdf_t * dt_pdf_start(const char *filename, float width, float height, float dpi, dt_pdf_stream_encoder_t default_encoder)
void dt_control_set_mouse_over_id(int32_t value)
void dt_control_log(const char *msg,...)
void dt_control_queue_redraw_center()
Request a redraw of the centre view.
void dt_control_queue_redraw()
Request a redraw of the whole workspace.
#define dt_control_change_cursor(cursor)
struct dt_control_t * dt_control_get_global(void)
void dt_get_printer_info(const char *printer_name, dt_printer_info_t *pinfo)
void dt_print_file(const int32_t imgid, const char *filename, const char *job_title, const dt_print_info_t *pinfo)
dt_medium_info_t * dt_get_medium(GList *media, const char *name)
GList * dt_get_media_type(const dt_printer_info_t *printer)
void dt_printers_discovery(void(*cb)(dt_printer_info_t *pr, void *user_data), void *user_data)
dt_paper_info_t * dt_get_paper(GList *papers, const char *name)
GList * dt_get_papers(const dt_printer_info_t *printer)
void dt_init_print_info(dt_print_info_t *pinfo)
void expose(dt_view_t *self, cairo_t *cri, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
struct dt_view_manager_t * dt_view_manager_get_global(void)
struct dt_bauhaus_t * dt_bauhaus_get_global(void)
GHashTable * names
GtkWidget* -> the name the application knows it by.
static void dt_gui_draw_rounded_rectangle(cairo_t *cr, float width, float height, float x, float y)
void dt_loc_get_tmp_dir(char *tmpdir, size_t bufsize)
void dt_loc_get_datadir(char *datadir, size_t bufsize)
void dt_loc_get_user_config_dir(char *configdir, size_t bufsize)
void dt_image_cache_set_print_timestamp(const int32_t imgid)
dt_image_t * dt_image_cache_get(const int32_t imgid, char mode)
void dt_image_cache_read_release(const dt_image_t *img)
int dt_imageio_export_with_flags(const int32_t imgid, const char *filename, dt_imageio_module_format_t *format, dt_imageio_module_data_t *format_params, const gboolean ignore_exif, const gboolean display_byteorder, const gboolean high_quality, gboolean is_scaling, const gboolean thumbnail_export, const char *filter, const gboolean copy_metadata, const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent, dt_imageio_module_storage_t *storage, dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata, dt_atomic_int *shutdown)
const dt_colorspaces_color_profile_t * dt_colorspaces_get_output_profile(const int32_t imgid, dt_colorspaces_color_profile_type_t *over_type, const char *over_filename)
dt_job_state_t dt_control_job_get_state(_dt_job_t *job)
dt_job_t * dt_control_job_create(dt_job_execute_callback execute, const char *msg,...)
int dt_control_add_job(dt_control_t *control, dt_job_queue_t queue_id, _dt_job_t *job)
void * dt_control_job_get_params(const _dt_job_t *job)
void dt_control_job_set_progress(dt_job_t *job, double value)
void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable)
void dt_control_job_set_params(_dt_job_t *job, void *params, dt_job_destroy_callback callback)
void dt_control_job_dispose(_dt_job_t *job)
@ DT_JOB_QUEUE_USER_EXPORT
GtkWidget * dt_ui_section_label_new(const gchar *str)
static int precision(double x, double adj)
GtkWidget * dt_action_button_new(dt_lib_module_t *self, const gchar *label, gpointer callback, gpointer data, const gchar *tooltip, guint accel_key, GdkModifierType mods)
_lib_location_type_t type
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
static void dt_free_gpointer(gpointer ptr)
g_free() one pointer, with the signature GDestroyNotify wants.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define dt_mipmap_cache_get(B, C, D, E, F)
#define dt_mipmap_cache_release(B)
#define DT_MODULE(MODVER)
Instantiate the version handshake every module must export. Use once, at file scope,...
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.
#define dt_pdf_pixel_to_point(px, dpi)
#define dt_pdf_mm_to_point(mm)
@ DT_PDF_STREAM_ENCODER_FLATE
static void _page_delete_area(const dt_lib_module_t *self, const int box_index)
static void _print_job_cleanup(void *p)
void gui_reset(dt_lib_module_t *self)
static GList * _get_profiles()
int set_params(dt_lib_module_t *self, const void *params, int size)
void _get_control(dt_lib_print_settings_t *ps, float x, float y)
void * get_params(dt_lib_module_t *self, int *size)
struct _dialog_description dialog_description_t
static void _printer_changed(GtkWidget *combo, const dt_lib_module_t *self)
static void _left_border_callback(GtkWidget *spin, gpointer user_data)
void gui_post_expose(struct dt_lib_module_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
static int _print_job_run(dt_job_t *job)
int mouse_leave(struct dt_lib_module_t *self)
static void _snap_grid_callback(GtkWidget *widget, dt_lib_module_t *self)
static void _print_button_clicked(GtkWidget *widget, gpointer user_data)
static const float units[UNIT_N]
static void _profile_changed(GtkWidget *widget, dt_lib_module_t *self)
static void _paper_changed(GtkWidget *combo, const dt_lib_module_t *self)
static void _grid_size_changed(GtkWidget *widget, dt_lib_module_t *self)
static float _vscreen_to_mm(dt_lib_print_settings_t *ps, const float value, const gboolean offset)
static void _printer_bpc_callback(GtkWidget *widget, dt_lib_module_t *self)
static void _grid_callback(GtkWidget *widget, dt_lib_module_t *self)
static void _y_changed(GtkWidget *widget, gpointer user_data)
static void _top_border_callback(GtkWidget *spin, gpointer user_data)
void _fill_box_values(dt_lib_print_settings_t *ps)
static void _orientation_changed(GtkWidget *combo, dt_lib_module_t *self)
static void _page_delete_area_clicked(GtkWidget *widget, gpointer user_data)
static void _print_settings_activate_or_update_callback(gpointer instance, int32_t imgid, gpointer user_data)
enum _set_controls dt_box_control_set
static void _create_pdf(dt_job_t *job, dt_images_box imgs, const float width, const float height)
static void _x_changed(GtkWidget *widget, gpointer user_data)
void gui_cleanup(dt_lib_module_t *self)
static void _swap(float *a, float *b)
static void _bottom_border_callback(GtkWidget *spin, gpointer user_data)
static float _to_mm(dt_lib_print_settings_t *ps, double value)
static void _width_changed(GtkWidget *widget, gpointer user_data)
static float _mm_to_hscreen(dt_lib_print_settings_t *ps, const float value, const gboolean offset)
static void _set_orientation(dt_lib_print_settings_t *ps, int32_t imgid)
static void _get_page_dimension(dt_print_info_t *prt, float *width, float *height)
static void _alignment_callback(GtkWidget *tb, gpointer user_data)
static void _lock_callback(GtkWidget *button, gpointer user_data)
static float _percent_unit_of(dt_lib_print_settings_t *ps, float ref, float value)
void _cairo_rectangle(cairo_t *cr, const int sel_controls, const int x1, const int y1, const int x2, const int y2)
static void _new_printer_callback(dt_printer_info_t *printer, void *user_data)
static void _style_callback(GtkWidget *widget, dt_lib_module_t *self)
int mouse_moved(struct dt_lib_module_t *self, double x, double y, double pressure, int which)
static void _intent_callback(GtkWidget *widget, dt_lib_module_t *self)
uint32_t container(dt_lib_module_t *self)
static void _printer_intent_callback(GtkWidget *widget, dt_lib_module_t *self)
static void _printer_profile_changed(GtkWidget *widget, dt_lib_module_t *self)
int button_pressed(struct dt_lib_module_t *self, double x, double y, double pressure, int which, int type, uint32_t state)
static void _update_slider(dt_lib_print_settings_t *ps)
static void _precision_by_unit(_unit_t unit, int *n_digits, float *incr, char **format)
static float _hscreen_to_mm(dt_lib_print_settings_t *ps, const float value, const gboolean offset)
static void _media_changed(GtkWidget *combo, const dt_lib_module_t *self)
static const char * mime(dt_imageio_module_data_t *data)
void view_leave(struct dt_lib_module_t *self, struct dt_view_t *old_view, struct dt_view_t *new_view)
void gui_init(dt_lib_module_t *self)
void view_enter(struct dt_lib_module_t *self, struct dt_view_t *old_view, struct dt_view_t *new_view)
const char ** views(dt_lib_module_t *self)
void * legacy_params(dt_lib_module_t *self, const void *const old_params, const size_t old_params_size, const int old_version, int *new_version, size_t *new_size)
static void _snap_to_grid(dt_lib_print_settings_t *ps, float *x, float *y)
static void _page_clear_area_clicked(GtkWidget *widget, gpointer user_data)
static int levels(dt_imageio_module_data_t *data)
static int write_image(dt_imageio_module_data_t *data, const char *filename, const void *in, dt_colorspaces_color_profile_type_t over_type, const char *over_filename, void *exif, int exif_len, int32_t imgid, int num, int total, dt_dev_pixelpipe_t *pipe, const gboolean export_masks)
static void _page_new_area_clicked(GtkWidget *widget, gpointer user_data)
static void _height_changed(GtkWidget *widget, gpointer user_data)
static int _export_and_setup_pos(dt_job_t *job, dt_image_box *img, const int32_t idx)
static float _mm_to_vscreen(dt_lib_print_settings_t *ps, const float value, const gboolean offset)
static void _right_border_callback(GtkWidget *spin, gpointer user_data)
static int _export_image(dt_job_t *job, dt_image_box *img)
static void _set_printer(const dt_lib_module_t *self, const char *printer_name)
static const gchar * _unit_names[]
int button_released(struct dt_lib_module_t *self, double x, double y, int which, uint32_t state)
static void _unit_changed(GtkWidget *combo, dt_lib_module_t *self)
void dt_printing_get_image_pos(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos)
int32_t dt_printing_get_image_box(const dt_images_box *imgs, const int x, const int y)
void dt_printing_clear_box(dt_image_box *img)
void dt_printing_setup_box(dt_images_box *imgs, const int idx, const float x, const float y, const float width, const float height)
void dt_printing_setup_image(dt_images_box *imgs, const int idx, const int32_t imgid, const int32_t width, const int32_t height, const dt_alignment_t alignment)
void dt_printing_setup_page(dt_images_box *imgs, const float page_width, const float page_height, const int resolution)
void dt_printing_clear_boxes(dt_images_box *imgs)
void dt_printing_get_image_pos_mm(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos)
#define MAX_IMAGE_PER_PAGE
int dt_apply_printer_profile(void **in, uint32_t width, uint32_t height, int bpp, cmsHPROFILE hInProfile, cmsHPROFILE hOutProfile, int intent, gboolean black_point_compensation)
Convert an interleaved RGB buffer from hInProfile to hOutProfile, replacing the caller's buffer with ...
The printer-profile application path: the last colour transform an image goes through before it is ha...
dt_iop_color_intent_t
ICC rendering intent, as stored in iop params and in conf.
dt_colorspaces_color_profile_type_t
@ DT_COLORSPACE_FILE
A user ICC file on disk; the only type whose filename is meaningful.
@ DT_COLORSPACE_SRGB
sRGB – registered TWICE, and the two entries are not interchangeable.
@ DT_COLORSPACE_NONE
No profile / "take it from the image settings". Never matches a list entry.
@ DT_PROFILE_ROLE_OUTPUT
Listed in the output/export-profile combo (colorout, export).
@ DT_PROFILE_ROLE_INPUT
Listed in the input-profile combo (colorin).
#define DT_DEBUG_CONTROL_SIGNAL_DISCONNECT(ctlsig, cb, user_data)
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
struct dt_control_signal_t * dt_control_signal_get_global(void)
@ DT_SIGNAL_TAG_CHANGED
This signal is raised when a tag is added/deleted/changed
@ DT_SIGNAL_VIEWMANAGER_FILMSTRIP_ACTIVATE
This signal is raised when a thumb is single-clicked in the filmstrip. Views that want filmstrip clic...
#define DT_DEBUG_CONTROL_SIGNAL_CONNECT(ctlsig, signal, cb, user_data)
static const dt_aligned_pixel_simd_t value
void dt_style_free(gpointer data)
GList * dt_styles_get_list(const char *filter)
const float uint32_t state[4]
A profile's public identity: what the GUI displays and stores, and nothing else.
char name[512]
translated, display-ready
char filename[DT_IOP_COLOR_ICC_LEN]
"" unless type == DT_COLORSPACE_FILE
One registered profile: its identity, its LCMS handle, and where it sits in each combo box.
cmsHPROFILE profile
the actual profile; NULL for the three category entries
char filename[DT_MAX_FILENAME_LEN]
dt_colorspaces_color_profile_type_t type
dt_colorspaces_color_profile_type_t p_icc_type
dt_iop_color_intent_t buf_icc_intent
dt_colorspaces_color_profile_type_t buf_icc_type
gboolean black_point_compensation
char pdf_filename[DT_PATH_MAX]
dt_iop_color_intent_t p_icc_intent
dt_box_control_set sel_controls
GtkWidget * black_point_compensation
GtkToggleButton * lock_button
gboolean v_black_point_compensation
GtkDarktableToggleButton * dtba[9]
dt_printer_info_t printer
dt_iop_color_intent_t intent
typedef double((*spd)(unsigned long int wavelength, double TempK))
char * dt_get_help_url(char *name)
size_t dt_utf8_strlcpy(char *dest, const char *src, size_t n)
void dt_view_print_settings(const dt_view_manager_t *vm, dt_print_info_t *pinfo, dt_images_box *imgs)
@ DT_UI_CONTAINER_PANEL_RIGHT_CENTER