Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
troubleshoot.ChooseNetworkPrinter.ChooseNetworkPrinter Class Reference
Inheritance diagram for troubleshoot.ChooseNetworkPrinter.ChooseNetworkPrinter:
Inheritance graph
[legend]
Collaboration diagram for troubleshoot.ChooseNetworkPrinter.ChooseNetworkPrinter:
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
 model
 op
 signal_id
 dests
 troubleshooter

Detailed Description

Definition at line 26 of file ChooseNetworkPrinter.py.


Constructor & Destructor Documentation

Definition at line 27 of file ChooseNetworkPrinter.py.

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

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

Reimplemented from troubleshoot.base.Question.

Definition at line 163 of file ChooseNetworkPrinter.py.

00163 
00164     def cancel_operation (self):
00165         self.op.cancel ()

Reimplemented from troubleshoot.base.Question.

Definition at line 135 of file ChooseNetworkPrinter.py.

00135 
00136     def collect_answer (self):
00137         if not self.troubleshooter.answers.get ('remote_server_cups', False):
00138             return {}
00139 
00140         model, iter = self.treeview.get_selection ().get_selected ()
00141         if not model:
00142             return {}
00143 
00144         dest = model.get_value (iter, 3)
00145         if dest == None:
00146             class enum_dests:
00147                 def __init__ (self, model):
00148                     self.dests = []
00149                     model.foreach (self.each, None)
00150 
00151                 def each (self, model, path, iter, user_data):
00152                     dest = model.get_value (iter, 3)
00153                     if dest:
00154                         self.dests.append ((dest.name, dest.instance))
00155 
00156             return { 'remote_cups_queue_listed': False,
00157                      'remote_cups_dests_available': enum_dests (model).dests }
00158         else:
00159             return { 'remote_cups_queue_listed': True,
00160                      'remote_cups_dest': dest,
00161                      'remote_cups_queue': dest.name,
00162                      'remote_cups_instance': dest.instance }

Here is the call graph for this function:

Reimplemented from troubleshoot.base.Question.

Definition at line 123 of file ChooseNetworkPrinter.py.

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

Reimplemented from troubleshoot.base.Question.

Definition at line 126 of file ChooseNetworkPrinter.py.

00126 
00127     def disconnect_signals (self):
00128         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 56 of file ChooseNetworkPrinter.py.

00056 
00057     def display (self):
00058         answers = self.troubleshooter.answers
00059         if answers['cups_queue_listed']:
00060             return False
00061 
00062         if not answers.get ('remote_server_cups', False):
00063             return False
00064 
00065         server = answers['remote_server_try_connect']
00066 
00067         model = gtk.ListStore (gobject.TYPE_STRING,
00068                                gobject.TYPE_STRING,
00069                                gobject.TYPE_STRING,
00070                                gobject.TYPE_PYOBJECT)
00071         self.model = model
00072         self.treeview.set_model (model)
00073         iter = model.append (None)
00074         model.set (iter, 0, _("Not listed"), 1, '', 2, '', 3, None)
00075 
00076         parent = self.troubleshooter.get_window ()
00077 
00078         try:
00079             self.op = TimedOperation (cups.Connection, 
00080                                       kwargs={"host": server},
00081                                       parent=parent)
00082             c = self.op.run ()
00083             self.op = TimedOperation (c.getDests, parent=parent)
00084             dests = self.op.run ()
00085             printers = None
00086             dests_list = []
00087             for (name, instance), dest in dests.iteritems ():
00088                 if name == None:
00089                     continue
00090 
00091                 if instance != None:
00092                     queue = "%s/%s" % (name, instance)
00093                 else:
00094                     queue = name
00095 
00096                 if printers == None:
00097                     self.op = TimedOperation (c.getPrinters)
00098                     printers = self.op.run ()
00099 
00100                 if not printers.has_key (name):
00101                     info = _("Unknown")
00102                     location = _("Unknown")
00103                 else:
00104                     printer = printers[name]
00105                     info = printer.get('printer-info', _("Unknown"))
00106                     location = printer.get('printer-location', _("Unknown"))
00107 
00108                 dests_list.append ((queue, location, info, dest))
00109 
00110             dests_list.sort (lambda x, y: cmp (x[0], y[0]))
00111             for queue, location, info, dest in dests_list:
00112                 iter = model.append (None)
00113                 model.set (iter, 0, queue, 1, location, 2, info, 3, dest)
00114 
00115         except cups.HTTPError:
00116             pass
00117         except cups.IPPError:
00118             pass
00119         except RuntimeError:
00120             pass
00121 
00122         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 147 of file ChooseNetworkPrinter.py.

Definition at line 70 of file ChooseNetworkPrinter.py.

Definition at line 78 of file ChooseNetworkPrinter.py.

Definition at line 124 of file ChooseNetworkPrinter.py.

Definition at line 53 of file ChooseNetworkPrinter.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: