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
printerproperties.PrinterPropertiesDialog Class Reference
Inheritance diagram for printerproperties.PrinterPropertiesDialog:
Inheritance graph
[legend]
Collaboration diagram for printerproperties.PrinterPropertiesDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __del__
def do_destroy
def destroy
def set_monitor
def show
def printer_properties_response
def on_delete
def on_printer_changed
def option_changed
def getPUsers
def setPUsers
def checkPUsersChanged
def on_btnPAddUser_clicked
def on_btnPDelUser_clicked
def on_entPUser_changed
def on_tvPUsers_cursor_changed
def on_job_option_reset
def on_job_option_changed
def draw_other_job_options
def add_job_option
def on_btnJOOtherRemove_clicked
def on_btnNewJobOption_clicked
def on_entNewJobOption_changed
def on_entNewJobOption_activate
def setDataButtonState
def save_printer
def getPrinterSettings
def on_tvPrinterProperties_selection_changed
 Printer Properties tree view signal handlers.
def on_tvPrinterProperties_cursor_changed
def printTestPage
def on_btnPrintTestPage_clicked
def maintenance_command
def on_btnSelfTest_clicked
def on_btnCleanHeads_clicked
def fillComboBox
def load
def updatePrinterPropertiesTreeView
def updateMarkerLevels
def on_btnRefreshMarkerLevels_clicked
def updateStateReasons
def set_printer_state_reason_icon
def set_printer_state_reason_text
def updatePrinterProperties
def fillPrinterOptions
def fillClassMembers
def on_btnClassAddMember_clicked
def on_btnClassDelMember_clicked
def on_btnSelectDevice_clicked
def on_btnChangePPD_clicked
def on_printer_modified
def on_printer_event
def on_printer_removed
def on_state_reason_added
def on_state_reason_removed
def on_cups_connection_error
def getWidgets

Public Attributes

 language
 encoding
 printer
 ppd
 conflicts
 changed
 signal_ids
 updating_widgets
 dialog
 static_tabs
 PrinterPropertiesDialog
 ppd_local
 parent
 newPrinterGUI
 server_settings
 printer_properties_last_iter_selected
 options
 cups
 server_is_publishing
 server_side_options
 other_job_options
 option_inputslot
 option_manualfeed

Static Public Attributes

dictionary printer_states
tuple model = gtk.ListStore(gobject.TYPE_STRING)
tuple cell = gtk.CellRendererText()
list opts

Private Member Functions

def _connect
def _disconnect

Private Attributes

 _monitor
 _host
 _encryption
 _ppdcache

Static Private Attributes

dictionary __gsignals__

Detailed Description

Definition at line 60 of file printerproperties.py.


Constructor & Destructor Documentation

Definition at line 72 of file printerproperties.py.

00072 
00073     def __init__(self):
00074         gobject.GObject.__init__ (self)
00075 
00076         try:
00077             self.language = locale.getlocale(locale.LC_MESSAGES)
00078             self.encoding = locale.getlocale(locale.LC_CTYPE)
00079         except:
00080             nonfatalException()
00081             os.environ['LC_ALL'] = 'C'
00082             locale.setlocale (locale.LC_ALL, "")
00083             self.language = locale.getlocale(locale.LC_MESSAGES)
00084             self.encoding = locale.getlocale(locale.LC_CTYPE)
00085 
00086         self.printer = self.ppd = None
00087         self.conflicts = set() # of options
00088         self.changed = set() # of options
00089         self.signal_ids = dict()
00090 
00091         # WIDGETS
00092         # =======
00093         self.updating_widgets = False
00094         self.getWidgets({"PrinterPropertiesDialog":
00095                              ["PrinterPropertiesDialog",
00096                               "tvPrinterProperties",
00097                               "btnPrinterPropertiesCancel",
00098                               "btnPrinterPropertiesOK",
00099                               "btnPrinterPropertiesApply",
00100                               "btnPrinterPropertiesClose",
00101                               "ntbkPrinter",
00102                               "entPDescription",
00103                               "entPLocation",
00104                               "entPMakeModel",
00105                               "lblPMakeModel2",
00106                               "entPState",
00107                               "entPDevice",
00108                               "lblPDevice2",
00109                               "btnSelectDevice",
00110                               "btnChangePPD",
00111                               "chkPEnabled",
00112                               "chkPAccepting",
00113                               "chkPShared",
00114                               "lblNotPublished",
00115                               "btnPrintTestPage",
00116                               "btnSelfTest",
00117                               "btnCleanHeads",
00118                               "btnConflict",
00119 
00120                               "cmbPStartBanner",
00121                               "cmbPEndBanner",
00122                               "cmbPErrorPolicy",
00123                               "cmbPOperationPolicy",
00124 
00125                               "rbtnPAllow",
00126                               "rbtnPDeny",
00127                               "tvPUsers",
00128                               "entPUser",
00129                               "btnPAddUser",
00130                               "btnPDelUser",
00131 
00132                               "lblPInstallOptions",
00133                               "swPInstallOptions",
00134                               "vbPInstallOptions",
00135                               "swPOptions",
00136                               "lblPOptions",
00137                               "vbPOptions",
00138                               "algnClassMembers",
00139                               "vbClassMembers",
00140                               "lblClassMembers",
00141                               "tvClassMembers",
00142                               "tvClassNotMembers",
00143                               "btnClassAddMember",
00144                               "btnClassDelMember",
00145                               "btnRefreshMarkerLevels",
00146                               "tvPrinterStateReasons",
00147                               "ntbkPrinterStateReasons",
00148 
00149                               # Job options
00150                               "sbJOCopies", "btnJOResetCopies",
00151                               "cmbJOOrientationRequested", "btnJOResetOrientationRequested",
00152                               "cbJOFitplot", "btnJOResetFitplot",
00153                               "cmbJONumberUp", "btnJOResetNumberUp",
00154                               "cmbJONumberUpLayout", "btnJOResetNumberUpLayout",
00155                               "sbJOBrightness", "btnJOResetBrightness",
00156                               "cmbJOFinishings", "btnJOResetFinishings",
00157                               "sbJOJobPriority", "btnJOResetJobPriority",
00158                               "cmbJOMedia", "btnJOResetMedia",
00159                               "cmbJOSides", "btnJOResetSides",
00160                               "cmbJOHoldUntil", "btnJOResetHoldUntil",
00161                               "cmbJOOutputOrder", "btnJOResetOutputOrder",
00162                               "cmbJOPrintQuality", "btnJOResetPrintQuality",
00163                               "cmbJOPrinterResolution",
00164                               "btnJOResetPrinterResolution",
00165                               "cmbJOOutputBin", "btnJOResetOutputBin",
00166                               "cbJOMirror", "btnJOResetMirror",
00167                               "sbJOScaling", "btnJOResetScaling",
00168                               "sbJOSaturation", "btnJOResetSaturation",
00169                               "sbJOHue", "btnJOResetHue",
00170                               "sbJOGamma", "btnJOResetGamma",
00171                               "sbJOCpi", "btnJOResetCpi",
00172                               "sbJOLpi", "btnJOResetLpi",
00173                               "sbJOPageLeft", "btnJOResetPageLeft",
00174                               "sbJOPageRight", "btnJOResetPageRight",
00175                               "sbJOPageTop", "btnJOResetPageTop",
00176                               "sbJOPageBottom", "btnJOResetPageBottom",
00177                               "cbJOPrettyPrint", "btnJOResetPrettyPrint",
00178                               "cbJOWrap", "btnJOResetWrap",
00179                               "sbJOColumns", "btnJOResetColumns",
00180                               "tblJOOther",
00181                               "entNewJobOption", "btnNewJobOption",
00182 
00183                               # Marker levels
00184                               "vboxMarkerLevels",
00185                               "btnRefreshMarkerLevels"]},
00186 
00187                         domain=config.PACKAGE)
00188 
00189 
00190         self.dialog = self.PrinterPropertiesDialog
00191 
00192         # Don't let delete-event destroy the dialog.
00193         self.dialog.connect ("delete-event", self.on_delete)
00194 
00195         # Printer properties combo boxes
00196         for combobox in [self.cmbPStartBanner,
00197                          self.cmbPEndBanner,
00198                          self.cmbPErrorPolicy,
00199                          self.cmbPOperationPolicy]:
00200             cell = gtk.CellRendererText ()
00201             combobox.clear ()
00202             combobox.pack_start (cell, True)
00203             combobox.add_attribute (cell, 'text', 0)
00204 
00205         btn = self.btnRefreshMarkerLevels
00206         btn.connect ("clicked", self.on_btnRefreshMarkerLevels_clicked)
00207 
00208         # Printer state reasons list
00209         column = gtk.TreeViewColumn (_("Message"))
00210         icon = gtk.CellRendererPixbuf ()
00211         column.pack_start (icon, False)
00212         text = gtk.CellRendererText ()
00213         column.pack_start (text, False)
00214         column.set_cell_data_func (icon, self.set_printer_state_reason_icon)
00215         column.set_cell_data_func (text, self.set_printer_state_reason_text)
00216         column.set_resizable (True)
00217         self.tvPrinterStateReasons.append_column (column)
00218         selection = self.tvPrinterStateReasons.get_selection ()
00219         selection.set_mode (gtk.SELECTION_NONE)
00220         store = gtk.ListStore (int, str)
00221         self.tvPrinterStateReasons.set_model (store)
00222         self.PrinterPropertiesDialog.connect ("delete-event",
00223                                               on_delete_just_hide)
00224 
00225         self.static_tabs = 3
00226 
00227         # setup some lists
00228         for name, treeview in (
00229             (_("Members of this class"), self.tvClassMembers),
00230             (_("Others"), self.tvClassNotMembers),
00231             (_("Users"), self.tvPUsers),
00232             ):
00233 
00234             model = gtk.ListStore(str)
00235             cell = gtk.CellRendererText()
00236             column = gtk.TreeViewColumn(name, cell, text=0)
00237             treeview.set_model(model)
00238             treeview.append_column(column)
00239             treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
00240 
00241         # Printer Properties dialog
00242         self.dialog.connect ('response', self.printer_properties_response)
00243 
00244         # Printer Properties tree view
00245         col = gtk.TreeViewColumn ('', gtk.CellRendererText (), markup=0)
00246         self.tvPrinterProperties.append_column (col)
00247         sel = self.tvPrinterProperties.get_selection ()
00248         sel.connect ('changed', self.on_tvPrinterProperties_selection_changed)
00249         sel.set_mode (gtk.SELECTION_SINGLE)
00250 
00251         # Job Options widgets.
00252         for (widget,
00253              opts) in [(self.cmbJOOrientationRequested,
00254                         [[_("Portrait (no rotation)")],
00255                          [_("Landscape (90 degrees)")],
00256                          [_("Reverse landscape (270 degrees)")],
00257                          [_("Reverse portrait (180 degrees)")]]),
00258 
00259                        (self.cmbJONumberUp,
00260                         [["1"], ["2"], ["4"], ["6"], ["9"], ["16"]]),
00261 
00262                        (self.cmbJONumberUpLayout,
00263                         [[_("Left to right, top to bottom")],
00264                          [_("Left to right, bottom to top")],
00265                          [_("Right to left, top to bottom")],
00266                          [_("Right to left, bottom to top")],
00267                          [_("Top to bottom, left to right")],
00268                          [_("Top to bottom, right to left")],
00269                          [_("Bottom to top, left to right")],
00270                          [_("Bottom to top, right to left")]]),
00271 
                       (self.cmbJOFinishings,

Definition at line 499 of file printerproperties.py.

00499 
00500     def __del__ (self):
00501         debugprint ("-%s" % self)
00502         del self._monitor


Member Function Documentation

def printerproperties.PrinterPropertiesDialog._connect (   self,
  collection,
  obj,
  name,
  handler 
) [private]

Definition at line 503 of file printerproperties.py.

00503 
00504     def _connect (self, collection, obj, name, handler):
00505         c = self.signal_ids.get (collection, [])
00506         c.append ((obj, obj.connect (name, handler)))
00507         self.signal_ids[collection] = c

Here is the caller graph for this function:

def printerproperties.PrinterPropertiesDialog._disconnect (   self,
  collection = None 
) [private]

Definition at line 508 of file printerproperties.py.

00508 
00509     def _disconnect (self, collection=None):
00510         if collection:
00511             collection = [collection]
00512         else:
00513             collection = self.signal_ids.keys ()
00514 
00515         for coll in collection:
00516             if self.signal_ids.has_key (coll):
00517                 for (obj, signal_id) in self.signal_ids[coll]:
00518                     obj.disconnect (signal_id)
00519 
00520                 del self.signal_ids[coll]

Here is the caller graph for this function:

def printerproperties.PrinterPropertiesDialog.add_job_option (   self,
  name,
  value = "",
  supported = "",
  is_new = True,
  editable = True 
)

Definition at line 826 of file printerproperties.py.

00826 
00827                        editable=True):
00828         try:
00829             option = options.OptionWidget(name, value, supported,
00830                                           self.option_changed)
00831         except ValueError:
00832             # We can't deal with this option type for some reason.
00833             nonfatalException ()
00834             return
00835 
00836         option.is_new = is_new
00837         self.other_job_options.append (option)
00838         self.draw_other_job_options (editable=editable)
00839         self.server_side_options[name] = option
00840         if name in self.changed: # was deleted before
00841             option.is_new = False
00842         self.changed.add(option)
00843         self.setDataButtonState()
00844         if is_new:
00845             option.selector.grab_focus ()

Here is the call graph for this function:

Here is the caller graph for this function:

check if users in GUI and printer are different
and set self.changed

Definition at line 726 of file printerproperties.py.

00726 
00727     def checkPUsersChanged(self):
00728         """check if users in GUI and printer are different
00729         and set self.changed"""
00730         if not self.printer:
00731             return
00732 
00733         if self.getPUsers() != self.printer.except_users:
00734             self.changed.add(self.tvPUsers)
00735         else:
00736             self.changed.discard(self.tvPUsers)
00737 
00738         self.on_tvPUsers_cursor_changed(self.tvPUsers)
00739         self.setDataButtonState()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 526 of file printerproperties.py.

00526 
00527     def destroy (self):
00528         debugprint ("DESTROY: %s" % self)
00529         self._disconnect ()
00530         self.ppd = None
00531         self.ppd_local = None
00532         self.printer = None
00533         self.emit ('destroy')

Here is the call graph for this function:

Definition at line 521 of file printerproperties.py.

00521 
00522     def do_destroy (self):
00523         if self.PrinterPropertiesDialog:
00524             self.PrinterPropertiesDialog.destroy ()
00525             self.PrinterPropertiesDialog = None

Definition at line 793 of file printerproperties.py.

00793 
00794     def draw_other_job_options (self, editable=True):
00795         n = len (self.other_job_options)
00796         if n == 0:
00797             self.tblJOOther.hide_all ()
00798             return
00799 
00800         self.tblJOOther.resize (n, 3)
00801         children = self.tblJOOther.get_children ()
00802         for child in children:
00803             self.tblJOOther.remove (child)
00804         i = 0
00805         for opt in self.other_job_options:
00806             self.tblJOOther.attach (opt.label, 0, 1, i, i + 1,
00807                                     xoptions=gtk.FILL,
00808                                     yoptions=gtk.FILL)
00809             opt.label.set_alignment (0.0, 0.5)
00810             self.tblJOOther.attach (opt.selector, 1, 2, i, i + 1,
00811                                     xoptions=gtk.FILL,
00812                                     yoptions=0)
00813             opt.selector.set_sensitive (editable)
00814 
00815             btn = gtk.Button(stock=gtk.STOCK_REMOVE)
00816             btn.connect("clicked", self.on_btnJOOtherRemove_clicked)
00817             btn.set_data("pyobject", opt)
00818             btn.set_sensitive (editable)
00819             self.tblJOOther.attach(btn, 2, 3, i, i + 1,
00820                                    xoptions=0,
00821                                    yoptions=0)
00822             i += 1
00823 
00824         self.tblJOOther.show_all ()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1766 of file printerproperties.py.

01766 
01767     def fillClassMembers(self, editable):
01768         self.btnClassAddMember.set_sensitive(editable)
01769         self.btnClassDelMember.set_sensitive(editable)
01770 
01771         # remove Options tab
01772         tab_nr = self.ntbkPrinter.page_num(self.swPOptions)
01773         if tab_nr != -1:
01774             self.ntbkPrinter.remove_page(tab_nr)
01775 
01776         # insert Member Tab
01777         if self.ntbkPrinter.page_num(self.algnClassMembers) == -1:
01778             self.ntbkPrinter.insert_page(
01779                 self.algnClassMembers, self.lblClassMembers,
01780                 self.static_tabs)
01781 
01782         model_members = self.tvClassMembers.get_model()
01783         model_not_members = self.tvClassNotMembers.get_model()
01784         model_members.clear()
01785         model_not_members.clear()
01786 
01787         names = list (self._monitor.get_printers ())
01788         names.sort ()
01789         for name in names:
01790             if name != self.printer.name:
01791                 if name in self.printer.class_members:
01792                     model_members.append((name, ))
01793                 else:
01794                     model_not_members.append((name, ))

def printerproperties.PrinterPropertiesDialog.fillComboBox (   self,
  combobox,
  values,
  value,
  translationdict = None 
)

Definition at line 1242 of file printerproperties.py.

01242 
01243     def fillComboBox(self, combobox, values, value, translationdict=None):
01244         if translationdict == None:
01245             translationdict = ppdippstr.TranslationDict ()
01246 
01247         model = gtk.ListStore (gobject.TYPE_STRING,
01248                                gobject.TYPE_STRING)
01249         combobox.set_model (model)
01250         set_active = False
01251         for nr, val in enumerate(values):
01252             model.append ([(translationdict.get (val)), val])
01253             if val == value:
01254                 combobox.set_active(nr)
01255                 set_active = True
01256 
01257         if not set_active:
01258             combobox.set_active (0)

Here is the caller graph for this function:

def printerproperties.PrinterPropertiesDialog.fillPrinterOptions (   self,
  name,
  editable 
)

Definition at line 1653 of file printerproperties.py.

01653 
01654     def fillPrinterOptions(self, name, editable):
01655         # remove Class membership tab
01656         tab_nr = self.ntbkPrinter.page_num(self.algnClassMembers)
01657         if tab_nr != -1:
01658             self.ntbkPrinter.remove_page(tab_nr)
01659 
01660         # clean Installable Options Tab
01661         for widget in self.vbPInstallOptions.get_children():
01662             self.vbPInstallOptions.remove(widget)
01663 
01664         # clean Options Tab
01665         for widget in self.vbPOptions.get_children():
01666             self.vbPOptions.remove(widget)
01667 
01668         # insert Options Tab
01669         if self.ntbkPrinter.page_num(self.swPOptions) == -1:
01670             self.ntbkPrinter.insert_page(
01671                 self.swPOptions, self.lblPOptions, self.static_tabs)
01672 
01673         if not self.ppd:
01674             tab_nr = self.ntbkPrinter.page_num(self.swPInstallOptions)
01675             if tab_nr != -1:
01676                 self.ntbkPrinter.remove_page(tab_nr)
01677             tab_nr = self.ntbkPrinter.page_num(self.swPOptions)
01678             if tab_nr != -1:
01679                 self.ntbkPrinter.remove_page(tab_nr)
01680             return
01681         ppd = self.ppd
01682         ppd.markDefaults()
01683         self.ppd_local.markDefaults()
01684 
01685         hasInstallableOptions = False
01686 
01687         # build option tabs
01688         for group in self.ppd_local.optionGroups:
01689             if group.name == "InstallableOptions":
01690                 hasInstallableOptions = True
01691                 container = self.vbPInstallOptions
01692                 tab_nr = self.ntbkPrinter.page_num(self.swPInstallOptions)
01693                 if tab_nr == -1:
01694                     self.ntbkPrinter.insert_page(self.swPInstallOptions,
01695                                                  gtk.Label(group.text),
01696                                                  self.static_tabs)
01697                 tab_label = self.lblPInstallOptions
01698             else:
01699                 frame = gtk.Frame("<b>%s</b>" % ppdippstr.ppd.get (group.text))
01700                 frame.get_label_widget().set_use_markup(True)
01701                 frame.set_shadow_type (gtk.SHADOW_NONE)
01702                 self.vbPOptions.pack_start (frame, False, False, 0)
01703                 container = gtk.Alignment (0.5, 0.5, 1.0, 1.0)
01704                 # We want a left padding of 12, but there is a Table with
01705                 # spacing 6, and the left-most column of it (the conflict
01706                 # icon) is normally hidden, so just use 6 here.
01707                 container.set_padding (6, 12, 6, 0)
01708                 frame.add (container)
01709                 tab_label = self.lblPOptions
01710 
01711             table = gtk.Table(1, 3, False)
01712             table.set_col_spacings(6)
01713             table.set_row_spacings(6)
01714             container.add(table)
01715 
01716             rows = 0
01717 
01718             # InputSlot and ManualFeed need special handling.  With
01719             # libcups, if ManualFeed is True, InputSlot gets unset.
01720             # Likewise, if InputSlot is set, ManualFeed becomes False.
01721             # We handle it by toggling the sensitivity of InputSlot
01722             # based on ManualFeed.
01723             self.option_inputslot = self.option_manualfeed = None
01724 
01725             for nr, option in enumerate(group.options):
01726                 if option.keyword == "PageRegion":
01727                     continue
01728                 rows += 1
01729                 table.resize (rows, 3)
01730                 o = OptionWidget(option, ppd, self, tab_label=tab_label)
01731                 table.attach(o.conflictIcon, 0, 1, nr, nr+1, 0, 0, 0, 0)
01732 
01733                 hbox = gtk.HBox()
01734                 if o.label:
01735                     a = gtk.Alignment (0.5, 0.5, 1.0, 1.0)
01736                     a.set_padding (0, 0, 0, 6)
01737                     a.add (o.label)
01738                     table.attach(a, 1, 2, nr, nr+1, gtk.FILL, 0, 0, 0)
01739                     table.attach(hbox, 2, 3, nr, nr+1, gtk.FILL, 0, 0, 0)
01740                 else:
01741                     table.attach(hbox, 1, 3, nr, nr+1, gtk.FILL, 0, 0, 0)
01742                 hbox.pack_start(o.selector, False)
01743                 self.options[option.keyword] = o
01744                 o.selector.set_sensitive(editable)
01745                 if option.keyword == "InputSlot":
01746                     self.option_inputslot = o
01747                 elif option.keyword == "ManualFeed":
01748                     self.option_manualfeed = o
01749 
01750         # remove Installable Options tab if not needed
01751         if not hasInstallableOptions:
01752             tab_nr = self.ntbkPrinter.page_num(self.swPInstallOptions)
01753             if tab_nr != -1:
01754                 self.ntbkPrinter.remove_page(tab_nr)
01755 
01756         # check for conflicts
01757         for option in self.options.itervalues():
01758             conflicts = option.checkConflicts()
01759             if conflicts:
01760                 self.conflicts.add(option)
01761 
01762         self.swPInstallOptions.show_all()
01763         self.swPOptions.show_all()

Definition at line 1106 of file printerproperties.py.

01106 
01107     def getPrinterSettings(self):
01108         #self.ppd.markDefaults()
01109         for option in self.options.itervalues():
01110             option.writeback()

Here is the caller graph for this function:

return list of usernames from the GUI

Definition at line 707 of file printerproperties.py.

00707 
00708     def getPUsers(self):
00709         """return list of usernames from the GUI"""
00710         model = self.tvPUsers.get_model()
00711         result = []
00712         model.foreach(lambda model, path, iter:
00713                       result.append(model.get(iter, 0)[0]))
00714         result.sort()
00715         return result

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)
def printerproperties.PrinterPropertiesDialog.load (   self,
  name,
  host = None,
  encryption = None,
  parent = None 
)

Definition at line 1259 of file printerproperties.py.

01259 
01260     def load (self, name, host=None, encryption=None, parent=None):
01261         self.changed = set() # of options
01262         self.options = {} # keyword -> Option object
01263         self.conflicts = set() # of options
01264 
01265         if not host:
01266             host = cups.getServer()
01267         if not encryption:
01268             encryption = cups.getEncryption ()
01269 
01270         c = authconn.Connection (parent=self.dialog,
01271                                  host=host,
01272                                  encryption=encryption)
01273         self.cups = c
01274 
01275         printer = cupshelpers.Printer (name, self.cups)
01276         self.printer = printer
01277         try:
01278             # CUPS 1.4
01279             publishing = printer.other_attributes['server-is-sharing-printers']
01280             self.server_is_publishing = publishing
01281         except KeyError:
01282             pass
01283 
01284         editable = not self.printer.discovered
01285 
01286         try:
01287             self.ppd = printer.getPPD()
01288             self.ppd_local = printer.getPPD()
01289             if self.ppd_local != False:
01290                 self.ppd_local.localize()
01291         except cups.IPPError, (e, m):
01292             # We might get IPP_INTERNAL_ERROR if this is a memberless
01293             # class.
01294             if e != cups.IPP_INTERNAL_ERROR:
01295                 # Some IPP error other than IPP_NOT_FOUND.
01296                 show_IPP_Error(e, m, self.parent)
01297 
01298             # Treat it as a raw queue.
01299             self.ppd = False
01300         except RuntimeError, e:
01301             # Either the underlying cupsGetPPD2() function returned
01302             # NULL without setting an IPP error (so it'll be something
01303             # like a failed connection), or the PPD could not be parsed.
01304             if e.message.startswith ("ppd"):
01305                 show_error_dialog (_("Error"),
01306                                    _("The PPD file for this queue "
01307                                      "is damaged."),
01308                                    self.parent)
01309             else:
01310                 show_error_dialog (_("Error"),
01311                                    _("There was a problem connecting to "
01312                                      "the CUPS server."),
01313                                    self.parent)
01314             raise
01315 
01316         for widget in (self.entPDescription, self.entPLocation,
01317                        self.entPDevice):
01318             widget.set_editable(editable)
01319 
01320         for widget in (self.btnSelectDevice, self.btnChangePPD,
01321                        self.chkPEnabled, self.chkPAccepting, self.chkPShared,
01322                        self.cmbPStartBanner, self.cmbPEndBanner,
01323                        self.cmbPErrorPolicy, self.cmbPOperationPolicy,
01324                        self.rbtnPAllow, self.rbtnPDeny, self.tvPUsers,
01325                        self.entPUser, self.btnPAddUser, self.btnPDelUser):
01326             widget.set_sensitive(editable)
01327 
01328         # Description page
01329         self.entPDescription.set_text(printer.info)
01330         self.entPLocation.set_text(printer.location)
01331 
01332         uri = printer.device_uri
01333         self.entPDevice.set_text(uri)
01334         self.changed.discard(self.entPDevice)
01335 
01336         # Hide make/model and Device URI for classes
01337         for widget in (self.lblPMakeModel2, self.entPMakeModel,
01338                        self.btnChangePPD, self.lblPDevice2,
01339                        self.entPDevice, self.btnSelectDevice):
01340             if printer.is_class:
01341                 widget.hide()
01342             else:
01343                 widget.show()
01344 
01345 
01346         # Policy tab
01347         # ----------
01348 
01349         try:
01350             if printer.is_shared:
01351                 if self.server_is_publishing:
01352                     self.lblNotPublished.hide_all ()
01353                 else:
01354                     self.lblNotPublished.show_all ()
01355             else:
01356                 self.lblNotPublished.hide_all ()
01357         except:
01358             nonfatalException()
01359             self.lblNotPublished.hide_all ()
01360 
01361         # Job sheets
01362         self.cmbPStartBanner.set_sensitive(editable)
01363         self.cmbPEndBanner.set_sensitive(editable)
01364 
01365         # Policies
01366         self.cmbPErrorPolicy.set_sensitive(editable)
01367         self.cmbPOperationPolicy.set_sensitive(editable)
01368 
01369         # Access control
01370         self.entPUser.set_text("")
01371 
01372         # Server side options (Job options)
01373         self.server_side_options = {}
01374         for option in self.job_options_widgets.values ():
01375             if option.name == "media" and self.ppd:
01376                 # Slightly special case because the 'system default'
01377                 # (i.e. what you get when you press Reset) depends
01378                 # on the printer's PageSize.
01379                 opt = self.ppd.findOption ("PageSize")
01380                 if opt:
01381                     option.set_default (opt.defchoice)
01382 
01383             option_editable = editable
01384             try:
01385                 value = self.printer.attributes[option.name]
01386             except KeyError:
01387                 option.reinit (None)
01388             else:
01389                 try:
01390                     if self.printer.possible_attributes.has_key (option.name):
01391                         supported = self.printer.\
01392                                     possible_attributes[option.name][1]
01393                         # Set the option widget.
01394                         # In CUPS 1.3.x the orientation-requested-default
01395                         # attribute may have the value None; this means there
01396                         # is no value set.  This suits our needs here, as None
01397                         # resets the option to the system default and makes the
01398                         # Reset button insensitive.
01399                         option.reinit (value, supported=supported)
01400                     else:
01401                         option.reinit (value)
01402 
01403                     self.server_side_options[option.name] = option
01404                 except:
01405                     option_editable = False
01406                     show_error_dialog (_("Error"),
01407                                        _("Option '%s' has value '%s' "
01408                                          "and cannot be edited.") %
01409                                        (option.name, value),
01410                                        self.parent)
01411             option.widget.set_sensitive (option_editable)
01412             if not editable:
01413                 option.button.set_sensitive (False)
01414         self.other_job_options = []
01415         self.draw_other_job_options (editable=editable)
01416         for option in self.printer.attributes.keys ():
01417             if self.server_side_options.has_key (option):
01418                 continue
01419             if option == "output-mode":
01420                 # Not settable
01421                 continue
01422             value = self.printer.attributes[option]
01423             if self.printer.possible_attributes.has_key (option):
01424                 supported = self.printer.possible_attributes[option][1]
01425             else:
01426                 if isinstance (value, bool):
01427                     supported = ["true", "false"]
01428                     value = str (value).lower ()
01429                 else:
01430                     supported = ""
01431                     value = str (value)
01432 
01433             self.add_job_option (option, value=value,
01434                                  supported=supported, is_new=False,
01435                                  editable=editable)
01436         self.entNewJobOption.set_text ('')
01437         self.entNewJobOption.set_sensitive (editable)
01438         self.btnNewJobOption.set_sensitive (False)
01439 
01440         if printer.is_class:
01441             # remove InstallOptions tab
01442             tab_nr = self.ntbkPrinter.page_num(self.swPInstallOptions)
01443             if tab_nr != -1:
01444                 self.ntbkPrinter.remove_page(tab_nr)
01445             self.fillClassMembers(editable)
01446         else:
01447             # real Printer
01448             self.fillPrinterOptions(name, editable)
01449 
01450         self.updateMarkerLevels()
01451         self.updateStateReasons()
01452         self.updatePrinterPropertiesTreeView()
01453 
01454         self.changed = set() # of options
01455         self.updatePrinterProperties ()
01456         self.setDataButtonState()

Here is the caller graph for this function:

Definition at line 1200 of file printerproperties.py.

01200 
01201     def maintenance_command (self, command):
01202         printer = self.printer
01203         if not printer:
01204             # Printer has been deleted meanwhile
01205             return
01206 
01207         (tmpfd, tmpfname) = tempfile.mkstemp ()
01208         os.write (tmpfd, "#CUPS-COMMAND\n%s\n" % command)
01209         os.close (tmpfd)
01210         self.cups._begin_operation (_("sending maintenance command"))
01211         try:
01212             format = "application/vnd.cups-command"
01213             job_id = self.cups.printTestPage (printer.name,
01214                                               format=format,
01215                                               file=tmpfname,
01216                                               user=cups.getUser ())
01217             show_info_dialog (_("Submitted"),
01218                               _("Maintenance command submitted as "
01219                                 "job %d") % job_id,
01220                               parent=self.parent)
01221         except cups.IPPError, (e, msg):
01222             if (e == cups.IPP_NOT_AUTHORIZED and
01223                 self.printer.name != 'localhost'):
01224                 show_error_dialog (_("Not possible"),
01225                                    _("The remote server did not accept "
01226                                      "the print job, most likely "
01227                                      "because the printer is not "
01228                                      "shared."),
01229                                    self.parent)
01230             else:
01231                 show_IPP_Error(e, msg, self.parent)
01232 
01233         self.cups._end_operation ()
01234 
01235         os.unlink (tmpfname)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1824 of file printerproperties.py.

01824 
01825     def on_btnChangePPD_clicked(self, button):
01826         busy (self.dialog)
01827         self.newPrinterGUI.init("ppd", device_uri=self.printer.device_uri,
01828                                 ppd=self.ppd,
01829                                 name=self.printer.name,
01830                                 host=self._host,
01831                                 encryption=self._encryption,
01832                                 parent=self.dialog)
01833         ready (self.dialog)

Definition at line 1795 of file printerproperties.py.

01795 
01796     def on_btnClassAddMember_clicked(self, button):
01797         newprinter.moveClassMembers(self.tvClassNotMembers,
01798                                     self.tvClassMembers)
01799         if newprinter.getCurrentClassMembers(self.tvClassMembers) != self.printer.class_members:
01800             self.changed.add(self.tvClassMembers)
01801         else:
01802             self.changed.discard(self.tvClassMembers)
01803         self.setDataButtonState()

Here is the call graph for this function:

Definition at line 1804 of file printerproperties.py.

01804 
01805     def on_btnClassDelMember_clicked(self, button):
01806         newprinter.moveClassMembers(self.tvClassMembers,
01807                                     self.tvClassNotMembers)
01808         if newprinter.getCurrentClassMembers(self.tvClassMembers) != self.printer.class_members:
01809             self.changed.add(self.tvClassMembers)
01810         else:
01811             self.changed.discard(self.tvClassMembers)
01812         self.setDataButtonState()

Here is the call graph for this function:

Definition at line 1239 of file printerproperties.py.

01239 
01240     def on_btnCleanHeads_clicked(self, button):
01241         self.maintenance_command ("Clean all")

Here is the call graph for this function:

Definition at line 846 of file printerproperties.py.

00846 
00847     def on_btnJOOtherRemove_clicked(self, button):
00848         option = button.get_data("pyobject")
00849         self.other_job_options.remove (option)
00850         self.draw_other_job_options ()
00851         if option.is_new:
00852             self.changed.discard(option)
00853         else:
00854             # keep name as reminder that option got deleted
00855             self.changed.add(option.name)
00856         del self.server_side_options[option.name]
00857         self.setDataButtonState()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 858 of file printerproperties.py.

00858 
00859     def on_btnNewJobOption_clicked(self, button):
00860         name = self.entNewJobOption.get_text()
00861         self.add_job_option(name)
00862         self.tblJOOther.show_all()
00863         self.entNewJobOption.set_text ('')
00864         self.btnNewJobOption.set_sensitive (False)
00865         self.setDataButtonState()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 740 of file printerproperties.py.

00740 
00741     def on_btnPAddUser_clicked(self, button):
00742         user = self.entPUser.get_text()
00743         if user:
00744             self.tvPUsers.get_model().insert(0, (user,))
00745             self.entPUser.set_text("")
00746         self.checkPUsersChanged()

Here is the call graph for this function:

Definition at line 747 of file printerproperties.py.

00747 
00748     def on_btnPDelUser_clicked(self, button):
00749         model, rows = self.tvPUsers.get_selection().get_selected_rows()
00750         rows = [gtk.TreeRowReference(model, row) for row in rows]
00751         for row in rows:
00752             path = row.get_path()
00753             iter = model.get_iter(path)
00754             model.remove(iter)
00755         self.checkPUsersChanged()

Here is the call graph for this function:

Definition at line 1141 of file printerproperties.py.

01141 
01142     def on_btnPrintTestPage_clicked(self, button):
01143         printer = self.printer
01144         if not printer:
01145             # Printer has been deleted meanwhile
01146             return
01147 
01148         # if we have a page size specific custom test page, use it;
01149         # otherwise use cups' default one
01150         custom_testpage = None
01151         if self.ppd != False:
01152             opt = self.ppd.findOption ("PageSize")
01153             if opt:
01154                 custom_testpage = os.path.join(pkgdata,
01155                                                'testpage-%s.ps' %
01156                                                opt.defchoice.lower())
01157 
01158         # Connect as the current user so that the test page can be managed
01159         # as a normal job.
01160         user = cups.getUser ()
01161         cups.setUser ('')
01162         try:
01163             c = authconn.Connection (self.parent, try_as_root=False,
01164                                      host=self._host,
01165                                      encryption=self._encryption)
01166         except RuntimeError, s:
01167             show_IPP_Error (None, s, self.parent)
01168             return
01169 
01170         job_id = None
01171         c._begin_operation (_("printing test page"))
01172         try:
01173             if custom_testpage and os.path.exists(custom_testpage):
01174                 debugprint ('Printing custom test page ' + custom_testpage)
01175                 job_id = c.printTestPage(printer.name,
01176                                          file=custom_testpage)
01177             else:
01178                 debugprint ('Printing default test page')
01179                 job_id = c.printTestPage(printer.name)
01180         except cups.IPPError, (e, msg):
01181             if (e == cups.IPP_NOT_AUTHORIZED and
01182                 self._host != 'localhost' and
01183                 self._host[0] != '/'):
01184                 show_error_dialog (_("Not possible"),
01185                                    _("The remote server did not accept "
01186                                      "the print job, most likely "
01187                                      "because the printer is not "
01188                                      "shared."),
01189                                    self.parent)
01190             else:
01191                 show_IPP_Error(e, msg, self.parent)
01192 
01193         c._end_operation ()
01194         cups.setUser (user)
01195 
01196         if job_id != None:
01197             show_info_dialog (_("Submitted"),
01198                               _("Test page submitted as job %d") % job_id,
01199                               parent=self.parent)

Here is the call graph for this function:

Definition at line 1565 of file printerproperties.py.

01565 
01566     def on_btnRefreshMarkerLevels_clicked (self, button):
01567         self.maintenance_command ("ReportLevels")

Here is the call graph for this function:

Definition at line 1814 of file printerproperties.py.

01814 
01815     def on_btnSelectDevice_clicked(self, button):
01816         busy (self.dialog)
01817         self.newPrinterGUI.init("device", device_uri=self.printer.device_uri,
01818                                 name=self.printer.name,
01819                                 host=self._host,
01820                                 encryption=self._encryption,
01821                                 parent=self.dialog)
01822         ready (self.dialog)

Definition at line 1236 of file printerproperties.py.

01236 
01237     def on_btnSelfTest_clicked(self, button):
01238         self.maintenance_command ("PrintSelfTestPage")

Here is the call graph for this function:

Definition at line 1878 of file printerproperties.py.

01878 
01879     def on_cups_connection_error (self, mon):
01880         # FIXME: figure out how to handle this
01881         pass

def printerproperties.PrinterPropertiesDialog.on_delete (   self,
  dialog,
  event 
)

Definition at line 647 of file printerproperties.py.

00647 
00648     def on_delete(self, dialog, event):
00649         self.printer_properties_response (dialog, gtk.RESPONSE_CANCEL)

Here is the call graph for this function:

Definition at line 871 of file printerproperties.py.

00871 
00872     def on_entNewJobOption_activate(self, widget):
00873         self.on_btnNewJobOption_clicked (widget) # wrong widget but ok

Here is the call graph for this function:

Definition at line 866 of file printerproperties.py.

00866 
00867     def on_entNewJobOption_changed(self, widget):
00868         text = self.entNewJobOption.get_text()
00869         active = (len(text) > 0) and text not in self.server_side_options
00870         self.btnNewJobOption.set_sensitive(active)

Definition at line 756 of file printerproperties.py.

00756 
00757     def on_entPUser_changed(self, widget):
00758         self.btnPAddUser.set_sensitive(bool(widget.get_text()))

Here is the caller graph for this function:

Definition at line 776 of file printerproperties.py.

00776 
00777     def on_job_option_changed(self, widget):
00778         if not self.printer:
00779             return
00780         option = self.job_options_widgets[widget]
00781         option.changed ()
00782         if option.is_changed ():
00783             self.server_side_options[option.name] = option
00784             self.changed.add(option)
00785         else:
00786             if self.server_side_options.has_key (option.name):
00787                 del self.server_side_options[option.name]
00788             self.changed.discard(option)
00789         self.setDataButtonState()
00790         # Don't set the reset button insensitive if the option hasn't
00791         # changed from the original value: it's still meaningful to
00792         # reset the option to the system default.

Here is the call graph for this function:

Definition at line 764 of file printerproperties.py.

00764 
00765     def on_job_option_reset(self, button):
00766         option = self.job_options_buttons[button]
00767         option.reset ()
00768         # Remember to set this option for removal in the IPP request.
00769         if self.server_side_options.has_key (option.name):
00770             del self.server_side_options[option.name]
00771         if option.is_changed ():
00772             self.changed.add(option)
00773         else:
00774             self.changed.discard(option)
00775         self.setDataButtonState()

Here is the call graph for this function:

Definition at line 650 of file printerproperties.py.

00650 
00651     def on_printer_changed(self, widget):
00652         if isinstance(widget, gtk.CheckButton):
00653             value = widget.get_active()
00654         elif isinstance(widget, gtk.Entry):
00655             value = widget.get_text()
00656         elif isinstance(widget, gtk.RadioButton):
00657             value = widget.get_active()
00658         elif isinstance(widget, gtk.ComboBox):
00659             model = widget.get_model ()
00660             iter = widget.get_active_iter()
00661             value = model.get_value (iter, 1)
00662         else:
00663             raise ValueError, "Widget type not supported (yet)"
00664 
00665         p = self.printer
00666         old_values = {
00667             self.entPDescription : p.info,
00668             self.entPLocation : p.location,
00669             self.entPDevice : p.device_uri,
00670             self.chkPEnabled : p.enabled,
00671             self.chkPAccepting : not p.rejecting,
00672             self.chkPShared : p.is_shared,
00673             self.cmbPStartBanner : p.job_sheet_start,
00674             self.cmbPEndBanner : p.job_sheet_end,
00675             self.cmbPErrorPolicy : p.error_policy,
00676             self.cmbPOperationPolicy : p.op_policy,
00677             self.rbtnPAllow: p.default_allow,
00678             }
00679 
00680         old_value = old_values[widget]
00681 
00682         if old_value == value:
00683             self.changed.discard(widget)
00684         else:
00685             self.changed.add(widget)
00686         self.setDataButtonState()

Here is the call graph for this function:

def printerproperties.PrinterPropertiesDialog.on_printer_event (   self,
  mon,
  printer,
  eventname,
  event 
)

Definition at line 1849 of file printerproperties.py.

01849 
01850     def on_printer_event (self, mon, printer, eventname, event):
01851         self.on_printer_modified (None, printer, False)

Here is the call graph for this function:

def printerproperties.PrinterPropertiesDialog.on_printer_modified (   self,
  obj,
  name,
  ppd_has_changed 
)

Definition at line 1835 of file printerproperties.py.

01835 
01836     def on_printer_modified (self, obj, name, ppd_has_changed):
01837         debugprint ("on_printer_modified called")
01838         if self.dialog.get_property ('visible') and self.printer:
01839             try:
01840                 self.printer.getAttributes ()
01841                 if ppd_has_changed:
01842                     self.load (name)
01843                 else:
01844                     self.updatePrinterProperties ()
01845 
01846             except cups.IPPError:
01847                 pass

Here is the call graph for this function:

Here is the caller graph for this function:

def printerproperties.PrinterPropertiesDialog.on_printer_removed (   self,
  mon,
  printer 
)

Definition at line 1852 of file printerproperties.py.

01852 
01853     def on_printer_removed (self, mon, printer):
01854         if (self.dialog.get_property ('visible') and
01855             self.printer and self.printer.name == printer):
01856             self.dialog.response (gtk.RESPONSE_CANCEL)
01857 
01858         if self.printer and self.printer.name == printer:
01859             self.printer = None

Definition at line 1860 of file printerproperties.py.

01860 
01861     def on_state_reason_added (self, mon, reason):
01862         if (self.dialog.get_property ('visible') and
01863             self.printer and self.printer.name == reason.get_printer ()):
01864             try:
01865                 self.printer.getAttributes ()
01866                 self.updatePrinterProperties ()
01867             except cups.IPPError:
01868                 pass

Here is the call graph for this function:

Definition at line 1869 of file printerproperties.py.

01869 
01870     def on_state_reason_removed (self, mon, reason):
01871         if (self.dialog.get_property ('visible') and
01872             self.printer and self.printer.name == reason.get_printer ()):
01873             try:
01874                 self.printer.getAttributes ()
01875                 self.updatePrinterProperties ()
01876             except cups.IPPError:
01877                 pass

Here is the call graph for this function:

Definition at line 1127 of file printerproperties.py.

01127 
01128     def on_tvPrinterProperties_cursor_changed (self, treeview):
01129         # Adjust notebook to reflect selected item.
01130         (path, column) = treeview.get_cursor ()
01131         if path != None:
01132             model = treeview.get_model ()
01133             iter = model.get_iter (path)
01134             n = model.get_value (iter, 1)
01135             self.ntbkPrinter.set_current_page (n)

Printer Properties tree view signal handlers.

Definition at line 1112 of file printerproperties.py.

01112 
01113     def on_tvPrinterProperties_selection_changed (self, selection):
01114         # Prevent selection from being de-selected.
01115         (model, iter) = selection.get_selected ()
01116         if iter:
01117             self.printer_properties_last_iter_selected = iter
01118         else:
01119             try:
01120                 iter = self.printer_properties_last_iter_selected
01121             except AttributeError:
01122                 # Not set yet.
01123                 return
01124 
01125             if model.iter_is_valid (iter):
01126                 selection.select_iter (iter)

Definition at line 759 of file printerproperties.py.

00759 
00760     def on_tvPUsers_cursor_changed(self, widget):
00761         model, rows = widget.get_selection().get_selected_rows()
00762         self.btnPDelUser.set_sensitive(bool(rows))

Here is the caller graph for this function:

Definition at line 687 of file printerproperties.py.

00687 
00688     def option_changed(self, option):
00689         if option.is_changed():
00690             self.changed.add(option)
00691         else:
00692             self.changed.discard(option)
00693 
00694         if option.conflicts:
00695             self.conflicts.add(option)
00696         else:
00697             self.conflicts.discard(option)
00698         self.setDataButtonState()
00699 
00700         if (self.option_manualfeed and self.option_inputslot and
00701             option == self.option_manualfeed):
00702             if option.get_current_value() == "True":
00703                 self.option_inputslot.disable ()
00704             else:
00705                 self.option_inputslot.enable ()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 596 of file printerproperties.py.

00596 
00597     def printer_properties_response (self, dialog, response):
00598         if not self.printer:
00599             response = gtk.RESPONSE_CANCEL
00600 
00601         if response == gtk.RESPONSE_REJECT:
00602             # The Conflict button was pressed.
00603             message = _("There are conflicting options.\n"
00604                         "Changes can only be applied after\n"
00605                         "these conflicts are resolved.")
00606             message += "\n\n"
00607             for option in self.conflicts:
00608                 message += option.option.text + "\n"
00609 
00610             dialog = gtk.MessageDialog(self.dialog,
00611                                        gtk.DIALOG_DESTROY_WITH_PARENT |
00612                                        gtk.DIALOG_MODAL,
00613                                        gtk.MESSAGE_WARNING,
00614                                        gtk.BUTTONS_CLOSE,
00615                                        message)
00616             dialog.run()
00617             dialog.destroy()
00618             return
00619 
00620         if (response == gtk.RESPONSE_OK or
00621             response == gtk.RESPONSE_APPLY):
00622             if (response == gtk.RESPONSE_OK and len (self.changed) == 0):
00623                 failed = False
00624             else:
00625                 failed = self.save_printer (self.printer)
00626 
00627         if response == gtk.RESPONSE_APPLY and not failed:
00628             try:
00629                 self.load (self.printer.name)
00630             except:
00631                 pass
00632 
00633             self.setDataButtonState ()
00634 
00635         if ((response == gtk.RESPONSE_OK and not failed) or
00636             response == gtk.RESPONSE_CANCEL):
00637             self.ppd = None
00638             self.ppd_local = None
00639             self.printer = None
00640             dialog.hide ()
00641             self.emit ('dialog-closed')
00642 
00643             if self.newPrinterGUI.NewPrinterWindow.get_property ("visible"):
00644                 self.newPrinterGUI.on_NPCancel (None)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1138 of file printerproperties.py.

01138 
01139     def printTestPage (self):
01140         self.btnPrintTestPage.clicked ()

def printerproperties.PrinterPropertiesDialog.save_printer (   self,
  printer,
  saveall = False,
  parent = None 
)

Definition at line 970 of file printerproperties.py.

00970 
00971     def save_printer(self, printer, saveall=False, parent=None):
00972         if parent == None:
00973             parent = self.dialog
00974         class_deleted = False
00975         name = printer.name
00976 
00977         if printer.is_class:
00978             self.cups._begin_operation (_("modifying class %s") % name)
00979         else:
00980             self.cups._begin_operation (_("modifying printer %s") % name)
00981 
00982         try:
00983             if not printer.is_class and self.ppd:
00984                 self.getPrinterSettings()
00985                 if self.ppd.nondefaultsMarked() or saveall:
00986                     self.cups.addPrinter(name, ppd=self.ppd)
00987 
00988             if printer.is_class:
00989                 # update member list
00990                 new_members = newprinter.getCurrentClassMembers(self.tvClassMembers)
00991                 if not new_members:
00992                     dialog = gtk.MessageDialog(
00993                         flags=0, type=gtk.MESSAGE_WARNING,
00994                         buttons=gtk.BUTTONS_NONE,
00995                         message_format=_("This will delete this class!"))
00996                     dialog.format_secondary_text(_("Proceed anyway?"))
00997                     dialog.add_buttons (gtk.STOCK_CANCEL, gtk.RESPONSE_NO,
00998                                         gtk.STOCK_DELETE, gtk.RESPONSE_YES)
00999                     result = dialog.run()
01000                     dialog.destroy()
01001                     if result==gtk.RESPONSE_NO:
01002                         self.cups._end_operation ()
01003                         return True
01004                     class_deleted = True
01005 
01006                 # update member list
01007                 old_members = printer.class_members[:]
01008 
01009                 for member in new_members:
01010                     if member in old_members:
01011                         old_members.remove(member)
01012                     else:
01013                         self.cups.addPrinterToClass(member, name)
01014                 for member in old_members:
01015                     self.cups.deletePrinterFromClass(member, name)
01016 
01017             location = self.entPLocation.get_text()
01018             info = self.entPDescription.get_text()
01019             device_uri = self.entPDevice.get_text()
01020 
01021             enabled = self.chkPEnabled.get_active()
01022             accepting = self.chkPAccepting.get_active()
01023             shared = self.chkPShared.get_active()
01024 
01025             if info!=printer.info or saveall:
01026                 self.cups.setPrinterInfo(name, info)
01027             if location!=printer.location or saveall:
01028                 self.cups.setPrinterLocation(name, location)
01029             if (not printer.is_class and
01030                 (device_uri!=printer.device_uri or saveall)):
01031                 self.cups.setPrinterDevice(name, device_uri)
01032 
01033             if enabled != printer.enabled or saveall:
01034                 printer.setEnabled(enabled)
01035             if accepting == printer.rejecting or saveall:
01036                 printer.setAccepting(accepting)
01037             if shared != printer.is_shared or saveall:
01038                 printer.setShared(shared)
01039 
01040             def get_combo_value (cmb):
01041                 model = cmb.get_model ()
01042                 iter = cmb.get_active_iter ()
01043                 return model.get_value (iter, 1)
01044 
01045             job_sheet_start = get_combo_value (self.cmbPStartBanner)
01046             job_sheet_end = get_combo_value (self.cmbPEndBanner)
01047             error_policy = get_combo_value (self.cmbPErrorPolicy)
01048             op_policy = get_combo_value (self.cmbPOperationPolicy)
01049 
01050             if (job_sheet_start != printer.job_sheet_start or
01051                 job_sheet_end != printer.job_sheet_end) or saveall:
01052                 printer.setJobSheets(job_sheet_start, job_sheet_end)
01053             if error_policy != printer.error_policy or saveall:
01054                 printer.setErrorPolicy(error_policy)
01055             if op_policy != printer.op_policy or saveall:
01056                 printer.setOperationPolicy(op_policy)
01057 
01058             default_allow = self.rbtnPAllow.get_active()
01059             except_users = self.getPUsers()
01060 
01061             if (default_allow != printer.default_allow or
01062                 except_users != printer.except_users) or saveall:
01063                 printer.setAccess(default_allow, except_users)
01064 
01065             for option in printer.attributes:
01066                 if option not in self.server_side_options:
01067                     printer.unsetOption(option)
01068             for option in self.server_side_options.itervalues():
01069                 if (option.is_changed() or
01070                     (saveall and
01071                      option.get_current_value () != option.get_default())):
01072                     debugprint ("Set %s = %s" % (option.name,
01073                                                  option.get_current_value()))
01074                     printer.setOption(option.name, option.get_current_value())
01075 
01076         except cups.IPPError, (e, s):
01077             show_IPP_Error(e, s, parent)
01078             self.cups._end_operation ()
01079             return True
01080         self.cups._end_operation ()
01081         self.changed = set() # of options
01082 
01083         if not self.cups._use_pk and not self.__dict__.has_key ("server_settings"):
01084             # We can authenticate with the server correctly at this point,
01085             # but we have never fetched the server settings to see whether
01086             # the server is publishing shared printers.  Fetch the settings
01087             # now so that we can update the "not published" label if necessary.
01088             self.cups._begin_operation (_("fetching server settings"))
01089             try:
01090                 self.server_settings = self.cups.adminGetServerSettings()
01091             except:
01092                 nonfatalException()
01093 
01094             self.cups._end_operation ()
01095 
01096         if not class_deleted:
01097             # Update our copy of the printer's settings.
01098             try:
01099                 printer.getAttributes ()
01100                 self.updatePrinterProperties ()
01101             except cups.IPPError:
01102                 pass
01103 
01104         self._monitor.update ()
01105         return False

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 534 of file printerproperties.py.

00534 
00535     def set_monitor (self, monitor):
00536         self._monitor = monitor
00537         if not monitor:
00538             return
00539 
00540         self._monitor.connect ('printer-event', self.on_printer_event)
00541         self._monitor.connect ('printer-removed', self.on_printer_removed)
00542         self._monitor.connect ('state-reason-added', self.on_state_reason_added)
00543         self._monitor.connect ('state-reason-removed',
00544                                self.on_state_reason_removed)
00545         self._monitor.connect ('cups-connection-error',
00546                                self.on_cups_connection_error)

def printerproperties.PrinterPropertiesDialog.set_printer_state_reason_icon (   self,
  column,
  cell,
  model,
  iter,
  data 
)

Definition at line 1595 of file printerproperties.py.

01595 
01596     def set_printer_state_reason_icon (self, column, cell, model, iter, *data):
01597         icon = model.get_value (iter, 0)
01598         theme = gtk.icon_theme_get_default ()
01599         try:
01600             pixbuf = theme.load_icon (icon, 22, 0)
01601             cell.set_property ("pixbuf", pixbuf)
01602         except gobject.GError, exc:
01603             pass # Couldn't load icon

def printerproperties.PrinterPropertiesDialog.set_printer_state_reason_text (   self,
  column,
  cell,
  model,
  iter,
  data 
)

Definition at line 1604 of file printerproperties.py.

01604 
01605     def set_printer_state_reason_text (self, column, cell, model, iter, *data):
01606         cell.set_property ("text", model.get_value (iter, 1))

Definition at line 875 of file printerproperties.py.

00875 
00876     def setDataButtonState(self):
00877         try:
00878             attrs = self.printer.other_attributes
00879             formats = attrs.get('document-format-supported', [])
00880             printable = (not bool (self.changed) and
00881                          self.printer.enabled and
00882                          not self.printer.rejecting)
00883             try:
00884                 formats.index ('application/postscript')
00885                 testpage = printable
00886             except ValueError:
00887                 # PostScript not accepted
00888                 testpage = False
00889 
00890             self.btnPrintTestPage.set_sensitive (testpage)
00891             adjustable = not (self.printer.discovered or bool (self.changed))
00892             for button in [self.btnChangePPD,
00893                            self.btnSelectDevice]:
00894                 button.set_sensitive (adjustable)
00895 
00896             selftest = False
00897             cleanheads = False
00898             if (printable and
00899                 (self.printer.type & cups.CUPS_PRINTER_COMMANDS) != 0):
00900                 try:
00901                     # Is the command format supported?
00902                     formats.index ('application/vnd.cups-command')
00903 
00904                     # Yes...
00905                     commands = attrs.get('printer-commands', [])
00906                     for command in commands:
00907                         if command == "PrintSelfTestPage":
00908                             selftest = True
00909                             if cleanheads:
00910                                 break
00911 
00912                         elif command == "Clean":
00913                             cleanheads = True
00914                             if selftest:
00915                                 break
00916                 except ValueError:
00917                     # Command format not supported.
00918                     pass
00919 
00920             for cond, button in [(selftest, self.btnSelfTest),
00921                                  (cleanheads, self.btnCleanHeads)]:
00922                 if cond:
00923                     button.show ()
00924                 else:
00925                     button.hide ()
00926         except:
00927             nonfatalException()
00928 
00929         installablebold = False
00930         optionsbold = False
00931         if self.conflicts:
00932             debugprint ("Conflicts detected")
00933             self.btnConflict.show()
00934             for option in self.conflicts:
00935                 if option.tab_label.get_text () == self.lblPInstallOptions.get_text ():
00936                     installablebold = True
00937                 else:
00938                     optionsbold = True
00939         else:
00940             self.btnConflict.hide()
00941         installabletext = _("Installable Options")
00942         optionstext = _("Printer Options")
00943         if installablebold:
00944             installabletext = "<b>%s</b>" % installabletext
00945         if optionsbold:
00946             optionstext = "<b>%s</b>" % optionstext
00947         self.lblPInstallOptions.set_markup (installabletext)
00948         self.lblPOptions.set_markup (optionstext)
00949 
00950         store = self.tvPrinterProperties.get_model ()
00951         if store:
00952             for n in range (self.ntbkPrinter.get_n_pages ()):
00953                 page = self.ntbkPrinter.get_nth_page (n)
00954                 label = self.ntbkPrinter.get_tab_label (page).get_text ()
00955                 try:
00956                     if label == self.lblPInstallOptions.get_text():
00957                         iter = store.get_iter ((n,))
00958                         store.set_value (iter, 0, installabletext)
00959                     elif label == self.lblPOptions.get_text ():
00960                         iter = store.get_iter ((n,))
00961                         store.set_value (iter, 0, optionstext)
00962                 except ValueError:
00963                     # If we get here, the store has not yet been set
00964                     # up (trac #111).
00965                     pass
00966 
00967         self.btnPrinterPropertiesApply.set_sensitive (len (self.changed) > 0 and
00968                                                       not self.conflicts)
00969         self.btnPrinterPropertiesOK.set_sensitive (not self.conflicts)

Here is the call graph for this function:

Here is the caller graph for this function:

write list of usernames inot the GUI

Definition at line 716 of file printerproperties.py.

00716 
00717     def setPUsers(self, users):
00718         """write list of usernames inot the GUI"""
00719         model = self.tvPUsers.get_model()
00720         model.clear()
00721         for user in users:
00722             model.append((user,))
00723 
00724         self.on_entPUser_changed(self.entPUser)
00725         self.on_tvPUsers_cursor_changed(self.tvPUsers)

Here is the call graph for this function:

Here is the caller graph for this function:

def printerproperties.PrinterPropertiesDialog.show (   self,
  name,
  host = None,
  encryption = None,
  parent = None 
)

Definition at line 547 of file printerproperties.py.

00547 
00548     def show (self, name, host=None, encryption=None, parent=None):
00549         self.parent = parent
00550         self._host = host
00551         self._encryption = encryption
00552         if not host:
00553             self._host = cups.getServer()
00554         if not encryption:
00555             self._encryption = cups.getEncryption ()
00556 
00557         if self._monitor == None:
00558             self.set_monitor (monitor.Monitor (monitor_jobs=False))
00559 
00560         self._ppdcache = self._monitor.get_ppdcache ()
00561 
00562         self._disconnect ("newPrinterGUI")
00563         self.newPrinterGUI = newprinter.NewPrinterGUI ()
00564         self._connect ("newPrinterGUI", self.newPrinterGUI,
00565                        "printer-modified", self.on_printer_modified)
00566         if parent:
00567             self.dialog.set_transient_for (parent)
00568 
00569         self.load (name, host=host, encryption=encryption, parent=parent)
00570         if not self.printer:
00571             return
00572 
00573         for button in [self.btnPrinterPropertiesCancel,
00574                        self.btnPrinterPropertiesOK,
00575                        self.btnPrinterPropertiesApply]:
00576             if self.printer.discovered:
00577                 button.hide ()
00578             else:
00579                 button.show ()
00580         if self.printer.discovered:
00581             self.btnPrinterPropertiesClose.show ()
00582         else:
00583             self.btnPrinterPropertiesClose.hide ()
00584         self.setDataButtonState ()
00585         self.btnPrintTestPage.set_tooltip_text(_("CUPS test page"))
00586         self.btnSelfTest.set_tooltip_text(_("Typically shows whether all jets "
00587                                             "on a print head are functioning "
00588                                             "and that the print feed mechanisms"
00589                                             " are working properly."))
00590         treeview = self.tvPrinterProperties
00591         treeview.set_cursor ((0,))
00592         host = CUPS_server_hostname ()
00593         self.dialog.set_title (_("Printer Properties - "
00594                                  "'%s' on %s") % (name, host))
00595         self.dialog.show ()

Definition at line 1470 of file printerproperties.py.

01470 
01471     def updateMarkerLevels (self):
01472         printer = self.printer
01473         if not printer:
01474             # Printer has been deleted meanwhile
01475             return
01476 
01477         # Marker levels
01478         for widget in self.vboxMarkerLevels.get_children ():
01479             self.vboxMarkerLevels.remove (widget)
01480 
01481         marker_info = dict()
01482         num_markers = 0
01483         for (attr, typ) in [('marker-colors', str),
01484                             ('marker-names', str),
01485                             ('marker-types', str),
01486                             ('marker-levels', float)]:
01487             val = printer.other_attributes.get (attr, [])
01488             if typ != str and len (val) > 0:
01489                 try:
01490                     # Can the value be coerced into the right type?
01491                     typ (val[0])
01492                 except TypeError, s:
01493                     debugprint ("%s value not coercible to %s: %s" %
01494                                 (attr, typ, s))
01495                     val = map (lambda x: 0.0, val)
01496 
01497             marker_info[attr] = val
01498             if num_markers == 0 or len (val) < num_markers:
01499                 num_markers = len (val)
01500 
01501         for attr in ['marker-colors', 'marker-names',
01502                      'marker-types', 'marker-levels']:
01503             if len (marker_info[attr]) > num_markers:
01504                 debugprint ("Trimming %s from %s" %
01505                             (marker_info[attr][num_markers:], attr))
01506                 del marker_info[attr][num_markers:]
01507 
01508         markers = map (lambda color, name, type, level:
01509                            (color, name, type, level),
01510                        marker_info['marker-colors'],
01511                        marker_info['marker-names'],
01512                        marker_info['marker-types'],
01513                        marker_info['marker-levels'])
01514         debugprint (markers)
01515 
01516         can_refresh = (printer.type & cups.CUPS_PRINTER_COMMANDS) != 0
01517         if can_refresh:
01518             self.btnRefreshMarkerLevels.show ()
01519         else:
01520             self.btnRefreshMarkerLevels.hide ()
01521 
01522         if len (markers) == 0:
01523             label = gtk.Label(_("Marker levels are not reported "
01524                                 "for this printer."))
01525             label.set_line_wrap (True)
01526             label.set_alignment (0.0, 0.0)
01527             self.vboxMarkerLevels.pack_start (label, False, False, 0)
01528         else:
01529             num_markers = 0
01530             cols = len (markers)
01531             rows = 1 + (cols - 1) / 4
01532             if cols > 4:
01533                 cols = 4
01534             table = gtk.Table (rows=rows,
01535                                columns=cols,
01536                                homogeneous=True)
01537             table.set_col_spacings (6)
01538             table.set_row_spacings (12)
01539             self.vboxMarkerLevels.pack_start (table)
01540             for color, name, marker_type, level in markers:
01541                 if name == None:
01542                     name = ''
01543                 elif self.ppd != False:
01544                     localized_name = self.ppd.localizeMarkerName(name)
01545                     if localized_name != None:
01546                         name = localized_name
01547 
01548                 row = num_markers / 4
01549                 col = num_markers % 4
01550 
01551                 vbox = gtk.VBox (spacing=6)
01552                 subhbox = gtk.HBox ()
01553                 inklevel = gtkinklevel.GtkInkLevel (color, level)
01554                 inklevel.set_tooltip_text ("%d%%" % level)
01555                 subhbox.pack_start (inklevel, True, False, 0)
01556                 vbox.pack_start (subhbox, False, False, 0)
01557                 label = gtk.Label (name)
01558                 label.set_width_chars (10)
01559                 label.set_line_wrap (True)
01560                 vbox.pack_start (label, False, False, 0)
01561                 table.attach (vbox, col, col + 1, row, row + 1)
01562                 num_markers += 1
01563 
01564         self.vboxMarkerLevels.show_all ()

Here is the caller graph for this function:

Definition at line 1607 of file printerproperties.py.

01607 
01608     def updatePrinterProperties(self):
01609         debugprint ("update printer properties")
01610         printer = self.printer
01611         self.entPMakeModel.set_text(printer.make_and_model)
01612         state = self.printer_states.get (printer.state, _("Unknown"))
01613         reason = printer.other_attributes.get ('printer-state-message', '')
01614         if len (reason) > 0:
01615             state += ' - ' + reason
01616         self.entPState.set_text(state)
01617         if len (self.changed) == 0:
01618             debugprint ("no changes yet: full printer properties update")
01619             # State
01620             self.chkPEnabled.set_active(printer.enabled)
01621             self.chkPAccepting.set_active(not printer.rejecting)
01622             self.chkPShared.set_active(printer.is_shared)
01623 
01624             # Job sheets
01625             self.fillComboBox(self.cmbPStartBanner,
01626                               printer.job_sheets_supported,
01627                               printer.job_sheet_start,
01628                               ppdippstr.job_sheets)
01629             self.fillComboBox(self.cmbPEndBanner, printer.job_sheets_supported,
01630                               printer.job_sheet_end,
01631                               ppdippstr.job_sheets)
01632 
01633             # Policies
01634             self.fillComboBox(self.cmbPErrorPolicy,
01635                               printer.error_policy_supported,
01636                               printer.error_policy,
01637                               ppdippstr.printer_error_policy)
01638             self.fillComboBox(self.cmbPOperationPolicy,
01639                               printer.op_policy_supported,
01640                               printer.op_policy,
01641                               ppdippstr.printer_op_policy)
01642 
01643             # Access control
01644             self.rbtnPAllow.set_active(printer.default_allow)
01645             self.rbtnPDeny.set_active(not printer.default_allow)
01646             self.setPUsers(printer.except_users)
01647 
01648             # Marker levels
01649             self.updateMarkerLevels ()
01650             self.updateStateReasons ()
01651 
01652             self.updatePrinterPropertiesTreeView ()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1457 of file printerproperties.py.

01457 
01458     def updatePrinterPropertiesTreeView (self):
01459         # Now update the tree view (which we use instead of the notebook tabs).
01460         store = gtk.ListStore (gobject.TYPE_STRING, gobject.TYPE_INT)
01461         self.ntbkPrinter.set_show_tabs (False)
01462         for n in range (self.ntbkPrinter.get_n_pages ()):
01463             page = self.ntbkPrinter.get_nth_page (n)
01464             label = self.ntbkPrinter.get_tab_label (page)
01465             iter = store.append (None)
01466             store.set_value (iter, 0, label.get_text ())
01467             store.set_value (iter, 1, n)
01468         sel = self.tvPrinterProperties.get_selection ()
01469         self.tvPrinterProperties.set_model (store)

Here is the caller graph for this function:

Definition at line 1568 of file printerproperties.py.

01568 
01569     def updateStateReasons (self):
01570         printer = self.printer
01571         reasons = printer.other_attributes.get ('printer-state-reasons', [])
01572         store = gtk.ListStore (str, str)
01573         any = False
01574         for reason in reasons:
01575             if reason == "none":
01576                 break
01577 
01578             any = True
01579             iter = store.append (None)
01580             r = statereason.StateReason (printer.name, reason, self._ppdcache)
01581             if r.get_reason () == "paused":
01582                 icon = gtk.STOCK_MEDIA_PAUSE
01583             else:
01584                 icon = statereason.StateReason.LEVEL_ICON[r.get_level ()]
01585             store.set_value (iter, 0, icon)
01586             (title, text) = r.get_description ()
01587             store.set_value (iter, 1, text)
01588 
01589         self.tvPrinterStateReasons.set_model (store)
01590         page = 0
01591         if any:
01592             page = 1
01593 
01594         self.ntbkPrinterStateReasons.set_current_page (page)

Here is the caller graph for this function:


Member Data Documentation

Initial value:
{
        'destroy':       ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
        'dialog-closed': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
        }

Definition at line 62 of file printerproperties.py.

Definition at line 550 of file printerproperties.py.

Definition at line 549 of file printerproperties.py.

Definition at line 535 of file printerproperties.py.

Definition at line 559 of file printerproperties.py.

tuple printerproperties.PrinterPropertiesDialog.cell = gtk.CellRendererText() [static]

Definition at line 329 of file printerproperties.py.

Definition at line 87 of file printerproperties.py.

Definition at line 86 of file printerproperties.py.

Definition at line 1272 of file printerproperties.py.

Definition at line 189 of file printerproperties.py.

Definition at line 77 of file printerproperties.py.

Definition at line 76 of file printerproperties.py.

tuple printerproperties.PrinterPropertiesDialog.model = gtk.ListStore(gobject.TYPE_STRING) [static]

Definition at line 325 of file printerproperties.py.

Definition at line 562 of file printerproperties.py.

Definition at line 1722 of file printerproperties.py.

Definition at line 1722 of file printerproperties.py.

Definition at line 1261 of file printerproperties.py.

Definition at line 334 of file printerproperties.py.

Definition at line 1413 of file printerproperties.py.

Definition at line 548 of file printerproperties.py.

Definition at line 85 of file printerproperties.py.

Definition at line 530 of file printerproperties.py.

Definition at line 85 of file printerproperties.py.

Definition at line 1116 of file printerproperties.py.

Initial value:
{ cups.IPP_PRINTER_IDLE: _("Idle"),
                       cups.IPP_PRINTER_PROCESSING: _("Processing"),
                       cups.IPP_PRINTER_BUSY: _("Busy"),
                       cups.IPP_PRINTER_STOPPED: _("Stopped") }

Definition at line 67 of file printerproperties.py.

Definition at line 524 of file printerproperties.py.

Definition at line 1279 of file printerproperties.py.

Definition at line 1089 of file printerproperties.py.

Definition at line 1372 of file printerproperties.py.

Definition at line 88 of file printerproperties.py.

Definition at line 224 of file printerproperties.py.

Definition at line 92 of file printerproperties.py.


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