Index: gtk/gtkprintoperation-unix.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkprintoperation-unix.c,v
retrieving revision 1.34
diff -u -r1.34 gtkprintoperation-unix.c
--- gtk/gtkprintoperation-unix.c	19 Jun 2006 11:43:34 -0000	1.34
+++ gtk/gtkprintoperation-unix.c	19 Jun 2006 15:51:24 -0000
@@ -1,4 +1,4 @@
-/* GTK - The GIMP Toolkit
+/* GTK+ - The GIMP Toolkit
  * gtkprintoperation-unix.c: Print Operation Details for Unix 
  *                           and Unix-like platforms
  * Copyright (C) 2006, Red Hat, Inc.
@@ -1061,7 +1061,7 @@
   finder->printer_name = g_strdup (printer);
   finder->func = func;
   finder->data = data;
-  
+
   finder->backends = NULL;
   if (g_module_supported ())
     finder->backends = gtk_print_backend_load_modules ();
@@ -1074,6 +1074,113 @@
 
   if (finder->backends == NULL && !finder->found_printer)
     g_idle_add (find_printer_idle, finder);
+}
+
+typedef struct 
+{
+  GList *backends;
+  GList *printers;
+  GMainLoop *loop;
+} PrinterList;
+
+static void
+list_added_cb (GtkPrintBackend *backend, 
+	       GtkPrinter      *printer, 
+	       PrinterList     *printer_list)
+{
+  printer_list->printers = g_list_prepend (printer_list->printers, printer);
+}
+
+static void
+list_done_cb (GtkPrintBackend *backend, 
+	      PrinterList     *printer_list)
+{
+  printer_list->backends = g_list_remove (printer_list->backends, backend);
+  
+  g_signal_handlers_disconnect_by_func (backend, list_added_cb, printer_list);
+  g_signal_handlers_disconnect_by_func (backend, list_done_cb, printer_list);
+  
+  gtk_print_backend_destroy (backend);
+  g_object_unref (backend);
+
+  if (printer_list->backends == NULL)
+    g_main_loop_quit (printer_list->loop);
+}
+
+static void
+list_printers_init (PrinterList     *printer_list,
+		    GtkPrintBackend *backend)
+{
+  GList *list;
+  GList *node;
+
+  list = gtk_print_backend_get_printer_list (backend);
+
+  for (node = list; node != NULL; node = node->next)
+    list_added_cb (backend, node->data, printer_list);
+
+  g_list_free (list);
+
+  if (gtk_print_backend_printer_list_is_done (backend))
+    {
+      printer_list->backends = g_list_remove (printer_list->backends, backend);
+      gtk_print_backend_destroy (backend);
+      g_object_unref (backend);
+    }
+  else
+    {
+      g_signal_connect (backend, "printer-added", 
+			(GCallback) list_added_cb, 
+			printer_list);
+      g_signal_connect (backend, "printer-list-done", 
+			(GCallback) list_done_cb, 
+			printer_list);
+    }
+
+}
+
+/**
+ * gtk_printer_list_all:
+ *
+ * Obtains a list of all printers. 
+ *
+ * Note that this function uses a recursive mainloop. 
+ *
+ * Returns: A list of #GtkPrinter objects. The printers must
+ * be unreffed, and the list freed when no longer needed.
+ *
+ * Since: 2.10
+ */
+GList *
+gtk_printer_list_all (void)
+{
+  PrinterList *printer_list;
+  GList *printers, *node;
+
+  printer_list = g_new0 (PrinterList, 1);
+
+  if (g_module_supported ())
+    printer_list->backends = gtk_print_backend_load_modules ();
+
+  for (node = printer_list->backends; node != NULL; node = node->next)
+    list_printers_init (printer_list, GTK_PRINT_BACKEND (node->data));
+
+  if (printer_list->backends)
+    {
+      printer_list->loop = g_main_loop_new (NULL, FALSE);
+
+      GDK_THREADS_LEAVE ();  
+      g_main_loop_run (printer_list->loop);
+      GDK_THREADS_ENTER ();  
+
+      g_main_loop_unref (printer_list->loop);
+    }
+
+  printers = printer_list->printers;
+
+  g_free (printer_list);
+
+  return printers;
 }
 
 #define __GTK_PRINT_OPERATION_UNIX_C__
