Debian Codegraph @

troubleshoot/QueueNotEnabled.py

raw
1 #!/usr/bin/python3
2
3 ## Printing troubleshooter
4
5 ## Copyright (C) 2008, 2009 Red Hat, Inc.
6 ## Copyright (C) 2008, 2009 Tim Waugh <[email protected]>
7
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
17
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program; if not, write to the Free Software
20 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 from gi.repository import Gtk
23
24 import cups
25 from .base import *
26 class QueueNotEnabled(Question):
27 def __init__ (self, troubleshooter):
28 Question.__init__ (self, troubleshooter, "Queue not enabled?")
29 self.label = Gtk.Label ()
30 solution = Gtk.VBox ()
31 self.label.set_line_wrap (True)
32 self.label.set_alignment (0, 0)
33 solution.pack_start (self.label, False, False, 0)
34 solution.set_border_width (12)
35 troubleshooter.new_page (solution, self)
36
37 def display (self):
38 answers = self.troubleshooter.answers
39 if not answers['cups_queue_listed']:
40 return False
41
42 if answers['is_cups_class']:
43 queue = answers['cups_class_dict']
44 else:
45 queue = answers['cups_printer_dict']
46
47 enabled = queue['printer-state'] != cups.IPP_PRINTER_STOPPED
48 if enabled:
49 return False
50
51 if answers['cups_printer_remote']:
52 attrs = answers['remote_cups_queue_attributes']
53 reason = attrs['printer-state-message']
54 else:
55 reason = queue['printer-state-message']
56
57 if reason:
58 reason = _("The reason given is: '%s'.") % reason
59 else:
60 reason = _("This may be due to the printer being disconnected or "
61 "switched off.")
62
63 text = ('<span weight="bold" size="larger">' +
64 _("Queue Not Enabled") + '</span>\n\n' +
65 _("The queue '%s' is not enabled.") %
66 answers['cups_queue'])
67
68 if reason:
69 text += ' ' + reason
70
71 if not answers['cups_printer_remote']:
72 text += '\n\n'
73 text += _("To enable it, select the 'Enabled' checkbox in the "
74 "'Policies' tab for the printer in the printer "
75 "administration tool.")
76 text += ' ' + _(TEXT_start_print_admin_tool)
77
78 self.label.set_markup (text)
79 return True
80
81 def can_click_forward (self):
82 return False