Merge pull request #525 from mwhudson/outermost-pile
Make the outermost widget an instance of Pile rather than Frame
This commit is contained in:
commit
f85fb6aac7
|
@ -227,7 +227,7 @@ class IdentityController(BaseController):
|
||||||
["snap", "create-user", "--sudoer", "--json", email])
|
["snap", "create-user", "--sudoer", "--json", email])
|
||||||
self.ui.set_footer("")
|
self.ui.set_footer("")
|
||||||
if cp.returncode != 0:
|
if cp.returncode != 0:
|
||||||
self.ui.frame.body.error.set_text(
|
self.ui.body.error.set_text(
|
||||||
"Creating user failed:\n" + cp.stderr)
|
"Creating user failed:\n" + cp.stderr)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -192,11 +192,11 @@ class FilesystemController(BaseController):
|
||||||
if 'obj' in action:
|
if 'obj' in action:
|
||||||
obj = self._action_get(action['obj'])
|
obj = self._action_get(action['obj'])
|
||||||
meth = getattr(
|
meth = getattr(
|
||||||
self.ui.frame.body.avail_list,
|
self.ui.body.avail_list,
|
||||||
"_{}_{}".format(obj.type, action['action']))
|
"_{}_{}".format(obj.type, action['action']))
|
||||||
meth(obj)
|
meth(obj)
|
||||||
yield
|
yield
|
||||||
body = self.ui.frame.body._w
|
body = self.ui.body._w
|
||||||
if not isinstance(body, StretchyOverlay):
|
if not isinstance(body, StretchyOverlay):
|
||||||
return
|
return
|
||||||
if isinstance(body.stretchy, ConfirmDeleteStretchy):
|
if isinstance(body.stretchy, ConfirmDeleteStretchy):
|
||||||
|
@ -208,25 +208,25 @@ class FilesystemController(BaseController):
|
||||||
action['data'],
|
action['data'],
|
||||||
action.get("submit", True))
|
action.get("submit", True))
|
||||||
elif action['action'] == 'create-raid':
|
elif action['action'] == 'create-raid':
|
||||||
self.ui.frame.body.create_raid()
|
self.ui.body.create_raid()
|
||||||
yield
|
yield
|
||||||
body = self.ui.frame.body._w
|
body = self.ui.body._w
|
||||||
yield from self._enter_form_data(
|
yield from self._enter_form_data(
|
||||||
body.stretchy.form,
|
body.stretchy.form,
|
||||||
action['data'],
|
action['data'],
|
||||||
action.get("submit", True),
|
action.get("submit", True),
|
||||||
clean_suffix='raid')
|
clean_suffix='raid')
|
||||||
elif action['action'] == 'create-vg':
|
elif action['action'] == 'create-vg':
|
||||||
self.ui.frame.body.create_vg()
|
self.ui.body.create_vg()
|
||||||
yield
|
yield
|
||||||
body = self.ui.frame.body._w
|
body = self.ui.body._w
|
||||||
yield from self._enter_form_data(
|
yield from self._enter_form_data(
|
||||||
body.stretchy.form,
|
body.stretchy.form,
|
||||||
action['data'],
|
action['data'],
|
||||||
action.get("submit", True),
|
action.get("submit", True),
|
||||||
clean_suffix='vg')
|
clean_suffix='vg')
|
||||||
elif action['action'] == 'done':
|
elif action['action'] == 'done':
|
||||||
if not self.ui.frame.body.done.enabled:
|
if not self.ui.body.done.enabled:
|
||||||
raise Exception("answers did not provide complete fs config")
|
raise Exception("answers did not provide complete fs config")
|
||||||
self.finish()
|
self.finish()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -88,18 +88,18 @@ class SSHController(BaseController):
|
||||||
return user_spec, ssh_import_id, key_material, fingerprints
|
return user_spec, ssh_import_id, key_material, fingerprints
|
||||||
|
|
||||||
def _fetched_ssh_keys(self, fut):
|
def _fetched_ssh_keys(self, fut):
|
||||||
if not isinstance(self.ui.frame.body, SSHView):
|
if not isinstance(self.ui.body, SSHView):
|
||||||
# This can happen if curtin failed while the keys where being
|
# This can happen if curtin failed while the keys where being
|
||||||
# fetched and we jump to the log view.
|
# fetched and we jump to the log view.
|
||||||
log.debug(
|
log.debug(
|
||||||
"view is now an instance of %s, not SSHView",
|
"view is now an instance of %s, not SSHView",
|
||||||
type(self.ui.frame.body))
|
type(self.ui.body))
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
result = fut.result()
|
result = fut.result()
|
||||||
except FetchSSHKeysFailure as e:
|
except FetchSSHKeysFailure as e:
|
||||||
log.debug("fetching ssh keys failed %s", e)
|
log.debug("fetching ssh keys failed %s", e)
|
||||||
self.ui.frame.body.fetching_ssh_keys_failed(e.message, e.output)
|
self.ui.body.fetching_ssh_keys_failed(e.message, e.output)
|
||||||
else:
|
else:
|
||||||
log.debug("_fetched_ssh_keys %s", result)
|
log.debug("_fetched_ssh_keys %s", result)
|
||||||
if result is None:
|
if result is None:
|
||||||
|
@ -111,7 +111,7 @@ class SSHController(BaseController):
|
||||||
self.loop.set_alarm_in(0.0,
|
self.loop.set_alarm_in(0.0,
|
||||||
lambda loop, ud: self.done(user_spec))
|
lambda loop, ud: self.done(user_spec))
|
||||||
else:
|
else:
|
||||||
self.ui.frame.body.confirm_ssh_keys(
|
self.ui.body.confirm_ssh_keys(
|
||||||
user_spec, ssh_import_id, key_material, fingerprints)
|
user_spec, ssh_import_id, key_material, fingerprints)
|
||||||
|
|
||||||
def fetch_ssh_keys(self, user_spec, ssh_import_id):
|
def fetch_ssh_keys(self, user_spec, ssh_import_id):
|
||||||
|
|
|
@ -235,7 +235,7 @@ class NetworkController(BaseController):
|
||||||
self.loop.set_alarm_in(0.1, lambda loop, ud: self.start_watching())
|
self.loop.set_alarm_in(0.1, lambda loop, ud: self.start_watching())
|
||||||
return
|
return
|
||||||
self.observer.data_ready(fd)
|
self.observer.data_ready(fd)
|
||||||
v = self.ui.frame.body
|
v = self.ui.body
|
||||||
if hasattr(v, 'refresh_model_inputs'):
|
if hasattr(v, 'refresh_model_inputs'):
|
||||||
v.refresh_model_inputs()
|
v.refresh_model_inputs()
|
||||||
|
|
||||||
|
@ -280,11 +280,11 @@ class NetworkController(BaseController):
|
||||||
if 'obj' in action:
|
if 'obj' in action:
|
||||||
obj = self._action_get(action['obj'])
|
obj = self._action_get(action['obj'])
|
||||||
meth = getattr(
|
meth = getattr(
|
||||||
self.ui.frame.body,
|
self.ui.body,
|
||||||
"_action_{}".format(action['action']))
|
"_action_{}".format(action['action']))
|
||||||
meth(obj)
|
meth(obj)
|
||||||
yield
|
yield
|
||||||
body = self.ui.frame.body._w
|
body = self.ui.body._w
|
||||||
if not isinstance(body, StretchyOverlay):
|
if not isinstance(body, StretchyOverlay):
|
||||||
return
|
return
|
||||||
for k, v in action.items():
|
for k, v in action.items():
|
||||||
|
@ -301,15 +301,15 @@ class NetworkController(BaseController):
|
||||||
v,
|
v,
|
||||||
action.get(submit_key, True))
|
action.get(submit_key, True))
|
||||||
elif action['action'] == 'create-bond':
|
elif action['action'] == 'create-bond':
|
||||||
self.ui.frame.body._create_bond()
|
self.ui.body._create_bond()
|
||||||
yield
|
yield
|
||||||
body = self.ui.frame.body._w
|
body = self.ui.body._w
|
||||||
yield from self._enter_form_data(
|
yield from self._enter_form_data(
|
||||||
body.stretchy.form,
|
body.stretchy.form,
|
||||||
action['data'],
|
action['data'],
|
||||||
action.get("submit", True))
|
action.get("submit", True))
|
||||||
elif action['action'] == 'done':
|
elif action['action'] == 'done':
|
||||||
self.ui.frame.body.done()
|
self.ui.body.done()
|
||||||
else:
|
else:
|
||||||
raise Exception("could not process action {}".format(action))
|
raise Exception("could not process action {}".format(action))
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,18 @@
|
||||||
|
|
||||||
""" Base Frame Widget """
|
""" Base Frame Widget """
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from urwid import (
|
from urwid import (
|
||||||
Frame,
|
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
from subiquitycore.ui.anchors import Header, Footer
|
from subiquitycore.ui.anchors import Header, Footer
|
||||||
from subiquitycore.ui.container import (
|
from subiquitycore.ui.container import (
|
||||||
ListBox,
|
ListBox,
|
||||||
|
Pile,
|
||||||
WidgetWrap,
|
WidgetWrap,
|
||||||
)
|
)
|
||||||
from subiquitycore.ui.utils import Color
|
from subiquitycore.ui.utils import Color
|
||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquitycore.ui.frame')
|
log = logging.getLogger('subiquitycore.ui.frame')
|
||||||
|
@ -36,28 +37,35 @@ class SubiquityUI(WidgetWrap):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.header = Header("")
|
self.header = Header("")
|
||||||
self.footer = Footer("", 0, 1)
|
self.footer = Footer("", 0, 1)
|
||||||
self.frame = Frame(
|
|
||||||
ListBox([Text("")]),
|
|
||||||
header=self.header, footer=self.footer)
|
|
||||||
self.progress_current = 0
|
self.progress_current = 0
|
||||||
self.progress_completion = 0
|
self.progress_completion = 0
|
||||||
# After the install starts, we want to stop setting the footer
|
# After the install starts, we want to stop setting the footer
|
||||||
# from the body view.
|
# from the body view.
|
||||||
self.auto_footer = True
|
self.auto_footer = True
|
||||||
super().__init__(Color.body(self.frame))
|
self.pile = Pile([
|
||||||
|
('pack', self.header),
|
||||||
|
ListBox([Text("")]),
|
||||||
|
('pack', self.footer),
|
||||||
|
])
|
||||||
|
super().__init__(Color.body(self.pile))
|
||||||
|
|
||||||
def keypress(self, size, key):
|
def _assign_contents(self, i, w):
|
||||||
return super().keypress(size, key)
|
self.pile.contents[i] = (w, self.pile.contents[i][1])
|
||||||
|
|
||||||
def set_header(self, title=None):
|
def set_header(self, title=None):
|
||||||
self.frame.header = Header(title)
|
self._assign_contents(0, Header(title))
|
||||||
|
|
||||||
def set_footer(self, message):
|
def set_footer(self, message):
|
||||||
self.frame.footer = Footer(message, self.progress_current,
|
self._assign_contents(
|
||||||
self.progress_completion)
|
2,
|
||||||
|
Footer(message, self.progress_current, self.progress_completion))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def body(self):
|
||||||
|
return self.pile.contents[1][0]
|
||||||
|
|
||||||
def set_body(self, widget):
|
def set_body(self, widget):
|
||||||
self.set_header(_(widget.title))
|
self.set_header(_(widget.title))
|
||||||
self.frame.body = widget
|
self._assign_contents(1, widget)
|
||||||
if self.auto_footer:
|
if self.auto_footer:
|
||||||
self.set_footer(_(widget.footer))
|
self.set_footer(_(widget.footer))
|
||||||
|
|
Loading…
Reference in New Issue