home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / hplip / ui / faxsettingsform.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  3.5 KB  |  100 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. from qt import *
  5. from faxsettingsform_base import FaxSettingsForm_base
  6. from base.g import *
  7. from base import device, pml, utils
  8.  
  9. class PhoneNumValidator(QValidator):
  10.     
  11.     def __init__(self, parent = None, name = None):
  12.         QValidator.__init__(self, parent, name)
  13.  
  14.     
  15.     def validate(self, input, pos):
  16.         input = str(input)
  17.         if not input:
  18.             return (QValidator.Acceptable, pos)
  19.         elif input[pos - 1] not in '0123456789-(+) ':
  20.             return (QValidator.Invalid, pos)
  21.         elif len(input) > 50:
  22.             return (QValidator.Invalid, pos)
  23.         else:
  24.             return (QValidator.Acceptable, pos)
  25.  
  26.  
  27.  
  28. class StationNameValidator(QValidator):
  29.     
  30.     def __init__(self, parent = None, name = None):
  31.         QValidator.__init__(self, parent, name)
  32.  
  33.     
  34.     def validate(self, input, pos):
  35.         input = str(input)
  36.         if not input:
  37.             return (QValidator.Acceptable, pos)
  38.         elif input != utils.printable(input):
  39.             return (QValidator.Invalid, pos)
  40.         elif len(input) > 50:
  41.             return (QValidator.Invalid, pos)
  42.         else:
  43.             return (QValidator.Acceptable, pos)
  44.  
  45.  
  46.  
  47. class FaxSettingsForm(FaxSettingsForm_base):
  48.     
  49.     def __init__(self, dev, fax_num, name_co, parent = None, name = None, modal = 0, fl = 0):
  50.         FaxSettingsForm_base.__init__(self, parent, name, modal, fl)
  51.         self.dev = dev
  52.         self.faxEdit.setValidator(PhoneNumValidator(self.faxEdit))
  53.         self.nameEdit.setValidator(StationNameValidator(self.nameEdit))
  54.         self.voiceEdit.setValidator(PhoneNumValidator(self.voiceEdit))
  55.         self.faxEdit.setText(fax_num)
  56.         self.nameEdit.setText(name_co)
  57.         if fax_num:
  58.             pass
  59.         self.setOKButton(name_co)
  60.         if not user_cfg.fax.voice_phone:
  61.             pass
  62.         self.voiceEdit.setText('')
  63.         if not user_cfg.fax.email_address and user_cfg.alerts.email_address:
  64.             pass
  65.         self.emailEdit.setText('')
  66.  
  67.     
  68.     def faxEdit_textChanged(self, a0):
  69.         self.setOKButton()
  70.  
  71.     
  72.     def nameEdit_textChanged(self, a0):
  73.         self.setOKButton()
  74.  
  75.     
  76.     def setOKButton(self, toggle = None):
  77.         if toggle is not None:
  78.             self.pushButtonOK.setEnabled(bool(toggle))
  79.         else:
  80.             name = str(self.nameEdit.text())
  81.             fax_num = str(self.faxEdit.text())
  82.             if name:
  83.                 pass
  84.             self.pushButtonOK.setEnabled(bool(fax_num))
  85.  
  86.     
  87.     def accept(self):
  88.         
  89.         try:
  90.             self.dev.setPML(pml.OID_FAX_LOCAL_PHONE_NUM, str(self.faxEdit.text()))
  91.             self.dev.setPML(pml.OID_FAX_STATION_NAME, str(self.nameEdit.text()))
  92.         except Error:
  93.             log.error('Error setting fax settings to device.')
  94.  
  95.         user_cfg.fax.voice_phone = str(self.voiceEdit.text())
  96.         user_cfg.fax.email_address = str(self.emailEdit.text())
  97.         FaxSettingsForm_base.accept(self)
  98.  
  99.  
  100.