=?utf-8?q?=5Bgtk+=5D_Set_cups_Custom_print_options_correctly_=28bug_=2354?= =?utf-8?b?MzUyMCwgcGF0Y2ggYnkgTWFyZWsgS2HFocOtayk=?=
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Set cups Custom print options correctly (bug #543520, patch by Marek KaÅÃk)
- Date: Thu, 5 Jan 2012 23:40:04 +0000 (UTC)
commit 6fa6576dda8da067af30532f84e6391d08ea9b1d
Author: Benjamin Berg <benjamin sipsolutions net>
Date: Sat Dec 24 17:26:32 2011 +0100
Set cups Custom print options correctly (bug #543520, patch by Marek KaÅÃk)
This patch fixes the cups print backend to pass Custom options with
the "Custom." prefix to cups if neccessary.
modules/printbackends/cups/gtkprintbackendcups.c | 46 ++++++++++++++++++++--
1 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index c5be26a..e4cde70 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -489,22 +489,44 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
GDK_THREADS_LEAVE ();
}
+typedef struct {
+ GtkCupsRequest *request;
+ GtkPrinterOptionSet *options;
+} CupsOptionsData;
+
static void
add_cups_options (const gchar *key,
const gchar *value,
gpointer user_data)
{
- GtkCupsRequest *request = user_data;
+ CupsOptionsData *data = (CupsOptionsData *) user_data;
+ GtkCupsRequest *request = data->request;
+ GtkPrinterOptionSet *options = data->options;
+ GtkPrinterOption *option = NULL;
+ gchar *new_value = NULL;
if (!g_str_has_prefix (key, "cups-"))
return;
if (strcmp (value, "gtk-ignore-value") == 0)
return;
+
+ option = gtk_printer_option_set_lookup (options, key);
key = key + strlen ("cups-");
- gtk_cups_request_encode_option (request, key, value);
+ /* Add "Custom." prefix to custom values */
+ if (value && option &&
+ !gtk_printer_option_has_choice (option, value))
+ new_value = g_strdup_printf ("Custom.%s", value);
+
+ if (new_value)
+ {
+ gtk_cups_request_encode_option (request, key, new_value);
+ g_free (new_value);
+ }
+ else
+ gtk_cups_request_encode_option (request, key, value);
}
static void
@@ -517,8 +539,12 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
{
GtkPrinterCups *cups_printer;
CupsPrintStreamData *ps;
+ CupsOptionsData *options_data;
GtkCupsRequest *request;
GtkPrintSettings *settings;
+ GtkPrinterOptionSet *options;
+ GtkPrintCapabilities capabilities;
+ GtkPageSetup *page_setup;
const gchar *title;
char printer_absolute_uri[HTTP_MAX_URI];
@@ -527,6 +553,8 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job));
settings = gtk_print_job_get_settings (job);
+ capabilities = cups_printer_get_capabilities (GTK_PRINTER (cups_printer));
+ page_setup = gtk_printer_get_default_page_size (GTK_PRINTER (cups_printer));
request = gtk_cups_request_new_with_username (NULL,
GTK_CUPS_POST,
@@ -564,8 +592,18 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
IPP_TAG_NAME, "job-name",
NULL, title);
- gtk_print_settings_foreach (settings, add_cups_options, request);
-
+ options = cups_printer_get_options (GTK_PRINTER (cups_printer), settings, page_setup, capabilities);
+
+ options_data = g_new0 (CupsOptionsData, 1);
+ options_data->request = request;
+ options_data->options = options;
+
+ gtk_print_settings_foreach (settings, add_cups_options, options_data);
+
+ g_object_unref (page_setup);
+ g_object_unref (options);
+ g_free (options_data);
+
ps = g_new0 (CupsPrintStreamData, 1);
ps->callback = callback;
ps->user_data = user_data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]