home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / hplip / ui / scrollprintsettings.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-04-29  |  20.7 KB  |  672 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from base.g import *
  5. from base import utils
  6. from prnt import cups
  7. from qt import *
  8. from scrollview import ScrollView
  9. import os.path as os
  10. import os
  11.  
  12. class OptionComboBox(QComboBox):
  13.     
  14.     def __init__(self, rw, parent, name, group, option, choices, default, typ = cups.PPD_UI_PICKONE, other = None):
  15.         QComboBox.__init__(self, rw, parent, name)
  16.         self.group = group
  17.         self.option = option
  18.         self.choices = choices
  19.         self.default = default
  20.         self.typ = typ
  21.         self.other = other
  22.  
  23.     
  24.     def setDefaultPushbutton(self, pushbutton):
  25.         self.pushbutton = pushbutton
  26.  
  27.     
  28.     def setOther(self, other):
  29.         self.other = other
  30.  
  31.  
  32.  
  33. class OptionSpinBox(QSpinBox):
  34.     
  35.     def __init__(self, parent, name, group, option, default):
  36.         QSpinBox.__init__(self, parent, name)
  37.         self.group = group
  38.         self.option = option
  39.         self.default = default
  40.  
  41.     
  42.     def setDefaultPushbutton(self, pushbutton):
  43.         self.pushbutton = pushbutton
  44.  
  45.  
  46.  
  47. class OptionButtonGroup(QButtonGroup):
  48.     
  49.     def __init__(self, parent, name, group, option, default):
  50.         QButtonGroup.__init__(self, parent, name)
  51.         self.group = group
  52.         self.option = option
  53.         self.default = default
  54.  
  55.     
  56.     def setDefaultPushbutton(self, pushbutton):
  57.         self.pushbutton = pushbutton
  58.  
  59.  
  60.  
  61. class DefaultPushButton(QPushButton):
  62.     
  63.     def __init__(self, parent, name, group, option, choices, default, control, typ):
  64.         QPushButton.__init__(self, parent, name)
  65.         self.group = group
  66.         self.option = option
  67.         self.default = default
  68.         self.control = control
  69.         self.typ = typ
  70.         self.choices = choices
  71.  
  72.  
  73.  
  74. class ScrollPrintSettingsView(ScrollView):
  75.     
  76.     def __init__(self, parent = None, name = None, fl = 0):
  77.         ScrollView.__init__(self, parent, name, fl)
  78.  
  79.     
  80.     def fillControls(self):
  81.         ScrollView.fillControls(self)
  82.         self.loading = True
  83.         cups.resetOptions()
  84.         cups.openPPD(self.cur_printer)
  85.         
  86.         try:
  87.             current_options = dict(cups.getOptions())
  88.             if not self.is_fax:
  89.                 self.addGroupHeading('basic', self._ScrollPrintSettingsView__tr('Basic'))
  90.                 log.debug('Group: Basic')
  91.                 current = current_options.get('orientation-requested', '3')
  92.                 self.addItem('basic', 'orientation-requested', self._ScrollPrintSettingsView__tr('Page Orientation'), cups.PPD_UI_PICKONE, current, [
  93.                     ('3', self._ScrollPrintSettingsView__tr('Portrait')),
  94.                     ('4', self._ScrollPrintSettingsView__tr('Landscape')),
  95.                     ('5', self._ScrollPrintSettingsView__tr('Reverse landscape')),
  96.                     ('6', self._ScrollPrintSettingsView__tr('Reverse portrait'))], '3')
  97.                 log.debug('Option: orientation-requested')
  98.                 log.debug('Current value: %s' % current)
  99.                 duplexer = self.cur_device.dq.get('duplexer', 0)
  100.                 log.debug('Duplexer = %d' % duplexer)
  101.                 if duplexer:
  102.                     current = current_options.get('sides', 'one-sided')
  103.                     self.addItem('basic', 'sides', self._ScrollPrintSettingsView__tr('Duplex (Print on both sides of the page)'), cups.PPD_UI_PICKONE, current, [
  104.                         ('one-sided', self._ScrollPrintSettingsView__tr('Single sided')),
  105.                         ('two-sided-long-edge', self._ScrollPrintSettingsView__tr('Two sided (long edge)')),
  106.                         ('two-sided-short-edge', self._ScrollPrintSettingsView__tr('Two sided (short edge)'))], 'one-sided')
  107.                     log.debug('Option: sides')
  108.                     log.debug('Current value: %s' % current)
  109.                 
  110.                 current = current_options.get('outputorder', 'normal')
  111.                 self.addItem('basic', 'outputorder', self._ScrollPrintSettingsView__tr('Output Order (Print last page first)'), cups.PPD_UI_PICKONE, current, [
  112.                     ('normal', self._ScrollPrintSettingsView__tr('Normal (Print first page first)')),
  113.                     ('reverse', self._ScrollPrintSettingsView__tr('Reversed (Print last page first)'))], 'normal')
  114.                 log.debug('Option: outputorder')
  115.                 log.debug('Current value: %s' % current)
  116.                 current = int(utils.to_bool(current_options.get('Collate', '0')))
  117.                 self.addItem('basic', 'Collate', self._ScrollPrintSettingsView__tr('Collate (Group together multiple copies)'), cups.PPD_UI_BOOLEAN, current, [], 0)
  118.                 log.debug('Option: Collate')
  119.                 log.debug('Current value: %s' % current)
  120.             
  121.             groups = cups.getGroupList()
  122.             for g in groups:
  123.                 log.debug('Group: %s' % g)
  124.                 (text, num_subgroups) = cups.getGroup(g)
  125.                 read_only = 'install' in g.lower()
  126.                 if g.lower() == 'printoutmode':
  127.                     text = self._ScrollPrintSettingsView__tr('Quality')
  128.                 
  129.                 self.addGroupHeading(g, text, read_only)
  130.                 log.debug('  Text: %s' % text)
  131.                 log.debug('Num subgroups: %d' % num_subgroups)
  132.                 options = cups.getOptionList(g)
  133.                 for o in options:
  134.                     log.debug('  Option: %s' % o)
  135.                     if 'pageregion' in o.lower():
  136.                         log.debug('Skipped.')
  137.                         continue
  138.                     
  139.                     (option_text, defchoice, conflicted, ui) = cups.getOption(g, o)
  140.                     if o.lower() == 'quality':
  141.                         option_text = self._ScrollPrintSettingsView__tr('Quality')
  142.                     
  143.                     log.debug('    Text: %s' % option_text)
  144.                     log.debug('    Defchoice: %s' % defchoice)
  145.                     choices = cups.getChoiceList(g, o)
  146.                     value = None
  147.                     choice_data = []
  148.                     for c in choices:
  149.                         log.debug('    Choice: %s' % c)
  150.                         if 'pagesize' in o.lower() and 'custom' in c.lower():
  151.                             log.debug('Skipped.')
  152.                             continue
  153.                         
  154.                         (choice_text, marked) = cups.getChoice(g, o, c)
  155.                         choice_text = choice_text.decode('utf-8')
  156.                         log.debug('      Text: %s' % choice_text)
  157.                         if marked:
  158.                             value = c
  159.                         
  160.                         choice_data.append((c, choice_text))
  161.                     
  162.                     self.addItem(g, o, option_text, ui, value, choice_data, defchoice, read_only)
  163.                 
  164.             
  165.             self.addGroupHeading('nup', self._ScrollPrintSettingsView__tr('N-Up (Multiple document pages per printed page)'))
  166.             log.debug('Group: N-Up')
  167.             current = current_options.get('number-up', '1')
  168.             self.addItem('nup', 'number-up', self._ScrollPrintSettingsView__tr('Pages per Sheet'), cups.PPD_UI_PICKONE, current, [
  169.                 ('1', self._ScrollPrintSettingsView__tr('1 sheet per page')),
  170.                 ('2', self._ScrollPrintSettingsView__tr('2 sheets per page')),
  171.                 ('4', self._ScrollPrintSettingsView__tr('4 sheets per page'))], '1')
  172.             log.debug('  Option: number-up')
  173.             log.debug('  Current value: %s' % current)
  174.             current = current_options.get('number-up-layout', 'lrtb')
  175.             self.addItem('nup', 'number-up-layout', self._ScrollPrintSettingsView__tr('Layout'), cups.PPD_UI_PICKONE, current, [
  176.                 ('btlr', self._ScrollPrintSettingsView__tr('Bottom to top, left to right')),
  177.                 ('btrl', self._ScrollPrintSettingsView__tr('Bottom to top, right to left')),
  178.                 ('lrbt', self._ScrollPrintSettingsView__tr('Left to right, bottom to top')),
  179.                 ('lrtb', self._ScrollPrintSettingsView__tr('Left to right, top to bottom')),
  180.                 ('rlbt', self._ScrollPrintSettingsView__tr('Right to left, bottom to top')),
  181.                 ('rltb', self._ScrollPrintSettingsView__tr('Right to left, top to bottom')),
  182.                 ('tblr', self._ScrollPrintSettingsView__tr('Top to bottom, left to right')),
  183.                 ('tbrl', self._ScrollPrintSettingsView__tr('Top to bottom, right to left'))], 'lrtb')
  184.             log.debug('  Option: number-up-layout')
  185.             log.debug('  Current value: %s' % current)
  186.             current = current_options.get('page-border', 'none')
  187.             self.addItem('nup', 'page-border', self._ScrollPrintSettingsView__tr('Printed Border Around Each Page'), cups.PPD_UI_PICKONE, current, [
  188.                 ('double', self._ScrollPrintSettingsView__tr('Two thin borders')),
  189.                 ('double-thick', self._ScrollPrintSettingsView__tr('Two thick borders')),
  190.                 ('none', self._ScrollPrintSettingsView__tr('No border')),
  191.                 ('single', self._ScrollPrintSettingsView__tr('One thin border')),
  192.                 ('single-thick', self._ScrollPrintSettingsView__tr('One thick border'))], 'none')
  193.             log.debug('  Option: page-border')
  194.             log.debug('  Current value: %s' % current)
  195.             if not self.is_fax:
  196.                 self.addGroupHeading('adjustment', self._ScrollPrintSettingsView__tr('Printout Appearance'))
  197.                 current = int(current_options.get('brightness', 100))
  198.                 log.debug('  Option: brightness')
  199.                 log.debug('  Current value: %s' % current)
  200.                 self.addItem('adjustment', 'brightness', self._ScrollPrintSettingsView__tr('Brightness'), cups.UI_SPINNER, current, (0, 200), 100, suffix = ' %')
  201.                 current = int(current_options.get('gamma', 1000))
  202.                 log.debug('  Option: gamma')
  203.                 log.debug('  Current value: %s' % current)
  204.                 self.addItem('adjustment', 'gamma', self._ScrollPrintSettingsView__tr('Gamma'), cups.UI_SPINNER, current, (1, 10000), 1000)
  205.             
  206.             self.addGroupHeading('image', self._ScrollPrintSettingsView__tr('Image Printing'))
  207.             current = current_options.get('fitplot', 'false')
  208.             self.addItem('image', 'fitplot', self._ScrollPrintSettingsView__tr('Fit to page'), cups.PPD_UI_BOOLEAN, current, [], 0)
  209.             current = current_options.get('position', 'center')
  210.             self.addItem('image', 'position', self._ScrollPrintSettingsView__tr('Position on Page'), cups.PPD_UI_PICKONE, current, [
  211.                 ('center', self._ScrollPrintSettingsView__tr('Centered')),
  212.                 ('top', self._ScrollPrintSettingsView__tr('Top')),
  213.                 ('left', self._ScrollPrintSettingsView__tr('Left')),
  214.                 ('right', self._ScrollPrintSettingsView__tr('Right')),
  215.                 ('top-left', self._ScrollPrintSettingsView__tr('Top left')),
  216.                 ('top-right', self._ScrollPrintSettingsView__tr('Top right')),
  217.                 ('bottom', self._ScrollPrintSettingsView__tr('Bottom')),
  218.                 ('bottom-left', self._ScrollPrintSettingsView__tr('Bottom left')),
  219.                 ('bottom-right', self._ScrollPrintSettingsView__tr('Bottom right'))], 'center')
  220.             log.debug('  Option: position')
  221.             log.debug('  Current value: %s' % current)
  222.             if not self.is_fax:
  223.                 current = int(current_options.get('saturation', 100))
  224.                 log.debug('  Option: saturation')
  225.                 log.debug('  Current value: %s' % current)
  226.                 self.addItem('image', 'saturation', self._ScrollPrintSettingsView__tr('Saturation'), cups.UI_SPINNER, current, (0, 200), 100, suffix = ' %')
  227.                 current = int(current_options.get('hue', 0))
  228.                 log.debug('  Option: hue')
  229.                 log.debug('  Current value: %s' % current)
  230.                 self.addItem('image', 'hue', self._ScrollPrintSettingsView__tr('Hue (color shift/rotation)'), cups.UI_SPINNER, current, (-100, 100), 0)
  231.             
  232.             current = int(current_options.get('natural-scaling', 100))
  233.             log.debug('  Option: natural-scaling')
  234.             log.debug('  Current value: %s' % current)
  235.             self.addItem('image', 'natural-scaling', self._ScrollPrintSettingsView__tr('"Natural" Scaling (relative to image)'), cups.UI_SPINNER, current, (1, 800), 100, suffix = ' %')
  236.             current = int(current_options.get('scaling', 100))
  237.             log.debug('  Option: scaling')
  238.             log.debug('  Current value: %s' % current)
  239.             self.addItem('image', 'scaling', self._ScrollPrintSettingsView__tr('Scaling (relative to page)'), cups.UI_SPINNER, current, (1, 800), 100, suffix = ' %')
  240.             self.addGroupHeading('misc', self._ScrollPrintSettingsView__tr('Miscellaneous'))
  241.             log.debug('Group: Misc')
  242.             current = int(utils.to_bool(current_options.get('prettyprint', '0')))
  243.             self.addItem('misc', 'prettyprint', self._ScrollPrintSettingsView__tr('"Pretty Print" Text Documents (Add headers and formatting)'), cups.PPD_UI_BOOLEAN, current, [], 0)
  244.             log.debug('  Option: prettyprint')
  245.             log.debug('  Current value: %s' % current)
  246.             if not self.is_fax:
  247.                 current = current_options.get('job-sheets', 'none').split(',')
  248.                 
  249.                 try:
  250.                     start = current[0]
  251.                 except IndexError:
  252.                     start = 'none'
  253.  
  254.                 
  255.                 try:
  256.                     end = current[1]
  257.                 except IndexError:
  258.                     end = 'none'
  259.  
  260.                 self.addItem('misc', 'job-sheets', self._ScrollPrintSettingsView__tr('Banner Pages'), cups.UI_BANNER_JOB_SHEETS, (start, end), [
  261.                     ('none', self._ScrollPrintSettingsView__tr('No banner page')),
  262.                     ('classified', self._ScrollPrintSettingsView__tr('Classified')),
  263.                     ('confidential', self._ScrollPrintSettingsView__tr('Confidential')),
  264.                     ('secret', self._ScrollPrintSettingsView__tr('Secret')),
  265.                     ('standard', self._ScrollPrintSettingsView__tr('Standard')),
  266.                     ('topsecret', self._ScrollPrintSettingsView__tr('Top secret')),
  267.                     ('unclassified', self._ScrollPrintSettingsView__tr('Unclassified'))], ('none', 'none'))
  268.                 log.debug('  Option: job-sheets')
  269.                 log.debug('  Current value: %s,%s' % (start, end))
  270.             
  271.             current = int(utils.to_bool(current_options.get('mirror', '0')))
  272.             self.addItem('misc', 'mirror', self._ScrollPrintSettingsView__tr('Mirror Printing'), cups.PPD_UI_BOOLEAN, current, [], 0)
  273.             log.debug('  Option: mirror')
  274.             log.debug('  Current value: %s' % current)
  275.         except Exception:
  276.             e = None
  277.             log.exception()
  278.         finally:
  279.             cups.closePPD()
  280.             self.loading = False
  281.  
  282.  
  283.     
  284.     def optionComboBox_activated(self, a):
  285.         a = str(a)
  286.         sender = self.sender()
  287.         choice = None
  288.         if sender.typ == cups.UI_BANNER_JOB_SHEETS:
  289.             (start, end) = (None, None)
  290.             for c, t in sender.choices:
  291.                 if t == a:
  292.                     start = c
  293.                     break
  294.                     continue
  295.             
  296.             for c, t in sender.other.choices:
  297.                 if t == sender.other.currentText():
  298.                     end = c
  299.                     break
  300.                     continue
  301.             
  302.             if sender.option == 'end':
  303.                 start = end
  304.                 end = start
  305.             
  306.             if start is not None and end is not None and start.lower() == sender.default[0].lower() and end.lower() == sender.default[1].lower():
  307.                 self.removePrinterOption('job-sheets')
  308.                 sender.pushbutton.setEnabled(False)
  309.             else:
  310.                 sender.pushbutton.setEnabled(True)
  311.                 if start is not None and end is not None:
  312.                     self.setPrinterOption('job-sheets', ','.join([
  313.                         start,
  314.                         end]))
  315.                 
  316.         else:
  317.             choice = None
  318.             for c, t in sender.choices:
  319.                 if t == a:
  320.                     choice = c
  321.                     break
  322.                     continue
  323.             
  324.             if choice is not None and choice.lower() == sender.default.lower():
  325.                 self.removePrinterOption(sender.option)
  326.                 sender.pushbutton.setEnabled(False)
  327.             else:
  328.                 sender.pushbutton.setEnabled(True)
  329.                 if choice is not None:
  330.                     self.setPrinterOption(sender.option, choice)
  331.                 
  332.             self.linkPrintoutModeAndQuality(sender.option, choice)
  333.  
  334.     
  335.     def linkPrintoutModeAndQuality(self, option, choice):
  336.         if option.lower() == 'quality' and choice is not None:
  337.             
  338.             try:
  339.                 c = self.items['o:PrintoutMode'].control
  340.             except KeyError:
  341.                 return None
  342.  
  343.             if c is not None:
  344.                 if choice.lower() == 'fromprintoutmode':
  345.                     c.setEnabled(True)
  346.                     QToolTip.remove(c)
  347.                     a = str(c.currentText())
  348.                     link_choice = None
  349.                     for x, t in c.choices:
  350.                         if t == a:
  351.                             link_choice = x
  352.                             break
  353.                             continue
  354.                     
  355.                     if link_choice is not None and link_choice.lower() == c.default.lower():
  356.                         c.pushbutton.setEnabled(False)
  357.                     else:
  358.                         c.pushbutton.setEnabled(True)
  359.                 else:
  360.                     c.setEnabled(False)
  361.                     QToolTip.add(c, self._ScrollPrintSettingsView__tr('Set Quality to "Controlled by \'Printout Mode\'" to enable.'))
  362.                     c.pushbutton.setEnabled(False)
  363.             
  364.         
  365.  
  366.     
  367.     def optionSpinBox_valueChanged(self, i):
  368.         sender = self.sender()
  369.         if i == sender.default:
  370.             self.removePrinterOption(sender.option)
  371.             sender.pushbutton.setEnabled(False)
  372.         else:
  373.             sender.pushbutton.setEnabled(True)
  374.             self.setPrinterOption(sender.option, str(i))
  375.  
  376.     
  377.     def optionButtonGroup_clicked(self, b):
  378.         sender = self.sender()
  379.         b = int(b)
  380.         if b == sender.default:
  381.             self.removePrinterOption(sender.option)
  382.             sender.pushbutton.setEnabled(False)
  383.         else:
  384.             sender.pushbutton.setEnabled(True)
  385.             if b:
  386.                 self.setPrinterOption(sender.option, 'true')
  387.             else:
  388.                 self.setPrinterOption(sender.option, 'false')
  389.  
  390.     
  391.     def defaultPushButton_clicked(self):
  392.         sender = self.sender()
  393.         sender.setEnabled(False)
  394.         if sender.typ == cups.PPD_UI_BOOLEAN:
  395.             if sender.default:
  396.                 sender.control.setButton(1)
  397.             else:
  398.                 sender.control.setButton(0)
  399.             self.removePrinterOption(sender.option)
  400.         elif sender.typ == cups.PPD_UI_PICKONE:
  401.             (choice, text) = (None, None)
  402.             for c, t in sender.choices:
  403.                 if c == sender.default:
  404.                     choice = c
  405.                     text = t
  406.                     break
  407.                     continue
  408.             
  409.             if choice is not None:
  410.                 self.removePrinterOption(sender.option)
  411.                 sender.control.setCurrentText(text)
  412.                 self.linkPrintoutModeAndQuality(sender.option, choice)
  413.             
  414.         elif sender.typ == cups.UI_SPINNER:
  415.             sender.control.setValue(sender.default)
  416.             self.removePrinterOption(sender.option)
  417.         elif sender.typ == cups.UI_BANNER_JOB_SHEETS:
  418.             (start, end, start_text, end_text) = (None, None, None, None)
  419.             for c, t in sender.choices:
  420.                 if c == sender.default[0]:
  421.                     start = c
  422.                     start_text = t
  423.                 
  424.                 if c == sender.default[1]:
  425.                     end = c
  426.                     end_text = t
  427.                     continue
  428.             
  429.             if start is not None:
  430.                 sender.control[0].setCurrentText(start_text)
  431.             
  432.             if end is not None:
  433.                 sender.control[1].setCurrentText(end_text)
  434.             
  435.             self.removePrinterOption('job-sheets')
  436.         
  437.  
  438.     
  439.     def setPrinterOption(self, option, value):
  440.         cups.openPPD(self.cur_printer)
  441.         
  442.         try:
  443.             cups.addOption('%s=%s' % (option, value))
  444.             cups.setOptions()
  445.         finally:
  446.             cups.closePPD()
  447.  
  448.  
  449.     
  450.     def removePrinterOption(self, option):
  451.         cups.openPPD(self.cur_printer)
  452.         
  453.         try:
  454.             cups.removeOption(option)
  455.             cups.setOptions()
  456.         finally:
  457.             cups.closePPD()
  458.  
  459.  
  460.     
  461.     def addItem(self, group, option, text, typ, value, choices, default, read_only = False, suffix = ''):
  462.         (widget, control) = (None, None)
  463.         if typ == cups.PPD_UI_BOOLEAN:
  464.             widget = self.getWidget()
  465.             layout = QGridLayout(widget, 1, 1, 5, 10, 'layout')
  466.             default = int(utils.to_bool(str(default)))
  467.             value = int(utils.to_bool(str(value)))
  468.             textLabel1 = QLabel(widget, 'textLabel1')
  469.             layout.addWidget(textLabel1, 0, 0)
  470.             buttonGroup = OptionButtonGroup(widget, 'buttonGroup', group, option, default)
  471.             buttonGroup.setLineWidth(0)
  472.             buttonGroup.setColumnLayout(0, Qt.Vertical)
  473.             buttonGroup.layout().setSpacing(1)
  474.             buttonGroup.layout().setMargin(5)
  475.             buttonGroupLayout = QHBoxLayout(buttonGroup.layout())
  476.             buttonGroupLayout.setAlignment(Qt.AlignTop)
  477.             defaultPushButton = DefaultPushButton(widget, 'defaultPushButton', group, option, choices, default, buttonGroup, typ)
  478.             buttonGroup.setDefaultPushbutton(defaultPushButton)
  479.             layout.addWidget(defaultPushButton, 0, 3)
  480.             spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  481.             layout.addItem(spacer1, 0, 1)
  482.             onRadioButton = QRadioButton(buttonGroup, 'onRadioButton')
  483.             buttonGroup.insert(onRadioButton, 1)
  484.             buttonGroupLayout.addWidget(onRadioButton)
  485.             offRadioButton = QRadioButton(buttonGroup, 'offRadioButton')
  486.             buttonGroup.insert(offRadioButton, 0)
  487.             buttonGroupLayout.addWidget(offRadioButton)
  488.             layout.addWidget(buttonGroup, 0, 2)
  489.             textLabel1.setText(text)
  490.             onRadioButton.setText(self._ScrollPrintSettingsView__tr('On'))
  491.             offRadioButton.setText(self._ScrollPrintSettingsView__tr('Off'))
  492.             if value == default:
  493.                 defaultPushButton.setEnabled(False)
  494.             
  495.             self.connect(defaultPushButton, SIGNAL('clicked()'), self.defaultPushButton_clicked)
  496.             self.connect(buttonGroup, SIGNAL('clicked(int)'), self.optionButtonGroup_clicked)
  497.             x = self._ScrollPrintSettingsView__tr('Off')
  498.             if default:
  499.                 x = self._ScrollPrintSettingsView__tr('On')
  500.             
  501.             if value:
  502.                 buttonGroup.setButton(1)
  503.             else:
  504.                 buttonGroup.setButton(0)
  505.             if read_only:
  506.                 onRadioButton.setEnabled(False)
  507.                 offRadioButton.setEnabled(False)
  508.                 defaultPushButton.setEnabled(False)
  509.             else:
  510.                 QToolTip.add(defaultPushButton, self._ScrollPrintSettingsView__tr('Set to default value of "%1".').arg(x))
  511.             defaultPushButton.setText('Default')
  512.         elif typ == cups.PPD_UI_PICKONE:
  513.             widget = self.getWidget()
  514.             layout1 = QHBoxLayout(widget, 5, 10, 'layout1')
  515.             textLabel1 = QLabel(widget, 'textLabel1')
  516.             layout1.addWidget(textLabel1)
  517.             spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  518.             layout1.addItem(spacer1)
  519.             optionComboBox = OptionComboBox(0, widget, 'optionComboBox', group, option, choices, default)
  520.             layout1.addWidget(optionComboBox)
  521.             defaultPushButton = DefaultPushButton(widget, 'defaultPushButton', group, option, choices, default, optionComboBox, typ)
  522.             optionComboBox.setDefaultPushbutton(defaultPushButton)
  523.             layout1.addWidget(defaultPushButton)
  524.             textLabel1.setText(text)
  525.             defaultPushButton.setText('Default')
  526.             (x, y) = (None, None)
  527.             for c, t in choices:
  528.                 d = c.lower()
  529.                 if value is not None and d == value.lower():
  530.                     x = t
  531.                 
  532.                 if d == default.lower():
  533.                     y = t
  534.                 
  535.                 optionComboBox.insertItem(t)
  536.             
  537.             if x is not None:
  538.                 optionComboBox.setCurrentText(x)
  539.             
  540.             if value is not None and value.lower() == default.lower():
  541.                 defaultPushButton.setEnabled(False)
  542.             
  543.             self.linkPrintoutModeAndQuality(option, value)
  544.             if read_only:
  545.                 optionComboBox.setEnabled(False)
  546.                 defaultPushButton.setEnabled(False)
  547.             elif y is not None:
  548.                 QToolTip.add(defaultPushButton, self._ScrollPrintSettingsView__tr('Set to default value of "%1".').arg(y))
  549.             
  550.             self.connect(defaultPushButton, SIGNAL('clicked()'), self.defaultPushButton_clicked)
  551.             self.connect(optionComboBox, SIGNAL('activated(const QString&)'), self.optionComboBox_activated)
  552.             control = optionComboBox
  553.         elif typ == cups.UI_SPINNER:
  554.             widget = self.getWidget()
  555.             layout1 = QHBoxLayout(widget, 5, 10, 'layout1')
  556.             textLabel1 = QLabel(widget, 'textLabel1')
  557.             layout1.addWidget(textLabel1)
  558.             spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  559.             layout1.addItem(spacer1)
  560.             optionSpinBox = OptionSpinBox(widget, 'optionSpinBox', group, option, default)
  561.             layout1.addWidget(optionSpinBox)
  562.             defaultPushButton = DefaultPushButton(widget, 'defaultPushButton', group, option, choices, default, optionSpinBox, typ)
  563.             optionSpinBox.setDefaultPushbutton(defaultPushButton)
  564.             layout1.addWidget(defaultPushButton)
  565.             (min, max) = choices
  566.             optionSpinBox.setMinValue(min)
  567.             optionSpinBox.setMaxValue(max)
  568.             optionSpinBox.setValue(value)
  569.             if suffix:
  570.                 optionSpinBox.setSuffix(suffix)
  571.             
  572.             textLabel1.setText(text)
  573.             defaultPushButton.setText('Default')
  574.             self.connect(optionSpinBox, SIGNAL('valueChanged(int)'), self.optionSpinBox_valueChanged)
  575.             self.connect(defaultPushButton, SIGNAL('clicked()'), self.defaultPushButton_clicked)
  576.             if value == default:
  577.                 defaultPushButton.setEnabled(False)
  578.             
  579.             if read_only:
  580.                 self.optionSpinBox.setEnabled(False)
  581.                 self.defaultPushButton.setEnabled()
  582.             else:
  583.                 QToolTip.add(defaultPushButton, self._ScrollPrintSettingsView__tr('Set to default value of "%1".').arg(default))
  584.         elif typ == cups.UI_BANNER_JOB_SHEETS:
  585.             widget = self.getWidget()
  586.             layout1 = QGridLayout(widget, 1, 1, 5, 10, 'layout1')
  587.             startComboBox = OptionComboBox(0, widget, 'startComboBox', group, 'start', choices, default, typ)
  588.             layout1.addWidget(startComboBox, 0, 3)
  589.             startTextLabel = QLabel(widget, 'startTextLabel')
  590.             layout1.addWidget(startTextLabel, 0, 2)
  591.             endTextLabel = QLabel(widget, 'endTextLabel')
  592.             layout1.addWidget(endTextLabel, 0, 4)
  593.             endComboBox = OptionComboBox(0, widget, 'endComboBox', group, 'end', choices, default, typ, startComboBox)
  594.             layout1.addWidget(endComboBox, 0, 5)
  595.             startComboBox.setOther(endComboBox)
  596.             defaultPushButton = DefaultPushButton(widget, 'defaultPushButton', group, option, choices, default, (startComboBox, endComboBox), typ)
  597.             layout1.addWidget(defaultPushButton, 0, 6)
  598.             startComboBox.setDefaultPushbutton(defaultPushButton)
  599.             endComboBox.setDefaultPushbutton(defaultPushButton)
  600.             textLabel1 = QLabel(widget, 'textLabel1')
  601.             layout1.addWidget(textLabel1, 0, 0)
  602.             spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  603.             layout1.addItem(spacer1, 0, 1)
  604.             textLabel1.setText(text)
  605.             defaultPushButton.setText('Default')
  606.             startTextLabel.setText(self._ScrollPrintSettingsView__tr('Start:'))
  607.             endTextLabel.setText(self._ScrollPrintSettingsView__tr('End:'))
  608.             (s, e, y, z) = (None, None, None, None)
  609.             for c, t in choices:
  610.                 d = c.lower()
  611.                 if value is not None:
  612.                     if d == value[0].lower():
  613.                         s = t
  614.                     
  615.                     if d == value[1].lower():
  616.                         e = t
  617.                     
  618.                 
  619.                 if d == default[0].lower():
  620.                     y = t
  621.                 
  622.                 if d == default[1].lower():
  623.                     z = t
  624.                 
  625.                 startComboBox.insertItem(t)
  626.                 endComboBox.insertItem(t)
  627.             
  628.             if s is not None:
  629.                 startComboBox.setCurrentText(s)
  630.             
  631.             if e is not None:
  632.                 endComboBox.setCurrentText(e)
  633.             
  634.             if value is not None and value[0].lower() == default[0].lower() and value[1].lower() == default[1].lower():
  635.                 defaultPushButton.setEnabled(False)
  636.             
  637.             if y is not None and z is not None:
  638.                 QToolTip.add(defaultPushButton, self._ScrollPrintSettingsView__tr('Set to default value of "Start: %1, End: %2".').arg(y).arg(z))
  639.             
  640.             self.connect(startComboBox, SIGNAL('activated(const QString&)'), self.optionComboBox_activated)
  641.             self.connect(endComboBox, SIGNAL('activated(const QString&)'), self.optionComboBox_activated)
  642.             self.connect(defaultPushButton, SIGNAL('clicked()'), self.defaultPushButton_clicked)
  643.         elif typ == cups.PPD_UI_PICKMANY:
  644.             print 'pickmany'
  645.         elif typ == cups.UI_UNITS_SPINNER:
  646.             widget = self.getWidget()
  647.             layout1 = QHBoxLayout(widget, 5, 10, 'layout1')
  648.             textLabel1 = QLabel(widget, 'textLabel1')
  649.             layout1.addWidget(textLabel1)
  650.             spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  651.             layout1.addItem(spacer1)
  652.             lineEdit1 = QLineEdit(widget, 'lineEdit1')
  653.             layout1.addWidget(lineEdit1)
  654.             comboBox1 = QComboBox(0, widget, 'comboBox1')
  655.             layout1.addWidget(comboBox1)
  656.             defaultPushButton = QPushButton(widget, 'defaultPushButton')
  657.             layout1.addWidget(defaultPushButton)
  658.             textLabel1.setText(text)
  659.             defaultPushButton.setText('Default')
  660.         else:
  661.             log.error('Invalid UI value: %s/%s' % (group, option))
  662.         if widget is not None:
  663.             self.addWidget(widget, 'o:' + option, control)
  664.             return widget
  665.         
  666.  
  667.     
  668.     def __tr(self, s, c = None):
  669.         return qApp.translate('DevMgr4', s, c)
  670.  
  671.  
  672.