Debian Codegraph @

troubleshoot/Welcome.py

raw
1 #!/usr/bin/python3
2
3 ## Printing troubleshooter
4
5 ## Copyright (C) 2008, 2009 Red Hat, Inc.
6 ## Author: 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 from .base import *
25 from timedops import TimedOperation
26 import authconn
27
28 class AuthConnFactory:
29 def __init__ (self, parent):
30 self.parent = parent
31
32 def get_connection (self):
33 return authconn.Connection (self.parent, lock=True)
34
35 class Welcome(Question):
36 def __init__ (self, troubleshooter):
37 Question.__init__ (self, troubleshooter, "Welcome")
38 welcome = Gtk.HBox ()
39 welcome.set_spacing (12)
40 welcome.set_border_width (12)
41 image = Gtk.Image ()
42 image.set_alignment (0, 0)
43 image.set_from_stock (Gtk.STOCK_PRINT, Gtk.IconSize.DIALOG)
44 intro = Gtk.Label(label='<span weight="bold" size="larger">' +
45 _("Trouble-shooting Printing") +
46 '</span>\n\n' +
47 _("The next few screens will contain some "
48 "questions about your problem with printing. "
49 "Based on your answers a solution may be "
50 "suggested.") + '\n\n' +
51 _("Click 'Forward' to begin."))
52 intro.set_alignment (0, 0)
53 intro.set_use_markup (True)
54 intro.set_line_wrap (True)
55 welcome.pack_start (image, False, False, 0)
56 welcome.pack_start (intro, True, True, 0)
57 page = troubleshooter.new_page (welcome, self)
58
59 def collect_answer (self):
60 parent = self.troubleshooter.get_window ()
61 # Store the authentication dialog instance in the answers. This
62 # allows the password to be cached.
63 factory = AuthConnFactory (parent)
64 self.op = TimedOperation (factory.get_connection, parent=parent)
65 return {'_authenticated_connection_factory': factory,
66 '_authenticated_connection': self.op.run () }
67
68 def cancel_operation (self):
69 self.op.cancel ()