summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2016-11-08 11:44:44 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2016-11-10 16:57:30 +0100
commitc836be0508b51ecccd893a833b0f290c627ad3bf (patch)
tree83724747a32880ac1312f24bc914c64807f6f5f6 /modules
parent7b2313a6df3bc8c9b3c25dbea319051b3d9cd789 (diff)
downloadgtk+-c836be0508b51ecccd893a833b0f290c627ad3bf.tar.gz
printing: Do not truncate job names in GtkPrintOperation
We are currently truncating job names to 255 bytes, because that's the maximum allowed length of job-name attribute in CUPS. This is a CUPS limitation that GtkPrintOperation shouldn't need to know, and it shouldn't affect other backends, that might have other limitations or even no limitation at all. This has another side effect, that what you set as GtkPrintOperation:job-name could be different to what you get if the property is truncated, this is not documented in gtk_print_operation_set_job_name(). So, I think the job name should be truncated by the CUPS backend, right before setting the job-name attribute. https://bugzilla.gnome.org/show_bug.cgi?id=774097
Diffstat (limited to 'modules')
-rw-r--r--modules/printbackends/cups/gtkprintbackendcups.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index d1140764a7..2056434bea 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -752,10 +752,26 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
NULL, printer_absolute_uri);
title = gtk_print_job_get_title (job);
- if (title)
+ if (title) {
+ char *title_truncated = NULL;
+ size_t title_bytes = strlen (title);
+
+ if (title_bytes >= IPP_MAX_NAME)
+ {
+ gchar *end;
+
+ end = g_utf8_find_prev_char (title, title + IPP_MAX_NAME - 1);
+ title_truncated = g_utf8_substring (title,
+ 0,
+ g_utf8_pointer_to_offset (title, end));
+ }
+
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION,
IPP_TAG_NAME, "job-name",
- NULL, title);
+ NULL,
+ title_truncated ? title_truncated : title);
+ g_free (title_truncated);
+ }
options_data = g_new0 (CupsOptionsData, 1);
options_data->request = request;