Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
troubleshoot.DeviceListed.DeviceListed Class Reference
Inheritance diagram for troubleshoot.DeviceListed.DeviceListed:
Inheritance graph
[legend]
Collaboration diagram for troubleshoot.DeviceListed.DeviceListed:
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 initial_vbox
 Helper functions.

Public Attributes

 treeview
 answers
 authconn
 op
 signal_id
 devices
 troubleshooter

Detailed Description

Definition at line 26 of file DeviceListed.py.


Constructor & Destructor Documentation

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

Definition at line 27 of file DeviceListed.py.

00027 
00028     def __init__ (self, troubleshooter):
00029         # Is the device listed?
00030         Question.__init__ (self, troubleshooter, "Choose device")
00031         page1 = self.initial_vbox (_("Choose Device"),
00032                                    _("Please select the device you want "
00033                                      "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         info = gtk.TreeViewColumn (_("Information"),
00040                                    gtk.CellRendererText (), text=1)
00041         uri = gtk.TreeViewColumn (_("Device URI"),
00042                                   gtk.CellRendererText (), text=2)
00043         name.set_property ("resizable", True)
00044         info.set_property ("resizable", True)
00045         uri.set_property ("resizable", True)
00046         tv.append_column (name)
00047         tv.append_column (info)
00048         tv.append_column (uri)
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 127 of file DeviceListed.py.

00127 
00128     def can_click_forward (self):
00129         model, iter = self.treeview.get_selection ().get_selected ()
00130         if iter == None:
00131             return False
00132         return True

Reimplemented from troubleshoot.base.Question.

Definition at line 162 of file DeviceListed.py.

00162 
00163     def cancel_operation (self):
00164         self.op.cancel ()
00165 
00166         # Abandon the CUPS connection and make another.
00167         answers = self.troubleshooter.answers
00168         factory = answers['_authenticated_connection_factory']
00169         self.authconn = factory.get_connection ()
00170         self.answers['_authenticated_connection'] = self.authconn
00171 

Reimplemented from troubleshoot.base.Question.

Definition at line 133 of file DeviceListed.py.

00133 
00134     def collect_answer (self):
00135         if not self.displayed:
00136             return self.answers
00137 
00138         model, iter = self.treeview.get_selection ().get_selected ()
00139         device = model.get_value (iter, 3)
00140         if device == None:
00141             class enum_devices:
00142                 def __init__ (self, model):
00143                     self.devices = {}
00144                     model.foreach (self.each, None)
00145 
00146                 def each (self, model, path, iter, user_data):
00147                     uri = model.get_value (iter, 2)
00148                     device = model.get_value (iter, 3)
00149                     if device:
00150                         self.devices[uri] = device
00151 
00152             self.answers['cups_device_listed'] = False
00153             avail = enum_devices (model).devices
00154             self.answers['cups_devices_available'] = avail
00155         else:
00156             uri = model.get_value (iter, 2)
00157             self.answers['cups_device_listed'] = True
00158             self.answers['cups_device_uri'] = uri
00159             self.answers['cups_device_attributes'] = device
00160 
00161         return self.answers

Here is the call graph for this function:

Reimplemented from troubleshoot.base.Question.

Definition at line 121 of file DeviceListed.py.

00121 
00122     def connect_signals (self, handler):
00123         self.signal_id = self.treeview.connect ("cursor-changed", handler)

Reimplemented from troubleshoot.base.Question.

Definition at line 124 of file DeviceListed.py.

00124 
00125     def disconnect_signals (self):
00126         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 DeviceListed.py.

00057 
00058     def display (self):
00059         self.answers = {}
00060         answers = self.troubleshooter.answers
00061         if (answers['printer_is_remote'] or
00062             answers.get ('cups_printer_remote', False)):
00063             return False
00064 
00065         model = gtk.ListStore (gobject.TYPE_STRING,
00066                                gobject.TYPE_STRING,
00067                                gobject.TYPE_STRING,
00068                                gobject.TYPE_PYOBJECT)
00069         self.treeview.set_model (model)
00070         iter = model.append (None)
00071         model.set (iter, 0, _("Not listed"), 1, '', 2, '', 3, None)
00072 
00073         devices = {}
00074         parent = self.troubleshooter.get_window ()
00075         # Skip device list if this page is hidden and we're skipping
00076         # backwards past it.
00077         if not (answers['cups_queue_listed'] and
00078                 self.troubleshooter.is_moving_backwards ()):
00079             # Otherwise, fetch devices.
00080             self.authconn = answers['_authenticated_connection']
00081             try:
00082                 self.op = TimedOperation (self.authconn.getDevices,
00083                                           parent=parent)
00084                 devices = self.op.run ()
00085                 devices_list = []
00086                 for uri, device in devices.iteritems ():
00087                     if uri.find (':') == -1:
00088                         continue
00089 
00090                     if device.get('device-class') != 'direct':
00091                         continue
00092 
00093                     name = device.get('device-info', _("Unknown"))
00094                     info = device.get('device-make-and-model', _("Unknown"))
00095                     devices_list.append ((name, info, uri, device))
00096 
00097                 devices_list.sort (lambda x, y: cmp (x[0], y[0]))
00098                 for name, info, uri, device in devices_list:
00099                     iter = model.append (None)
00100                     model.set (iter, 0, name, 1, info, 2, uri, 3, device)
00101 
00102             except cups.HTTPError:
00103                 pass
00104             except cups.IPPError:
00105                 pass
00106             except RuntimeError:
00107                 pass
00108 
00109         if answers['cups_queue_listed']:
00110             try:
00111                 printer_dict = answers['cups_printer_dict']
00112                 uri = printer_dict['device-uri']
00113                 device = devices[uri]
00114                 self.answers['cups_device_dict'] = device
00115             except KeyError:
00116                 pass
00117 
00118             return False
00119 
00120         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 58 of file DeviceListed.py.

Definition at line 79 of file DeviceListed.py.

Definition at line 142 of file DeviceListed.py.

Definition at line 81 of file DeviceListed.py.

Definition at line 122 of file DeviceListed.py.

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