Back to index

system-config-printer  1.3.9+20120706
Welcome.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 ## Printing troubleshooter
00004 
00005 ## Copyright (C) 2008, 2009 Red Hat, Inc.
00006 ## Author: Tim Waugh <twaugh@redhat.com>
00007 
00008 ## This program is free software; you can redistribute it and/or modify
00009 ## it under the terms of the GNU General Public License as published by
00010 ## the Free Software Foundation; either version 2 of the License, or
00011 ## (at your option) any later version.
00012 
00013 ## This program is distributed in the hope that it will be useful,
00014 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 ## GNU General Public License for more details.
00017 
00018 ## You should have received a copy of the GNU General Public License
00019 ## along with this program; if not, write to the Free Software
00020 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 
00022 from base import *
00023 from timedops import TimedOperation
00024 import authconn
00025 
00026 class AuthConnFactory:
00027     def __init__ (self, parent):
00028         self.parent = parent
00029 
00030     def get_connection (self):
00031         return authconn.Connection (self.parent, lock=True)
00032 
00033 class Welcome(Question):
00034     def __init__ (self, troubleshooter):
00035         Question.__init__ (self, troubleshooter, "Welcome")
00036         welcome = gtk.HBox ()
00037         welcome.set_spacing (12)
00038         welcome.set_border_width (12)
00039         image = gtk.Image ()
00040         image.set_alignment (0, 0)
00041         image.set_from_stock (gtk.STOCK_PRINT, gtk.ICON_SIZE_DIALOG)
00042         intro = gtk.Label ('<span weight="bold" size="larger">' +
00043                            _("Trouble-shooting Printing") +
00044                            '</span>\n\n' +
00045                            _("The next few screens will contain some "
00046                              "questions about your problem with printing. "
00047                              "Based on your answers a solution may be "
00048                              "suggested.") + '\n\n' +
00049                            _("Click 'Forward' to begin."))
00050         intro.set_alignment (0, 0)
00051         intro.set_use_markup (True)
00052         intro.set_line_wrap (True)
00053         welcome.pack_start (image, False, False, 0)
00054         welcome.pack_start (intro, True, True, 0)
00055         page = troubleshooter.new_page (welcome, self)
00056 
00057     def collect_answer (self):
00058         parent = self.troubleshooter.get_window ()
00059         # Store the authentication dialog instance in the answers.  This
00060         # allows the password to be cached.
00061         factory = AuthConnFactory (parent)
00062         self.op = TimedOperation (factory.get_connection, parent=parent)
00063         return {'_authenticated_connection_factory': factory,
00064                 '_authenticated_connection': self.op.run () }
00065 
00066     def cancel_operation (self):
00067         self.op.cancel ()