diff -Npur system-config-printer.old/system-config-printer.py system-config-printer.new/system-config-printer.py
--- system-config-printer.old/system-config-printer.py	2009-07-29 17:24:40.000000000 +0800
+++ system-config-printer.new/system-config-printer.py	2009-07-29 17:24:35.000000000 +0800
@@ -43,6 +43,9 @@ def show_help():
     print ("\nThis is system-config-printer, " \
            "a CUPS server configuration program.\n\n"
            "Options:\n\n"
+	   "  --setup-printer URL\n"
+	   "		Select the (detected) CUPS device URI on start-up,\n"
+	   "		and run the new-printer wizard for it.\n\n"
            "  --configure-printer NAME\n"
            "            Select the named printer on start-up.\n\n"
            "  --choose-driver NAME\n"
@@ -168,7 +171,7 @@ class GUI(GtkGUI, monitor.Watcher):
                        cups.IPP_PRINTER_BUSY: _("Busy"),
                        cups.IPP_PRINTER_STOPPED: _("Stopped") }
 
-    def __init__(self, configure_printer = None, change_ppd = False,
+    def __init__(self, setup_printer = None, configure_printer = None, change_ppd = False,
                  devid = ""):
 
         try:
@@ -606,6 +609,15 @@ class GUI(GtkGUI, monitor.Watcher):
         except:
             nonfatalException ()
 
+        if setup_printer:
+            self.device_uri = setup_printer
+            self.devid = devid
+            self.ppd = None
+            try:
+                 self.on_autodetected_printer_without_driver(None)
+            except RuntimeError:
+                 pass
+  
         if configure_printer:
             # Need to find the entry in the iconview model and activate it.
             model = self.dests_iconview.get_model ()
@@ -2524,6 +2536,12 @@ class GUI(GtkGUI, monitor.Watcher):
         self.newPrinterGUI.init("printer")
         self.ready (self.MainWindow)
 
+    # new printer, auto-detected, but now driver found
+    def on_autodetected_printer_without_driver(self, widget):
+        self.busy (self.MainWindow)
+        self.newPrinterGUI.init ("printer_with_uri")
+        self.ready (self.MainWindow)
+
     # new class
     def on_new_class_activate(self, widget):
         self.newPrinterGUI.init("class")
@@ -2621,6 +2639,9 @@ class NewPrinterGUI(GtkGUI):
         self.changed = set()
         self.conflicts = set()
         self.ppd = None
+        self.remotecupsqueue = False
+        self.exactdrivermatch = False
+        self.installable_options = False
         self.jockey_installed_files = []
 
         # Synchronisation objects.
@@ -2818,8 +2839,12 @@ class NewPrinterGUI(GtkGUI):
         self.btnNPDownloadableDriverSearch_label = label
         label.set_text (_("Search"))
 
-        if self.dialog_mode in ("printer", "class"):
-            self.entNPName.set_text (self.mainapp.makeNameUnique(self.dialog_mode))
+        if self.dialog_mode in ("printer", "printer_with_uri", "class"):
+            if self.dialog_mode == "class":
+               name_proto = "class"
+            else:
+               name_proto = "printer"
+            self.entNPName.set_text (self.mainapp.makeNameUnique(name_proto))
             self.entNPName.grab_focus()
             for widget in [self.entNPLocation,
                            self.entNPDescription,
@@ -2827,6 +2852,9 @@ class NewPrinterGUI(GtkGUI):
                            self.entSMBPassword]:
                 widget.set_text('')
 
+        if self.dialog_mode == "printer_with_uri":
+            self.device = cupshelpers.Device (self.mainapp.device_uri)
+
         self.entNPTDirectJetPort.set_text('9100')
 
         if self.dialog_mode == "printer":
@@ -2849,8 +2877,13 @@ class NewPrinterGUI(GtkGUI):
             self.NewPrinterWindow.set_title(_("Change Device URI"))
             self.ntbkNewPrinter.set_current_page(1)
             self.fillDeviceTab(self.mainapp.printer.device_uri)
-        elif self.dialog_mode == "ppd":
-            self.NewPrinterWindow.set_title(_("Change Driver"))
+        elif self.dialog_mode == "ppd" or \
+            self.dialog_mode == "printer_with_uri":
+            if self.dialog_mode == "ppd":
+                self.NewPrinterWindow.set_title(_("Change Driver"))
+            else:
+                self.NewPrinterWindow.set_title(_("New Printer"))
+                
             self.ntbkNewPrinter.set_current_page(2)
             self.rbtnNPFoomatic.set_active (True)
             self.on_rbtnNPFoomatic_toggled(self.rbtnNPFoomatic)
@@ -2860,6 +2893,10 @@ class NewPrinterGUI(GtkGUI):
             ppd = self.mainapp.ppd
             #self.mainapp.devid = "MFG:Samsung;MDL:ML-3560;DES:;CMD:GDI;"
             devid = self.mainapp.devid
+            if self.dialog_mode == "ppd":
+                uri = self.mainapp.printer.device_uri
+            else:
+                uri = self.mainapp.device_uri
             if devid != "":
                 try:
                     devid_dict = cupshelpers.parseDeviceID (devid)
@@ -2871,7 +2908,7 @@ class NewPrinterGUI(GtkGUI):
                                                     devid_dict["MDL"],
                                                     devid_dict["DES"],
                                                     devid_dict["CMD"],
-                                                    self.mainapp.printer.device_uri,
+                                                    uri,
                                                     self.jockey_installed_files)
                         if (status != self.ppds.STATUS_SUCCESS and
                             reloaded == 0):
@@ -2891,6 +2928,12 @@ class NewPrinterGUI(GtkGUI):
                         make_model = ppddict['ppd-make-and-model']
                         (self.auto_make, self.auto_model) = \
                             cupshelpers.ppds.ppdMakeModelSplit (make_model)
+                        if (status == self.ppds.STATUS_SUCCESS and \
+                            self.dialog_mode != "ppd"):
+                            self.exactdrivermatch = True
+                            self.fillMakeList()
+                            self.ntbkNewPrinter.set_current_page(6)
+                            self.nextNPTab(step = 0)
                     else:
                         self.auto_make = devid_dict["MFG"]
                         self.auto_model = devid_dict["MDL"]
@@ -3147,7 +3190,8 @@ class NewPrinterGUI(GtkGUI):
 
         if self.dialog_mode == "class":
             order = [0, 4, 5]
-        elif self.dialog_mode == "printer":
+        elif self.dialog_mode == "printer" or \
+                self.dialog_mode == "printer_with_uri":
             self.busy (self.NewPrinterWindow)
             if page_nr == 1: # Device (first page)
                 self.auto_make, self.auto_model = None, None
@@ -3513,7 +3557,8 @@ class NewPrinterGUI(GtkGUI):
 
         if nr == 0: # Name
             self.btnNPBack.show()
-            if self.dialog_mode == "printer":
+            if self.dialog_mode == "printer" or \
+                    self.dialog_mode == "printer_with_uri":
                 self.btnNPForward.hide()
                 self.btnNPApply.show()
                 self.btnNPApply.set_sensitive(
@@ -3522,6 +3567,11 @@ class NewPrinterGUI(GtkGUI):
                 # This is the first page for the New Class dialog, so
                 # hide the Back button.
                 self.btnNPBack.hide ()
+            if self.dialog_mode == "printer_with_uri" and \
+                    (self.remotecupsqueue or \
+                         (self.exactdrivermatch and \
+                              not self.installable_options)):
+                self.btnNPBack.hide ()
         if nr == 2: # Make/PPD file
             downloadable_selected = False
             if self.rbtnNPDownloadableDriverSearch.get_active ():
@@ -3534,6 +3584,8 @@ class NewPrinterGUI(GtkGUI):
                 self.rbtnNPFoomatic.get_active() or
                 self.filechooserPPD.get_filename() or
                 downloadable_selected))
+            if self.dialog_mode == "printer_with_uri":
+                self.btnNPBack.hide()
         if nr == 3: # Model/Driver
             model, iter = self.tvNPDrivers.get_selection().get_selected()
             self.btnNPForward.set_sensitive(bool(iter))
@@ -3542,6 +3594,10 @@ class NewPrinterGUI(GtkGUI):
             self.btnNPApply.show()
             self.btnNPApply.set_sensitive(
                 bool(self.getCurrentClassMembers(self.tvNCMembers)))
+        if nr == 6: # Installable options
+            if self.dialog_mode == "printer_with_uri" and \
+                   self.exactdrivermatch:
+                self.btnNPBack.hide()
         if nr == 7: # Downloadable drivers
             if self.ntbkNPDownloadableDriverProperties.get_current_page() == 1:
                 accepted = self.rbtnNPDownloadLicenseYes.get_active ()
@@ -5206,7 +5262,7 @@ class NewPrinterGUI(GtkGUI):
             
     # Create new Printer
     def on_btnNPApply_clicked(self, widget):
-        if self.dialog_mode in ("class", "printer"):
+        if self.dialog_mode in ("class", "printer", "printer_with_uri"):
             name = self.entNPName.get_text()
             location = self.entNPLocation.get_text()
             info = self.entNPDescription.get_text()
@@ -5226,7 +5282,8 @@ class NewPrinterGUI(GtkGUI):
             except cups.IPPError, (e, msg):
                 self.show_IPP_Error(e, msg)
                 return
-        elif self.dialog_mode=="printer":
+        elif self.dialog_mode=="printer" or \
+                self.dialog_mode == "printer_with_uri":
             uri = None
             if self.device.uri:
                 uri = self.device.uri
@@ -5275,7 +5332,7 @@ class NewPrinterGUI(GtkGUI):
                 fatalException (1)
             self.WaitWindow.hide ()
             self.ready (self.NewPrinterWindow)
-        if self.dialog_mode in ("class", "printer"):
+        if self.dialog_mode in ("class", "printer", "printer_with_uri"):
             try:
                 self.mainapp.cups.setPrinterLocation(name, location)
                 self.mainapp.cups.setPrinterInfo(name, info)
@@ -5439,11 +5496,11 @@ class NewPrinterGUI(GtkGUI):
                                    self.mainapp.MainWindow)
 
 
-def main(configure_printer = None, change_ppd = False, devid = ""):
+def main(setup_printer = None, configure_printer = None, change_ppd = False, devid = ""):
     cups.setUser (os.environ.get ("CUPS_USER", cups.getUser()))
     gtk.gdk.threads_init()
 
-    mainwindow = GUI(configure_printer, change_ppd, devid)
+    mainwindow = GUI(setup_printer, configure_printer, change_ppd, devid)
     if gtk.__dict__.has_key("main"):
         gtk.main()
     else:
@@ -5454,7 +5511,8 @@ if __name__ == "__main__":
     import getopt
     try:
         opts, args = getopt.gnu_getopt (sys.argv[1:], '',
-                                        ['configure-printer=',
+                                        ['setup-printer=',
+					 'configure-printer=',
                                          'choose-driver=',
                                          'devid=',
                                          'debug'])
@@ -5462,6 +5520,7 @@ if __name__ == "__main__":
         show_help ()
         sys.exit (1)
 
+    setup_printer = None
     configure_printer = None
     change_ppd = False
     devid = ""
@@ -5471,11 +5530,12 @@ if __name__ == "__main__":
             configure_printer = optarg
             if opt == "--choose-driver":
                 change_ppd = True
-
+	elif opt == '--setup-printer':
+		setup_printer = optarg
         elif opt == '--devid':
             devid = optarg
 
         elif opt == '--debug':
             set_debugging (True)
 
-    main(configure_printer, change_ppd, devid)
+    main(setup_printer, configure_printer, change_ppd, devid)
