Permalink
Switch branches/tags
workflow-change-base ttt-tag-will-be-removed taroon-pre-package-changes taroon-merge-point taroon-emd-base taroon-base start sent-alpnet s390-beforeheadmerge rhel5-base rhel4-base r6.1.beta1 r4-3-17 r0-49 r0-9-2 r0-9-1 r0-9-0 r0-8-14 r0-8-11 r0-8-10 r0-8-7 r0-8-6 r0-8-2 r0-7-11 r0-7-9 r0-7-5 r0-7-4 r0-7-3 r0-7-2 r0-7-1 pre-tab-convert pre-newcomps merged-to-taroon merge.with.pot kudzu-r0-98-10 kudzu-r0-97 kudzu-r0-69 kudzu-r0-66 kudzu-r0-46 kudzu-r0-44 i18n-update-from-sources-07-20-2001 help hampton-post-HEAD-merge fc5-base fc4-base fc3-base f17-pre-noloader-merge f8-base f7-base desc config-migrate-base before.390.merge before.removing.utc before.po.msgmerge before.libdir.changes before.kudzu.loader.patch before.jj.patch2 before.bootloader.merge before-taroon-updates before-taroon-merge before-taroon-merge-2 before-rpm-4.1 before-parted-1-6-changes before-nfs-mount-upgrade before-loader-switch before-hampton-merge before-ccb-qu2-cleanup before-cambridge-monitor-query-change before-6-1-merge b4.msf.really.broke.x ancaonda-fairfax-beta-3 anaconda.8.0.90 anaconda-sparc-alpha-base anaconda-s390-tag7 anaconda-s390-tag5 anaconda-s390-tag4 anaconda-s390-tag3 anaconda-s390-tag2 anaconda-s390-tag anaconda-s390-new-tag6 anaconda-s390-GA2 anaconda-parted-base anaconda-hampton-rescueloader-base anaconda-hampton-beta1-5 anaconda-hampton-beta1-4 anaconda-hampton-beta1-3 anaconda-hampton-beta1-2 anaconda-hampton-beta-1 anaconda-hampton-base anaconda-gtk-2-0-base anaconda-fairfax-rc2 anaconda-fairfax-rc1 anaconda-fairfax-beta-3 anaconda-fairfax-beta-2 anaconda-fairfax-beta-1 anaconda-fairfax-beta-1-2 anaconda-dispatch-base anaconda-before-rpm-head-changes anaconda-before-japanese-merge anaconda-before-2.6
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
126 lines (99 sloc) 4.14 KB
# The base classes for Anaconda TUI Spokes
#
# Copyright (C) (2012) Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from pyanaconda.ui.common import Spoke, StandaloneSpoke, NormalSpoke
from pyanaconda.ui.tui.tuiobject import TUIObject
from pyanaconda.core.i18n import N_, _
from pyanaconda import ihelp
from simpleline.render.adv_widgets import HelpScreen
from simpleline.render.screen import InputState
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.prompt import Prompt
from simpleline.render.widgets import Widget, CheckboxWidget
__all__ = ["TUISpoke", "StandaloneSpoke", "NormalTUISpoke"]
# Inherit abstract methods from Spoke
# pylint: disable=abstract-method
class TUISpoke(TUIObject, Widget, Spoke):
"""Base TUI Spoke class implementing the pyanaconda.ui.common.Spoke API.
It also acts as a Widget so we can easily add it to Hub, where is shows
as a summary box with title, description and completed checkbox.
:param category: category this spoke belongs to
:type category: string
.. inheritance-diagram:: TUISpoke
:parts: 3
"""
def __init__(self, data, storage, payload, instclass):
if self.__class__ is TUISpoke:
raise TypeError("TUISpoke is an abstract class")
TUIObject.__init__(self, data)
Widget.__init__(self)
Spoke.__init__(self, storage, payload, instclass)
self.input_required = True
self.title = N_("Default spoke title")
@property
def status(self):
return _("testing status...")
@property
def completed(self):
return True
def refresh(self, args=None):
TUIObject.refresh(self, args)
def input(self, args, key):
"""Handle the input, the base class just forwards it to the App level."""
return key
def render(self, width):
"""Render the summary representation for Hub to internal buffer."""
Widget.render(self, width)
if self.mandatory and not self.completed:
key = "!"
elif self.completed:
key = "x"
else:
key = " "
# always set completed = True here; otherwise key value won't be
# displayed if completed (spoke value from above) is False
c = CheckboxWidget(key=key, completed=True,
title=_(self.title), text=self.status)
c.render(width)
self.draw(c)
class NormalTUISpoke(TUISpoke, NormalSpoke):
"""
.. inheritance-diagram:: NormalTUISpoke
:parts: 3
"""
def input(self, args, key):
"""Handle the input."""
# TRANSLATORS: 'h' to help
if key.lower() == Prompt.HELP:
if self.has_help:
help_path = ihelp.get_help_path(self.helpFile, self.instclass, True)
ScreenHandler.push_screen_modal(HelpScreen(help_path))
return InputState.PROCESSED_AND_REDRAW
return super().input(args, key)
def prompt(self, args=None):
"""Return the prompt."""
prompt = TUISpoke.prompt(self, args)
if self.has_help:
prompt.add_help_option()
return prompt
class StandaloneTUISpoke(TUISpoke, StandaloneSpoke):
"""
.. inheritance-diagram:: StandaloneTUISpoke
:parts: 3
"""
pass