Back to index

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

List of all members.

Public Member Functions

def __init__
def display
def collect_answer
def cancel_operation
def connect_signals
def disconnect_signals
def can_click_forward
def initial_vbox
 Helper functions.

Public Attributes

 label
 op
 state_message
 state_reasons
 troubleshooter

Detailed Description

Definition at line 28 of file PrinterStateReasons.py.


Constructor & Destructor Documentation

Definition at line 29 of file PrinterStateReasons.py.

00029 
00030     def __init__ (self, troubleshooter):
00031         Question.__init__ (self, troubleshooter, "Printer state reasons")
00032         page = self.initial_vbox (_("Status Messages"),
00033                                   _("There are status messages associated with "
00034                                     "this queue."))
00035         self.label = gtk.Label ()
00036         self.label.set_alignment (0, 0)
00037         self.label.set_line_wrap (True)
00038         page.pack_start (self.label, False, False, 0)
00039 
00040         troubleshooter.new_page (page, self)

Here is the call graph for this function:


Member Function Documentation

Reimplemented from troubleshoot.base.Question.

Definition at line 119 of file PrinterStateReasons.py.

00119 
00120     def cancel_operation (self):
00121         self.op.cancel ()

Reimplemented from troubleshoot.base.Question.

Definition at line 112 of file PrinterStateReasons.py.

00112 
00113     def collect_answer (self):
00114         if not self.displayed:
00115             return {}
00116 
00117         return { 'printer-state-message': self.state_message,
00118                  'printer-state-reasons': self.state_reasons }

def troubleshoot.base.Question.connect_signals (   self,
  handler 
) [inherited]
Returns True if this page should be displayed, or False
if it should be skipped.

Reimplemented from troubleshoot.base.Question.

Definition at line 41 of file PrinterStateReasons.py.

00041 
00042     def display (self):
00043         troubleshooter = self.troubleshooter
00044         try:
00045             queue = troubleshooter.answers['cups_queue']
00046         except KeyError:
00047             return False
00048 
00049         parent = self.troubleshooter.get_window ()
00050         cups.setServer ('')
00051         self.op = TimedOperation (cups.Connection, parent=parent)
00052         c = self.op.run ()
00053         self.op = TimedOperation (c.getPrinterAttributes,
00054                                   args=(queue,),
00055                                   parent=parent)
00056         dict = self.op.run ()
00057 
00058         the_ppdcache = ppdcache.PPDCache ()
00059 
00060         text = ''
00061         state_message = dict['printer-state-message']
00062         if state_message:
00063             text += _("The printer's state message is: '%s'.") % state_message
00064             text += '\n\n'
00065 
00066         state_reasons_list = dict['printer-state-reasons']
00067         if type (state_reasons_list) == unicode:
00068             state_reasons_list = [state_reasons_list]
00069 
00070         self.state_message = state_message
00071         self.state_reasons = state_reasons_list
00072 
00073         human_readable_errors = []
00074         human_readable_warnings = []
00075         for reason in state_reasons_list:
00076             if reason == "none":
00077                 continue
00078 
00079             r = statereason.StateReason (queue, reason, the_ppdcache)
00080             (title, description) = r.get_description ()
00081             level = r.get_level ()
00082             if level == statereason.StateReason.ERROR:
00083                 human_readable_errors.append (description)
00084             elif level == statereason.StateReason.WARNING:
00085                 human_readable_warnings.append (description)
00086 
00087         if human_readable_errors:
00088             text += _("Errors are listed below:") + '\n'
00089             text += reduce (lambda x, y: x + "\n" + y, human_readable_errors)
00090             text += '\n\n'
00091 
00092         if human_readable_warnings:
00093             text += _("Warnings are listed below:") + '\n'
00094             text += reduce (lambda x, y: x + "\n" + y, human_readable_warnings)
00095 
00096         self.label.set_text (text)
00097         if (state_message == '' and
00098             len (human_readable_errors) == 0 and
00099             len (human_readable_warnings) == 0):
00100             return False
00101 
00102         # If this screen has been show before, don't show it again if
00103         # nothing changed.
00104         if troubleshooter.answers.has_key ('printer-state-message'):
00105             if (troubleshooter.answers['printer-state-message'] ==
00106                 self.state_message and
00107                 troubleshooter.answers['printer-state-reasons'] ==
00108                 self.state_reasons):
00109                 return False
00110 
00111         return True

def troubleshoot.base.Question.initial_vbox (   self,
  title = '',
  text = '' 
) [inherited]

Helper functions.

Definition at line 66 of file base.py.

00066 
00067     def initial_vbox (self, title='', text=''):
00068         vbox = gtk.VBox ()
00069         vbox.set_border_width (12)
00070         vbox.set_spacing (12)
00071         if title:
00072             s = '<span weight="bold" size="larger">' + title + '</span>\n\n'
00073         else:
00074             s = ''
00075         s += text
00076         label = gtk.Label (s)
00077         label.set_alignment (0, 0)
00078         label.set_line_wrap (True)
00079         label.set_use_markup (True)
00080         vbox.pack_start (label, False, False, 0)
00081         return vbox

Here is the caller graph for this function:


Member Data Documentation

Definition at line 34 of file PrinterStateReasons.py.

Definition at line 50 of file PrinterStateReasons.py.

Definition at line 69 of file PrinterStateReasons.py.

Definition at line 70 of file PrinterStateReasons.py.

Reimplemented in troubleshoot.CheckPrinterSanity.CheckPrinterSanity.

Definition at line 41 of file base.py.


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