Back to index

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

List of all members.

Public Member Functions

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

Public Attributes

 treeview
 signal_id
 dests
 op
 troubleshooter

Detailed Description

Definition at line 26 of file ChoosePrinter.py.


Constructor & Destructor Documentation

def troubleshoot.ChoosePrinter.ChoosePrinter.__init__ (   self,
  troubleshooter 
)

Definition at line 27 of file ChoosePrinter.py.

00027 
00028     def __init__ (self, troubleshooter):
00029         # First question: which printer? (page 1)
00030         Question.__init__ (self, troubleshooter, "Choose printer")
00031         page1 = self.initial_vbox (_("Choose Printer"),
00032                                    _("Please select the printer you are "
00033                                      "trying to use from the list below. "
00034                                      "If it does not appear in the list, "
00035                                      "select 'Not listed'."))
00036         tv = gtk.TreeView ()
00037         name = gtk.TreeViewColumn (_("Name"),
00038                                    gtk.CellRendererText (), text=0)
00039         location = gtk.TreeViewColumn (_("Location"),
00040                                        gtk.CellRendererText (), text=1)
00041         info = gtk.TreeViewColumn (_("Information"),
00042                                    gtk.CellRendererText (), text=2)
00043         name.set_property ("resizable", True)
00044         location.set_property ("resizable", True)
00045         info.set_property ("resizable", True)
00046         tv.append_column (name)
00047         tv.append_column (location)
00048         tv.append_column (info)
00049         tv.set_rules_hint (True)
00050         sw = gtk.ScrolledWindow ()
00051         sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
00052         sw.set_shadow_type (gtk.SHADOW_IN)
00053         sw.add (tv)
00054         page1.pack_start (sw, True, True, 0)
00055         self.treeview = tv
00056         troubleshooter.new_page (page1, self)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

Reimplemented from troubleshoot.base.Question.

Definition at line 116 of file ChoosePrinter.py.

00116 
00117     def can_click_forward (self):
00118         model, iter = self.treeview.get_selection ().get_selected ()
00119         if iter == None:
00120             return False
00121         return True

Reimplemented from troubleshoot.base.Question.

Definition at line 144 of file ChoosePrinter.py.

00144 
00145     def cancel_operation (self):
00146         self.op.cancel ()

Reimplemented from troubleshoot.base.Question.

Definition at line 122 of file ChoosePrinter.py.

00122 
00123     def collect_answer (self):
00124         model, iter = self.treeview.get_selection ().get_selected ()
00125         dest = model.get_value (iter, 3)
00126         if dest == None:
00127             class enum_dests:
00128                 def __init__ (self, model):
00129                     self.dests = []
00130                     model.foreach (self.each, None)
00131 
00132                 def each (self, model, path, iter, user_data):
00133                     dest = model.get_value (iter, 3)
00134                     if dest:
00135                         self.dests.append ((dest.name, dest.instance))
00136 
00137             return { 'cups_queue_listed': False,
00138                      'cups_dests_available': enum_dests (model).dests }
00139         else:
00140             return { 'cups_queue_listed': True,
00141                      'cups_dest': dest,
00142                      'cups_queue': dest.name,
00143                      'cups_instance': dest.instance }

Here is the call graph for this function:

Reimplemented from troubleshoot.base.Question.

Definition at line 110 of file ChoosePrinter.py.

00110 
00111     def connect_signals (self, handler):
00112         self.signal_id = self.treeview.connect ("cursor-changed", handler)

Reimplemented from troubleshoot.base.Question.

Definition at line 113 of file ChoosePrinter.py.

00113 
00114     def disconnect_signals (self):
00115         self.treeview.disconnect (self.signal_id)

Returns True if this page should be displayed, or False
if it should be skipped.

Reimplemented from troubleshoot.base.Question.

Definition at line 57 of file ChoosePrinter.py.

00057 
00058     def display (self):
00059         model = gtk.ListStore (gobject.TYPE_STRING,
00060                                gobject.TYPE_STRING,
00061                                gobject.TYPE_STRING,
00062                                gobject.TYPE_PYOBJECT)
00063         self.treeview.set_model (model)
00064         iter = model.append (None)
00065         model.set (iter, 0, _("Not listed"), 1, '', 2, '', 3, None)
00066 
00067         parent = self.troubleshooter.get_window ()
00068         try:
00069             cups.setServer ('')
00070             c = self.timedop (cups.Connection, parent=parent).run ()
00071             dests = self.timedop (c.getDests, parent=parent).run ()
00072             printers = None
00073             dests_list = []
00074             for (name, instance), dest in dests.iteritems ():
00075                 if name == None:
00076                     continue
00077 
00078                 if instance != None:
00079                     queue = "%s/%s" % (name, instance)
00080                 else:
00081                     queue = name
00082 
00083                 if printers == None:
00084                     printers = self.timedop (c.getPrinters,
00085                                              parent=parent).run ()
00086 
00087                 if not printers.has_key (name):
00088                     info = _("Unknown")
00089                     location = _("Unknown")
00090                 else:
00091                     printer = printers[name]
00092                     info = printer.get('printer-info', _("Unknown"))
00093                     location = printer.get('printer-location', _("Unknown"))
00094 
00095                 dests_list.append ((queue, location, info, dest))
00096 
00097             dests_list.sort (lambda x, y: cmp (x[0], y[0]))
00098             for queue, location, info, dest in dests_list:
00099                 iter = model.append (None)
00100                 model.set (iter, 0, queue, 1, location, 2, info, 3, dest)
00101 
00102         except cups.HTTPError:
00103             pass
00104         except cups.IPPError:
00105             pass
00106         except RuntimeError:
00107             pass
00108 
00109         return True

Here is the call graph for this function:

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:

def troubleshoot.ChoosePrinter.ChoosePrinter.timedop (   self,
  args,
  kwargs 
)

Definition at line 147 of file ChoosePrinter.py.

00147 
00148     def timedop (self, *args, **kwargs):
00149         self.op = TimedOperation (*args, **kwargs)
00150         return self.op

Here is the caller graph for this function:


Member Data Documentation

Definition at line 128 of file ChoosePrinter.py.

Definition at line 148 of file ChoosePrinter.py.

Definition at line 111 of file ChoosePrinter.py.

Definition at line 54 of file ChoosePrinter.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: