Index: gtk/gtk.symbols
===================================================================
--- gtk/gtk.symbols	(revision 21872)
+++ gtk/gtk.symbols	(working copy)
@@ -2688,6 +2688,8 @@
 gtk_page_setup_set_left_margin
 gtk_page_setup_get_right_margin
 gtk_page_setup_set_right_margin
+gtk_page_setup_get_printer_name
+gtk_page_setup_set_printer_name
 gtk_page_setup_set_paper_size_and_default_margins
 gtk_page_setup_get_paper_width
 gtk_page_setup_get_paper_height
Index: gtk/gtkpagesetupunixdialog.c
===================================================================
--- gtk/gtkpagesetupunixdialog.c	(revision 21872)
+++ gtk/gtkpagesetupunixdialog.c	(working copy)
@@ -1210,11 +1210,29 @@
 gtk_page_setup_unix_dialog_get_page_setup (GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetup *page_setup;
+  GtkTreeIter   iter;
+  GtkComboBox  *combo;
+  GtkPrinter   *printer;
   
   page_setup = get_current_page_setup (dialog);
 
   gtk_page_setup_set_orientation (page_setup, get_orientation (dialog));
 
+  combo = GTK_COMBO_BOX (dialog->priv->printer_combo);
+  if (gtk_combo_box_get_active_iter  (combo, &iter))
+    {
+      gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
+                          PRINTER_LIST_COL_PRINTER, &printer, -1);
+
+      if (printer && gtk_printer_has_details (printer))
+        {
+          gtk_page_setup_set_printer_name (page_setup,
+                                           gtk_printer_get_name (printer));
+
+          g_object_unref (printer);
+        }
+    }
+
   return page_setup;
 }
 
Index: gtk/gtkprintunixdialog.c
===================================================================
--- gtk/gtkprintunixdialog.c	(revision 21872)
+++ gtk/gtkprintunixdialog.c	(working copy)
@@ -141,6 +149,7 @@
   GtkTreeModelFilter *printer_list_filter;
 
   GtkPageSetup *page_setup;
+  GtkPageSetup *default_page_setup;
   gboolean page_setup_set;
 
   GtkWidget *all_pages_radio;
@@ -542,6 +569,12 @@
       priv->page_setup = NULL;
     }
 
+ if (priv->default_page_setup)
+    {
+      g_object_unref (priv->default_page_setup);
+      priv->default_page_setup = NULL;
+    }
+
   if (priv->initial_settings)
     {
       g_object_unref (priv->initial_settings);
@@ -1534,9 +1567,19 @@
 
   if (printer != NULL)
     {
-      if (!priv->page_setup_set)
-	{
-	  /* if no explicit page setup has been set, use the printer default */	  
+      if ((gtk_page_setup_get_printer_name (priv->default_page_setup) == NULL ||
+           strcmp (gtk_page_setup_get_printer_name (priv->default_page_setup), "Any") == 0 ||
+           strcmp (gtk_page_setup_get_printer_name (priv->default_page_setup), gtk_printer_get_name (printer)) == 0) &&
+          priv->page_setup_set)
+        {
+          if (priv->page_setup != priv->default_page_setup)
+            {
+              g_object_unref (priv->page_setup);
+              priv->page_setup = g_object_ref (priv->default_page_setup);
+	    }
+        }
+      else
+        {
   	  GtkPageSetup *page_setup;
 
 	  page_setup = gtk_printer_get_default_page_size (printer);
@@ -1546,7 +1589,7 @@
 
 	  g_object_unref (priv->page_setup);
 	  priv->page_setup = page_setup;
-	}
+        }
 
       priv->printer_capabilities = gtk_printer_get_capabilities (printer);
       priv->options = _gtk_printer_get_options (printer, 
@@ -3039,6 +3084,7 @@
     {
       g_object_unref (priv->page_setup);
       priv->page_setup = g_object_ref (page_setup);
+      priv->default_page_setup = g_object_ref (page_setup);
 
       priv->page_setup_set = TRUE;
 
Index: gtk/gtkprintoperation-unix.c
===================================================================
--- gtk/gtkprintoperation-unix.c	(revision 21872)
+++ gtk/gtkprintoperation-unix.c	(working copy)
@@ -429,7 +431,7 @@
       gtk_print_operation_set_print_settings (op, settings);
       priv->print_context = _gtk_print_context_new (op);
 
-      if ( (page_setup != NULL) && (gtk_print_operation_get_default_page_setup (op) == NULL))
+      if (page_setup != NULL)
         gtk_print_operation_set_default_page_setup (op, page_setup);
 
       _gtk_print_context_set_page_setup (priv->print_context, page_setup);
Index: gtk/gtkpagesetup.c
===================================================================
--- gtk/gtkpagesetup.c	(revision 21872)
+++ gtk/gtkpagesetup.c	(working copy)
@@ -43,6 +43,8 @@
   GtkPaperSize *paper_size;
   /* These are stored in mm */
   double top_margin, bottom_margin, left_margin, right_margin;
+  
+  gchar *printer_name;
 };
 
 struct _GtkPageSetupClass
@@ -58,6 +60,8 @@
   GtkPageSetup *setup = GTK_PAGE_SETUP (object);
   
   gtk_paper_size_free (setup->paper_size);
+
+  g_free (setup->printer_name);
   
   G_OBJECT_CLASS (gtk_page_setup_parent_class)->finalize (object);
 }
@@ -71,6 +75,7 @@
   setup->bottom_margin = gtk_paper_size_get_default_bottom_margin (setup->paper_size, GTK_UNIT_MM);
   setup->left_margin = gtk_paper_size_get_default_left_margin (setup->paper_size, GTK_UNIT_MM);
   setup->right_margin = gtk_paper_size_get_default_right_margin (setup->paper_size, GTK_UNIT_MM);
+  setup->printer_name = NULL;
 }
 
 static void
@@ -119,6 +124,7 @@
   copy->bottom_margin = other->bottom_margin;
   copy->left_margin = other->left_margin;
   copy->right_margin = other->right_margin;
+  copy->printer_name = g_strdup (other->printer_name);
 
   return copy;
 }
@@ -367,6 +373,44 @@
 }
 
 /**
+ * gtk_page_setup_get_printer_name:
+ * @setup: a #GtkPageSetup
+ * 
+ * Gets the name of printer.
+ * 
+ * Return value: the printer name
+ *
+ * Since: 2.16
+ */
+G_CONST_RETURN gchar *
+gtk_page_setup_get_printer_name (GtkPageSetup *setup)
+{
+  return setup->printer_name;
+}
+
+/**
+ * gtk_page_setup_set_printer_name:
+ * @setup: a #GtkPageSetup
+ * @printer_name: the name of the printer
+ * 
+ * Sets the printer name of the #GtkPageSetup.
+ *
+ * Since: 2.16
+ */
+void
+gtk_page_setup_set_printer_name (GtkPageSetup *setup,
+				 const gchar  *printer_name)
+{
+  if (setup->printer_name != NULL)
+    {
+      g_free (setup->printer_name);
+      setup->printer_name = NULL;
+    }
+
+  setup->printer_name = g_strdup (printer_name);
+}
+
+/**
  * gtk_page_setup_get_paper_width:
  * @setup: a #GtkPageSetup
  * @unit: the unit for the return value
@@ -582,6 +626,7 @@
   char *orientation = NULL, *freeme = NULL;
   gboolean retval = FALSE;
   GError *err = NULL;
+  gchar *printer_name = NULL;
 
   g_return_val_if_fail (GTK_IS_PAGE_SETUP (setup), FALSE);
   g_return_val_if_fail (key_file != NULL, FALSE);
@@ -638,6 +683,11 @@
       g_free (orientation);
     }
 
+  printer_name = g_key_file_get_string (key_file, group_name,
+				        "PrinterName", NULL);
+  if (printer_name)
+    gtk_page_setup_set_printer_name (setup, printer_name);
+
   retval = TRUE;
 
 out:
@@ -780,6 +830,14 @@
 				gtk_page_setup_get_orientation (setup));
   g_key_file_set_string (key_file, group_name,
 			 "Orientation", orientation);
+
+  if (gtk_page_setup_get_printer_name (setup) != NULL)
+    g_key_file_set_string (key_file, group_name,
+			   "PrinterName", gtk_page_setup_get_printer_name (setup));
+  else
+    g_key_file_set_string (key_file, group_name,
+			   "PrinterName", "Any");
+
   g_free (orientation);
 }
 
Index: gtk/gtkpagesetup.h
===================================================================
--- gtk/gtkpagesetup.h	(revision 21872)
+++ gtk/gtkpagesetup.h	(working copy)
@@ -66,6 +66,9 @@
 void               gtk_page_setup_set_right_margin  (GtkPageSetup       *setup,
 						     gdouble             margin,
 						     GtkUnit             unit);
+G_CONST_RETURN gchar * gtk_page_setup_get_printer_name  (GtkPageSetup       *setup);
+void               gtk_page_setup_set_printer_name  (GtkPageSetup       *setup,
+						     const gchar        *printer_name);
 
 void gtk_page_setup_set_paper_size_and_default_margins (GtkPageSetup    *setup,
 							GtkPaperSize    *size);
Index: docs/reference/gtk/gtk-sections.txt
===================================================================
--- docs/reference/gtk/gtk-sections.txt	(revision 21872)
+++ docs/reference/gtk/gtk-sections.txt	(working copy)
@@ -6751,6 +6751,8 @@
 gtk_page_setup_set_left_margin
 gtk_page_setup_get_right_margin
 gtk_page_setup_set_right_margin
+gtk_page_setup_get_printer_name
+gtk_page_setup_set_printer_name
 gtk_page_setup_set_paper_size_and_default_margins
 gtk_page_setup_get_paper_width
 gtk_page_setup_get_paper_height
Index: modules/printbackends/cups/gtkprintbackendcups.c
===================================================================
--- modules/printbackends/cups/gtkprintbackendcups.c	(revision 21872)
+++ modules/printbackends/cups/gtkprintbackendcups.c	(working copy)
@@ -3009,28 +3009,31 @@
 
       ppdMarkDefaults (ppd_file);
 
-      paper_size = gtk_page_setup_get_paper_size (page_setup);
+      if (page_setup != NULL)
+        {
+          paper_size = gtk_page_setup_get_paper_size (page_setup);
 
-      option = ppdFindOption (ppd_file, "PageSize");
-      ppd_name = gtk_paper_size_get_ppd_name (paper_size);
+          option = ppdFindOption (ppd_file, "PageSize");
+          ppd_name = gtk_paper_size_get_ppd_name (paper_size);
       
-      if (ppd_name)
-	strncpy (option->defchoice, ppd_name, PPD_MAX_NAME);
-      else
-        {
-          gchar *custom_name;
-	  char width[G_ASCII_DTOSTR_BUF_SIZE];
-	  char height[G_ASCII_DTOSTR_BUF_SIZE];
+          if (ppd_name)
+    	    strncpy (option->defchoice, ppd_name, PPD_MAX_NAME);
+          else
+            {
+              gchar *custom_name;
+     	      char width[G_ASCII_DTOSTR_BUF_SIZE];
+	      char height[G_ASCII_DTOSTR_BUF_SIZE];
 
-	  g_ascii_formatd (width, sizeof (width), "%.2f", gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS));
-	  g_ascii_formatd (height, sizeof (height), "%.2f", gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS));
-          /* Translators: this format is used to display a custom paper
-           * size. The two placeholders are replaced with the width and height
-           * in points. E.g: "Custom 230.4x142.9"
-           */
-	  custom_name = g_strdup_printf (_("Custom %sx%s"), width, height);
-          strncpy (option->defchoice, custom_name, PPD_MAX_NAME);
-          g_free (custom_name);
+	      g_ascii_formatd (width, sizeof (width), "%.2f", gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS));
+	      g_ascii_formatd (height, sizeof (height), "%.2f", gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS));
+              /* Translators: this format is used to display a custom paper
+               * size. The two placeholders are replaced with the width and height
+               * in points. E.g: "Custom 230.4x142.9"
+               */
+	      custom_name = g_strdup_printf (_("Custom %sx%s"), width, height);
+              strncpy (option->defchoice, custom_name, PPD_MAX_NAME);
+              g_free (custom_name);
+            }
         }
 
       for (i = 0; i < ppd_file->num_groups; i++)
@@ -3579,9 +3582,10 @@
 }
 
 static GtkPageSetup *
-create_page_setup (ppd_file_t *ppd_file,
-		   ppd_size_t *size)
- {
+create_page_setup (ppd_file_t  *ppd_file,
+		   ppd_size_t  *size,
+		   const gchar *printer_name)
+{
    char *display_name;
    GtkPageSetup *page_setup;
    GtkPaperSize *paper_size;
@@ -3612,6 +3616,9 @@
   gtk_page_setup_set_bottom_margin (page_setup, size->bottom, GTK_UNIT_POINTS);
   gtk_page_setup_set_left_margin (page_setup, size->left, GTK_UNIT_POINTS);
   gtk_page_setup_set_right_margin (page_setup, size->width - size->right, GTK_UNIT_POINTS);
+
+  if (printer_name != NULL)
+    gtk_page_setup_set_printer_name (page_setup, printer_name);
   
   g_free (display_name);
 
@@ -3637,7 +3644,7 @@
     {
       size = &ppd_file->sizes[i];      
 
-      page_setup = create_page_setup (ppd_file, size);
+      page_setup = create_page_setup (ppd_file, size, gtk_printer_get_name (printer));
 
       l = g_list_prepend (l, page_setup);
     }
@@ -3660,7 +3667,10 @@
   option = ppdFindOption (ppd_file, "PageSize");
   size = ppdPageSize (ppd_file, option->defchoice); 
 
-  return create_page_setup (ppd_file, size);
+  if (size != NULL)
+    return create_page_setup (ppd_file, size, gtk_printer_get_name (printer));
+  else
+    return NULL;
 }
 
 static void
