Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
troubleshoot.Troubleshooter Class Reference

List of all members.

Public Member Functions

def __init__
def quit
def get_window
def no_more_questions
def new_page
def is_moving_backwards
def answers_as_text
def busy
def ready

Public Attributes

 main
 quitfn
 back
 close
 cancel
 forward
 ntbk
 current_page
 questions
 question_answers
 answers
 moving_backwards

Private Member Functions

def _set_back_forward_buttons
def _on_back_clicked
def _on_forward_clicked
def _dump_answers
def _report_traceback
def _display
def _can_click_forward
def _collect_answer

Private Attributes

 _in_module_call

Detailed Description

Definition at line 44 of file __init__.py.


Constructor & Destructor Documentation

def troubleshoot.Troubleshooter.__init__ (   self,
  quitfn = None,
  parent = None 
)

Definition at line 45 of file __init__.py.

00045 
00046     def __init__ (self, quitfn=None, parent=None):
00047         self._in_module_call = False
00048 
00049         main = gtk.Window ()
00050         if parent:
00051             main.set_transient_for (parent)
00052             main.set_position (gtk.WIN_POS_CENTER_ON_PARENT)
00053             main.set_modal (True)
00054 
00055         main.set_title (_("Printing troubleshooter"))
00056         main.set_property ("default-width", 400)
00057         main.set_property ("default-height", 350)
00058         main.connect ("delete_event", self.quit)
00059         self.main = main
00060         self.quitfn = quitfn
00061 
00062         vbox = gtk.VBox ()
00063         main.add (vbox)
00064         ntbk = gtk.Notebook ()
00065         ntbk.set_border_width (6)
00066         vbox.pack_start (ntbk, True, True, 0)
00067         vbox.pack_start (gtk.HSeparator (), False, False, 0)
00068         box = gtk.HButtonBox ()
00069         box.set_border_width (6)
00070         box.set_spacing (3)
00071         box.set_layout (gtk.BUTTONBOX_END)
00072 
00073         back = gtk.Button (stock=gtk.STOCK_GO_BACK)
00074         back.connect ('clicked', self._on_back_clicked)
00075         back.set_sensitive (False)
00076         self.back = back
00077 
00078         close = gtk.Button (stock=gtk.STOCK_CLOSE)
00079         close.connect ('clicked', self.quit)
00080         self.close = close
00081 
00082         cancel = gtk.Button (stock=gtk.STOCK_CANCEL)
00083         cancel.connect ('clicked', self.quit)
00084         self.cancel = cancel
00085 
00086         forward = gtk.Button (stock=gtk.STOCK_GO_FORWARD)
00087         forward.connect ('clicked', self._on_forward_clicked)
00088         forward.set_flags (gtk.CAN_DEFAULT | gtk.HAS_DEFAULT)
00089         self.forward = forward
00090 
00091         box.pack_start (back, False, False, 0)
00092         box.pack_start (cancel, False, False, 0)
00093         box.pack_start (close, False, False, 0)
00094         box.pack_start (forward, False, False, 0)
00095         vbox.pack_start (box, False, False, 0)
00096 
00097         ntbk.set_current_page (0)
00098         ntbk.set_show_tabs (False)
00099         self.ntbk = ntbk
00100         self.current_page = 0
00101 
00102         self.questions = []
00103         self.question_answers = []
00104         self.answers = {}
00105         self.moving_backwards = False
00106 
00107         main.show_all ()


Member Function Documentation

def troubleshoot.Troubleshooter._can_click_forward (   self,
  question 
) [private]

Definition at line 304 of file __init__.py.

00304 
00305     def _can_click_forward (self, question):
00306         try:
00307             return question.can_click_forward ()
00308         except:
00309             self._report_traceback ()
00310             return True

Here is the call graph for this function:

Here is the caller graph for this function:

def troubleshoot.Troubleshooter._collect_answer (   self,
  question 
) [private]

Definition at line 311 of file __init__.py.

00311 
00312     def _collect_answer (self, question):
00313         answer = {}
00314         try:
00315             answer = question.collect_answer ()
00316         except:
00317             self._report_traceback ()
00318 
00319         return answer

Here is the call graph for this function:

Here is the caller graph for this function:

def troubleshoot.Troubleshooter._display (   self,
  question 
) [private]

Definition at line 294 of file __init__.py.

00294 
00295     def _display (self, question):
00296         result = False
00297         try:
00298             result = question.display ()
00299         except:
00300             self._report_traceback ()
00301 
00302         question.displayed = result
00303         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 277 of file __init__.py.

00277 
00278     def _dump_answers (self):
00279         debugprint (self.answers_as_text ())

Here is the call graph for this function:

Here is the caller graph for this function:

def troubleshoot.Troubleshooter._on_back_clicked (   self,
  widget 
) [private]

Definition at line 214 of file __init__.py.

00214 
00215     def _on_back_clicked (self, widget):
00216         self.busy ()
00217         self.moving_backwards = True
00218         try:
00219             self.questions[self.current_page].disconnect_signals ()
00220         except:
00221             self._report_traceback ()
00222 
00223         self.current_page -= 1
00224         question = self.questions[self.current_page]
00225         while not self._display (question):
00226             # Skip this one.            
00227             debugprint ("Page %d: skip" % (self.current_page))
00228             self.current_page -= 1
00229             question = self.questions[self.current_page]
00230 
00231         self.ntbk.set_current_page (self.current_page)
00232         answers = {}
00233         for i in range (self.current_page):
00234             answers.update (self.question_answers[i])
00235         self.answers = answers
00236 
00237         try:
00238             self.questions[self.current_page].\
00239                 connect_signals (self._set_back_forward_buttons)
00240         except:
00241             self._report_traceback ()
00242 
00243         self.moving_backwards = False
00244         self.ready ()

Here is the call graph for this function:

def troubleshoot.Troubleshooter._on_forward_clicked (   self,
  widget 
) [private]

Definition at line 245 of file __init__.py.

00245 
00246     def _on_forward_clicked (self, widget):
00247         self.busy ()
00248         answer_dict = self._collect_answer (self.questions[self.current_page])
00249         self.question_answers[self.current_page] = answer_dict
00250         self.answers.update (answer_dict)
00251 
00252         try:
00253             self.questions[self.current_page].disconnect_signals ()
00254         except:
00255             self._report_traceback ()
00256 
00257         self.current_page += 1
00258         question = self.questions[self.current_page]
00259         while not self._display (question):
00260             # Skip this one, but collect its answers.
00261             answer_dict = self._collect_answer (question)
00262             self.question_answers[self.current_page] = answer_dict
00263             self.answers.update (answer_dict)
00264             debugprint ("Page %d: skip" % (self.current_page))
00265             self.current_page += 1
00266             question = self.questions[self.current_page]
00267 
00268         self.ntbk.set_current_page (self.current_page)
00269         try:
00270             question.connect_signals (self._set_back_forward_buttons)
00271         except:
00272             self._report_traceback ()
00273 
00274         self.ready ()
00275         if get_debugging ():
00276             self._dump_answers ()

Here is the call graph for this function:

Definition at line 280 of file __init__.py.

00280 
00281     def _report_traceback (self):
00282         try:
00283             print "Traceback:"
00284             (type, value, tb) = sys.exc_info ()
00285             tblast = traceback.extract_tb (tb, limit=None)
00286             if len (tblast):
00287                 tblast = tblast[:len (tblast) - 1]
00288             extxt = traceback.format_exception_only (type, value)
00289             for line in traceback.format_tb(tb):
00290                 print line.strip ()
00291             print extxt[0].strip ()
00292         except:
00293             pass

Here is the caller graph for this function:

def troubleshoot.Troubleshooter._set_back_forward_buttons (   self,
  args 
) [private]

Definition at line 198 of file __init__.py.

00198 
00199     def _set_back_forward_buttons (self, *args):
00200         page = self.current_page
00201         self.back.set_sensitive (page != 0)
00202         if len (self.questions) == page + 1:
00203             # Out of questions.
00204             debugprint ("Out of questions")
00205             self.forward.set_sensitive (False)
00206             self.close.show ()
00207             self.cancel.hide ()
00208         else:
00209             can = self._can_click_forward (self.questions[page])
00210             debugprint ("Page %d: can click forward? %s" % (page, can))
00211             self.forward.set_sensitive (can)
00212             self.close.hide ()
00213             self.cancel.show ()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 166 of file __init__.py.

00166 
00167     def answers_as_text (self):
00168         text = ""
00169         n = 1
00170         for i in range (self.current_page):
00171             answers = self.question_answers[i].copy ()
00172             for hidden in filter (lambda x: x.startswith ("_"), answers.keys()):
00173                 del answers[hidden]
00174             if len (answers.keys ()) == 0:
00175                 continue
00176             text += "Page %d (%s):" % (n, self.questions[i]) + '\n'
00177             text += pprint.pformat (answers) + '\n'
00178             n += 1
00179         return text.rstrip () + '\n'

Here is the caller graph for this function:

Definition at line 180 of file __init__.py.

00180 
00181     def busy (self):
00182         self._in_module_call = True
00183         self.forward.set_sensitive (False)
00184         self.back.set_sensitive (False)
00185         gdkwin = self.get_window ().window
00186         if gdkwin:
00187             gdkwin.set_cursor (gtk.gdk.Cursor (gtk.gdk.WATCH))
00188             while gtk.events_pending ():
00189                 gtk.main_iteration ()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 131 of file __init__.py.

00131 
00132     def get_window (self):
00133         # Any error dialogs etc from the modules need to be able
00134         # to set themselves transient for this window.
00135         return self.main

Here is the caller graph for this function:

Definition at line 163 of file __init__.py.

00163 
00164     def is_moving_backwards (self):
00165         return self.moving_backwards

def troubleshoot.Troubleshooter.new_page (   self,
  widget,
  question 
)

Definition at line 145 of file __init__.py.

00145 
00146     def new_page (self, widget, question):
00147         page = len (self.questions)
00148         debugprint ("Page %d: new: %s" % (page, str (question)))
00149         self.questions.append (question)
00150         self.question_answers.append ([])
00151         self.ntbk.insert_page (widget, position=page)
00152         widget.show_all ()
00153         if page == 0:
00154             try:
00155                 question.connect_signals (self._set_back_forward_buttons)
00156             except:
00157                 self._report_traceback ()
00158 
00159             self.ntbk.set_current_page (page)
00160             self.current_page = page
00161         self._set_back_forward_buttons ()
00162         return page

Here is the call graph for this function:

def troubleshoot.Troubleshooter.no_more_questions (   self,
  question 
)

Definition at line 136 of file __init__.py.

00136 
00137     def no_more_questions (self, question):
00138         page = self.questions.index (question)
00139         debugprint ("Page %d: No more questions." % page)
00140         self.questions = self.questions[:page + 1]
00141         self.question_answers = self.question_answers[:page + 1]
00142         for p in range (self.ntbk.get_n_pages () - 1, page, -1):
00143             self.ntbk.remove_page (p)
00144         self._set_back_forward_buttons ()

Here is the call graph for this function:

def troubleshoot.Troubleshooter.quit (   self,
  args 
)

Definition at line 108 of file __init__.py.

00108 
00109     def quit (self, *args):
00110         if self._in_module_call:
00111             try:
00112                 self.questions[self.current_page].cancel_operation ()
00113             except:
00114                 self._report_traceback ()
00115 
00116             return
00117 
00118         try:
00119             self.questions[self.current_page].disconnect_signals ()
00120         except:
00121             self._report_traceback ()
00122 
00123         # Delete the questions so that their __del__ hooks can run.
00124         # Do this in reverse order of creation.
00125         for i in xrange (len (self.questions)):
00126             self.questions.pop ()
00127 
00128         self.main.hide ()
00129         if self.quitfn:
00130             self.quitfn (self)

Here is the call graph for this function:

Definition at line 190 of file __init__.py.

00190 
00191     def ready (self):
00192         self._in_module_call = False
00193         gdkwin = self.get_window ().window
00194         if gdkwin:
00195             gdkwin.set_cursor (gtk.gdk.Cursor (gtk.gdk.LEFT_PTR))
00196 
00197         self._set_back_forward_buttons ()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 46 of file __init__.py.

Definition at line 103 of file __init__.py.

Definition at line 75 of file __init__.py.

Definition at line 83 of file __init__.py.

Definition at line 79 of file __init__.py.

Definition at line 99 of file __init__.py.

Definition at line 88 of file __init__.py.

Definition at line 58 of file __init__.py.

Definition at line 104 of file __init__.py.

Definition at line 98 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 101 of file __init__.py.

Definition at line 59 of file __init__.py.


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