[PATCH 1/4] Add settable quit message to TUI

Martin Sivak msivak at redhat.com
Fri Mar 8 13:57:01 UTC 2013


---
 pyanaconda/ui/tui/__init__.py        | 15 +++++++++++++--
 pyanaconda/ui/tui/simpleline/base.py |  6 ++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/tui/__init__.py b/pyanaconda/ui/tui/__init__.py
index 8da9846..d051590 100644
--- a/pyanaconda/ui/tui/__init__.py
+++ b/pyanaconda/ui/tui/__init__.py
@@ -116,7 +116,9 @@ class TextUserInterface(ui.UserInterface):
 
     ENVIRONMENT = "anaconda"
 
-    def __init__(self, storage, payload, instclass):
+    def __init__(self, storage, payload, instclass,
+                 productTitle = u"Anaconda", isFinal = True,
+                 quitMessage = None):
         """
         For detailed description of the arguments see
         the parent class.
@@ -129,12 +131,20 @@ class TextUserInterface(ui.UserInterface):
 
         :param instclass: install class reference
         :type instclass: instance of install class
+
+        :param productTitle: the name of the product
+        :type productTitle: unicode string
+
         """
 
         ui.UserInterface.__init__(self, storage, payload, instclass)
         self._app = None
         self._meh_interface = meh.ui.text.TextIntf()
 
+        self.productTitle = productTitle
+        self.isFinal = isFinal
+        self.quitMessage = quitMessage
+
     basemask = "pyanaconda.ui.tui"
     basepath = os.path.dirname(__file__)
     updatepath = "/tmp/updates/pyanaconda/ui/tui"
@@ -171,7 +181,8 @@ class TextUserInterface(ui.UserInterface):
         """Construct all the objects required to implement this interface.
            This method must be provided by all subclasses.
         """
-        self._app = tui.App(u"Anaconda", yes_or_no_question=YesNoDialog, queue=communication.hubQ)
+        self._app = tui.App(self.productTitle, yes_or_no_question = YesNoDialog,
+                            quit_message = self.quitMessage)
         _hubs = self._list_hubs()
 
         # First, grab a list of all the standalone spokes.
diff --git a/pyanaconda/ui/tui/simpleline/base.py b/pyanaconda/ui/tui/simpleline/base.py
index 131a54a..0dbfa04 100644
--- a/pyanaconda/ui/tui/simpleline/base.py
+++ b/pyanaconda/ui/tui/simpleline/base.py
@@ -62,7 +62,8 @@ class App(object):
     STOP_MAINLOOP = False
     NOP = None
 
-    def __init__(self, title, yes_or_no_question = None, width = 80, queue = None):
+    def __init__(self, title, yes_or_no_question = None, width = 80, queue = None,
+                 quit_message = None):
         """
         :param title: application title for whenever we need to display app name
         :type title: unicode
@@ -78,6 +79,7 @@ class App(object):
         self._spacer = "\n".join(2*[width*"="])
         self._width = width
         self.quit_question = yes_or_no_question
+        self.quit_message = quit_message or u"Do you really want to quit?"
 
         # async control queue
         if queue:
@@ -433,7 +435,7 @@ class App(object):
         # global quit command
         elif self._screens and (key == _('q')):
             if self.quit_question:
-                d = self.quit_question(self, _(u"Do you really want to quit?"))
+                d = self.quit_question(self, _(self.quit_message))
                 self.switch_screen_modal(d)
                 if d.answer:
                     raise ExitAllMainLoops()
-- 
1.7.11.7



More information about the anaconda-patches mailing list