Blob Blame History Raw
diff -up cups-1.6.4/cups/dest.c.str4332 cups-1.6.4/cups/dest.c
--- cups-1.6.4/cups/dest.c.str4332	2014-03-11 15:41:45.903450653 +0000
+++ cups-1.6.4/cups/dest.c	2014-03-11 15:42:36.019765361 +0000
@@ -889,6 +889,10 @@ cupsEnumDests(
 			num_dests;	/* Number of destinations */
   cups_dest_t		*dests = NULL,	/* Destinations */
 			*dest;		/* Current destination */
+  const char		*defprinter;	/* Default printer */
+  char			name[1024],	/* Copy of printer name */
+			*instance,	/* Pointer to instance name */
+			*user_default;	/* User default printer */
 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
   int			count,		/* Number of queries started */
 			remaining;	/* Remainder of timeout */
@@ -934,6 +938,31 @@ cupsEnumDests(
   num_dests = _cupsGetDests(CUPS_HTTP_DEFAULT, CUPS_GET_PRINTERS, NULL, &dests,
                             type, mask);
 
+  if ((user_default = _cupsUserDefault(name, sizeof(name))) != NULL)
+    defprinter = name;
+  else if ((defprinter = cupsGetDefault2(CUPS_HTTP_DEFAULT)) != NULL)
+  {
+    strlcpy(name, defprinter, sizeof(name));
+    defprinter = name;
+  }
+
+  if (defprinter)
+  {
+   /*
+    * Separate printer and instance name...
+    */
+
+    if ((instance = strchr(name, '/')) != NULL)
+      *instance++ = '\0';
+
+   /*
+    * Lookup the printer and instance and make it the default...
+    */
+
+    if ((dest = cupsGetDest(name, instance, num_dests, dests)) != NULL)
+      dest->is_default = 1;
+  }
+
   for (i = num_dests, dest = dests;
        i > 0 && (!cancel || !*cancel);
        i --, dest ++)