Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
newprinter.NewPrinterGUI Class Reference
Inheritance diagram for newprinter.NewPrinterGUI:
Inheritance graph
[legend]
Collaboration diagram for newprinter.NewPrinterGUI:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __del__
def do_destroy
def inc_spinner_task
def dec_spinner_task
def show_IPP_Error
def option_changed
def setDataButtonState
def makeNameUnique
def destroy
def init
def on_ppdsloader_finished_initial
def change_ppd_got_devs
def change_ppd_have_devs_and_ppds
def on_ppdsloader_finished_next
def fillNewClassMembers
def on_btnNCAddMember_clicked
def on_btnNCDelMember_clicked
def on_tvNCMembers_cursor_changed
def on_tvNCNotMembers_cursor_changed
def on_NPCancel
def on_btnNPBack_clicked
def on_btnNPForward_clicked
def nextNPTab
def setNPButtons
def on_entNPName_changed
def fetchDevices
def error_getting_devices
def local_devices_reply
def network_devices_reply
def dnssd_resolve_reply
def get_hpfax_device_id
def get_hplip_scan_type_for_uri
def get_hplip_uri_for_network_printer
def getNetworkPrinterMakeModel
def fillDeviceTab
def on_firewall_read
def adjust_firewall_response
def start_fetching_devices
def add_devices
def browse_smb_hosts
 SMB browsing.
def smb_select_function
def smbbrowser_cell_share
def smbbrowser_cell_comment
def on_tvSMBBrowser_row_activated
def on_tvSMBBrowser_row_expanded
def on_entSMBURI_changed
def on_tvSMBBrowser_cursor_changed
def on_btnSMBBrowse_clicked
def on_btnSMBBrowseOk_clicked
def on_btnSMBBrowseCancel_clicked
def on_btnSMBBrowseRefresh_clicked
def on_rbtnSMBAuthSet_toggled
def on_btnSMBVerify_clicked
def entry_changed
def on_entNPTDevice_changed
def on_entNPTJetDirectHostname_changed
def on_entNPTJetDirectPort_changed
def on_expNPDeviceURIs_expanded
def device_row_separator_fn
def device_row_activated
def device_select_function
def on_tvNPDevices_cursor_changed
def on_tvNPDeviceURIs_cursor_changed
def on_entNPTLpdHost_changed
def on_entNPTLpdQueue_changed
def on_btnNPTLpdProbe_clicked
def on_entNPTNetworkHostname_changed
 Find Network Printer.
def on_btnNetworkFind_clicked
def found_network_printer_callback
def getDeviceURI
def on_rbtnNPFoomatic_toggled
def on_filechooserPPD_selection_changed
def on_btnNPDownloadableDriverSearch_clicked
def openprinting_printers_found
def openprinting_query_next_printer
def openprinting_printer_drivers_found
def openprinting_drivers_found
def on_cmbNPDownloadableDriverFoundPrinters_changed
def fillDownloadableDrivers
def on_rbtnNPDownloadLicense_toggled
def fillMakeList
def on_tvNPMakes_cursor_changed
def fillModelList
def fillDriverList
def on_NPDrivers_query_tooltip
def on_tvNPModels_cursor_changed
def on_tvNPDrivers_cursor_changed
def on_tvNPDownloadableDrivers_cursor_changed
def getNPPPD
def fillNPInstallableOptions
def on_btnNPApply_clicked
def getWidgets

Public Attributes

 language
 options
 changed
 conflicts
 device
 ppd
 remotecupsqueue
 exactdrivermatch
 installable_options
 ppdsloader
 jockey_installed_files
 printers
 drivers_lock
 WaitWindow_handler
 spinner
 spinner_count
 openprinting
 openprinting_query_handle
 smb_store
 SMBBrowseDialog
 NewPrinterWindow
 WaitWindow
 parent
 dialog_mode
 orig_ppd
 devid
 fetchDevices_conn
 ppds
 ppdsmatch_result
 printer_finder
 cups
 btnNPDownloadableDriverSearch_label
 auto_make
 auto_model
 auto_driver
 id_matched_ppdnames
 ppds_loader
 device_selected
 devices
 devices_uri_iter
 devices_find_nw_iter
 devices_network_iter
 devices_network_fetched
 current_uri
 firewall
 expanding_row
 network_found
 downloadable_printers
 downloadable_printers_unchecked
 downloadable_drivers
 recommended_make_selected
 NPMake
 recommended_model_selected
 NPModel
 NPDrivers

Static Public Attributes

dictionary new_printer_device_tabs
 DOWNLOADABLE_ONLYPPD = True

Private Member Functions

def _getPPDs_reply

Private Attributes

 _host
 _encryption
 _name

Static Private Attributes

dictionary __gsignals__

Detailed Description

Definition at line 142 of file newprinter.py.


Constructor & Destructor Documentation

Definition at line 173 of file newprinter.py.

00173 
00174     def __init__(self):
00175         gobject.GObject.__init__ (self)
00176         self.language = locale.getlocale (locale.LC_MESSAGES)
00177 
00178         self.options = {} # keyword -> Option object
00179         self.changed = set()
00180         self.conflicts = set()
00181         self.device = None
00182         self.ppd = None
00183         self.remotecupsqueue = False
00184         self.exactdrivermatch = False
00185         self.installable_options = False
00186         self.ppdsloader = None
00187         self.jockey_installed_files = []
00188         self.printers = {} # set in init()
00189 
00190         # Synchronisation objects.
00191         self.drivers_lock = thread.allocate_lock()
00192 
00193         self.getWidgets({"NewPrinterWindow":
00194                              ["NewPrinterWindow",
00195                               "ntbkNewPrinter",
00196                               "btnNPBack",
00197                               "btnNPForward",
00198                               "btnNPApply",
00199                               "imgProcessWorking",
00200                               "entNPName",
00201                               "entNPDescription",
00202                               "entNPLocation",
00203                               "tvNPDevices",
00204                               "ntbkNPType",
00205                               "lblNPDeviceDescription",
00206                               "expNPDeviceURIs",
00207                               "tvNPDeviceURIs",
00208                               "cmbNPTSerialBaud",
00209                               "cmbNPTSerialParity",
00210                               "cmbNPTSerialBits",
00211                               "cmbNPTSerialFlow",
00212                               "btnNPTLpdProbe",
00213                               "entNPTLpdHost",
00214                               "entNPTLpdQueue",
00215                               "entNPTJetDirectHostname",
00216                               "entNPTJetDirectPort",
00217                               "entSMBURI",
00218                               "btnSMBBrowse",
00219                               "tblSMBAuth",
00220                               "rbtnSMBAuthPrompt",
00221                               "rbtnSMBAuthSet",
00222                               "entSMBUsername",
00223                               "entSMBPassword",
00224                               "btnSMBVerify",
00225                               "entNPTNetworkHostname",
00226                               "btnNetworkFind",
00227                               "lblNetworkFindSearching",
00228                               "lblNetworkFindNotFound",
00229                               "entNPTDevice",
00230                               "tvNCMembers",
00231                               "tvNCNotMembers",
00232                               "btnNCAddMember",
00233                               "btnNCDelMember",
00234                               "ntbkPPDSource",
00235                               "rbtnNPPPD",
00236                               "tvNPMakes",
00237                               "rbtnNPFoomatic",
00238                               "filechooserPPD",
00239                               "rbtnNPDownloadableDriverSearch",
00240                               "entNPDownloadableDriverSearch",
00241                               "btnNPDownloadableDriverSearch",
00242                               "cmbNPDownloadableDriverFoundPrinters",
00243                               "tvNPModels",
00244                               "tvNPDrivers",
00245                               "rbtnChangePPDasIs",
00246                               "rbtnChangePPDKeepSettings",
00247                               "scrNPInstallableOptions",
00248                               "vbNPInstallOptions",
00249                               "tvNPDownloadableDrivers",
00250                               "ntbkNPDownloadableDriverProperties",
00251                               "lblNPDownloadableDriverSupplier",
00252                               "cbNPDownloadableDriverSupplierVendor",
00253                               "lblNPDownloadableDriverLicense",
00254                               "cbNPDownloadableDriverLicensePatents",
00255                               "cbNPDownloadableDriverLicenseFree",
00256                               "lblNPDownloadableDriverDescription",
00257                               "lblNPDownloadableDriverSupportContacts",
00258                               "hsDownloadableDriverPerfText",
00259                               "hsDownloadableDriverPerfLineArt",
00260                               "hsDownloadableDriverPerfGraphics",
00261                               "hsDownloadableDriverPerfPhoto",
00262                               "lblDownloadableDriverPerfTextUnknown",
00263                               "lblDownloadableDriverPerfLineArtUnknown",
00264                               "lblDownloadableDriverPerfGraphicsUnknown",
00265                               "lblDownloadableDriverPerfPhotoUnknown",
00266                               "frmNPDownloadableDriverLicenseTerms",
00267                               "tvNPDownloadableDriverLicense",
00268                               "rbtnNPDownloadLicenseYes",
00269                               "rbtnNPDownloadLicenseNo"],
00270                          "WaitWindow":
00271                              ["WaitWindow",
00272                               "lblWait"],
00273                          "SMBBrowseDialog":
00274                              ["SMBBrowseDialog",
00275                               "tvSMBBrowser",
00276                               "btnSMBBrowseOk"]},
00277 
00278                         domain=config.PACKAGE)
00279 
00280         # Fill in liststores for combo-box widgets
00281         for (widget,
00282              opts) in [(self.cmbNPTSerialBaud,
00283                         [[_("Default")],
00284                          [_("1200")],
00285                          [_("2400")],
00286                          [_("4800")],
00287                          [_("9600")],
00288                          [_("19200")],
00289                          [_("38400")],
00290                          [_("57600")],
00291                          [_("115200")]]),
00292 
00293                        (self.cmbNPTSerialParity,
00294                         [[_("Default")],
00295                          [_("None")],
00296                          [_("Odd")],
00297                          [_("Even")]]),
00298 
00299                        (self.cmbNPTSerialBits,
00300                         [[_("Default")],
00301                          [_("8")],
00302                          [_("7")]]),
00303 
00304                        (self.cmbNPTSerialFlow,
00305                         [[_("Default")],
00306                          [_("None")],
00307                          [_("XON/XOFF (Software)")],
00308                          [_("RTS/CTS (Hardware)")],
00309                          [_("DTR/DSR (Hardware)")]]),
00310 
00311                        ]:
00312             model = gtk.ListStore (gobject.TYPE_STRING)
00313             for row in opts:
00314                 model.append (row=row)
00315 
00316             cell = gtk.CellRendererText ()
00317             widget.pack_start (cell, True)
00318             widget.add_attribute (cell, 'text', 0)
00319             widget.set_model (model)
00320 
00321         # Set up some lists
00322         m = gtk.SELECTION_MULTIPLE
00323         s = gtk.SELECTION_SINGLE
00324         b = gtk.SELECTION_BROWSE
00325         for name, model, treeview, selection_mode in (
00326             (_("Members of this class"), gtk.ListStore(str),
00327              self.tvNCMembers, m),
00328             (_("Others"), gtk.ListStore(str), self.tvNCNotMembers, m),
00329             (_("Devices"), gtk.ListStore(str), self.tvNPDevices, s),
00330             (_("Connections"), gtk.ListStore(str), self.tvNPDeviceURIs, s),
00331             (_("Makes"), gtk.ListStore(str, str), self.tvNPMakes,s),
00332             (_("Models"), gtk.ListStore(str, str), self.tvNPModels,s),
00333             (_("Drivers"), gtk.ListStore(str), self.tvNPDrivers,s),
00334             (_("Downloadable Drivers"), gtk.ListStore(str),
00335              self.tvNPDownloadableDrivers, b),
00336             ):
00337 
00338             cell = gtk.CellRendererText()
00339             column = gtk.TreeViewColumn(name, cell, text=0)
00340             treeview.set_model(model)
00341             treeview.append_column(column)
00342             treeview.get_selection().set_mode(selection_mode)
00343 
00344         # Since some dialogs are reused we can't let the delete-event's
00345         # default handler destroy them
00346         self.SMBBrowseDialog.connect ("delete-event", on_delete_just_hide)
00347         self.WaitWindow_handler = self.WaitWindow.connect ("delete-event",
00348                                                            on_delete_just_hide)
00349 
00350         try:
00351             slip.gtk.label_set_autowrap(self.NewPrinterWindow)
00352         except: # no slip.gtk module
00353             gtk_label_autowrap.set_autowrap(self.NewPrinterWindow)
00354 
00355         self.ntbkNewPrinter.set_show_tabs(False)
00356         self.ntbkPPDSource.set_show_tabs(False)
00357         self.ntbkNPType.set_show_tabs(False)
00358         self.ntbkNPDownloadableDriverProperties.set_show_tabs(False)
00359 
00360         self.spinner = gtkspinner.Spinner (self.imgProcessWorking)
00361         self.spinner_count = 0
00362 
00363         # Set up OpenPrinting widgets.
00364         self.openprinting = cupshelpers.openprinting.OpenPrinting ()
00365         self.openprinting_query_handle = None
00366         combobox = self.cmbNPDownloadableDriverFoundPrinters
00367         cell = gtk.CellRendererText()
00368         combobox.pack_start (cell, True)
00369         combobox.add_attribute(cell, 'text', 0)
00370         if self.DOWNLOADABLE_ONLYPPD:
00371             for widget in [self.cbNPDownloadableDriverLicenseFree,
00372                            self.cbNPDownloadableDriverLicensePatents]:
00373                 widget.hide ()
00374 
00375         def protect_toggle (toggle_widget):
00376             active = toggle_widget.get_data ('protect_active')
00377             if active != None:
00378                 toggle_widget.set_active (active)
00379 
00380         for widget in [self.cbNPDownloadableDriverSupplierVendor,
00381                        self.cbNPDownloadableDriverLicenseFree,
00382                        self.cbNPDownloadableDriverLicensePatents]:
00383             widget.connect ('clicked', protect_toggle)
00384 
00385         for widget in [self.hsDownloadableDriverPerfText,
00386                        self.hsDownloadableDriverPerfLineArt,
00387                        self.hsDownloadableDriverPerfGraphics,
00388                        self.hsDownloadableDriverPerfPhoto]:
00389             widget.connect ('change-value',
00390                             lambda x, y, z: True)
00391 
00392         # Device list
00393         slct = self.tvNPDevices.get_selection ()
00394         slct.set_select_function (self.device_select_function)
00395         self.tvNPDevices.set_row_separator_func (self.device_row_separator_fn)
00396         self.tvNPDevices.connect ("row-activated", self.device_row_activated)
00397 
00398         # Devices expander
00399         self.expNPDeviceURIs.connect ("notify::expanded",
00400                                       self.on_expNPDeviceURIs_expanded)
00401         self.expNPDeviceURIs.set_expanded(1)
00402 
00403         # SMB browser
00404         self.smb_store = gtk.TreeStore (gobject.TYPE_PYOBJECT)
00405         self.btnSMBBrowse.set_sensitive (PYSMB_AVAILABLE)
00406         if not PYSMB_AVAILABLE:
00407             self.btnSMBBrowse.set_tooltip_text (_("Browsing not available "
00408                                                   "(pysmbc not installed)"))
00409 
00410         self.tvSMBBrowser.set_model (self.smb_store)
00411 
00412         # SMB list columns
00413         col = gtk.TreeViewColumn (_("Share"))
00414         cell = gtk.CellRendererText ()
00415         col.pack_start (cell, False)
00416         col.set_cell_data_func (cell, self.smbbrowser_cell_share)
00417         self.tvSMBBrowser.append_column (col)
00418 
00419         col = gtk.TreeViewColumn (_("Comment"))
00420         cell = gtk.CellRendererText ()
00421         col.pack_start (cell, False)
00422         col.set_cell_data_func (cell, self.smbbrowser_cell_comment)
00423         self.tvSMBBrowser.append_column (col)
00424 
00425         slct = self.tvSMBBrowser.get_selection ()
00426         slct.set_select_function (self.smb_select_function)
00427 
00428         self.SMBBrowseDialog.set_transient_for(self.NewPrinterWindow)
00429 
00430         self.tvNPDrivers.set_has_tooltip(True)
00431         self.tvNPDrivers.connect("query-tooltip", self.on_NPDrivers_query_tooltip)
00432 
00433         ppd_filter = gtk.FileFilter()
00434         ppd_filter.set_name(_("PostScript Printer Description files (*.ppd, *.PPD, *.ppd.gz, *.PPD.gz, *.PPD.GZ)"))
00435         ppd_filter.add_pattern("*.ppd")
00436         ppd_filter.add_pattern("*.PPD")
00437         ppd_filter.add_pattern("*.ppd.gz")
00438         ppd_filter.add_pattern("*.PPD.gz")
00439         ppd_filter.add_pattern("*.PPD.GZ")
00440         self.filechooserPPD.add_filter(ppd_filter)
00441 
00442         ppd_filter = gtk.FileFilter()
00443         ppd_filter.set_name(_("All files (*)"))
00444         ppd_filter.add_pattern("*")
00445         self.filechooserPPD.add_filter(ppd_filter)
00446         debugprint ("+%s" % self)

Definition at line 447 of file newprinter.py.

00447 
00448     def __del__ (self):
00449         debugprint ("-%s" % self)


Member Function Documentation

def newprinter.NewPrinterGUI._getPPDs_reply (   self,
  ppdsloader 
) [private]

Definition at line 798 of file newprinter.py.

00798 
00799     def _getPPDs_reply (self, ppdsloader):
00800         exc = ppdsloader.get_error ()
00801         if exc:
00802             try:
00803                 raise exc
00804             except cups.IPPError, (e, m):
00805                 show_IPP_Error (e, m, parent=self.NewPrinterWindow)
00806                 return
00807 
00808         ppds = ppdsloader.get_ppds ()
00809         if ppds:
00810             self.ppds = ppds
00811             self.ppdsmatch_result = ppdsloader.get_ppdsmatch_result ()
00812             self.jockey_installed_files = ppdsloader.get_installed_files ()
00813         else:
00814             self.ppds = None
00815             self.ppdsmatch_result = None
00816 
00817         ppdsloader.destroy ()
00818         self.ppdsloader = None

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.add_devices (   self,
  devices,
  current_uri,
  no_more = False 
)

Definition at line 1693 of file newprinter.py.

01693 
01694     def add_devices (self, devices, current_uri, no_more=False):
01695         if current_uri:
01696             if devices.has_key (current_uri):
01697                 current = devices.pop(current_uri)
01698             elif devices.has_key (current_uri.replace (":9100", "")):
01699                 current_uri = current_uri.replace (":9100", "")
01700                 current = devices.pop(current_uri)
01701             elif no_more:
01702                 current = cupshelpers.Device (current_uri)
01703                 current.info = "Current device"
01704             else:
01705                 current_uri = None
01706 
01707         devices = devices.values()
01708 
01709         for device in devices:
01710             if device.type == "socket":
01711                 # Remove default port to more easily find duplicate URIs
01712                 device.uri = device.uri.replace (":9100", "")
01713 
01714         # Map generic URIs to something canonical
01715         def replace_generic (device):
01716             if device.uri == "hp:/no_device_found":
01717                 device.uri = "hp"
01718             elif device.uri == "hpfax:/no_device_found":
01719                 device.uri = "hpfax"
01720             return device
01721 
01722         devices = map (replace_generic, devices)
01723 
01724         # Mark duplicate URIs for deletion
01725         for i in range (len (devices) - 1):
01726             for j in range (i + 1, len (devices)):
01727                 device1 = devices[i]
01728                 device2 = devices[j]
01729                 if device1.uri == "delete" or device2.uri == "delete":
01730                     continue
01731                 if device1.uri == device2.uri:
01732                     # Keep the one with the longer (better) device ID
01733                     if (not device1.id):
01734                         device1.uri = "delete"
01735                     elif (not device2.id):
01736                         device2.uri = "delete"
01737                     elif (len (device1.id) < len (device2.id)):
01738                         device1.uri = "delete"
01739                     else:
01740                         device2.uri = "delete"
01741         devices = filter(lambda x: x.uri not in ("hp", "hpfax",
01742                                                  "hal", "beh",
01743                                                  "scsi", "http", "delete"),
01744                          devices)
01745         newdevices = []
01746         for device in devices:
01747             physicaldevice = PhysicalDevice (device)
01748             try:
01749                 i = self.devices.index (physicaldevice)
01750                 self.devices[i].add_device (device)
01751             except ValueError:
01752                 self.devices.append (physicaldevice)
01753                 newdevices.append (physicaldevice)
01754 
01755         self.devices.sort()
01756         if current_uri:
01757             current_device = PhysicalDevice (current)
01758             try:
01759                 i = self.devices.index (current_device)
01760                 self.devices[i].add_device (current)
01761                 current_device = self.devices[i]
01762             except ValueError:
01763                 self.devices.append (current_device)
01764                 newdevices.append (current_device)
01765         else:
01766             current_device = None
01767 
01768         model = self.tvNPDevices.get_model ()
01769 
01770         network_iter = self.devices_network_iter
01771         find_nw_iter = self.devices_find_nw_iter
01772         for device in newdevices:
01773             devs = device.get_devices ()
01774             network = devs[0].device_class == 'network'
01775             info = device.get_info ()
01776             if device == current_device:
01777                 info += _(" (Current)")
01778             row=[info, device, False]
01779             if network:
01780                 if devs[0].uri != devs[0].type:
01781                     # An actual network printer device.  Put this at the top.
01782                     iter = model.insert_before (network_iter, find_nw_iter,
01783                                                 row=row)
01784 
01785                     # If this is the currently selected device we need
01786                     # to expand the "Network Printer" row so that it
01787                     # is visible.
01788                     if device == current_device:
01789                         network_path = model.get_path (network_iter)
01790                         self.tvNPDevices.expand_row (network_path, False)
01791                 else:
01792                     # Just a method of finding one.
01793                     iter = model.append (network_iter, row=row)
01794             else:
01795                 # Insert this local device in order.
01796                 network_path = model.get_path (network_iter)
01797                 iter = model.get_iter_first ()
01798                 while model.get_path (iter) != network_path:
01799                     physdev = model.get_value (iter, 1)
01800                     if physdev > device:
01801                         break
01802 
01803                     iter = model.iter_next (iter)
01804 
01805                 iter = model.insert_before (None, iter, row=row)
01806 
01807             if device == current_device:
01808                 device_select_path = model.get_path (iter)
01809                 self.tvNPDevices.scroll_to_cell (device_select_path,
01810                                                  row_align=0.5)
01811                 column = self.tvNPDevices.get_column (0)
01812                 self.tvNPDevices.set_cursor (device_select_path, column)
01813 
01814         connection_select_path = 0
01815         if current_uri:
01816             model = self.tvNPDeviceURIs.get_model ()
01817             iter = model.get_iter_first ()
01818             i = 0
01819             while iter:
01820                 dev = model.get_value (iter, 1)
01821                 if current_uri == dev.uri:
01822                     connection_select_path = i
01823                     break
01824 
01825                 iter = model.iter_next (iter)
01826                 i += 1
01827         elif not self.device_selected:
01828             # Select the device.
01829             column = self.tvNPDevices.get_column (0)
01830             self.tvNPDevices.set_cursor ((0,), column)
01831 
01832             # Select the connection.
01833             column = self.tvNPDeviceURIs.get_column (0)
01834             self.tvNPDeviceURIs.set_cursor (connection_select_path, column)

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.adjust_firewall_response (   self,
  dialog,
  response 
)

Definition at line 1678 of file newprinter.py.

01678 
01679     def adjust_firewall_response (self, dialog, response):
01680         dialog.destroy ()
01681         if response == gtk.RESPONSE_YES:
01682             self.firewall.add_rule (self.firewall.ALLOW_IPP_SERVER)
01683             self.firewall.write ()
01684 
01685         debugprint ("Fetching devices after firewall dialog response")
01686         self.start_fetching_devices ()

Here is the call graph for this function:

Here is the caller graph for this function:

SMB browsing.

Initialise the SMB tree store.

Definition at line 1837 of file newprinter.py.

01837 
01838     def browse_smb_hosts(self):
01839         """Initialise the SMB tree store."""
01840         store = self.smb_store
01841         store.clear ()
01842         busy(self.SMBBrowseDialog)
01843         class X:
01844             pass
01845         dummy = X()
01846         dummy.smbc_type = pysmb.smbc.PRINTER_SHARE
01847         dummy.name = _('Scanning...')
01848         dummy.comment = ''
01849         store.append(None, [dummy])
01850         while gtk.events_pending ():
01851             gtk.main_iteration ()
01852 
01853         debug = 0
01854         if get_debugging ():
01855             debug = 10
01856         smbc_auth = pysmb.AuthContext (self.SMBBrowseDialog)
01857         ctx = pysmb.smbc.Context (debug=debug,
01858                                   auth_fn=smbc_auth.callback)
01859         entries = None
01860         try:
01861             while smbc_auth.perform_authentication () > 0:
01862                 try:
01863                     entries = ctx.opendir ("smb://").getdents ()
01864                 except Exception, e:
01865                     smbc_auth.failed (e)
01866         except RuntimeError, (e, s):
01867             if e != errno.ENOENT:
01868                 debugprint ("Runtime error: %s" % repr ((e, s)))
01869         except:
01870             nonfatalException ()
01871 
01872         store.clear ()
01873         if entries:
01874             for entry in entries:
01875                 if entry.smbc_type in [pysmb.smbc.WORKGROUP,
01876                                        pysmb.smbc.SERVER]:
01877                     iter = store.append (None, [entry])
01878                     i = store.append (iter)
01879 
01880         specified_uri = SMBURI (uri=self.entSMBURI.get_text ())
01881         (group, host, share, user, password) = specified_uri.separate ()
01882         if len (host) > 0:
01883             # The user has specified a server before clicking Browse.
01884             # Append the server as a top-level entry.
01885             class FakeEntry:
01886                 pass
01887             toplevel = FakeEntry ()
01888             toplevel.smbc_type = pysmb.smbc.SERVER
01889             toplevel.name = host
01890             toplevel.comment = ''
01891             iter = store.append (None, [toplevel])
01892             i = store.append (iter)
01893 
01894             # Now expand it.
01895             path = store.get_path (iter)
01896             self.tvSMBBrowser.expand_row (path, 0)
01897 
01898         ready(self.SMBBrowseDialog)
01899 
01900         if store.get_iter_first () == None:
01901             self.SMBBrowseDialog.hide ()
01902             show_info_dialog (_("No Print Shares"),
01903                               _("There were no print shares found.  "
01904                                 "Please check that the Samba service is "
01905                                 "marked as trusted in your firewall "
01906                                 "configuration."),
01907                               parent=self.NewPrinterWindow)

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.change_ppd_got_devs (   self,
  conn,
  result 
)

Definition at line 693 of file newprinter.py.

00693 
00694     def change_ppd_got_devs (self, conn, result):
00695         self.fetchDevices_conn._end_operation ()
00696         self.fetchDevices_conn.destroy ()
00697         self.fetchDevices_conn = None
00698         self.dec_spinner_task ()
00699         if isinstance (result, Exception):
00700             current_devices = {}
00701         else:
00702             current_devices = result
00703 
00704         devid = None
00705         mm = None
00706         if self.devid != "":
00707             devid = self.devid
00708         else:
00709             device = current_devices.get (self.device.uri)
00710             if device:
00711                 devid = device.id
00712                 mm = device.make_and_model
00713                 self.device = device
00714 
00715         # We'll also need the list of PPDs.
00716         self.ppdsloader = ppdsloader.PPDsLoader (device_id=devid,
00717                                                  device_uri=self.device.uri,
00718                                                  device_make_and_model=mm,
00719                                                  parent=self.NewPrinterWindow,
00720                                                  host=self._host,
00721                                                  encryption=self._encryption,
00722                                                  language=self.language[0])
00723         self.ppdsloader.connect ('finished',
00724                                  self.change_ppd_have_devs_and_ppds)
00725         self.ppdsloader.run ()

Here is the call graph for this function:

Definition at line 726 of file newprinter.py.

00726 
00727     def change_ppd_have_devs_and_ppds (self, ppdsloader):
00728         self._getPPDs_reply (ppdsloader)
00729         if not self.ppds:
00730             self.setNPButtons()
00731             return
00732 
00733         self.exactdrivermatch = False
00734         self.id_matched_ppdnames = []
00735         if self.ppdsmatch_result != None:
00736             try:
00737                 (fit, ppdnamelist) = self.ppdsmatch_result
00738                 self.id_matched_ppdnames = ppdnamelist
00739                 ppdname = ppdnamelist[0]
00740                 status = fit[ppdname]
00741                 ppddict = self.ppds.getInfoFromPPDName (ppdname)
00742                 make_model = _singleton (ppddict['ppd-make-and-model'])
00743                 (self.auto_make, self.auto_model) = \
00744                     cupshelpers.ppds.ppdMakeModelSplit (make_model)
00745                 self.auto_driver = ppdname
00746                 if (status.startswith ("exact") and
00747                     self.dialog_mode == "printer_with_uri"):
00748                     self.exactdrivermatch = True
00749                     self.fillMakeList()
00750                     self.ntbkNewPrinter.set_current_page(6)
00751                     self.nextNPTab(step = 0)
00752             except:
00753                 nonfatalException ()
00754         elif self.orig_ppd:
00755             attr = self.orig_ppd.findAttr("NickName")
00756             if not attr:
00757                 attr = self.orig_ppd.findAttr("ModelName")
00758 
00759             if attr and attr.value:
00760                 value = attr.value
00761                 if value.endswith (" (recommended)"):
00762                     value = value[:-14]
00763 
00764                 mfgmdl = cupshelpers.ppds.ppdMakeModelSplit (value)
00765                 (self.auto_make, self.auto_model) = mfgmdl
00766 
00767                 # Search for ppdname with that make-and-model
00768                 ppds = self.ppds.getInfoFromModel (self.auto_make,
00769                                                    self.auto_model)
00770                 for ppd, info in ppds.iteritems ():
00771                     if _singleton (info.
00772                                    get ("ppd-make-and-model")) == value:
00773                         self.auto_driver = ppd
00774                         break
00775         else:
00776             # Special CUPS names for a raw queue.
00777             self.auto_make = 'Generic'
00778             self.auto_model = 'Raw Queue'
00779 
00780         self.fillMakeList()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 471 of file newprinter.py.

00471 
00472     def dec_spinner_task (self):
00473         self.spinner_count -= 1
00474         if self.spinner_count == 0:
00475             self.imgProcessWorking.hide ()
00476             self.spinner.stop ()

Here is the caller graph for this function:

Definition at line 511 of file newprinter.py.

00511 
00512     def destroy (self):
00513         self.emit ('destroy')

Here is the call graph for this function:

def newprinter.NewPrinterGUI.device_row_activated (   self,
  view,
  path,
  column 
)

Definition at line 2259 of file newprinter.py.

02259 
02260     def device_row_activated (self, view, path, column):
02261         if view.row_expanded (path):
02262             view.collapse_row (path)
02263         else:
02264             view.expand_row (path, False)

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.device_row_separator_fn (   self,
  model,
  iter 
)

Definition at line 2256 of file newprinter.py.

02256 
02257     def device_row_separator_fn (self, model, iter):
02258         return model.get_value (iter, 2)

Allow this path to be selected as long as there
is a device associated with it.  Otherwise, expand or collapse it.

Definition at line 2265 of file newprinter.py.

02265 
02266     def device_select_function (self, path):
02267         """
02268         Allow this path to be selected as long as there
02269         is a device associated with it.  Otherwise, expand or collapse it.
02270         """
02271         model = self.tvNPDevices.get_model ()
02272         iter = model.get_iter (path)
02273         if model.get_value (iter, 1) != None:
02274             return True
02275 
02276         self.device_row_activated (self.tvNPDevices, path, None)
02277         return False

Here is the call graph for this function:

def newprinter.NewPrinterGUI.dnssd_resolve_reply (   self,
  current_uri,
  devices 
)

Definition at line 1424 of file newprinter.py.

01424 
01425     def dnssd_resolve_reply (self, current_uri, devices):
01426         self.add_devices (devices, current_uri, no_more=True)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 450 of file newprinter.py.

00450 
00451     def do_destroy (self):
00452         debugprint ("DESTROY: %s" % self)
00453         if self.SMBBrowseDialog:
00454             self.SMBBrowseDialog.destroy ()
00455             self.SMBBrowseDialog = None
00456 
00457         if self.NewPrinterWindow:
00458             self.NewPrinterWindow.destroy ()
00459             self.NewPrinterWindow = None
00460 
00461         if self.WaitWindow:
00462             self.WaitWindow.destroy ()
00463             self.WaitWindow = None

def newprinter.NewPrinterGUI.entry_changed (   self,
  entry,
  allowed_chars 
)

Definition at line 2211 of file newprinter.py.

02211 
02212     def entry_changed(self, entry, allowed_chars):
02213         "Remove all chars from entry's text that are not in allowed_chars."
02214         try:
02215             allowed_chars = unicode (allowed_chars, locale.getpreferredencoding())
02216         except UnicodeDecodeError:
02217             allowed_chars = unicode (allowed_chars)
02218         origtext = unicode (entry.get_text())
02219         new_text = origtext
02220         for char in origtext:
02221             if char not in allowed_chars:
02222                 new_text = new_text.replace(char, "")
02223                 debugprint ("removed disallowed character %s" % char)
02224         if origtext!=new_text:
02225             entry.set_text(new_text)

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.error_getting_devices (   self,
  conn,
  exc 
)

Definition at line 1381 of file newprinter.py.

01381 
01382     def error_getting_devices (self, conn, exc):
01383         # Just ignore the error.
01384         debugprint ("Error fetching devices: %s" % repr (exc))
01385         self.dec_spinner_task ()
01386         self.fetchDevices_conn._end_operation ()
01387         self.fetchDevices_conn.destroy ()
01388         self.fetchDevices_conn = None

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.fetchDevices (   self,
  network = False,
  current_uri = None 
)

Definition at line 1356 of file newprinter.py.

01356 
01357     def fetchDevices(self, network=False, current_uri=None):
01358         debugprint ("fetchDevices")
01359         self.inc_spinner_task ()
01360 
01361         # Search for Bluetooth printers together with the network printers
01362         # as the Bluetooth search takes rather long time
01363         network_schemes = ["dnssd", "snmp", "bluetooth"]
01364         error_handler = self.error_getting_devices
01365         if network == False:
01366             reply_handler = (lambda x, y:
01367                                  self.local_devices_reply (x, y,
01368                                                            current_uri))
01369             cupshelpers.getDevices (self.fetchDevices_conn,
01370                                     exclude_schemes=network_schemes,
01371                                     reply_handler=reply_handler,
01372                                     error_handler=error_handler)
01373         else:
01374             reply_handler = (lambda x, y:
01375                                  self.network_devices_reply (x, y,
01376                                                              current_uri))
01377             cupshelpers.getDevices (self.fetchDevices_conn,
01378                                     include_schemes=network_schemes,
01379                                     reply_handler=reply_handler,
01380                                     error_handler=error_handler)

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.fillDeviceTab (   self,
  current_uri = None 
)

Definition at line 1586 of file newprinter.py.

01586 
01587     def fillDeviceTab(self, current_uri=None):
01588         self.device_selected = -1
01589         model = gtk.TreeStore (gobject.TYPE_STRING,   # device-info
01590                                gobject.TYPE_PYOBJECT, # PhysicalDevice obj
01591                                gobject.TYPE_BOOLEAN)  # Separator?
01592         other = cupshelpers.Device('', **{'device-info' :_("Enter URI")})
01593         physother = PhysicalDevice (other)
01594         self.devices = [physother]
01595         uri_iter = model.append (None, row=[physother.get_info (),
01596                                             physother, False])
01597         network_iter = model.append (None, row=[_("Network Printer"),
01598                                                 None,
01599                                                 False])
01600         network_dict = { 'device-class': 'network',
01601                          'device-info': _("Find Network Printer") }
01602         network = cupshelpers.Device ('network', **network_dict)
01603         find_nw_iter = model.append (network_iter,
01604                                      row=[network_dict['device-info'],
01605                                           PhysicalDevice (network), False])
01606         model.insert_after (network_iter, find_nw_iter, row=['', None, True])
01607         self.devices_uri_iter = uri_iter
01608         self.devices_find_nw_iter = find_nw_iter
01609         self.devices_network_iter = network_iter
01610         self.devices_network_fetched = False
01611         self.tvNPDevices.set_model (model)
01612         self.entNPTDevice.set_text ('')
01613         self.expNPDeviceURIs.hide ()
01614         column = self.tvNPDevices.get_column (0)
01615         self.tvNPDevices.set_cursor ((0,), column)
01616 
01617         allowed = True
01618         self.current_uri = current_uri
01619         try:
01620             if (self._host == 'localhost' or
01621                 self._host[0] == '/'):
01622                 self.firewall = firewall.Firewall ()
01623                 debugprint ("Examining firewall")
01624                 self.firewall.read (reply_handler=self.on_firewall_read,
01625                                     error_handler=lambda x:
01626                                         self.start_fetching_devices())
01627                 allowed = False
01628             else:
01629                 # This is a remote server.  Nothing we can do about
01630                 # the firewall there.
01631                 allowed = True
01632         except (dbus.DBusException, Exception):
01633             nonfatalException ()
01634 
01635         if allowed:
01636             debugprint ("Fetching devices (no firewall service")
01637             self.start_fetching_devices ()

Definition at line 2967 of file newprinter.py.

02967 
02968     def fillDownloadableDrivers(self):
02969         # Clear out the properties.
02970         self.lblNPDownloadableDriverSupplier.set_text ('')
02971         self.lblNPDownloadableDriverLicense.set_text ('')
02972         self.lblNPDownloadableDriverDescription.set_text ('')
02973         self.lblNPDownloadableDriverSupportContacts.set_text ('')
02974         self.rbtnNPDownloadLicenseNo.set_active (True)
02975         self.frmNPDownloadableDriverLicenseTerms.hide ()
02976 
02977         widget = self.cmbNPDownloadableDriverFoundPrinters
02978         model = widget.get_model ()
02979         iter = widget.get_active_iter ()
02980         if iter:
02981             printer_id = model.get_value (iter, 1)
02982         else:
02983             printer_id = None
02984 
02985         if printer_id == None:
02986             return
02987 
02988         drivers = self.downloadable_drivers[printer_id]
02989         model = gtk.ListStore (str,                     # driver name
02990                                gobject.TYPE_PYOBJECT)   # driver data
02991         recommended_iter = None
02992         first_iter = None
02993         for driver in drivers.values ():
02994             iter = model.append (None)
02995             if first_iter == None:
02996                 first_iter = iter
02997 
02998             model.set_value (iter, 0, driver['name'])
02999             model.set_value (iter, 1, driver)
03000 
03001             if driver['recommended']:
03002                 recommended_iter = iter
03003 
03004         if recommended_iter == None:
03005             recommended_iter = first_iter
03006 
03007         treeview = self.tvNPDownloadableDrivers
03008         treeview.set_model (model)
03009         if recommended_iter != None:
03010             treeview.get_selection ().select_iter (recommended_iter)

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.fillDriverList (   self,
  pmake,
  pmodel 
)

Definition at line 3107 of file newprinter.py.

03107 
03108     def fillDriverList(self, pmake, pmodel):
03109         self.NPModel = pmodel
03110         model = self.tvNPDrivers.get_model()
03111         model.clear()
03112 
03113         if self.device:
03114             devid = self.device.id_dict
03115         else:
03116             devid = None
03117 
03118         if (self.device and self.device.make_and_model and
03119             self.recommended_model_selected and
03120             self.id_matched_ppdnames):
03121             # Use the actual device-make-and-model string.
03122             make_and_model = self.device.make_and_model
03123 
03124             # and the ID-matched list of PPDs.
03125             self.NPDrivers = self.id_matched_ppdnames
03126             debugprint ("ID matched PPDs: %s" % repr (self.NPDrivers))
03127         elif self.ppds:
03128             # Use a generic make and model string for generating the
03129             # driver preference list.
03130             make_and_model = pmake + " " + pmodel
03131             ppds = self.ppds.getInfoFromModel(pmake, pmodel)
03132             ppdnames = ppds.keys ()
03133 
03134             files = self.jockey_installed_files
03135             try:
03136                 self.NPDrivers = self.ppds.orderPPDNamesByPreference(ppdnames,
03137                                                                      files,
03138                                                                      make_and_model,
03139                                                                      devid)
03140             except:
03141                 nonfatalException ()
03142                 self.NPDrivers = ppdnames
03143 
03144             # Put the current driver first.
03145             if self.auto_driver and self.device:
03146                 drivers = []
03147                 for driver in self.NPDrivers:
03148                     if driver == self.auto_driver:
03149                         drivers.insert (0, driver)
03150                     else:
03151                         drivers.append (driver)
03152 
03153                 self.NPDrivers = drivers
03154         else:
03155             # No available PPDs for some reason(!)
03156             debugprint ("No PPDs available?")
03157             self.NPDrivers = []
03158 
03159         driverlist = []
03160         NPDrivers = []
03161         i = 0
03162         for ppdname in self.NPDrivers:
03163             ppd = self.ppds.getInfoFromPPDName (ppdname)
03164             driver = _singleton (ppd["ppd-make-and-model"])
03165             driver = driver.replace(" (recommended)", "")
03166 
03167             try:
03168                 lpostfix = " [%s]" % _singleton (ppd["ppd-natural-language"])
03169                 driver += lpostfix
03170             except KeyError:
03171                 pass
03172 
03173             duplicate = driver in driverlist
03174 
03175             if (not (self.device and self.device.make_and_model) and
03176                 self.auto_driver == ppdname):
03177                 driverlist.append (driver)
03178                 NPDrivers.append (ppdname)
03179                 i += 1
03180                 iter = model.append ((driver + _(" (Current)"),))
03181                 path = model.get_path (iter)
03182                 self.tvNPDrivers.get_selection().select_path(path)
03183                 self.tvNPDrivers.scroll_to_cell(path, None, True, 0.5, 0.0)
03184             elif self.device and i == 0:
03185                 driverlist.append (driver)
03186                 NPDrivers.append (ppdname)
03187                 i += 1
03188                 iter = model.append ((driver + _(" (recommended)"),))
03189                 path = model.get_path (iter)
03190                 self.tvNPDrivers.get_selection().select_path(path)
03191                 self.tvNPDrivers.scroll_to_cell(path, None, True, 0.5, 0.0)
03192             else:
03193                 if duplicate:
03194                     continue
03195                 driverlist.append (driver)
03196                 NPDrivers.append (ppdname)
03197                 i += 1
03198                 model.append((driver, ))
03199 
03200         self.NPDrivers = NPDrivers
03201         self.tvNPDrivers.columns_autosize()

Here is the caller graph for this function:

Definition at line 3016 of file newprinter.py.

03016 
03017     def fillMakeList(self):
03018         self.recommended_make_selected = False
03019         makes = self.ppds.getMakes()
03020         model = self.tvNPMakes.get_model()
03021         model.clear()
03022         found = False
03023         if self.auto_make:
03024             auto_make_norm = cupshelpers.ppds.normalize (self.auto_make)
03025         else:
03026             auto_make_norm = None
03027 
03028         for make in makes:
03029             recommended = (auto_make_norm and
03030                            cupshelpers.ppds.normalize (make) == auto_make_norm)
03031             if self.device and self.device.make_and_model and recommended:
03032                 text = make + _(" (recommended)")
03033             else:
03034                 text = make
03035 
03036             iter = model.append((text, make,))
03037             if recommended:
03038                 path = model.get_path(iter)
03039                 self.tvNPMakes.set_cursor (path)
03040                 self.tvNPMakes.scroll_to_cell(path, None,
03041                                               True, 0.5, 0.5)
03042                 found = True
03043 
03044         if not found:
03045             self.tvNPMakes.set_cursor (0,)
03046             self.tvNPMakes.scroll_to_cell(0, None, True, 0.0, 0.0)
03047 
03048         # Also pre-fill the OpenPrinting.org search box.
03049         search = ''
03050         if self.device and self.device.id_dict:
03051             devid_dict = self.device.id_dict
03052             if devid_dict["MFG"] and devid_dict["MDL"]:
03053                 search = devid_dict["MFG"] + " " + devid_dict["MDL"]
03054             elif devid_dict["DES"]:
03055                 search = devid_dict["DES"]
03056             elif devid_dict["MFG"]:
03057                 search = devid_dict["MFG"]
03058         if search == '' and self.auto_make != None:
03059             search += self.auto_make
03060             if self.auto_model != None:
03061                 search += " " + self.auto_model
03062         self.entNPDownloadableDriverSearch.set_text (search)

Here is the caller graph for this function:

Definition at line 3075 of file newprinter.py.

03075 
03076     def fillModelList(self):
03077         self.recommended_model_selected = False
03078         models = self.ppds.getModels(self.NPMake)
03079         model = self.tvNPModels.get_model()
03080         model.clear()
03081         selected = False
03082         is_auto_make = (cupshelpers.ppds.normalize (self.NPMake) ==
03083                         cupshelpers.ppds.normalize (self.auto_make))
03084         if is_auto_make:
03085             auto_model_norm = cupshelpers.ppds.normalize (self.auto_model)
03086 
03087         for pmodel in models:
03088             recommended = (is_auto_make and
03089                            cupshelpers.ppds.normalize (pmodel) ==
03090                            auto_model_norm)
03091             if self.device and self.device.make_and_model and recommended:
03092                 text = pmodel + _(" (recommended)")
03093             else:
03094                 text = pmodel
03095 
03096             iter = model.append((text, pmodel,))
03097             if recommended:
03098                 path = model.get_path(iter)
03099                 self.tvNPModels.set_cursor (path)
03100                 self.tvNPModels.scroll_to_cell(path, None,
03101                                                True, 0.5, 0.5)
03102                 selected = True
03103         if not selected:
03104             self.tvNPModels.set_cursor (0,)
03105             self.tvNPModels.scroll_to_cell(0, None, True, 0.0, 0.0)
03106         self.tvNPModels.columns_autosize()

Definition at line 821 of file newprinter.py.

00821 
00822     def fillNewClassMembers(self):
00823         model = self.tvNCMembers.get_model()
00824         model.clear()
00825         model = self.tvNCNotMembers.get_model()
00826         model.clear()
00827         try:
00828             self.printers = cupshelpers.getPrinters (self.cups)
00829         except cups.IPPError:
00830             self.printers = {}
00831 
00832         for printer in self.printers.keys():
00833             model.append((printer,))

Definition at line 3434 of file newprinter.py.

03434 
03435     def fillNPInstallableOptions(self):
03436         debugprint ("Examining installable options")
03437         self.installable_options = False
03438         self.options = { }
03439 
03440         container = self.vbNPInstallOptions
03441         for child in container.get_children():
03442             container.remove(child)
03443 
03444         if not self.ppd:
03445             l = gtk.Label(_("No Installable Options"))
03446             container.add(l)
03447             l.show()
03448             debugprint ("No PPD so no installable options")
03449             return
03450 
03451         # build option tabs
03452         for group in self.ppd.optionGroups:
03453             if group.name != "InstallableOptions":
03454                 continue
03455             self.installable_options = True
03456 
03457             table = gtk.Table(1, 3, False)
03458             table.set_col_spacings(6)
03459             table.set_row_spacings(6)
03460             container.add(table)
03461             rows = 0
03462 
03463             for nr, option in enumerate(group.options):
03464                 if option.keyword == "PageRegion":
03465                     continue
03466                 rows += 1
03467                 table.resize (rows, 3)
03468                 o = OptionWidget(option, self.ppd, self)
03469                 table.attach(o.conflictIcon, 0, 1, nr, nr+1, 0, 0, 0, 0)
03470 
03471                 hbox = gtk.HBox()
03472                 if o.label:
03473                     a = gtk.Alignment (0.5, 0.5, 1.0, 1.0)
03474                     a.set_padding (0, 0, 0, 6)
03475                     a.add (o.label)
03476                     table.attach(a, 1, 2, nr, nr+1, gtk.FILL, 0, 0, 0)
03477                     table.attach(hbox, 2, 3, nr, nr+1, gtk.FILL, 0, 0, 0)
03478                 else:
03479                     table.attach(hbox, 1, 3, nr, nr+1, gtk.FILL, 0, 0, 0)
03480                 hbox.pack_start(o.selector, False)
03481                 self.options[option.keyword] = o
03482         if not self.installable_options:
03483             l = gtk.Label(_("No Installable Options"))
03484             container.add(l)
03485             l.show()
03486         self.scrNPInstallableOptions.hide()
03487         self.scrNPInstallableOptions.show_all()
03488 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2693 of file newprinter.py.

02693 
02694     def found_network_printer_callback (self, new_device):
02695         gtk.gdk.threads_enter ()
02696         if new_device:
02697             self.network_found += 1
02698             dev = PhysicalDevice (new_device)
02699             try:
02700                 i = self.devices.index (dev)
02701 
02702                 # Adding a new URI to an existing physical device.
02703                 self.devices[i].add_device (new_device)
02704 
02705                 (path, column) = self.tvNPDevices.get_cursor ()
02706                 if path:
02707                     model = self.tvNPDevices.get_model ()
02708                     iter = model.get_iter (path)
02709                     if model.get_value (iter, 1) == self.devices[i]:
02710                         self.on_tvNPDevices_cursor_changed (self.tvNPDevices)
02711             except ValueError:
02712                 # New physical device.
02713                 dev.set_data ('checked-hplip', True)
02714                 self.devices.append (dev)
02715                 self.devices.sort ()
02716                 model = self.tvNPDevices.get_model ()
02717                 iter = model.insert_before (None, self.devices_find_nw_iter,
02718                                             row=[dev.get_info (), dev, False])
02719 
02720                 # If this is the first one we've found, select it.
02721                 if self.network_found == 1:
02722                     path = model.get_path (iter)
02723                     self.tvNPDevices.set_cursor (path)
02724         else:
02725             self.printer_finder = None
02726             self.dec_spinner_task ()
02727             self.lblNetworkFindSearching.hide ()
02728             self.entNPTNetworkHostname.set_sensitive (True)
02729             self.btnNetworkFind.set_sensitive (True)
02730             if self.network_found == 0:
02731                 self.lblNetworkFindNotFound.set_markup ('<i>' +
02732                                                         _("No printer was "
02733                                                           "found at that "
02734                                                           "address.") + '</i>')
02735                 self.lblNetworkFindNotFound.show ()
02736 
        gtk.gdk.threads_leave ()

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.get_hpfax_device_id (   self,
  faxuri 
)

Definition at line 1427 of file newprinter.py.

01427 
01428     def get_hpfax_device_id(self, faxuri):
01429         new_environ = os.environ.copy()
01430         new_environ['LC_ALL'] = "C"
01431         new_environ['DISPLAY'] = ""
01432         args = ["hp-info", "-x", "-i", "-d" + faxuri]
01433         debugprint (faxuri + ": " + repr(args))
01434         try:
01435             p = subprocess.Popen (args, env=new_environ, close_fds=True,
01436                                   stdin=file("/dev/null"),
01437                                   stdout=subprocess.PIPE,
01438                                   stderr=subprocess.PIPE)
01439             (stdout, stderr) = p.communicate ()
01440         except:
01441             # Problem executing command.
01442             return None
01443 
01444         faxtype = -1
01445         for line in stdout.split ("\n"):
01446             if line.find ("fax-type") == -1:
01447                 continue
01448             res = re.search ("(\d+)", line)
01449             if res:
01450                 resg = res.groups()
01451                 faxtype = resg[0]
01452             if faxtype >= 0:
01453                 break
01454         if faxtype <= 0:
01455             return None
01456         elif faxtype == 4:
01457             return 'MFG:HP;MDL:Fax 2;DES:HP Fax 2;'
01458         else:
01459             return 'MFG:HP;MDL:Fax;DES:HP Fax;'

Here is the caller graph for this function:

Definition at line 1460 of file newprinter.py.

01460 
01461     def get_hplip_scan_type_for_uri(self, uri):
01462         args = ["hp-query", "-k", "scan-type", "-d", uri]
01463         debugprint (uri + ": " + repr(args))
01464         try:
01465             p = subprocess.Popen (args, close_fds=True,
01466                                   stdin=file("/dev/null"),
01467                                   stdout=subprocess.PIPE,
01468                                   stderr=subprocess.PIPE)
01469             (stdout, stderr) = p.communicate ()
01470             if p.returncode != 0:
01471                 return None
01472         except:
01473             # Problem executing command.
01474             return None
01475 
01476         scan_type = stdout.strip ()
01477         fields = scan_type.split ("=", 1)
01478         if len (fields) < 2:
01479             return None
01480 
01481         value = fields[1]
01482         if value == '0':
01483             return None
01484 
01485         return value

Here is the caller graph for this function:

Definition at line 1486 of file newprinter.py.

01486 
01487     def get_hplip_uri_for_network_printer(self, host, mode):
01488         if mode == "print": mod = "-c"
01489         elif mode == "fax": mod = "-f"
01490         else: mod = "-c"
01491         args = ["hp-makeuri", mod, host]
01492         debugprint (host + ": " + repr(args))
01493         uri = None
01494         try:
01495             p = subprocess.Popen (args, close_fds=True,
01496                                   stdin=file("/dev/null"),
01497                                   stdout=subprocess.PIPE,
01498                                   stderr=subprocess.PIPE)
01499             (stdout, stderr) = p.communicate ()
01500             if p.returncode != 0:
01501                 return None
01502         except:
01503             # Problem executing command.
01504             return None
01505 
01506         uri = stdout.strip ()
01507         return uri

Here is the caller graph for this function:

Definition at line 2739 of file newprinter.py.

02739 
02740     def getDeviceURI(self):
02741         type = self.device.type
02742         page = self.new_printer_device_tabs.get (type, 1)
02743         device = type
02744         if page == 0:
02745             # The "no options page".  We already have the URI.
02746             device = self.device.uri
02747         elif type == "socket": # JetDirect
02748             host = self.entNPTJetDirectHostname.get_text()
02749             port = self.entNPTJetDirectPort.get_text()
02750             if host:
02751                 device += "://" + host
02752                 if port:
02753                     device += ":" + port
02754         elif type == "lpd": # LPD
02755             host = self.entNPTLpdHost.get_text()
02756             printer = self.entNPTLpdQueue.get_text()
02757             if host:
02758                 device += "://" + host
02759                 if printer:
02760                     device += "/" + printer
02761         elif type == "serial": # Serial
02762             options = []
02763             for widget, name, optionvalues in (
02764                 (self.cmbNPTSerialBaud, "baud", None),
02765                 (self.cmbNPTSerialBits, "bits", None),
02766                 (self.cmbNPTSerialParity, "parity",
02767                  ("none", "odd", "even")),
02768                 (self.cmbNPTSerialFlow, "flow",
02769                  ("none", "soft", "hard", "hard"))):
02770                 nr = widget.get_active()
02771                 if nr:
02772                     if optionvalues is not None:
02773                         option = optionvalues[nr-1]
02774                     else:
02775                         option = widget.get_active_text()
02776                     options.append(name + "=" + option)
02777             options = "+".join(options)
02778             device =  self.device.uri.split("?")[0] #"serial:/dev/ttyS%s"
02779             if options:
02780                 device = device + "?" + options
02781         elif type == "smb":
02782             uri = self.entSMBURI.get_text ()
02783             (group, host, share, u, p) = SMBURI (uri=uri).separate ()
02784             user = ''
02785             password = ''
02786             if self.rbtnSMBAuthSet.get_active ():
02787                 user = self.entSMBUsername.get_text ()
02788                 password = self.entSMBPassword.get_text ()
02789             uri = SMBURI (group=group, host=host, share=share,
02790                           user=user, password=password).get_uri ()
02791             if uri:
02792                 device += "://" + uri
02793         else:
02794             device = self.entNPTDevice.get_text()
02795         return device

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.getNetworkPrinterMakeModel (   self,
  host = None,
  device = None 
)
Try to determine the make and model for the currently selected
network printer, and store this in the data structure for the
printer.
Returns (hostname or None, uri or None).

Definition at line 1508 of file newprinter.py.

01508 
01509     def getNetworkPrinterMakeModel(self, host=None, device=None):
01510         """
01511         Try to determine the make and model for the currently selected
01512         network printer, and store this in the data structure for the
01513         printer.
01514         Returns (hostname or None, uri or None).
01515         """
01516         uri = None
01517         if device == None:
01518             device = self.device
01519         # Determine host name/IP
01520         if host == None:
01521             s = device.uri.find ("://")
01522             if s != -1:
01523                 s += 3
01524                 e = device.uri[s:].find (":")
01525                 if e == -1: e = device.uri[s:].find ("/")
01526                 if e == -1: e = device.uri[s:].find ("?")
01527                 if e == -1: e = len (device.uri)
01528                 host = device.uri[s:s+e]
01529         # Try to get make and model via SNMP
01530         if host:
01531             args = ["/usr/lib/cups/backend/snmp", host]
01532             debugprint (host + ": " + repr(args))
01533             stdout = None
01534             try:
01535                 p = subprocess.Popen (args, close_fds=True,
01536                                       stdin=file("/dev/null"),
01537                                       stdout=subprocess.PIPE,
01538                                       stderr=subprocess.PIPE)
01539                 (stdout, stderr) = p.communicate ()
01540                 if p.returncode != 0:
01541                     stdout = None
01542             except:
01543                 # Problem executing command.
01544                 pass
01545 
01546             if stdout != None:
01547                 line = stdout.strip ()
01548                 words = probe_printer.wordsep (line)
01549                 n = len (words)
01550                 if n < 4:
01551                     words.extend (['','','',''])
01552                     words = words[:4]
01553                     n = 4
01554                 elif n > 6:
01555                     words = words[:6]
01556                     n = 6
01557 
01558                 if n == 6:
01559                     (device_class, uri, make_and_model,
01560                      info, device_id, device_location) = words
01561                 elif n == 5:
01562                     (device_class, uri, make_and_model,
01563                      info, device_id) = words
01564                 elif n == 4:
01565                     (device_class, uri, make_and_model, info) = words
01566 
01567                 if n == 4:
01568                     # No Device ID given so we'll have to make one
01569                     # up.
01570                     debugprint ("No Device ID from snmp backend")
01571                     (mk, md) = cupshelpers.ppds.\
01572                         ppdMakeModelSplit (make_and_model)
01573                     device.id = "MFG:%s;MDL:%s;DES:%s %s;" % (mk, md,
01574                                                               mk, md)
01575                 else:
01576                     debugprint ("Got Device ID: %s" % device_id)
01577                     device.id = device_id
01578 
01579                 device.id_dict = cupshelpers.parseDeviceID (device.id)
01580                 device.make_and_model = make_and_model
01581                 device.info = info
01582                 if n == 6:
01583                     device.location = device_location
01584 
01585         return (host, uri)

Here is the caller graph for this function:

Definition at line 3334 of file newprinter.py.

03334 
03335     def getNPPPD(self):
03336         try:
03337             if self.rbtnNPFoomatic.get_active():
03338                 model, iter = self.tvNPDrivers.get_selection().get_selected()
03339                 nr = model.get_path(iter)[0]
03340                 ppd = self.NPDrivers[nr]
03341             elif self.rbtnNPPPD.get_active():
03342                 ppd = cups.PPD(self.filechooserPPD.get_filename())
03343             else:
03344                 # PPD of the driver downloaded from OpenPrinting XXX
03345                 treeview = self.tvNPDownloadableDrivers
03346                 model, iter = treeview.get_selection ().get_selected ()
03347                 driver = model.get_value (iter, 1)
03348                 if driver.has_key ('ppds'):
03349                     # Only need to download a PPD.
03350                     if (len(driver['ppds']) > 0):
03351                         file_to_download = driver['ppds'][0]
03352                         debugprint ("ppd file to download [" + file_to_download+ "]")
03353                         file_to_download = file_to_download.strip()
03354                         if (len(file_to_download) > 0):
03355                             ppdurlobj = urllib.urlopen(file_to_download)
03356                             ppdcontent = ppdurlobj.read()
03357                             ppdurlobj.close()
03358                             (tmpfd, ppdname) = tempfile.mkstemp()
03359                             debugprint(ppdname)
03360                             ppdfile = os.fdopen(tmpfd, 'w')
03361                             ppdfile.write(ppdcontent)
03362                             ppdfile.close()
03363                             ppd = cups.PPD(ppdname)
03364                             os.unlink(ppdname)
03365 
03366         except RuntimeError, e:
03367             debugprint ("RuntimeError: " + str(e))
03368             if self.rbtnNPFoomatic.get_active():
03369                 # Foomatic database problem of some sort.
03370                 err_title = _('Database error')
03371                 err_text = _("The '%s' driver cannot be "
03372                              "used with printer '%s %s'.")
03373                 model, iter = (self.tvNPDrivers.get_selection().
03374                                get_selected())
03375                 nr = model.get_path(iter)[0]
03376                 driver = self.NPDrivers[nr]
03377                 if driver.startswith ("gutenprint"):
03378                     # This printer references some XML that is not
03379                     # installed by default.  Point the user at the
03380                     # package they need to install.
03381                     err = _("You will need to install the '%s' package "
03382                             "in order to use this driver.") % \
03383                             "gutenprint-foomatic"
03384                 else:
03385                     err = err_text % (driver, self.NPMake, self.NPModel)
03386             elif self.rbtnNPPPD.get_active():
03387                 # This error came from trying to open the PPD file.
03388                 err_title = _('PPD error')
03389                 filename = self.filechooserPPD.get_filename()
03390                 err = _('Failed to read PPD file.  Possible reason '
03391                         'follows:') + '\n'
03392                 try:
03393                     # We want this to be in the current natural language,
03394                     # so we intentionally don't set LC_ALL=C here.
03395                     p = subprocess.Popen (['/usr/bin/cupstestppd',
03396                                            '-rvv', filename],
03397                                           close_fds=True,
03398                                           stdin=file("/dev/null"),
03399                                           stdout=subprocess.PIPE,
03400                                           stderr=subprocess.PIPE)
03401                     (stdout, stderr) = p.communicate ()
03402                     err += stdout
03403                 except:
03404                     # Problem executing command.
03405                     raise
03406             else:
03407                 # Failed to get PPD downloaded from OpenPrinting XXX
03408                 err_title = _('Downloadable drivers')
03409                 err = _("Failed to download PPD.")
03410 
03411             show_error_dialog (err_title, err, self.NewPrinterWindow)
03412             return None
03413 
03414         debugprint("ppd: " + repr(ppd))
03415         if isinstance(ppd, str) or isinstance(ppd, unicode):
03416             self.cups._begin_operation (_("fetching PPD"))
03417             try:
03418                 if ppd != "raw":
03419                     f = self.cups.getServerPPD(ppd)
03420                     ppd = cups.PPD(f)
03421                     os.unlink(f)
03422             except RuntimeError:
03423                 nonfatalException()
03424                 debugprint ("libcups from CUPS 1.3 not available: never mind")
03425             except cups.IPPError:
03426                 nonfatalException()
03427                 debugprint ("CUPS 1.3 server not available: never mind")
03428 
03429             self.cups._end_operation ()
03430 
03431         return ppd

Here is the call graph for this function:

Here is the caller graph for this function:

def gui.GtkGUI.getWidgets (   self,
  widgets,
  domain = None 
) [inherited]

Definition at line 32 of file gui.py.

00032 
00033     def getWidgets(self, widgets, domain=None):
00034         ui_dir = os.environ.get ("SYSTEM_CONFIG_PRINTER_UI",
00035                                  os.path.join (pkgdata, "ui"))
00036         for xmlfile, names in widgets.iteritems ():
00037             bld = gtk.Builder ()
00038 
00039             if domain:
00040                 bld.set_translation_domain (domain)
00041 
00042             bld.add_from_file (os.path.join (ui_dir, xmlfile + ".ui"))
00043             for name in names:
00044                 widget = bld.get_object(name)
00045                 if widget is None:
00046                     raise ValueError, "Widget '%s' not found" % name
00047                 setattr(self, name, widget)
00048 
00049             try:
00050                 win = widget.get_top_level()
00051             except AttributeError:
00052                 win = None
00053             
00054             if win != None:
00055                 gtk.Window.set_focus_on_map(widget.get_top_level (),
00056                                             self.focus_on_map)
00057                 widget.show()
00058 
00059             bld.connect_signals (self)

Definition at line 464 of file newprinter.py.

00464 
00465     def inc_spinner_task (self):
00466         if self.spinner_count == 0:
00467             self.imgProcessWorking.show ()
00468             self.spinner.start ()
00469 
00470         self.spinner_count += 1

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.init (   self,
  dialog_mode,
  device_uri = None,
  name = None,
  ppd = None,
  devid = "",
  host = None,
  encryption = None,
  parent = None,
  xid = 0 
)

Definition at line 515 of file newprinter.py.

00515 
00516              devid="", host=None, encryption=None, parent=None, xid=0):
00517         if xid != 0:
00518             display = gtk.gdk.display_get_default ()
00519             parent = gtk.gdk.window_foreign_new_for_display (display, xid)
00520             debugprint ("Parent is %s" % parent)
00521             self.parent = parent
00522         else:
00523             self.parent = parent
00524             if not self.parent:
00525                 self.NewPrinterWindow.set_focus_on_map (False)
00526             
00527         self.dialog_mode = dialog_mode
00528         self.orig_ppd = ppd
00529         self.devid = devid
00530         self._host = host
00531         self._encryption = encryption
00532         self._name = name
00533         if not host:
00534             self._host = cups.getServer ()
00535         if not encryption:
00536             self._encryption = cups.getEncryption ()
00537 
00538         self.options = {} # keyword -> Option object
00539         self.changed = set()
00540         self.conflicts = set()
00541         self.fetchDevices_conn = None
00542         self.ppds = None
00543         self.ppdsmatch_result = None
00544         self.printer_finder = None
00545 
00546         # Get a current list of printers so that we can know whether
00547         # the chosen name is unique.
00548         try:
00549             self.cups = authconn.Connection (parent=self.NewPrinterWindow,
00550                                              host=self._host,
00551                                              encryption=self._encryption)
00552         except cups.HTTPError, (s,):
00553             show_HTTP_Error (s, self.parent)
00554             return False
00555         except RuntimeError:
00556             show_HTTP_Error (-1, self.parent)
00557             return False
00558         except Exception, e:
00559             nonfatalException (e)
00560             return False
00561 
00562         try:
00563             self.printers = cupshelpers.getPrinters (self.cups)
00564         except cups.IPPError, (e, m):
00565             show_IPP_Error (e, m, parent=self.parent)
00566             return False
00567 
00568         # Initialise widgets.
00569         self.lblNetworkFindSearching.hide ()
00570         self.entNPTNetworkHostname.set_sensitive (True)
00571         self.entNPTNetworkHostname.set_text ('')
00572         self.btnNetworkFind.set_sensitive (True)
00573         self.lblNetworkFindNotFound.hide ()
00574 
00575         # Clear out any previous list of makes.
00576         model = self.tvNPMakes.get_model()
00577         model.clear()
00578 
00579         if device_uri == None and dialog_mode in ['printer_with_uri',
00580                                                   'device',
00581                                                   'ppd']:
00582             raise RuntimeError
00583 
00584         combobox = self.cmbNPDownloadableDriverFoundPrinters
00585         combobox.set_model (gtk.ListStore (str, str))
00586         self.entNPDownloadableDriverSearch.set_text ('')
00587         button = self.btnNPDownloadableDriverSearch
00588         label = button.get_children ()[0].get_children ()[0].get_children ()[1]
00589         self.btnNPDownloadableDriverSearch_label = label
00590         label.set_text (_("Search"))
00591 
00592         if self.dialog_mode in ("printer", "printer_with_uri", "class"):
00593             if self.dialog_mode == "class":
00594                 name_proto = "class"
00595             else:
00596                 name_proto = "printer"
00597             self.entNPName.set_text (self.makeNameUnique(name_proto))
00598             self.entNPName.grab_focus()
00599             for widget in [self.entNPLocation,
00600                            self.entNPDescription,
00601                            self.entSMBURI, self.entSMBUsername,
00602                            self.entSMBPassword]:
00603                 widget.set_text('')
00604 
00605         if self.dialog_mode in ['printer_with_uri', 'ppd']:
00606             device_dict = { }
00607             self.device = cupshelpers.Device (device_uri, **device_dict)
00608 
00609         self.entNPTJetDirectPort.set_text('9100')
00610         self.rbtnSMBAuthPrompt.set_active(True)
00611 
00612         if xid != 0 and self.parent:
00613             self.NewPrinterWindow.show_now()
00614             self.NewPrinterWindow.window.set_transient_for (self.parent)
00615 
00616         if self.dialog_mode == "printer":
00617             self.NewPrinterWindow.set_title(_("New Printer"))
00618             # Start on devices page (1, not 0)
00619             self.ntbkNewPrinter.set_current_page(1)
00620             self.fillDeviceTab()
00621             self.rbtnNPFoomatic.set_active (True)
00622             self.on_rbtnNPFoomatic_toggled(self.rbtnNPFoomatic)
00623 
00624         elif self.dialog_mode == "class":
00625             self.NewPrinterWindow.set_title(_("New Class"))
00626             self.fillNewClassMembers()
00627             # Start on name page
00628             self.ntbkNewPrinter.set_current_page(0)
00629         elif self.dialog_mode == "device":
00630             self.NewPrinterWindow.set_title(_("Change Device URI"))
00631             self.ntbkNewPrinter.set_current_page(1)
00632             self.fillDeviceTab(device_uri)
00633         elif self.dialog_mode == "ppd" or \
00634             self.dialog_mode == "printer_with_uri":
00635             if self.dialog_mode == "ppd":
00636                 self.NewPrinterWindow.set_title(_("Change Driver"))
00637             else:
00638                 self.NewPrinterWindow.set_title(_("New Printer"))
00639 
00640             # We'll need to know the Device ID for this device.
00641             if self.dialog_mode == "ppd" and not self.devid:
00642                 scheme = str(device_uri.split (":", 1)[0])
00643                 schemes = [scheme]
00644                 if scheme in ["socket", "lpd", "ipp"]:
00645                     schemes.extend (["snmp", "dnssd"])
00646                 self.fetchDevices_conn = asyncconn.Connection ()
00647                 self.fetchDevices_conn._begin_operation (_("fetching device "
00648                                                            "list"))
00649                 self.inc_spinner_task ()
00650                 cupshelpers.getDevices (self.fetchDevices_conn,
00651                                         include_schemes=schemes,
00652                                         reply_handler=self.change_ppd_got_devs,
00653                                         error_handler=self.change_ppd_got_devs)
00654 
00655             self.ntbkNewPrinter.set_current_page(2)
00656             self.rbtnNPFoomatic.set_active (True)
00657             self.on_rbtnNPFoomatic_toggled(self.rbtnNPFoomatic)
00658             self.rbtnChangePPDKeepSettings.set_active(True)
00659 
00660             if self.dialog_mode == "printer_with_uri":
00661                 p = ppdsloader.PPDsLoader (device_id=devid,
00662                                            device_uri=device_uri,
00663                                            parent=self.NewPrinterWindow,
00664                                            host=self._host,
00665                                            encryption=self._encryption)
00666                 self.ppdsloader = p
00667                 p.connect ('finished',self.change_ppd_have_devs_and_ppds)
00668                 p.run ()
00669 
00670             self.auto_make = ""
00671             self.auto_model = ""
00672             self.auto_driver = None
00673 
00674         if xid == 0 and self.parent:
00675             self.NewPrinterWindow.set_transient_for (parent)
00676 
00677         self.NewPrinterWindow.show()
00678         self.setNPButtons()
00679         return True

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.local_devices_reply (   self,
  conn,
  result,
  current_uri 
)

Definition at line 1389 of file newprinter.py.

01389 
01390     def local_devices_reply (self, conn, result, current_uri):
01391         self.dec_spinner_task ()
01392 
01393         # Now we've got the local devices, start a request for the
01394         # network devices.
01395         self.fetchDevices (network=True, current_uri=current_uri)
01396 
01397         # Add the local devices to the list.
01398         self.add_devices (result, current_uri)

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.makeNameUnique (   self,
  name 
)
Make a suggested queue name valid and unique.

Definition at line 497 of file newprinter.py.

00497 
00498     def makeNameUnique(self, name):
00499         """Make a suggested queue name valid and unique."""
00500         name = name.replace (" ", "-")
00501         name = name.replace ("/", "-")
00502         name = name.replace ("#", "-")
00503         if not checkNPName (self.printers, name):
00504             suffix=2
00505             while not checkNPName (self.printers, name + "-" + str (suffix)):
00506                 suffix += 1
00507                 if suffix == 100:
00508                     break
00509             name += "-" + str (suffix)
00510         return name

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.network_devices_reply (   self,
  conn,
  result,
  current_uri 
)

Definition at line 1399 of file newprinter.py.

01399 
01400     def network_devices_reply (self, conn, result, current_uri):
01401         self.dec_spinner_task ()
01402         self.fetchDevices_conn._end_operation ()
01403         self.fetchDevices_conn.destroy ()
01404         self.fetchDevices_conn = None
01405 
01406         # Add the network devices to the list.
01407         no_more = True
01408         need_resolving = {}
01409         for uri, device in result.iteritems ():
01410             if uri.startswith ("dnssd://"):
01411                 need_resolving[uri] = device
01412                 no_more = False
01413 
01414         for uri in need_resolving.keys ():
01415             del result[uri]
01416 
01417         self.add_devices (result, current_uri, no_more=no_more)
01418 
01419         if len (need_resolving) > 0:
01420             resolver = dnssdresolve.DNSSDHostNamesResolver (need_resolving)
01421             resolver.resolve (reply_handler=lambda devices:
01422                                   self.dnssd_resolve_reply (current_uri,
01423                                                             devices))

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.nextNPTab (   self,
  step = 1 
)

Definition at line 889 of file newprinter.py.

00889 
00890     def nextNPTab(self, step=1):
00891         page_nr = self.ntbkNewPrinter.get_current_page()
00892 
00893         if self.dialog_mode == "class":
00894             order = [0, 4, 5]
00895         elif self.dialog_mode == "printer" or \
00896                 self.dialog_mode == "printer_with_uri":
00897             busy (self.NewPrinterWindow)
00898             if page_nr == 1: # Device (first page)
00899                 self.auto_make, self.auto_model = "", ""
00900                 self.auto_driver = None
00901                 self.device.uri = self.getDeviceURI()
00902 
00903                 # Cancel the printer finder now as the user has
00904                 # already selected their device.
00905                 if self.printer_finder:
00906                     self.printer_finder.cancel ()
00907                     self.printer_finder = None
00908                     self.dec_spinner_task ()
00909 
00910                 if (not self.device.id and
00911                     self.device.type in ["socket", "lpd", "ipp"]):
00912                     # This is a network printer whose model we don't yet know.
00913                     # Try to discover it.
00914                     self.getNetworkPrinterMakeModel ()
00915 
00916                 uri = self.device.uri
00917                 if uri and uri.startswith ("smb://"):
00918                     uri = SMBURI (uri=uri[6:]).sanitize_uri ()
00919 
00920                 # Try to access the PPD, in this case our detected IPP
00921                 # printer is a queue on a remote CUPS server which is
00922                 # not automatically set up on our local CUPS server
00923                 # (for example DNS-SD broadcasted queue from Mac OS X)
00924                 self.remotecupsqueue = None
00925                 res = re.search ("ipp://(\S+?)(:\d+|)/printers/(\S+)", uri)
00926                 if res:
00927                     resg = res.groups()
00928                     if len (resg[1]) > 0:
00929                         port = int (resg[1][1:])
00930                     else:
00931                         port = 631
00932                     try:
00933                         conn = httplib.HTTPConnection(resg[0], port)
00934                         conn.request("GET", "/printers/%s.ppd" % resg[2])
00935                         resp = conn.getresponse()
00936                         if resp.status == 200: self.remotecupsqueue = resg[2]
00937                     except:
00938                         pass
00939 
00940                     # We also want to fetch the printer-info and
00941                     # printer-location attributes, to pre-fill those
00942                     # fields for this new queue.
00943                     try:
00944                         encryption = cups.HTTP_ENCRYPT_IF_REQUESTED
00945                         c = cups.Connection (host=resg[0],
00946                                              port=port,
00947                                              encryption=encryption)
00948 
00949                         r = ['printer-info', 'printer-location']
00950                         attrs = c.getPrinterAttributes (uri=uri,
00951                                                         requested_attributes=r)
00952                         info = attrs.get ('printer-info', '')
00953                         location = attrs.get ('printer-location', '')
00954                         if len (info) > 0:
00955                             self.entNPDescription.set_text (info)
00956                         if len (location) > 0:
00957                             self.device.location = location
00958                     except RuntimeError:
00959                         pass
00960                     except:
00961                         nonfatalException ()
00962                 elif ((uri.startswith ("dnssd:") or uri.startswith("mdns:")) and
00963                       uri.find ("/cups") != -1 and
00964                       self.device.info):
00965                     # Remote CUPS queue discovered by "dnssd" CUPS backend
00966                     self.remotecupsqueue = self.device.info
00967 
00968                 if not self.remotecupsqueue:
00969                     if self.ppds == None:
00970                         devid = self.device.id # ID of selected device
00971                         if not devid:
00972                             devid = self.devid # ID supplied at init()
00973                         if not devid:
00974                             devid = None
00975 
00976                         debugprint ("nextNPTab: need PPDs loaded")
00977                         p = ppdsloader.PPDsLoader (device_id=devid,
00978                                                    device_uri=uri,
00979                                                    parent=self.NewPrinterWindow,
00980                                                    host=self._host,
00981                                                    encryption=self._encryption)
00982                         self.ppdsloader = p
00983                         p.connect ('finished',self.on_ppdsloader_finished_next)
00984                         p.run ()
00985                         ready (self.NewPrinterWindow)
00986                         return
00987 
00988                 if (hasattr (self.device, 'hp_scannable') and
00989                     self.device.hp_scannable and
00990                     not os.access ("/etc/sane.d/dll.d/hpaio", os.R_OK)):
00991                     try:
00992                         pk = installpackage.PackageKit ()
00993                         xid = self.NewPrinterWindow.window.xid
00994                         pk.InstallPackageName (xid, 0, "libsane-hpaio")
00995                     except:
00996                         pass
00997 
00998                 ppdname = None
00999                 self.id_matched_ppdnames = []
01000                 try:
01001                     if self.remotecupsqueue:
01002                         # We have a remote CUPS queue, let the client queue
01003                         # stay raw so that the driver on the server gets used
01004                         ppdname = 'raw'
01005                         self.ppd = ppdname
01006                         name = self.remotecupsqueue
01007                         name = self.makeNameUnique (name)
01008                         self.entNPName.set_text (name)
01009                     elif (self.device.id or
01010                           (self.device.make_and_model and
01011                            self.device.make_and_model != "Unknown")):
01012                         if self.device.id:
01013                             id_dict = self.device.id_dict
01014                         else:
01015                             id_dict = {}
01016                             (id_dict["MFG"],
01017                              id_dict["MDL"]) = cupshelpers.ppds.\
01018                                  ppdMakeModelSplit (self.device.make_and_model)
01019                             id_dict["DES"] = ""
01020                             id_dict["CMD"] = []
01021 
01022                         fit = self.ppds.\
01023                             getPPDNamesFromDeviceID (id_dict["MFG"],
01024                                                      id_dict["MDL"],
01025                                                      id_dict["DES"],
01026                                                      id_dict["CMD"],
01027                                                      self.device.uri,
01028                                                      self.device.make_and_model)
01029                         ppdnamelist = self.ppds.\
01030                             orderPPDNamesByPreference (fit.keys (),
01031                                                        self.jockey_installed_files,
01032                                                        devid=id_dict, fit=fit)
01033                         self.id_matched_ppdnames = ppdnamelist
01034                         ppdname = ppdnamelist[0]
01035                         status = fit[ppdname]
01036                     else:
01037                         (status, ppdname) = self.ppds.\
01038                             getPPDNameFromDeviceID ("Generic",
01039                                                     "Printer",
01040                                                     "Generic Printer",
01041                                                     [],
01042                                                     self.device.uri)
01043                         status = "generic"
01044 
01045                     if ppdname and not self.remotecupsqueue:
01046                         ppddict = self.ppds.getInfoFromPPDName (ppdname)
01047                         make_model = _singleton (ppddict['ppd-make-and-model'])
01048                         (make, model) = \
01049                             cupshelpers.ppds.ppdMakeModelSplit (make_model)
01050                         self.auto_make = make
01051                         self.auto_model = model
01052                         self.auto_driver = ppdname
01053                         if (status == "exact" and \
01054                             self.dialog_mode != "ppd"):
01055                             self.exactdrivermatch = True
01056                         else:
01057                             self.exactdrivermatch = False
01058                 except:
01059                     nonfatalException ()
01060 
01061                 if not self.remotecupsqueue:
01062                     self.fillMakeList()
01063             elif page_nr == 3: # Model has been selected
01064                 if not self.device.id:
01065                     # Choose an appropriate name when no Device ID
01066                     # is available, based on the model the user has
01067                     # selected.
01068                     try:
01069                         model, iter = self.tvNPModels.get_selection ().\
01070                                       get_selected ()
01071                         name = model.get(iter, 0)[0]
01072                         name = self.makeNameUnique (name)
01073                         self.entNPName.set_text (name)
01074                     except:
01075                         nonfatalException ()
01076 
01077             ready (self.NewPrinterWindow)
01078             if self.dialog_mode == "printer":
01079                 if self.remotecupsqueue:
01080                     order = [1, 0]
01081                 elif self.exactdrivermatch:
01082                     order = [1, 6, 0]
01083                 elif self.rbtnNPFoomatic.get_active():
01084                     order = [1, 2, 3, 6, 0]
01085                 elif self.rbtnNPPPD.get_active():
01086                     order = [1, 2, 6, 0]
01087                 else:
01088                     # Downloadable driver
01089                     order = [1, 2, 7, 6, 0]
01090             else:
01091                 if self.remotecupsqueue:
01092                     order = [0]
01093                 elif self.exactdrivermatch:
01094                     order = [6, 0]
01095                 elif self.rbtnNPFoomatic.get_active():
01096                     order = [2, 3, 6, 0]
01097                 elif self.rbtnNPPPD.get_active():
01098                     order = [2, 6, 0]
01099                 else:
01100                     # Downloadable driver
01101                     order = [2, 7, 6, 0]
01102         elif self.dialog_mode == "device":
01103             order = [1]
01104         elif self.dialog_mode == "ppd":
01105             if self.rbtnNPFoomatic.get_active():
01106                 order = [2, 3, 5, 6]
01107             elif self.rbtnNPPPD.get_active():
01108                 order = [2, 5, 6]
01109             else:
01110                 # Downloadable driver
01111                 order = [2, 7, 5, 6]
01112 
01113         next_page_nr = order[order.index(page_nr)+step]
01114 
01115         # fill Installable Options tab
01116         fetch_ppd = False
01117         try:
01118             if order.index (5) > -1:
01119                 # There is a copy settings page in this set
01120                 fetch_ppd = next_page_nr == 5 and step >= 0
01121         except ValueError:
01122             fetch_ppd = next_page_nr == 6 and step >= 0
01123 
01124         debugprint ("Will fetch ppd? %d" % fetch_ppd)
01125         if fetch_ppd:
01126             self.ppd = self.getNPPPD()
01127             self.installable_options = False
01128             if self.ppd == None:
01129                 return
01130 
01131             # Prepare Installable Options screen.
01132             if isinstance(self.ppd, cups.PPD):
01133                 self.fillNPInstallableOptions()
01134             else:
01135                 # Put a label there explaining why the page is empty.
01136                 ppd = self.ppd
01137                 self.ppd = None
01138                 self.fillNPInstallableOptions()
01139                 self.ppd = ppd
01140 
01141             if not self.installable_options:
01142                 if next_page_nr == 6:
01143                     # step over if empty
01144                     next_page_nr = order[order.index(next_page_nr)+1]
01145 
01146         # Step over empty Installable Options tab when moving backwards.
01147         if next_page_nr == 6 and not self.installable_options and step<0:
01148             next_page_nr = order[order.index(next_page_nr)-1]
01149 
01150         if step >= 0 and next_page_nr == 7: # About to show downloadable drivers
01151             if self.drivers_lock.locked ():
01152                 # Still searching for drivers.
01153                 self.lblWait.set_markup ('<span weight="bold" size="larger">' +
01154                                          _('Searching') + '</span>\n\n' +
01155                                          _('Searching for drivers'))
01156                 self.WaitWindow.set_transient_for (self.NewPrinterWindow)
01157                 self.WaitWindow.show ()
01158                 busy (self.WaitWindow)
01159                 busy (self.NewPrinterWindow)
01160 
01161                 # Keep the UI refreshed while we wait for the drivers
01162                 # query to complete.
01163                 while self.drivers_lock.locked ():
01164                     while gtk.events_pending ():
01165                         gtk.main_iteration ()
01166                     time.sleep (0.1)
01167 
01168                 ready (self.NewPrinterWindow)
01169                 self.WaitWindow.hide ()
01170 
01171             self.fillDownloadableDrivers()
01172 
01173         if step >= 0 and next_page_nr == 0: # About to choose a name.
01174             # Suggest an appropriate name.
01175             name = None
01176             descr = None
01177 
01178             try:
01179                 if (self.device.id and
01180                     not self.device.type in ("socket", "lpd", "ipp",
01181                                              "http", "https", "bluetooth")):
01182                     name = "%s %s" % (self.device.id_dict["MFG"], 
01183                                       self.device.id_dict["MDL"])
01184             except:
01185                 nonfatalException ()
01186 
01187             try:
01188                 if name == None and isinstance (self.ppd, cups.PPD):
01189                     mname = self.ppd.findAttr ("modelName").value
01190                     make, model = cupshelpers.ppds.ppdMakeModelSplit (mname)
01191                     if make and model:
01192                         name = "%s %s" % (make, model)
01193                     elif make or model:
01194                         name = "%s%s" % (make, model)
01195             except:
01196                 nonfatalException ()
01197 
01198             if name:
01199                 descr = name
01200             else:
01201                 name = 'printer'
01202 
01203             name = self.makeNameUnique (name)
01204             self.entNPName.set_text (name)
01205 
01206             if self.entNPDescription.get_text () == '' and descr:
01207                 self.entNPDescription.set_text (descr)
01208 
01209         self.ntbkNewPrinter.set_current_page(next_page_nr)
01210 
01211         self.setNPButtons()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 834 of file newprinter.py.

00834 
00835     def on_btnNCAddMember_clicked(self, button):
00836         moveClassMembers(self.tvNCNotMembers, self.tvNCMembers)
00837         self.btnNPApply.set_sensitive(
00838             bool(getCurrentClassMembers(self.tvNCMembers)))
00839         button.set_sensitive(False)

Here is the call graph for this function:

Definition at line 840 of file newprinter.py.

00840 
00841     def on_btnNCDelMember_clicked(self, button):
00842         moveClassMembers(self.tvNCMembers, self.tvNCNotMembers)
00843         self.btnNPApply.set_sensitive(
00844             bool(getCurrentClassMembers(self.tvNCMembers)))
00845         button.set_sensitive(False)

Here is the call graph for this function:

Definition at line 2674 of file newprinter.py.

02674 
02675     def on_btnNetworkFind_clicked(self, button):
02676         host = self.entNPTNetworkHostname.get_text ()
02677 
02678         def found_callback (new_device):
02679             if self.printer_finder == None:
02680                 return
02681 
02682             gobject.idle_add (self.found_network_printer_callback, new_device)
02683 
02684         self.btnNetworkFind.set_sensitive (False)
02685         self.entNPTNetworkHostname.set_sensitive (False)
02686         self.network_found = 0
02687         self.lblNetworkFindNotFound.hide ()
02688         self.lblNetworkFindSearching.show_all ()
02689         finder = probe_printer.PrinterFinder ()
02690         self.inc_spinner_task ()
02691         finder.find (host, found_callback)
02692         self.printer_finder = finder

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_btnNPApply_clicked (   self,
  widget 
)

Definition at line 3490 of file newprinter.py.

03490 
03491     def on_btnNPApply_clicked(self, widget):
03492         if self.fetchDevices_conn:
03493             self.fetchDevices_conn.destroy ()
03494             self.fetchDevices_conn = None
03495             self.dec_spinner_task ()
03496 
03497         if self.ppdsloader:
03498             self.ppdsloader.destroy ()
03499             self.ppdsloader = None
03500 
03501         if self.printer_finder:
03502             self.printer_finder.cancel ()
03503             self.printer_finder = None
03504             self.dec_spinner_task ()
03505 
03506         if self.dialog_mode in ("class", "printer", "printer_with_uri"):
03507             name = unicode (self.entNPName.get_text())
03508             location = unicode (self.entNPLocation.get_text())
03509             info = unicode (self.entNPDescription.get_text())
03510         else:
03511             name = self._name
03512 
03513         # Whether to check for missing drivers.
03514         check = False
03515         checkppd = None
03516         ppd = self.ppd
03517 
03518         if self.dialog_mode == "class":
03519             members = getCurrentClassMembers(self.tvNCMembers)
03520             try:
03521                 for member in members:
03522                     self.cups.addPrinterToClass(member, name)
03523             except cups.IPPError, (e, msg):
03524                 self.show_IPP_Error(e, msg)
03525                 return
03526         elif self.dialog_mode == "printer" or \
03527                 self.dialog_mode == "printer_with_uri":
03528             uri = None
03529             if self.device.uri:
03530                 uri = self.device.uri
03531             else:
03532                 uri = self.getDeviceURI()
03533             if not self.ppd: # XXX needed?
03534                 # Go back to previous page to re-select driver.
03535                 self.nextNPTab(-1)
03536                 return
03537 
03538             # write Installable Options to ppd
03539             for option in self.options.itervalues():
03540                 option.writeback()
03541 
03542             busy (self.NewPrinterWindow)
03543             while gtk.events_pending ():
03544                 gtk.main_iteration ()
03545             self.cups._begin_operation (_("adding printer %s") % name)
03546             try:
03547                 if isinstance(ppd, str) or isinstance(ppd, unicode):
03548                     self.cups.addPrinter(name, ppdname=ppd,
03549                          device=uri, info=info, location=location)
03550                     check = True
03551                 elif ppd is None: # raw queue
03552                     self.cups.addPrinter(name, device=uri,
03553                                          info=info, location=location)
03554                 else:
03555                     cupshelpers.setPPDPageSize(ppd, self.language[0])
03556                     self.cups.addPrinter(name, ppd=ppd, device=uri,
03557                                          info=info, location=location)
03558                     check = True
03559                     checkppd = ppd
03560             except cups.IPPError, (e, msg):
03561                 ready (self.NewPrinterWindow)
03562                 self.show_IPP_Error(e, msg)
03563                 self.cups._end_operation()
03564                 return
03565             except:
03566                 ready (self.NewPrinterWindow)
03567                 self.cups._end_operation()
03568                 fatalException (1)
03569             self.cups._end_operation()
03570             ready (self.NewPrinterWindow)
03571         if self.dialog_mode in ("class", "printer", "printer_with_uri"):
03572             self.cups._begin_operation (_("modifying printer %s") % name)
03573             try:
03574                 cupshelpers.activateNewPrinter (self.cups, name)
03575                 self.cups.setPrinterLocation(name, location)
03576                 self.cups.setPrinterInfo(name, info)
03577             except cups.IPPError, (e, msg):
03578                 self.show_IPP_Error(e, msg)
03579                 self.cups._end_operation ()
03580                 return
03581             self.cups._end_operation ()
03582         elif self.dialog_mode == "device":
03583             self.cups._begin_operation (_("modifying printer %s") % name)
03584             try:
03585                 uri = self.getDeviceURI()
03586                 self.cups.addPrinter(name, device=uri)
03587             except cups.IPPError, (e, msg):
03588                 self.show_IPP_Error(e, msg)
03589                 self.cups._end_operation ()
03590                 return
03591             self.cups._end_operation ()
03592         elif self.dialog_mode == "ppd":
03593             if not ppd:
03594                 ppd = self.ppd = self.getNPPPD()
03595                 if not ppd:
03596                     # Go back to previous page to re-select driver.
03597                     self.nextNPTab(-1)
03598                     return
03599 
03600             self.cups._begin_operation (_("modifying printer %s") % name)
03601             # set ppd on server and retrieve it
03602             # cups doesn't offer a way to just download a ppd ;(=
03603             raw = False
03604             if isinstance(ppd, str) or isinstance(ppd, unicode):
03605                 if self.rbtnChangePPDasIs.get_active():
03606                     # To use the PPD as-is we need to prevent CUPS copying
03607                     # the old options over.  Do this by setting it to a
03608                     # raw queue (no PPD) first.
03609                     try:
03610                         self.cups.addPrinter(name, ppdname='raw')
03611                     except cups.IPPError, (e, msg):
03612                         self.show_IPP_Error(e, msg)
03613                 try:
03614                     self.cups.addPrinter(name, ppdname=ppd)
03615                 except cups.IPPError, (e, msg):
03616                     self.show_IPP_Error(e, msg)
03617                     self.cups._end_operation ()
03618                     return
03619 
03620                 try:
03621                     filename = self.cups.getPPD(name)
03622                     ppd = cups.PPD(filename)
03623                     os.unlink(filename)
03624                 except cups.IPPError, (e, msg):
03625                     if e == cups.IPP_NOT_FOUND:
03626                         raw = True
03627                     else:
03628                         self.show_IPP_Error(e, msg)
03629                         self.cups._end_operation ()
03630                         return
03631             else:
03632                 # We have an actual PPD to upload, not just a name.
03633                 if ((not self.rbtnChangePPDasIs.get_active()) and
03634                     isinstance (self.orig_ppd, cups.PPD)):
03635                     cupshelpers.copyPPDOptions(self.orig_ppd, ppd)
03636                 else:
03637                     cupshelpers.setPPDPageSize(ppd, self.language[0])
03638 
03639                 # write Installable Options to ppd
03640                 for option in self.options.itervalues():
03641                     option.writeback()
03642 
03643                 try:
03644                     self.cups.addPrinter(name, ppd=ppd)
03645                 except cups.IPPError, (e, msg):
03646                     self.show_IPP_Error(e, msg)
03647                     self.cups._end_operation ()
03648                     return
03649 
03650             self.cups._end_operation ()
03651 
03652             if not raw:
03653                 check = True
03654                 checkppd = ppd
03655 
03656         self.NewPrinterWindow.hide()
03657         if self.dialog_mode in ["printer", "printer_with_uri", "class"]:
03658             self.emit ('printer-added', name)
03659         else:
03660             self.emit ('printer-modified', name, self.orig_ppd != self.ppd)
03661 
03662         self.device = None
03663         self.printers = {}

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_btnNPBack_clicked (   self,
  widget 
)

Definition at line 883 of file newprinter.py.

00883 
00884     def on_btnNPBack_clicked(self, widget):
00885         self.nextNPTab(-1)

Here is the call graph for this function:

Definition at line 2835 of file newprinter.py.

02835 
02836     def on_btnNPDownloadableDriverSearch_clicked(self, widget):
02837         if self.openprinting_query_handle != None:
02838             self.openprinting.cancelOperation (self.openprinting_query_handle)
02839             self.openprinting_query_handle = None
02840 
02841         widget.set_sensitive (False)
02842         label = self.btnNPDownloadableDriverSearch_label
02843         label.set_text (_("Searching"))
02844         searchterm = self.entNPDownloadableDriverSearch.get_text ()
02845         debugprint ('Searching for "%s"' % searchterm)
02846         self.drivers_lock.acquire (0)
02847         self.openprinting_query_handle = \
02848             self.openprinting.searchPrinters (searchterm,
02849                                               self.openprinting_printers_found)
02850         self.cmbNPDownloadableDriverFoundPrinters.set_sensitive (False)

Here is the call graph for this function:

Definition at line 886 of file newprinter.py.

00886 
00887     def on_btnNPForward_clicked(self, widget):
00888         self.nextNPTab()

Here is the call graph for this function:

Definition at line 2619 of file newprinter.py.

02619 
02620     def on_btnNPTLpdProbe_clicked(self, button):
02621         # read hostname, probe, fill printer names
02622         hostname = self.entNPTLpdHost.get_text()
02623         server = probe_printer.LpdServer(hostname)
02624 
02625         self.lblWait.set_markup ('<span weight="bold" size="larger">' +
02626                                  _('Searching') + '</span>\n\n' +
02627                                  _('Searching for printers'))
02628         self.WaitWindow.set_transient_for (self.NewPrinterWindow)
02629         self.WaitWindow.show_now ()
02630         busy (self.WaitWindow)
02631         def stop (widget, event):
02632             server.destroy ()
02633             return True
02634 
02635         self.WaitWindow.disconnect (self.WaitWindow_handler)
02636         signal = self.WaitWindow.connect ("delete-event", stop)
02637         printers = server.probe()
02638         self.WaitWindow.disconnect (signal)
02639         self.WaitWindow_handler = self.WaitWindow.connect ("delete-event",
02640                                                            on_delete_just_hide)
02641         self.WaitWindow.hide ()
02642 
02643         model = gtk.ListStore (gobject.TYPE_STRING)
02644         for printer in printers:
02645             model.append ([printer])
02646 
02647         completion = gtk.EntryCompletion ()
02648         completion.set_model (model)
02649         completion.set_text_column (0)
02650         completion.set_minimum_key_length (0)
02651         self.entNPTLpdQueue.set_completion (completion)

Definition at line 2067 of file newprinter.py.

02067 
02068     def on_btnSMBBrowse_clicked(self, button):
02069         self.btnSMBBrowseOk.set_sensitive(False)
02070 
02071         try:
02072             # Note: we do the browsing from *this* machine, regardless
02073             # of which CUPS server we are connected to.
02074             f = firewall.Firewall ()
02075             allowed = f.check_samba_client_allowed ()
02076             secondary_text = TEXT_adjust_firewall + "\n\n"
02077             if not allowed:
02078                 dialog = gtk.MessageDialog (self.NewPrinterWindow,
02079                                             gtk.DIALOG_MODAL |
02080                                             gtk.DIALOG_DESTROY_WITH_PARENT,
02081                                             gtk.MESSAGE_QUESTION,
02082                                             gtk.BUTTONS_NONE,
02083                                             _("Adjust Firewall"))
02084                 secondary_text += ("- " +
02085                                    _("Allow all incoming SMB/CIFS "
02086                                      "browse packets"))
02087                 dialog.format_secondary_markup (secondary_text)
02088                 dialog.add_buttons (_("Do It Later"), gtk.RESPONSE_NO,
02089                                     _("Adjust Firewall"), gtk.RESPONSE_YES)
02090                 response = dialog.run ()
02091                 dialog.destroy ()
02092 
02093                 if response == gtk.RESPONSE_YES:
02094                     f.add_rule (f.ALLOW_SAMBA_CLIENT)
02095                     f.write ()
02096         except (dbus.DBusException, Exception):
02097             nonfatalException ()
02098 
02099         self.SMBBrowseDialog.show()
02100         self.browse_smb_hosts()

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_btnSMBBrowseCancel_clicked (   self,
  widget,
  args 
)

Definition at line 2131 of file newprinter.py.

02131 
02132     def on_btnSMBBrowseCancel_clicked(self, widget, *args):
02133         self.SMBBrowseDialog.hide()

Definition at line 2101 of file newprinter.py.

02101 
02102     def on_btnSMBBrowseOk_clicked(self, button):
02103         store, iter = self.tvSMBBrowser.get_selection().get_selected()
02104         is_share = False
02105         if iter:
02106             entry = store.get_value (iter, 0)
02107             if entry:
02108                 is_share = entry.smbc_type == pysmb.smbc.PRINTER_SHARE
02109 
02110         if not iter or not is_share:
02111             self.SMBBrowseDialog.hide()
02112             return
02113 
02114         parent_iter = store.iter_parent (iter)
02115         domain_iter = store.iter_parent (parent_iter)
02116         share = store.get_value (iter, 0)
02117         host = store.get_value (parent_iter, 0)
02118         if domain_iter:
02119             group = store.get_value (domain_iter, 0).name
02120         else:
02121             group = ''
02122         uri = SMBURI (group=group,
02123                       host=host.name,
02124                       share=share.name).get_uri ()
02125 
02126         self.entSMBUsername.set_text ('')
02127         self.entSMBPassword.set_text ('')
02128         self.entSMBURI.set_text (uri)
02129 
02130         self.SMBBrowseDialog.hide()

Definition at line 2134 of file newprinter.py.

02134 
02135     def on_btnSMBBrowseRefresh_clicked(self, button):
02136         self.browse_smb_hosts()

Here is the call graph for this function:

Definition at line 2140 of file newprinter.py.

02140 
02141     def on_btnSMBVerify_clicked(self, button):
02142         uri = self.entSMBURI.get_text ()
02143         (group, host, share, u, p) = SMBURI (uri=uri).separate ()
02144         user = ''
02145         passwd = ''
02146         reason = None
02147         auth_set = self.rbtnSMBAuthSet.get_active()
02148         if auth_set:
02149             user = self.entSMBUsername.get_text ()
02150             passwd = self.entSMBPassword.get_text ()
02151 
02152         accessible = False
02153         canceled = False
02154         busy (self.NewPrinterWindow)
02155         try:
02156             debug = 0
02157             if get_debugging ():
02158                 debug = 10
02159 
02160             if auth_set:
02161                 # No prompting.
02162                 def do_auth (svr, shr, wg, un, pw):
02163                     return (group, user, passwd)
02164                 ctx = pysmb.smbc.Context (debug=debug, auth_fn=do_auth)
02165                 try:
02166                     ctx.optionUseKerberos = True
02167                 except AttributeError:
02168                     # requires pysmbc >= 1.0.12
02169                     pass
02170 
02171                 f = ctx.open ("smb://%s/%s" % (host, share),
02172                               os.O_RDWR, 0777)
02173                 accessible = True
02174             else:
02175                 # May need to prompt.
02176                 smbc_auth = pysmb.AuthContext (self.NewPrinterWindow,
02177                                                workgroup=group,
02178                                                user=user,
02179                                                passwd=passwd)
02180                 ctx = pysmb.smbc.Context (debug=debug,
02181                                           auth_fn=smbc_auth.callback)
02182                 while smbc_auth.perform_authentication () > 0:
02183                     try:
02184                         f = ctx.open ("smb://%s/%s" % (host, share),
02185                                       os.O_RDWR, 0777)
02186                         accessible = True
02187                     except Exception, e:
02188                         smbc_auth.failed (e)
02189 
02190                 if not accessible:
02191                     canceled = True
02192         except RuntimeError, (e, s):
02193             debugprint ("Error accessing share: %s" % repr ((e, s)))
02194             reason = s
02195         except:
02196             nonfatalException()
02197         ready (self.NewPrinterWindow)
02198 
02199         if accessible:
02200             show_info_dialog (_("Print Share Verified"),
02201                               _("This print share is accessible."),
02202                               parent=self.NewPrinterWindow)
02203             return
02204 
02205         if not canceled:
02206             text = _("This print share is not accessible.")
02207             if reason:
02208                 text = reason
02209             show_error_dialog (_("Print Share Inaccessible"), text,
02210                                parent=self.NewPrinterWindow)

Here is the call graph for this function:

Definition at line 2959 of file newprinter.py.

02959 
02960     def on_cmbNPDownloadableDriverFoundPrinters_changed(self, widget):
02961         self.setNPButtons ()
02962 
02963         if self.openprinting_query_handle != None:
02964             self.openprinting.cancelOperation (self.openprinting_query_handle)
02965             self.openprinting_query_handle = None
02966             self.drivers_lock.release()

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_entNPName_changed (   self,
  widget 
)

Definition at line 1340 of file newprinter.py.

01340 
01341     def on_entNPName_changed(self, widget):
01342         # restrict
01343         text = unicode (widget.get_text())
01344         new_text = text
01345         new_text = new_text.replace("/", "")
01346         new_text = new_text.replace("#", "")
01347         new_text = new_text.replace(" ", "")
01348         if text!=new_text:
01349             widget.set_text(new_text)
01350         if self.dialog_mode == "printer":
01351             self.btnNPApply.set_sensitive(
01352                 checkNPName(self.printers, new_text))
01353         else:
01354             self.btnNPForward.set_sensitive(
01355                 checkNPName(self.printers, new_text))

Here is the call graph for this function:

Definition at line 2226 of file newprinter.py.

02226 
02227     def on_entNPTDevice_changed(self, ent):
02228         allowed_chars = string.letters+string.digits+'_-./:%()@?=&'
02229         self.entry_changed(ent, allowed_chars)
02230         self.setNPButtons()

Here is the call graph for this function:

Definition at line 2231 of file newprinter.py.

02231 
02232     def on_entNPTJetDirectHostname_changed(self, ent):
02233         allowed_chars = string.letters+string.digits+'_-.'
02234         self.entry_changed(ent, allowed_chars)
02235         self.setNPButtons()

Here is the call graph for this function:

Definition at line 2236 of file newprinter.py.

02236 
02237     def on_entNPTJetDirectPort_changed(self, ent):
02238         self.entry_changed(ent, string.digits)
02239         self.setNPButtons()

Here is the call graph for this function:

Definition at line 2611 of file newprinter.py.

02611 
02612     def on_entNPTLpdHost_changed(self, ent):
02613         hostname = ent.get_text()
02614         self.btnNPTLpdProbe.set_sensitive (len (hostname) > 0)
02615         self.setNPButtons()

Here is the call graph for this function:

Definition at line 2616 of file newprinter.py.

02616 
02617     def on_entNPTLpdQueue_changed(self, ent):
02618         self.setNPButtons()

Here is the call graph for this function:

Find Network Printer.

Definition at line 2653 of file newprinter.py.

02653 
02654     def on_entNPTNetworkHostname_changed(self, ent):
02655         text = ent.get_text ()
02656         if text.find (":") != -1:
02657             # The user is typing in a URI.  In that case, switch to URI entry.
02658             ent.set_text ('')
02659             debugprint ("URI detected (%s) -> Enter URI" % text)
02660             self.entNPTDevice.set_text (text)
02661             model = self.tvNPDevices.get_model ()
02662             path = model.get_path (self.devices_uri_iter)
02663             self.tvNPDevices.set_cursor (path)
02664             self.entNPTDevice.select_region (0, 0)
02665             self.entNPTDevice.set_position (-1)
02666             return
02667 
02668         allowed_chars = string.letters+string.digits+'_-.'
02669         self.entry_changed(ent, allowed_chars)
02670         s = ent.get_text ()
02671         self.btnNetworkFind.set_sensitive (len (s) > 0)
02672         self.lblNetworkFindNotFound.hide ()
02673         self.setNPButtons ()

Here is the call graph for this function:

Definition at line 2038 of file newprinter.py.

02038 
02039     def on_entSMBURI_changed (self, ent):
02040         allowed_chars = string.letters+string.digits+'_-./:@%'
02041         self.entry_changed(ent, allowed_chars)
02042         uri = ent.get_text ()
02043         (group, host, share, user, password) = SMBURI (uri=uri).separate ()
02044         if user:
02045             self.entSMBUsername.set_text (user)
02046         if password:
02047             self.entSMBPassword.set_text (password)
02048         if user or password:
02049             uri = SMBURI (group=group, host=host, share=share).get_uri ()
02050             ent.set_text(uri)
02051             self.rbtnSMBAuthSet.set_active(True)
02052         elif self.entSMBUsername.get_text () == '':
02053             self.rbtnSMBAuthPrompt.set_active(True)
02054 
02055         self.btnSMBVerify.set_sensitive(bool(uri))
02056         self.setNPButtons ()

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_expNPDeviceURIs_expanded (   self,
  widget,
  UNUSED 
)

Definition at line 2240 of file newprinter.py.

02240 
02241     def on_expNPDeviceURIs_expanded (self, widget, UNUSED):
02242         # When the expanded is not expanded we want its packing to be
02243         # 'expand = false' so that it aligns at the bottom (it packs
02244         # to the end of its vbox).  But when it is expanded we'd like
02245         # it to expand with the window.
02246         #
02247         # Adjust its 'expand' packing state depending on whether the
02248         # widget is expanded.
02249 
02250         parent = widget.get_parent ()
02251         (expand, fill,
02252          padding, pack_type) = parent.query_child_packing (widget)
02253         expand = widget.get_expanded ()
02254         parent.set_child_packing (widget, expand, fill,
02255                                   padding, pack_type)

Definition at line 2832 of file newprinter.py.

02832 
02833     def on_filechooserPPD_selection_changed(self, widget):
02834         self.setNPButtons()

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_firewall_read (   self,
  data 
)

Definition at line 1638 of file newprinter.py.

01638 
01639     def on_firewall_read (self, data):
01640         f = self.firewall
01641         allowed = True
01642         try:
01643             ipp_allowed = f.check_ipp_client_allowed ()
01644             mdns_allowed = f.check_mdns_allowed ()
01645             allowed = (ipp_allowed and mdns_allowed)
01646 
01647             secondary_text = TEXT_adjust_firewall + "\n\n"
01648             if not ipp_allowed:
01649                 secondary_text += ("- " +
01650                                    _("Allow all incoming IPP Browse packets") +
01651                                    "\n")
01652                 f.add_rule (f.ALLOW_IPP_CLIENT)
01653             if not mdns_allowed:
01654                 secondary_text += ("- " +
01655                                    _("Allow all incoming mDNS traffic") + "\n")
01656                 f.add_rule (f.ALLOW_MDNS)
01657 
01658             if not allowed:
01659                 debugprint ("Asking for permission to adjust firewall:\n%s" %
01660                             secondary_text)
01661                 dialog = gtk.MessageDialog (self.NewPrinterWindow,
01662                                             gtk.DIALOG_MODAL |
01663                                             gtk.DIALOG_DESTROY_WITH_PARENT,
01664                                             gtk.MESSAGE_QUESTION,
01665                                             gtk.BUTTONS_NONE,
01666                                             _("Adjust Firewall"))
01667                 dialog.format_secondary_markup (secondary_text)
01668                 dialog.add_buttons (_("Do It Later"), gtk.RESPONSE_NO,
01669                                     _("Adjust Firewall"), gtk.RESPONSE_YES)
01670                 dialog.connect ('response', self.adjust_firewall_response)
01671                 dialog.show ()
01672         except (dbus.DBusException, Exception):
01673             nonfatalException ()
01674 
01675         if allowed:
01676             debugprint ("Firewall all OK; fetching devices")
01677             self.start_fetching_devices ()

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_NPCancel (   self,
  widget,
  event = None 
)

Definition at line 858 of file newprinter.py.

00858 
00859     def on_NPCancel(self, widget, event=None):
00860         if self.fetchDevices_conn:
00861             self.fetchDevices_conn.destroy ()
00862             self.fetchDevices_conn = None
00863             self.dec_spinner_task ()
00864 
00865         if self.ppdsloader:
00866             self.ppdsloader.destroy ()
00867             self.ppds_loader = None
00868 
00869         if self.printer_finder:
00870             self.printer_finder.cancel ()
00871             self.printer_finder = None
00872             self.dec_spinner_task ()
00873 
00874         self.NewPrinterWindow.hide()
00875         if self.openprinting_query_handle != None:
00876             self.openprinting.cancelOperation (self.openprinting_query_handle)
00877             self.openprinting_query_handle = None
00878 
00879         self.device = None
00880         self.printers = {}
00881         self.emit ('dialog-canceled')
00882         return True

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_NPDrivers_query_tooltip (   self,
  tv,
  x,
  y,
  keyboard_mode,
  tooltip 
)

Definition at line 3202 of file newprinter.py.

03202 
03203     def on_NPDrivers_query_tooltip(self, tv, x, y, keyboard_mode, tooltip):
03204         if keyboard_mode:
03205             path = tv.get_cursor()[0]
03206             if path is None:
03207                 return False
03208         else:
03209             bin_x, bin_y = tv.convert_widget_to_bin_window_coords(x, y)
03210             ret = tv.get_path_at_pos (bin_x, bin_y)
03211             if ret is None:
03212                 return False
03213             path = ret[0]
03214 
03215         drivername = self.NPDrivers[path[0]]
03216         ppddict = self.ppds.getInfoFromPPDName(drivername)
03217         markup = _singleton (ppddict['ppd-make-and-model'])
03218         if (drivername.startswith ("foomatic:")):
03219             markup += " "
03220             markup += _("This PPD is generated by foomatic.")
03221         tooltip.set_markup(markup)
03222         return True

This method is called when the PPDs loader has finished
loading PPDs in preparation for the first screen the user
sees.  We are either changing the PPD of an existing queue
(dialog_mode=="ppd") or else we are setting up a queue for a
given device URI (dialog_mode=="printer_with_uri").

Definition at line 680 of file newprinter.py.

00680 
00681     def on_ppdsloader_finished_initial (self, ppdsloader):
00682         """
00683         This method is called when the PPDs loader has finished
00684         loading PPDs in preparation for the first screen the user
00685         sees.  We are either changing the PPD of an existing queue
00686         (dialog_mode=="ppd") or else we are setting up a queue for a
00687         given device URI (dialog_mode=="printer_with_uri").
00688         """
00689 
00690         self._getPPDs_reply (ppdsloader)
00691         if not self.ppds:
00692             return

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_ppdsloader_finished_next (   self,
  ppdsloader 
)
This method is called when the PPDs loader has finished
loading PPDs in preparation for the next screen the user will
see, having clicked 'Forward'.  We are creating a new queue,
and dialog_mode is either "printer" or "printer_with_uri".

Definition at line 781 of file newprinter.py.

00781 
00782     def on_ppdsloader_finished_next (self, ppdsloader):
00783         """
00784         This method is called when the PPDs loader has finished
00785         loading PPDs in preparation for the next screen the user will
00786         see, having clicked 'Forward'.  We are creating a new queue,
00787         and dialog_mode is either "printer" or "printer_with_uri".
00788         """
00789 
00790         self._getPPDs_reply (ppdsloader)
00791         if not self.ppds:
00792             return
00793 
00794         debugprint ("Loaded PPDs this time; try nextNPTab again...")
00795         self.nextNPTab()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3011 of file newprinter.py.

03011 
03012     def on_rbtnNPDownloadLicense_toggled(self, widget):
03013         self.setNPButtons ()

Here is the call graph for this function:

Definition at line 2798 of file newprinter.py.

02798 
02799     def on_rbtnNPFoomatic_toggled(self, widget):
02800         rbtn1 = self.rbtnNPFoomatic.get_active()
02801         rbtn2 = self.rbtnNPPPD.get_active()
02802         rbtn3 = self.rbtnNPDownloadableDriverSearch.get_active()
02803         self.tvNPMakes.set_sensitive(rbtn1)
02804         self.filechooserPPD.set_sensitive(rbtn2)
02805 
02806         if rbtn1:
02807             page = 0
02808         if rbtn2:
02809             page = 1
02810         if rbtn3:
02811             page = 2
02812         self.ntbkPPDSource.set_current_page (page)
02813 
02814         if not rbtn3 and self.openprinting_query_handle:
02815             # Need to cancel a search in progress.
02816             self.openprinting.cancelOperation (self.openprinting_query_handle)
02817             self.openprinting_query_handle = None
02818             self.btnNPDownloadableDriverSearch_label.set_text (_("Search"))
02819             # Clear printer list.
02820             model = gtk.ListStore (str, str)
02821             combobox = self.cmbNPDownloadableDriverFoundPrinters
02822             combobox.set_model (model)
02823             combobox.set_sensitive (False)
02824 
02825         for widget in [self.entNPDownloadableDriverSearch,
02826                        self.cmbNPDownloadableDriverFoundPrinters]:
02827             widget.set_sensitive(rbtn3)
02828         self.btnNPDownloadableDriverSearch.\
02829             set_sensitive (rbtn3 and (self.openprinting_query_handle == None))
02830 
02831         self.setNPButtons()

Here is the call graph for this function:

Definition at line 2137 of file newprinter.py.

02137 
02138     def on_rbtnSMBAuthSet_toggled(self, widget):
02139         self.tblSMBAuth.set_sensitive(widget.get_active())

Definition at line 846 of file newprinter.py.

00846 
00847     def on_tvNCMembers_cursor_changed(self, widget):
00848         selection = widget.get_selection()
00849         model_from, rows = selection.get_selected_rows()
00850         self.btnNCDelMember.set_sensitive(rows != [])

Definition at line 851 of file newprinter.py.

00851 
00852     def on_tvNCNotMembers_cursor_changed(self, widget):
00853         selection = widget.get_selection()
00854         model_from, rows = selection.get_selected_rows()
00855         self.btnNCAddMember.set_sensitive(rows != [])

Definition at line 2278 of file newprinter.py.

02278 
02279     def on_tvNPDevices_cursor_changed(self, widget):
02280         self.device_selected += 1
02281         path, column = widget.get_cursor ()
02282         if path == None:
02283             return
02284 
02285         model = widget.get_model ()
02286         iter = model.get_iter (path)
02287         physicaldevice = model.get_value (iter, 1)
02288         if physicaldevice == None:
02289             return
02290         for device in physicaldevice.get_devices ():
02291             if device.type == "parallel":
02292                 device.menuentry = _("Parallel Port")
02293             elif device.type == "serial":
02294                 device.menuentry = _("Serial Port")
02295             elif device.type == "usb":
02296                 device.menuentry = _("USB")
02297             elif device.type == "bluetooth":
02298                 device.menuentry = _("Bluetooth")
02299             elif device.type == "hp":
02300                 device.menuentry = _("HP Linux Imaging and Printing (HPLIP)")
02301             elif device.type == "hpfax":
02302                 device.menuentry = _("Fax") + " - " + \
02303                     _("HP Linux Imaging and Printing (HPLIP)")
02304             elif device.type == "hal":
02305                 device.menuentry = _("Hardware Abstraction Layer (HAL)")
02306             elif device.type == "socket":
02307                 device.menuentry = _("AppSocket/HP JetDirect")
02308             elif device.type == "lpd":
02309                 (scheme, rest) = urllib.splittype (device.uri)
02310                 (hostport, rest) = urllib.splithost (rest)
02311                 (queue, rest) = urllib.splitquery (rest)
02312                 if queue != '':
02313                     if queue[0] == '/':
02314                         queue = queue[1:]
02315 
02316                     device.menuentry = _("LPD/LPR queue '%s'") % queue
02317                 else:
02318                     device.menuentry = _("LPD/LPR queue")
02319 
02320             elif device.type == "smb":
02321                 device.menuentry = _("Windows Printer via SAMBA")
02322             elif device.type == "ipp":
02323                 (scheme, rest) = urllib.splittype (device.uri)
02324                 (hostport, rest) = urllib.splithost (rest)
02325                 (queue, rest) = urllib.splitquery (rest)
02326                 if queue != '':
02327                     if queue[0] == '/':
02328                         queue = queue[1:]
02329                     if queue.startswith("printers/"):
02330                         queue = queue[9:]
02331                 if queue != '':
02332                     device.menuentry = _("IPP") + " (%s)" % queue
02333                 else:
02334                     device.menuentry = _("IPP")
02335             elif device.type == "http" or device.type == "https":
02336                 device.menuentry = _("HTTP")
02337             elif device.type == "dnssd" or device.type == "mdns":
02338                 (scheme, rest) = urllib.splittype (device.uri)
02339                 (name, rest) = urllib.splithost (rest)
02340                 (cupsqueue, rest) = urllib.splitquery (rest)
02341                 if cupsqueue[0] == '/':
02342                     cupsqueue = cupsqueue[1:]
02343                 if cupsqueue == 'cups':
02344                     device.menuentry = _("Remote CUPS printer via DNS-SD")
02345                     if device.info != '':
02346                          device.menuentry += " (%s)" % device.info
02347                 else:
02348                     protocol = None
02349                     if name.find("._ipp") != -1:
02350                         protocol = "IPP"
02351                     elif name.find("._printer") != -1:
02352                         protocol = "LPD"
02353                     elif name.find("._pdl-datastream") != -1:
02354                         protocol = "AppSocket/JetDirect"
02355                     if protocol != None:
02356                         device.menuentry = \
02357                             _("%s network printer via DNS-SD") % protocol
02358                     else:
02359                         device.menuentry = \
02360                             _("Network printer via DNS-SD")
02361             else:
02362                 device.menuentry = device.uri
02363 
02364         model = gtk.ListStore (str,                    # URI description
02365                                gobject.TYPE_PYOBJECT)  # cupshelpers.Device
02366         self.tvNPDeviceURIs.set_model (model)
02367 
02368         # If this is a network device, check whether HPLIP can drive it.
02369         if physicaldevice.get_data ('checked-hplip') != True:
02370             hp_drivable = False
02371             hp_scannable = False
02372             is_network = False
02373             remotecups = False
02374             host = None
02375             device_dict = { 'device-class': 'network' }
02376             if physicaldevice._network_host:
02377                 host = physicaldevice._network_host
02378             for device in physicaldevice.get_devices ():
02379                 if device.type == "hp":
02380                     # We already know that HPLIP can drive this device.
02381                     hp_drivable = True
02382 
02383                     # But can we scan using it?
02384                     if self.get_hplip_scan_type_for_uri (device.uri):
02385                         hp_scannable = True
02386 
02387                     break
02388                 elif device.type in ["socket", "lpd", "ipp", "dnssd", "mdns"]:
02389                     # This is a network printer.
02390                     if host == None and device.type in ["socket", "lpd", "ipp"]:
02391                         (scheme, rest) = urllib.splittype (device.uri)
02392                         (hostport, rest) = urllib.splithost (rest)
02393                         if hostport != None:
02394                             (host, port) = urllib.splitport (hostport)
02395                     if host:
02396                         is_network = True
02397                         remotecups = ((device.uri.startswith('dnssd:') or \
02398                                        device.uri.startswith('mdns:')) and \
02399                                       device.uri.endswith('/cups'))
02400                         if (not device.make_and_model or \
02401                             device.make_and_model == "Unknown") and not \
02402                            remotecups:
02403                             self.getNetworkPrinterMakeModel(host=host,
02404                                                             device=device)
02405                         device_dict['device-info'] = device.info
02406                         device_dict['device-make-and-model'] = (device.
02407                                                                 make_and_model)
02408                         device_dict['device-id'] = device.id
02409                         device_dict['device-location'] = device.location
02410 
02411             if not hp_drivable and is_network and not remotecups:
02412                 if (hasattr (physicaldevice, "dnssd_hostname") and \
02413                     physicaldevice.dnssd_hostname):
02414                     hpliphost = physicaldevice.dnssd_hostname
02415                 else:
02416                     hpliphost = host
02417                 hplipuri = self.get_hplip_uri_for_network_printer (hpliphost,
02418                                                                    "print")
02419                 if hplipuri:
02420                     dev = cupshelpers.Device (hplipuri, **device_dict)
02421                     dev.menuentry = "HP Linux Imaging and Printing (HPLIP)"
02422                     physicaldevice.add_device (dev)
02423 
02424                     # Now check to see if we can also send faxes using
02425                     # this device.
02426                     faxuri = self.get_hplip_uri_for_network_printer (hpliphost,
02427                                                                      "fax")
02428                     if faxuri:
02429                         faxdevid = self.get_hpfax_device_id (faxuri)
02430                         device_dict['device-id'] = faxdevid
02431                         device_dict['device-info'] = _("Fax")
02432                         faxdev = cupshelpers.Device (faxuri, **device_dict)
02433                         faxdev.menuentry = _("Fax") + " - " + \
02434                             "HP Linux Imaging and Printing (HPLIP)"
02435                         physicaldevice.add_device (faxdev)
02436 
02437             physicaldevice.set_data ('hp-scannable', True)
02438             physicaldevice.set_data ('checked-hplip', True)
02439 
02440         device.hp_scannable = physicaldevice.get_data ('hp-scannable')
02441 
02442         # Fill the list of connections for this device.
02443         n = 0
02444         for device in physicaldevice.get_devices ():
02445             model.append ((device.menuentry, device))
02446             n += 1
02447         column = self.tvNPDeviceURIs.get_column (0)
02448         self.tvNPDeviceURIs.set_cursor (0, column)
02449         if n > 1:
02450             self.expNPDeviceURIs.show_all ()
02451         else:
02452             self.expNPDeviceURIs.hide ()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2453 of file newprinter.py.

02453 
02454     def on_tvNPDeviceURIs_cursor_changed(self, widget):
02455         path, column = widget.get_cursor ()
02456         if path == None:
02457             return
02458 
02459         model = widget.get_model ()
02460         iter = model.get_iter (path)
02461         device = model.get_value(iter, 1)
02462         self.device = device
02463         self.lblNPDeviceDescription.set_text ('')
02464         page = self.new_printer_device_tabs.get(device.type, 1)
02465         self.ntbkNPType.set_current_page(page)
02466 
02467         location = ''
02468         type = device.type
02469         url = device.uri.split(":", 1)[-1]
02470         if page == 0:
02471             # This is the "no options" page, with just a label to describe
02472             # the selected device.
02473             if device.type == "parallel":
02474                 text = _("A printer connected to the parallel port.")
02475             elif device.type == "usb":
02476                 text = _("A printer connected to a USB port.")
02477             elif device.type == "bluetooth":
02478                 text = _("A printer connected via Bluetooth.")
02479             elif device.type == "hp":
02480                 text = _("HPLIP software driving a printer, "
02481                          "or the printer function of a multi-function device.")
02482             elif device.type == "hpfax":
02483                 text = _("HPLIP software driving a fax machine, "
02484                          "or the fax function of a multi-function device.")
02485             elif device.type == "hal":
02486                 text = _("Local printer detected by the "
02487                          "Hardware Abstraction Layer (HAL).")
02488             elif device.type == "dnssd" or device.type == "mdns":
02489                 (scheme, rest) = urllib.splittype (device.uri)
02490                 (name, rest) = urllib.splithost (rest)
02491                 (cupsqueue, rest) = urllib.splitquery (rest)
02492                 if cupsqueue[0] == '/':
02493                     cupsqueue = cupsqueue[1:]
02494                 if cupsqueue == 'cups':
02495                     text = _("Remote CUPS printer via DNS-SD")
02496                 else:
02497                     protocol = None
02498                     if name.find("._ipp") != -1:
02499                         protocol = "IPP"
02500                     elif name.find("._printer") != -1:
02501                         protocol = "LPD"
02502                     elif name.find("._pdl-datastream") != -1:
02503                         protocol = "AppSocket/JetDirect"
02504                     if protocol != None:
02505                         text = _("%s network printer via DNS-SD") % protocol
02506                     else:
02507                         text = _("Network printer via DNS-SD")
02508             else:
02509                 text = device.uri
02510 
02511             self.lblNPDeviceDescription.set_text (text)
02512         elif device.type=="socket":
02513             (scheme, rest) = urllib.splittype (device.uri)
02514             host = ''
02515             port = 9100
02516             if scheme == "socket":
02517                 (hostport, rest) = urllib.splithost (rest)
02518                 (host, port) = urllib.splitnport (hostport, defport=port)
02519                 debugprint ("socket: host is %s, port is %s" % (host,
02520                                                                 repr (port)))
02521                 if device.location != '':
02522                     location = device.location
02523                 else:
02524                     location = host
02525             self.entNPTJetDirectHostname.set_text (host)
02526             self.entNPTJetDirectPort.set_text (str (port))
02527         elif device.type=="serial":
02528             if not device.is_class:
02529                 options = device.uri.split("?")[1]
02530                 options = options.split("+")
02531                 option_dict = {}
02532                 for option in options:
02533                     name, value = option.split("=")
02534                     option_dict[name] = value
02535 
02536                 for widget, name, optionvalues in (
02537                     (self.cmbNPTSerialBaud, "baud", None),
02538                     (self.cmbNPTSerialBits, "bits", None),
02539                     (self.cmbNPTSerialParity, "parity",
02540                      ["none", "odd", "even"]),
02541                     (self.cmbNPTSerialFlow, "flow",
02542                      ["none", "soft", "hard", "hard"])):
02543                     if option_dict.has_key(name): # option given in URI?
02544                         if optionvalues is None: # use text in widget
02545                             model = widget.get_model()
02546                             iter = model.get_iter_first()
02547                             nr = 0
02548                             while iter:
02549                                 value = model.get(iter,0)[0]
02550                                 if value == option_dict[name]:
02551                                     widget.set_active(nr)
02552                                     break
02553                                 iter = model.iter_next(iter)
02554                                 nr += 1
02555 
02556                             if not iter:
02557                                 widget.set_active (0)
02558                         else: # use optionvalues
02559                             nr = optionvalues.index(
02560                                 option_dict[name])
02561                             widget.set_active(nr+1) # compensate "Default"
02562                     else:
02563                         widget.set_active(0)
02564 
02565         # XXX FILL TABS FOR VALID DEVICE URIs
02566         elif device.type=="lpd":
02567             self.entNPTLpdHost.set_text ('')
02568             self.entNPTLpdQueue.set_text ('')
02569             self.entNPTLpdQueue.set_completion (None)
02570             self.btnNPTLpdProbe.set_sensitive (False)
02571             if len (device.uri) > 6:
02572                 host = device.uri[6:]
02573                 i = host.find ("/")
02574                 if i != -1:
02575                     printer = host[i + 1:]
02576                     host = host[:i]
02577                 else:
02578                     printer = ""
02579                 self.entNPTLpdHost.set_text (host)
02580                 self.entNPTLpdQueue.set_text (printer)
02581                 location = host
02582                 self.btnNPTLpdProbe.set_sensitive (True)
02583         elif device.uri == "smb":
02584             self.entSMBURI.set_text('')
02585             self.btnSMBVerify.set_sensitive(False)
02586         elif device.type == "smb":
02587             self.entSMBUsername.set_text ('')
02588             self.entSMBPassword.set_text ('')
02589             self.entSMBURI.set_text(device.uri[6:])
02590             self.btnSMBVerify.set_sensitive(True)
02591         else:
02592             if device.uri:
02593                 self.entNPTDevice.set_text(device.uri)
02594 
02595         try:
02596             if len (location) == 0 and self.device.device_class == "direct":
02597                 # Set location to the name of this host.
02598                 if (self._host == 'localhost' or
02599                     self._host[0] == '/'):
02600                     u = os.uname ()
02601                     location = u[1]
02602                 else:
02603                     location = self._host
02604 
02605             # Pre-fill location field.
02606             self.entNPLocation.set_text (location)
02607         except:
02608             nonfatalException ()
02609 
02610         self.setNPButtons()

Here is the call graph for this function:

Definition at line 3241 of file newprinter.py.

03241 
03242     def on_tvNPDownloadableDrivers_cursor_changed(self, widget):
03243         model, iter = widget.get_selection ().get_selected ()
03244         if not iter:
03245             path, column = widget.get_cursor()
03246             iter = model.get_iter (path)
03247         driver = model.get_value (iter, 1)
03248         import pprint
03249         pprint.pprint (driver)
03250         self.ntbkNPDownloadableDriverProperties.set_current_page(1)
03251         supplier = driver.get('supplier', _("OpenPrinting"))
03252         vendor = self.cbNPDownloadableDriverSupplierVendor
03253         active = driver['manufacturersupplied']
03254 
03255         def set_protect_active (widget, active):
03256             widget.set_active (active)
03257             widget.set_data ('protect_active', active)
03258 
03259         set_protect_active (vendor, active)
03260         self.lblNPDownloadableDriverSupplier.set_text (supplier)
03261 
03262         license = driver.get('license', _("Distributable"))
03263         patents = self.cbNPDownloadableDriverLicensePatents
03264         free = self.cbNPDownloadableDriverLicenseFree
03265         set_protect_active (patents, driver['patents'])
03266         set_protect_active (free, driver['freesoftware'])
03267         self.lblNPDownloadableDriverLicense.set_text (license)
03268 
03269         description = driver.get('shortdescription', _("None"))
03270         self.lblNPDownloadableDriverDescription.set_markup (description)
03271 
03272         functionality = driver['functionality']
03273         for field in ["Graphics", "LineArt", "Photo", "Text"]:
03274             key = field.lower ()
03275             value = None
03276             hs = self.__dict__.get ("hsDownloadableDriverPerf%s" % field)
03277             unknown = self.__dict__.get ("lblDownloadableDriverPerf%sUnknown"
03278                                          % field)
03279             if functionality.has_key (key):
03280                 if hs:
03281                     try:
03282                         value = int (functionality[key])
03283                         hs.set_value (value)
03284                         hs.show_all ()
03285                         unknown.hide ()
03286                     except:
03287                         pass
03288 
03289             if value == None:
03290                 hs.hide ()
03291                 unknown.show_all ()
03292         supportcontacts = ""
03293         if driver.has_key ('supportcontacts'):
03294             for supportentry in driver['supportcontacts']:
03295                 if supportentry['name']:
03296                     supportcontact = " - " + supportentry['name']
03297                     supportcontact_extra = ""
03298                     if supportentry['url']:
03299                         supportcontact_extra = supportcontact_extra + \
03300                             supportentry['url']
03301                     if supportentry['level']:
03302                         if supportcontact_extra:
03303                             supportcontact_extra = supportcontact_extra + _(", ")
03304                         supportcontact_extra = supportcontact_extra + \
03305                             supportentry['level']
03306                     if supportcontact_extra:
03307                         supportcontact = supportcontact + \
03308                             _("\n(%s)") % supportcontact_extra
03309                         if supportcontacts:
03310                             supportcontacts = supportcontacts + "\n"
03311                         supportcontacts = supportcontacts + supportcontact
03312         if not supportcontacts:
03313             supportcontacts = _("No support contacts known")
03314         self.lblNPDownloadableDriverSupportContacts.set_text (supportcontacts)
03315         if driver.has_key ('licensetext'):
03316             self.frmNPDownloadableDriverLicenseTerms.show ()
03317             terms = driver.get('licensetext', _("Not specified."))
03318             self.tvNPDownloadableDriverLicense.get_buffer ().set_text (terms)
03319         else:
03320             self.frmNPDownloadableDriverLicenseTerms.hide ()
03321         if not driver['nonfreesoftware'] and not driver['patents']:
03322             self.rbtnNPDownloadLicenseYes.set_active (True)
03323             self.rbtnNPDownloadLicenseYes.hide ()
03324             self.rbtnNPDownloadLicenseNo.hide ()
03325         else:
03326             self.rbtnNPDownloadLicenseNo.set_active (True)
03327             self.rbtnNPDownloadLicenseYes.show ()
03328             self.rbtnNPDownloadLicenseNo.show ()
03329             self.frmNPDownloadableDriverLicenseTerms.show ()
03330             terms = driver.get('licensetext', _("Not specified."))
03331             self.tvNPDownloadableDriverLicense.get_buffer ().set_text (terms)
03332 
03333         self.setNPButtons()

Here is the call graph for this function:

Definition at line 3238 of file newprinter.py.

03238 
03239     def on_tvNPDrivers_cursor_changed(self, widget):
03240         self.setNPButtons()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3063 of file newprinter.py.

03063 
03064     def on_tvNPMakes_cursor_changed(self, tvNPMakes):
03065         path, column = tvNPMakes.get_cursor()
03066         if path != None:
03067             model = tvNPMakes.get_model ()
03068             iter = model.get_iter (path)
03069             self.NPMake = model.get(iter, 1)[0]
03070             recommended_make = (self.auto_make and
03071                                 cupshelpers.ppds.normalize (self.auto_make) ==
03072                                 cupshelpers.ppds.normalize (self.NPMake))
03073             self.recommended_make_selected = recommended_make
03074             self.fillModelList()

Definition at line 3223 of file newprinter.py.

03223 
03224     def on_tvNPModels_cursor_changed(self, widget):
03225         path, column = widget.get_cursor()
03226         if path != None:
03227             model = widget.get_model ()
03228             iter = model.get_iter (path)
03229             pmodel = model.get(iter, 1)[0]
03230 
03231             # Find out if this is the auto-detected make and model
03232             recommended_model = (self.recommended_make_selected and
03233                                  self.auto_model and
03234                                  self.auto_model.lower () == pmodel.lower ())
03235             self.recommended_model_selected = recommended_model
03236             self.fillDriverList(self.NPMake, pmodel)
03237             self.on_tvNPDrivers_cursor_changed(self.tvNPDrivers)

Here is the call graph for this function:

Definition at line 2057 of file newprinter.py.

02057 
02058     def on_tvSMBBrowser_cursor_changed(self, widget):
02059         store, iter = self.tvSMBBrowser.get_selection().get_selected()
02060         is_share = False
02061         if iter:
02062             entry = store.get_value (iter, 0)
02063             if entry:
02064                 is_share = entry.smbc_type == pysmb.smbc.PRINTER_SHARE
02065 
02066         self.btnSMBBrowseOk.set_sensitive(iter != None and is_share)

def newprinter.NewPrinterGUI.on_tvSMBBrowser_row_activated (   self,
  view,
  path,
  column 
)
Handle double-clicks in the SMB tree view.

Definition at line 1927 of file newprinter.py.

01927 
01928     def on_tvSMBBrowser_row_activated (self, view, path, column):
01929         """Handle double-clicks in the SMB tree view."""
01930         store = self.smb_store
01931         iter = store.get_iter (path)
01932         entry = store.get_value (iter, 0)
01933         if entry and entry.smbc_type == pysmb.smbc.PRINTER_SHARE:
01934             # This is a share, not a host.
01935             self.btnSMBBrowseOk.clicked ()
01936             return
01937 
01938         if view.row_expanded (path):
01939             view.collapse_row (path)
01940         else:
01941             self.on_tvSMBBrowser_row_expanded (view, iter, path)

Here is the call graph for this function:

def newprinter.NewPrinterGUI.on_tvSMBBrowser_row_expanded (   self,
  view,
  iter,
  path 
)
Handler for expanding a row in the SMB tree view.

Definition at line 1942 of file newprinter.py.

01942 
01943     def on_tvSMBBrowser_row_expanded (self, view, iter, path):
01944         """Handler for expanding a row in the SMB tree view."""
01945         model = view.get_model ()
01946         entry = model.get_value (iter, 0)
01947         if entry == None:
01948             return
01949 
01950         if entry.smbc_type == pysmb.smbc.WORKGROUP:
01951             # Workgroup
01952             # Be careful though: if there is a server with the
01953             # same name as the workgroup we will get a list of its
01954             # shares, not the workgroup's servers.
01955             try:
01956                 if self.expanding_row:
01957                     return
01958             except:
01959                 self.expanding_row = 1
01960 
01961             busy (self.SMBBrowseDialog)
01962             uri = "smb://%s/" % entry.name
01963             debug = 0
01964             if get_debugging ():
01965                 debug = 10
01966             smbc_auth = pysmb.AuthContext (self.SMBBrowseDialog)
01967             ctx = pysmb.smbc.Context (debug=debug,
01968                                       auth_fn=smbc_auth.callback)
01969             entries = []
01970             try:
01971                 while smbc_auth.perform_authentication () > 0:
01972                     try:
01973                         entries = ctx.opendir (uri).getdents ()
01974                     except Exception, e:
01975                         smbc_auth.failed (e)
01976             except RuntimeError, (e, s):
01977                 if e != errno.ENOENT:
01978                     debugprint ("Runtime error: %s" % repr ((e, s)))
01979             except:
01980                 nonfatalException()
01981 
01982             while model.iter_has_child (iter):
01983                 i = model.iter_nth_child (iter, 0)
01984                 model.remove (i)
01985 
01986             for entry in entries:
01987                 if entry.smbc_type in [pysmb.smbc.SERVER,
01988                                        pysmb.smbc.PRINTER_SHARE]:
01989                     i = model.append (iter, [entry])
01990                 if entry.smbc_type == pysmb.smbc.SERVER:
01991                     n = model.append (i)
01992 
01993             view.expand_row (path, 0)
01994             del self.expanding_row
01995             ready (self.SMBBrowseDialog)
01996 
01997         elif entry.smbc_type == pysmb.smbc.SERVER:
01998             # Server
01999             try:
02000                 if self.expanding_row:
02001                     return
02002             except:
02003                 self.expanding_row = 1
02004 
02005             busy (self.SMBBrowseDialog)
02006             uri = "smb://%s/" % entry.name
02007             debug = 0
02008             if get_debugging ():
02009                 debug = 10
02010             smbc_auth = pysmb.AuthContext (self.SMBBrowseDialog)
02011             ctx = pysmb.smbc.Context (debug=debug,
02012                                       auth_fn=smbc_auth.callback)
02013             shares = []
02014             try:
02015                 while smbc_auth.perform_authentication () > 0:
02016                     try:
02017                         shares = ctx.opendir (uri).getdents ()
02018                     except Exception, e:
02019                         smbc_auth.failed (e)
02020             except RuntimeError, (e, s):
02021                 if e != errno.EACCES and e != errno.EPERM:
02022                     debugprint ("Runtime error: %s" % repr ((e, s)))
02023             except:
02024                 nonfatalException()
02025 
02026             while model.iter_has_child (iter):
02027                 i = model.iter_nth_child (iter, 0)
02028                 model.remove (i)
02029 
02030             for share in shares:
02031                 if share.smbc_type == pysmb.smbc.PRINTER_SHARE:
02032                     i = model.append (iter, [share])
02033                     debugprint (repr (share))
02034 
02035             view.expand_row (path, 0)
02036             del self.expanding_row
02037             ready (self.SMBBrowseDialog)

Here is the caller graph for this function:

Definition at line 2919 of file newprinter.py.

02919 
02920     def openprinting_drivers_found (self):
02921         button = self.btnNPDownloadableDriverSearch
02922         label = self.btnNPDownloadableDriverSearch_label
02923         gtk.gdk.threads_enter ()
02924         try:
02925             label.set_text (_("Search"))
02926             button.set_sensitive (True)
02927             model = gtk.ListStore (str, str)
02928             if len (self.downloadable_printers) != 1:
02929                 if len (self.downloadable_printers) > 1:
02930                     first = _("-- Select from search results --")
02931                 else:
02932                     first = _("-- No matches found --")
02933 
02934                 iter = model.append (None)
02935                 model.set_value (iter, 0, first)
02936                 model.set_value (iter, 1, None)
02937 
02938             sorted_list = []
02939             for printer_id, printer_name in self.downloadable_printers:
02940                 sorted_list.append ((printer_id, printer_name))
02941 
02942             sorted_list.sort (lambda x, y: cups.modelSort (x[1], y[1]))
02943             sought = self.entNPDownloadableDriverSearch.get_text ().lower ()
02944             select_index = 0
02945             for id, name in sorted_list:
02946                 iter = model.append (None)
02947                 model.set_value (iter, 0, name)
02948                 model.set_value (iter, 1, id)
02949                 if name.lower () == sought:
02950                     select_index = model.get_path (iter)[0]
02951             combobox = self.cmbNPDownloadableDriverFoundPrinters
02952             combobox.set_model (model)
02953             combobox.set_active (select_index)
02954             combobox.set_sensitive (True)
02955             self.setNPButtons ()
02956         except:
02957             nonfatalException()
02958         gtk.gdk.threads_leave ()

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.openprinting_printer_drivers_found (   self,
  status,
  user_data,
  drivers 
)

Definition at line 2899 of file newprinter.py.

02899 
02900     def openprinting_printer_drivers_found (self, status, user_data, drivers):
02901         self.openprinting_query_handle = None
02902         if status != 0:
02903             print "HTTP Status %d" % status
02904             print drivers
02905             print traceback.extract_tb(drivers[2], limit=None)
02906             self.downloadable_printers = []
02907             self.openprinting_drivers_found ()
02908             return
02909 
02910         if drivers:
02911             debugprint (" - drivers found")
02912             (printer_id, printer_name) = user_data
02913             self.downloadable_drivers[printer_id] = drivers
02914             self.downloadable_printers.append (user_data)
02915 
02916         if not self.openprinting_query_next_printer ():
02917             self.drivers_lock.release ()
02918             self.openprinting_drivers_found ()

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.openprinting_printers_found (   self,
  status,
  user_data,
  printers 
)

Definition at line 2851 of file newprinter.py.

02851 
02852     def openprinting_printers_found (self, status, user_data, printers):
02853         if status != 0:
02854             # Should report error.
02855             print "HTTP Status %d" % status
02856             print printers
02857             print traceback.extract_tb(printers[2], limit=None)
02858             self.downloadable_printers = []
02859             self.openprinting_drivers_found ()
02860             return
02861 
02862         self.openprinting_query_handle = None
02863         self.downloadable_printers_unchecked = map (lambda x:
02864                                                         (x, printers[x]),
02865                                                     printers)
02866         self.downloadable_printers = []
02867         self.downloadable_drivers = dict() # by printer id of dict
02868 
02869         # Kick off a search for drivers for each model.
02870         self.openprinting_query_next_printer ()

Here is the caller graph for this function:

If there are more printers to query, kick off a query and
return True.

Otherwise return False.

Definition at line 2871 of file newprinter.py.

02871 
02872     def openprinting_query_next_printer (self):
02873         """
02874         If there are more printers to query, kick off a query and
02875         return True.
02876 
02877         Otherwise return False.
02878         """
02879 
02880         try:
02881             a = self.downloadable_printers_unchecked.pop ()
02882             (printer_id, printer_name) = a
02883         except IndexError:
02884             debugprint ("All printer driver queries finished")
02885             return False
02886 
02887         extra_options = dict()
02888         if self.DOWNLOADABLE_ONLYPPD:
02889             extra_options['onlyppdfiles'] = '1'
02890 
02891         debugprint ("Querying drivers for %s" % printer_id)
02892         self.openprinting_query_handle = \
02893             self.openprinting.listDrivers (printer_id,
02894                                            self.openprinting_printer_drivers_found,
02895                                            user_data=(printer_id, printer_name),
02896                                            extra_options=extra_options)
02897 
02898         return True

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.option_changed (   self,
  option 
)

Definition at line 480 of file newprinter.py.

00480 
00481     def option_changed(self, option):
00482         if option.is_changed():
00483             self.changed.add(option)
00484         else:
00485             self.changed.discard(option)
00486 
00487         if option.conflicts:
00488             self.conflicts.add(option)
00489         else:
00490             self.conflicts.discard(option)
00491         self.setDataButtonState()
00492 
00493         return

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 494 of file newprinter.py.

00494 
00495     def setDataButtonState(self):
00496         self.btnNPForward.set_sensitive(not bool(self.conflicts))

Here is the caller graph for this function:

Definition at line 1212 of file newprinter.py.

01212 
01213     def setNPButtons(self):
01214         nr = self.ntbkNewPrinter.get_current_page()
01215 
01216         if self.dialog_mode == "device":
01217             self.btnNPBack.hide()
01218             self.btnNPForward.hide()
01219             self.btnNPApply.show()
01220             try:
01221                 uri = self.getDeviceURI ()
01222                 valid = validDeviceURI (uri)
01223             except AttributeError:
01224                 # No device selected yet.
01225                 valid = False
01226             self.btnNPApply.set_sensitive (valid)
01227             return
01228 
01229         if self.dialog_mode == "ppd":
01230             if nr == 5: # Apply
01231                 if not self.installable_options:
01232                     # There are no installable options, so this is the
01233                     # last page.
01234                     debugprint ("No installable options")
01235                     self.btnNPForward.hide ()
01236                     self.btnNPApply.show ()
01237                 else:
01238                     self.btnNPForward.show ()
01239                     self.btnNPApply.hide ()
01240                 return
01241             elif nr == 6:
01242                 self.btnNPForward.hide()
01243                 self.btnNPApply.show()
01244                 return
01245             else:
01246                 self.btnNPForward.show()
01247                 self.btnNPApply.hide()
01248             if nr == 2:
01249                 self.btnNPBack.hide()
01250                 self.btnNPForward.show()
01251                 downloadable_selected = False
01252                 if self.rbtnNPDownloadableDriverSearch.get_active ():
01253                     combobox = self.cmbNPDownloadableDriverFoundPrinters
01254                     iter = combobox.get_active_iter ()
01255                     if iter and combobox.get_model ().get_value (iter, 1):
01256                         downloadable_selected = True
01257 
01258                 self.btnNPForward.set_sensitive(bool(
01259                         (self.rbtnNPFoomatic.get_active() and
01260                          self.tvNPMakes.get_cursor()[0] != None) or
01261                         self.filechooserPPD.get_filename() or
01262                         downloadable_selected))
01263                 return
01264             else:
01265                 self.btnNPBack.show()
01266 
01267         # class/printer
01268 
01269         if nr == 1: # Device
01270             valid = False
01271             try:
01272                 uri = self.getDeviceURI ()
01273                 valid = validDeviceURI (uri)
01274             except:
01275                 pass
01276             self.btnNPForward.set_sensitive(valid)
01277             self.btnNPBack.hide ()
01278         else:
01279             self.btnNPBack.show()
01280 
01281         self.btnNPForward.show()
01282         self.btnNPApply.hide()
01283 
01284         if nr == 0: # Name
01285             self.btnNPBack.show()
01286             if self.dialog_mode == "printer" or \
01287                     self.dialog_mode == "printer_with_uri":
01288                 self.btnNPForward.hide()
01289                 self.btnNPApply.show()
01290                 self.btnNPApply.set_sensitive(
01291                     checkNPName(self.printers, self.entNPName.get_text()))
01292             if self.dialog_mode == "class":
01293                 # This is the first page for the New Class dialog, so
01294                 # hide the Back button.
01295                 self.btnNPBack.hide ()
01296             if self.dialog_mode == "printer_with_uri" and \
01297                     (self.remotecupsqueue or \
01298                          (self.exactdrivermatch and \
01299                               not self.installable_options)):
01300                 self.btnNPBack.hide ()
01301         if nr == 2: # Make/PPD file
01302             downloadable_selected = False
01303             if self.rbtnNPDownloadableDriverSearch.get_active ():
01304                 combobox = self.cmbNPDownloadableDriverFoundPrinters
01305                 iter = combobox.get_active_iter ()
01306                 if iter and combobox.get_model ().get_value (iter, 1):
01307                     downloadable_selected = True
01308 
01309             self.btnNPForward.set_sensitive(bool(
01310                 self.rbtnNPFoomatic.get_active() or
01311                 self.filechooserPPD.get_filename() or
01312                 downloadable_selected))
01313             # If we have an auto-detected printer for which there was no
01314             # driver found, we have already the URI and so this step is
01315             # not needed in the wizard. This makes manufacturer?PPD selection
01316             # the firts step
01317             if self.dialog_mode == "printer_with_uri":
01318                 self.btnNPBack.hide()
01319         if nr == 3: # Model/Driver
01320             model, iter = self.tvNPDrivers.get_selection().get_selected()
01321             self.btnNPForward.set_sensitive(bool(iter))
01322         if nr == 4: # Class Members
01323             self.btnNPForward.hide()
01324             self.btnNPApply.show()
01325             self.btnNPApply.set_sensitive(
01326                 bool(getCurrentClassMembers(self.tvNCMembers)))
01327         if nr == 6: # Installable options
01328             if self.dialog_mode == "printer_with_uri" and \
01329                     self.exactdrivermatch:
01330                 self.btnNPBack.hide ()
01331         if nr == 7: # Downloadable drivers
01332             if self.ntbkNPDownloadableDriverProperties.get_current_page() == 1:
01333                 accepted = self.rbtnNPDownloadLicenseYes.get_active ()
01334             else:
01335                 treeview = self.tvNPDownloadableDrivers
01336                 model, iter = treeview.get_selection ().get_selected ()
01337                 accepted = (iter != None)
01338 
01339             self.btnNPForward.set_sensitive(accepted)

Here is the call graph for this function:

Here is the caller graph for this function:

def newprinter.NewPrinterGUI.show_IPP_Error (   self,
  exception,
  message 
)

Definition at line 477 of file newprinter.py.

00477 
00478     def show_IPP_Error (self, exception, message):
00479         return show_IPP_Error (exception, message, parent=self.NewPrinterWindow)

Here is the caller graph for this function:

Don't allow this path to be selected unless it is a leaf.

Definition at line 1908 of file newprinter.py.

01908 
01909     def smb_select_function (self, path):
01910         """Don't allow this path to be selected unless it is a leaf."""
01911         iter = self.smb_store.get_iter (path)
01912         return not self.smb_store.iter_has_child (iter)

def newprinter.NewPrinterGUI.smbbrowser_cell_comment (   self,
  column,
  cell,
  model,
  iter 
)

Definition at line 1920 of file newprinter.py.

01920 
01921     def smbbrowser_cell_comment (self, column, cell, model, iter):
01922         entry = model.get_value (iter, 0)
01923         comment = ''
01924         if entry != None:
01925             comment = entry.comment
01926         cell.set_property ('text', comment)

def newprinter.NewPrinterGUI.smbbrowser_cell_share (   self,
  column,
  cell,
  model,
  iter 
)

Definition at line 1913 of file newprinter.py.

01913 
01914     def smbbrowser_cell_share (self, column, cell, model, iter):
01915         entry = model.get_value (iter, 0)
01916         share = ''
01917         if entry != None:
01918             share = entry.name
01919         cell.set_property ('text', share)

Definition at line 1687 of file newprinter.py.

01687 
01688     def start_fetching_devices (self):
01689         self.fetchDevices_conn = asyncconn.Connection ()
01690         self.fetchDevices_conn._begin_operation (_("fetching device list"))
01691         self.fetchDevices (network=False, current_uri=self.current_uri)
01692         del self.current_uri

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

dictionary newprinter.NewPrinterGUI.__gsignals__ [static, private]
Initial value:
{
        'destroy':          (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
        'printer-added' :   (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
                             [gobject.TYPE_STRING]),
        'printer-modified': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
                             [gobject.TYPE_STRING, # printer name
                              gobject.TYPE_BOOLEAN]), # PPD modified?
        'dialog-canceled':  (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
        }

Definition at line 144 of file newprinter.py.

Definition at line 530 of file newprinter.py.

Definition at line 529 of file newprinter.py.

Definition at line 531 of file newprinter.py.

Definition at line 671 of file newprinter.py.

Definition at line 669 of file newprinter.py.

Definition at line 670 of file newprinter.py.

Definition at line 588 of file newprinter.py.

Definition at line 178 of file newprinter.py.

Definition at line 179 of file newprinter.py.

Definition at line 548 of file newprinter.py.

Definition at line 1617 of file newprinter.py.

Definition at line 180 of file newprinter.py.

Definition at line 1587 of file newprinter.py.

Definition at line 1593 of file newprinter.py.

Definition at line 1607 of file newprinter.py.

Definition at line 1609 of file newprinter.py.

Definition at line 1608 of file newprinter.py.

Definition at line 1606 of file newprinter.py.

Definition at line 528 of file newprinter.py.

Definition at line 526 of file newprinter.py.

Definition at line 2866 of file newprinter.py.

Definition at line 171 of file newprinter.py.

Definition at line 2857 of file newprinter.py.

Definition at line 2862 of file newprinter.py.

Definition at line 190 of file newprinter.py.

Definition at line 183 of file newprinter.py.

Definition at line 1958 of file newprinter.py.

Definition at line 540 of file newprinter.py.

Definition at line 1621 of file newprinter.py.

Definition at line 733 of file newprinter.py.

Definition at line 184 of file newprinter.py.

Definition at line 186 of file newprinter.py.

Definition at line 175 of file newprinter.py.

Definition at line 2685 of file newprinter.py.

Initial value:
{
        "parallel" : 0, # empty tab
        "usb" : 0,
        "bluetooth" : 0,
        "hal" : 0,
        "beh" : 0,
        "hp" : 0,
        "hpfax" : 0,
        "dnssd" : 0,
        "socket": 2,
        "lpd" : 3,
        "scsi" : 4,
        "serial" : 5,
        "smb" : 6,
        "network": 7,
        }

Definition at line 154 of file newprinter.py.

Definition at line 458 of file newprinter.py.

Definition at line 3124 of file newprinter.py.

Definition at line 3068 of file newprinter.py.

Definition at line 3108 of file newprinter.py.

Definition at line 363 of file newprinter.py.

Definition at line 364 of file newprinter.py.

Definition at line 177 of file newprinter.py.

Definition at line 527 of file newprinter.py.

Definition at line 520 of file newprinter.py.

Definition at line 181 of file newprinter.py.

Definition at line 541 of file newprinter.py.

Definition at line 866 of file newprinter.py.

Definition at line 185 of file newprinter.py.

Definition at line 542 of file newprinter.py.

Definition at line 543 of file newprinter.py.

Definition at line 187 of file newprinter.py.

Definition at line 3017 of file newprinter.py.

Definition at line 3076 of file newprinter.py.

Definition at line 182 of file newprinter.py.

Definition at line 403 of file newprinter.py.

Definition at line 454 of file newprinter.py.

Definition at line 359 of file newprinter.py.

Definition at line 360 of file newprinter.py.

Definition at line 462 of file newprinter.py.

Definition at line 346 of file newprinter.py.


The documentation for this class was generated from the following file: