make it possible for subiquity and console_conf to use different colours
This commit is contained in:
parent
a9de883e0b
commit
34f1e67d49
|
@ -22,6 +22,8 @@ log = logging.getLogger('console_conf.core')
|
|||
|
||||
class ConsoleConf(Application):
|
||||
|
||||
from console_conf.palette import STYLES, STYLES_MONO
|
||||
|
||||
project = "console_conf"
|
||||
controllers = [
|
||||
"Welcome",
|
||||
|
|
|
@ -22,6 +22,8 @@ log = logging.getLogger('console_conf.core')
|
|||
|
||||
class Subiquity(Application):
|
||||
|
||||
from subiquity.palette import STYLES, STYLES_MONO
|
||||
|
||||
project = "subiquity"
|
||||
controllers = [
|
||||
"Welcome",
|
||||
|
|
|
@ -19,7 +19,6 @@ import logging
|
|||
import urwid
|
||||
|
||||
from subiquitycore.signals import Signal
|
||||
from subiquitycore.palette import STYLES, STYLES_MONO
|
||||
from subiquitycore.prober import Prober, ProberException
|
||||
|
||||
log = logging.getLogger('subiquitycore.core')
|
||||
|
@ -122,7 +121,7 @@ class Application:
|
|||
|
||||
def run(self):
|
||||
if not hasattr(self, 'loop'):
|
||||
palette = STYLES
|
||||
palette = self.STYLES
|
||||
additional_opts = {
|
||||
'screen': urwid.raw_display.Screen(),
|
||||
'unhandled_input': self.header_hotkeys,
|
||||
|
@ -130,7 +129,7 @@ class Application:
|
|||
'pop_ups': True,
|
||||
}
|
||||
if self.common['opts'].run_on_serial:
|
||||
palette = STYLES_MONO
|
||||
palette = self.STYLES_MONO
|
||||
else:
|
||||
additional_opts['screen'].set_terminal_properties(colors=256)
|
||||
additional_opts['screen'].reset_default_terminal_palette()
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" Palette definitions """
|
||||
|
||||
dark_magenta = 'dark magenta'
|
||||
light_magenta = 'light magenta'
|
||||
light_green = 'light green'
|
||||
dark_green = 'dark green'
|
||||
white = 'white'
|
||||
black = 'black'
|
||||
light_gray = 'light gray'
|
||||
dark_gray = 'dark gray'
|
||||
dark_red = 'dark red'
|
||||
light_red = 'light red'
|
||||
|
||||
STYLES = [
|
||||
('frame_header', '', '', '', white, ''),
|
||||
('frame_footer', '', '', '', white, ''),
|
||||
('body', '', '', '', white, ''),
|
||||
('menu_button', '', '', '', white, ''),
|
||||
('menu_button focus', '', '', '', black, light_gray),
|
||||
('button', '', '', '', white, ''),
|
||||
('button focus', '', '', '', black, dark_green),
|
||||
('info_primary', '', '', '', white, ''),
|
||||
('info_major', '', '', '', light_gray, ''),
|
||||
('info_minor', '', '', '', dark_gray, ''),
|
||||
('info_error', '', '', '', dark_red, ''),
|
||||
('string_input', '', '', '', black, light_gray),
|
||||
('string_input focus', '', '', '', white, dark_gray),
|
||||
('progress_incomplete', '', '', '', white, dark_magenta),
|
||||
('progress_complete', '', '', '', white, light_magenta)
|
||||
]
|
||||
|
||||
STYLES_MONO = [
|
||||
('frame_header', white, black, '', '', ''),
|
||||
('frame_footer', white, black, '', '', ''),
|
||||
('body', white, black, '', '', ''),
|
||||
('info_minor', white, black, '', '', ''),
|
||||
('menu_button', '', '', '', white, ''),
|
||||
('menu_button focus', '', '', '', white, ''),
|
||||
('button', white, black, '', '', ''),
|
||||
('button focus', white, black, '', '', ''),
|
||||
('string_input', '', '', '', white, ''),
|
||||
('string_input focus', '', '', '', white, ''),
|
||||
('progress_incomplete', '', '', '', '', black),
|
||||
('progress_complete', '', '', '', '', white),
|
||||
]
|
|
@ -18,7 +18,6 @@
|
|||
from urwid import Padding as _Padding
|
||||
from urwid import AttrMap, Text
|
||||
from functools import partialmethod
|
||||
from subiquitycore.palette import STYLES
|
||||
|
||||
|
||||
def apply_padders(cls):
|
||||
|
@ -124,6 +123,26 @@ class Padding:
|
|||
"""
|
||||
line_break = partialmethod(Text)
|
||||
|
||||
# This makes assumptions about the style names defined by both
|
||||
# subiquity and console_conf. The fix is to stop using the Color class
|
||||
# below, I think.
|
||||
STYLE_NAMES = set([
|
||||
'frame_header',
|
||||
'frame_footer',
|
||||
'body',
|
||||
'menu_button',
|
||||
'menu_button focus',
|
||||
'button',
|
||||
'button focus',
|
||||
'info_primary',
|
||||
'info_major',
|
||||
'info_minor',
|
||||
'info_error',
|
||||
'string_input',
|
||||
'string_input focus',
|
||||
'progress_incomplete',
|
||||
'progress_complete',
|
||||
])
|
||||
|
||||
def apply_style_map(cls):
|
||||
""" Applies AttrMap attributes to Color class
|
||||
|
@ -133,15 +152,12 @@ def apply_style_map(cls):
|
|||
Color.frame_header(Text("I'm text in the Orange frame header"))
|
||||
Color.body(Text("Im text in wrapped with the body color"))
|
||||
"""
|
||||
style_names = set()
|
||||
for k in STYLES:
|
||||
style_names.add(k[0])
|
||||
for k in STYLES:
|
||||
kf = k[0] + ' focus'
|
||||
if k[0] + ' focus' in style_names:
|
||||
setattr(cls, k[0], partialmethod(AttrMap, attr_map=k[0], focus_map=kf))
|
||||
for k in STYLE_NAMES:
|
||||
kf = k + ' focus'
|
||||
if kf in STYLE_NAMES:
|
||||
setattr(cls, k, partialmethod(AttrMap, attr_map=k[0], focus_map=kf))
|
||||
else:
|
||||
setattr(cls, k[0], partialmethod(AttrMap, attr_map=k[0]))
|
||||
setattr(cls, k, partialmethod(AttrMap, attr_map=k[0]))
|
||||
return cls
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue