Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.8469
diff -p -u -r1.8469 ChangeLog
--- ChangeLog	7 Dec 2006 17:01:15 -0000	1.8469
+++ ChangeLog	8 Dec 2006 13:49:59 -0000
@@ -1,3 +1,8 @@
+2006-12-08  Jürg Billeter  <j@bitron.ch>
+
+	* modules/printbackends/cups/gtkcupsutils.c:
+	(gtk_cups_request_encode_option): Support muli-value options.
+
 2006-12-07  Paolo Maggi  <paolo@gnome.org>
 
 	Fixes bug #383407
Index: modules/printbackends/cups/gtkcupsutils.c
===================================================================
RCS file: /cvs/gnome/gtk+/modules/printbackends/cups/gtkcupsutils.c,v
retrieving revision 1.6
diff -p -u -r1.6 gtkcupsutils.c
--- modules/printbackends/cups/gtkcupsutils.c	3 Oct 2006 18:19:15 -0000	1.6
+++ modules/printbackends/cups/gtkcupsutils.c	8 Dec 2006 13:50:05 -0000
@@ -474,12 +474,79 @@ gtk_cups_request_encode_option (GtkCupsR
         }
 
       default:
-        ippAddString (request->ipp_request,
-                      IPP_TAG_OPERATION,
-                      option_tag,
-                      option,
-                      NULL,
-                      value);
+        {
+          char *values;
+          char *s;
+          int in_quotes;
+          char *next;
+          GPtrArray *strings;
+          
+          values = g_strdup (value);
+          strings = NULL;
+          
+          for (s = values, next = s, in_quotes = 0; *s != '\0'; s++)
+            {
+              if (in_quotes != 2 && *s == '\'')
+                {
+                  /* skip quoted value */
+                  if (in_quotes == 0)
+                    in_quotes = 1;
+                  else
+                    in_quotes = 0;
+                }
+              else if (in_quotes != 1 && *s == '\"')
+                {
+                  /* skip quoted value */
+                  if (in_quotes == 0)
+                    in_quotes = 2;
+                  else
+                    in_quotes = 0;
+                }
+              else if (in_quotes == 0 && *s == ',')
+                {
+                  /* found delimiter, add to value array */
+                  *s = '\0';
+                  if (strings == NULL)
+                    strings = g_ptr_array_new ();
+                  g_ptr_array_add (strings, next);
+                  next = s + 1;
+                }
+              else if (in_quotes == 0 && *s == '\\' && s[1] != '\0')
+                {
+                  /* skip escaped character */
+                  s++;
+                }
+            }
+          
+          if (strings == NULL)
+            {
+              /* single value */
+              ippAddString (request->ipp_request,
+                            IPP_TAG_OPERATION,
+                            option_tag,
+                            option,
+                            NULL,
+                            value);
+            }
+          else
+            {
+              /* multiple values */
+              
+              /* add last value */
+              g_ptr_array_add (strings, next);
+              
+              ippAddStrings (request->ipp_request,
+                             IPP_TAG_OPERATION,
+                             option_tag,
+                             option,
+                             strings->len,
+                             NULL,
+                             (const char **) strings->pdata);
+              g_ptr_array_free (strings, TRUE);
+            }
+
+          g_free (values);
+        }
 
         break;
     }
