Merge remote-tracking branch 'origin/master' into mwhudson/ipv4-validation

This commit is contained in:
Michael Hudson-Doyle 2017-02-08 16:10:36 +13:00
commit 9854d5ccce
27 changed files with 104 additions and 182 deletions

View File

@ -88,9 +88,7 @@ class IdentityView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("Email address:", align="right")), ("weight", 0.2, Text("Email address:", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.email)),
Color.string_input(self.email,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -102,8 +100,8 @@ class IdentityView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel),
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -46,8 +46,7 @@ class LoginView(BaseView):
def _build_buttons(self): def _build_buttons(self):
self.buttons = [ self.buttons = [
Color.button(finish_btn(on_press=self.done), Color.button(finish_btn(on_press=self.done)),
focus_map='button focus'),
] ]
return Pile(self.buttons) return Pile(self.buttons)

View File

@ -37,8 +37,7 @@ class WelcomeView(BaseView):
def _build_buttons(self): def _build_buttons(self):
self.buttons = [ self.buttons = [
Color.button(ok_btn(on_press=self.confirm), Color.button(ok_btn(on_press=self.confirm)),
focus_map='button focus'),
] ]
return Pile(self.buttons) return Pile(self.buttons)

View File

@ -71,8 +71,7 @@ class BcacheView(BaseView):
selector = Selector(avail_devs) selector = Selector(avail_devs)
self.selected_disks[section] = selector self.selected_disks[section] = selector
items.append(Color.string_input(selector, items.append(Color.string_input(selector))
focus_map="string_input focus"))
return Pile(items) return Pile(items)
@ -119,8 +118,8 @@ class BcacheView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -45,9 +45,7 @@ class CephDiskView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("Ceph MON", align="right")), ("weight", 0.2, Text("Ceph MON", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.ceph_mon))
Color.string_input(self.ceph_mon,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -55,18 +53,14 @@ class CephDiskView(BaseView):
[ [
("weight", 0.2, Text("Username", ("weight", 0.2, Text("Username",
align="right")), align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.username))
Color.string_input(self.username,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Key", align="right")), ("weight", 0.2, Text("Key", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.ceph_key))
Color.string_input(self.ceph_key,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
) )
@ -78,8 +72,8 @@ class CephDiskView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -55,8 +55,8 @@ class AddFormatView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -91,7 +91,7 @@ class AddPartitionView(BaseView):
buttons = [ buttons = [
Toggleable(done, 'button'), Toggleable(done, 'button'),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -43,7 +43,7 @@ class DiskInfoView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -49,8 +49,8 @@ class DiskPartitionView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)
@ -100,8 +100,7 @@ class DiskPartitionView(BaseView):
return Color.menu_button( return Color.menu_button(
menu_btn( menu_btn(
label=text, label=text,
on_press=self.show_disk_info on_press=self.show_disk_info))
), focus_map='menu_button focus')
def create_swap_w(self): def create_swap_w(self):
""" Handles presenting an enabled create swap on """ Handles presenting an enabled create swap on
@ -113,8 +112,7 @@ class DiskPartitionView(BaseView):
if len(self.disk_obj.partitions) == 0 and \ if len(self.disk_obj.partitions) == 0 and \
self.disk_obj.available: self.disk_obj.available:
return Color.menu_button(menu_btn(label=text, return Color.menu_button(menu_btn(label=text,
on_press=self.create_swap), on_press=self.create_swap))
focus_map='menu_button focus')
def add_partition_w(self): def add_partition_w(self):
""" Handles presenting the add partition widget button """ Handles presenting the add partition widget button
@ -128,8 +126,7 @@ class DiskPartitionView(BaseView):
if self.disk_obj.available and \ if self.disk_obj.available and \
self.disk_obj.blocktype not in self.model.no_partition_blocktypes: self.disk_obj.blocktype not in self.model.no_partition_blocktypes:
return Color.menu_button(menu_btn(label=text, return Color.menu_button(menu_btn(label=text,
on_press=self.add_partition), on_press=self.add_partition))
focus_map='menu_button focus')
def show_disk_info(self, result): def show_disk_info(self, result):
self.controller.show_disk_information(self.selected_disk) self.controller.show_disk_information(self.selected_disk)

View File

@ -112,13 +112,10 @@ class FilesystemView(BaseView):
# don't enable done botton if we can't install # don't enable done botton if we can't install
if self.model.installable(): if self.model.installable():
buttons.append( buttons.append(
Color.button(done_btn(on_press=self.done), Color.button(done_btn(on_press=self.done)))
focus_map='button focus'))
buttons.append(Color.button(reset_btn(on_press=self.reset), buttons.append(Color.button(reset_btn(on_press=self.reset)))
focus_map='button focus')) buttons.append(Color.button(cancel_btn(on_press=self.cancel)))
buttons.append(Color.button(cancel_btn(on_press=self.cancel),
focus_map='button focus'))
return Pile(buttons) return Pile(buttons)
@ -146,8 +143,7 @@ class FilesystemView(BaseView):
btn = menu_btn(label=disk.name, btn = menu_btn(label=disk.name,
on_press=self.show_disk_partition_view) on_press=self.show_disk_partition_view)
col_1.append( col_1.append(Color.menu_button(btn))
Color.menu_button(btn, focus_map='menu_button focus'))
disk_sz = _humanize_size(disk.size) disk_sz = _humanize_size(disk.size)
log.debug('device partitions: {}'.format(len(device.partitions))) log.debug('device partitions: {}'.format(len(device.partitions)))
# if we've consumed some of the device, show # if we've consumed some of the device, show
@ -160,8 +156,7 @@ class FilesystemView(BaseView):
part = device.get_partition(partname) part = device.get_partition(partname)
btn = menu_btn(label=partname, btn = menu_btn(label=partname,
on_press=self.show_disk_partition_view) on_press=self.show_disk_partition_view)
col_1.append( col_1.append(Color.menu_button(btn))
Color.menu_button(btn, focus_map='menu_button focus'))
col_2.append(Text(_humanize_size(part.size))) col_2.append(Text(_humanize_size(part.size)))
col_1 = BoxAdapter(SimpleList(col_1), col_1 = BoxAdapter(SimpleList(col_1),
@ -188,8 +183,7 @@ class FilesystemView(BaseView):
opts.append(Color.menu_button( opts.append(Color.menu_button(
menu_btn(label=opt, menu_btn(label=opt,
on_press=self.on_fs_menu_press, on_press=self.on_fs_menu_press,
user_data=sig), user_data=sig)))
focus_map='menu_button focus'))
return Pile(opts) return Pile(opts)
def on_fs_menu_press(self, result, sig): def on_fs_menu_press(self, result, sig):

View File

@ -65,8 +65,8 @@ class IdentityView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)
@ -75,9 +75,7 @@ class IdentityView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("Your name:", align="right")), ("weight", 0.2, Text("Your name:", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.realname)),
Color.string_input(self.realname,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -85,9 +83,7 @@ class IdentityView(BaseView):
[ [
("weight", 0.2, Text("Your server's name:", ("weight", 0.2, Text("Your server's name:",
align="right")), align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.hostname)),
Color.string_input(self.hostname,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -104,8 +100,7 @@ class IdentityView(BaseView):
[ [
("weight", 0.2, Text("Pick a username:", align="right")), ("weight", 0.2, Text("Pick a username:", align="right")),
("weight", 0.3, ("weight", 0.3,
Color.string_input(self.username, Color.string_input(self.username))
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -113,8 +108,7 @@ class IdentityView(BaseView):
[ [
("weight", 0.2, Text("Choose a password:", align="right")), ("weight", 0.2, Text("Choose a password:", align="right")),
("weight", 0.3, ("weight", 0.3,
Color.string_input(self.password, Color.string_input(self.password))
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -123,8 +117,7 @@ class IdentityView(BaseView):
("weight", 0.2, Text("Confirm your password:", ("weight", 0.2, Text("Confirm your password:",
align="right")), align="right")),
("weight", 0.3, ("weight", 0.3,
Color.string_input(self.confirm_password, Color.string_input(self.confirm_password))
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -133,8 +126,7 @@ class IdentityView(BaseView):
("weight", 0.2, Text("Import SSH identity:", ("weight", 0.2, Text("Import SSH identity:",
align="right")), align="right")),
("weight", 0.3, ("weight", 0.3,
Color.string_input(self.ssh_import_id, Color.string_input(self.ssh_import_id))
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),

View File

@ -44,8 +44,7 @@ class InstallpathView(BaseView):
def _build_buttons(self): def _build_buttons(self):
self.buttons = [ self.buttons = [
Color.button(cancel_btn(on_press=self.cancel), Color.button(cancel_btn(on_press=self.cancel)),
focus_map='button focus'),
] ]
return Pile(self.buttons) return Pile(self.buttons)
@ -56,8 +55,7 @@ class InstallpathView(BaseView):
sl.append(Color.menu_button( sl.append(Color.menu_button(
menu_btn(label=ipath, menu_btn(label=ipath,
on_press=self.confirm, on_press=self.confirm,
user_data=sig), user_data=sig)))
focus_map='menu_button focus'))
return BoxAdapter(SimpleList(sl), return BoxAdapter(SimpleList(sl),
height=len(sl)) height=len(sl))

View File

@ -55,14 +55,10 @@ class ProgressView(BaseView):
def show_complete(self): def show_complete(self):
w = Padding.fixed_20( w = Padding.fixed_20(
Color.button(confirm_btn(label="Reboot now", Color.button(confirm_btn(label="Reboot now", on_press=self.reboot)))
on_press=self.reboot),
focus_map='button focus'))
z = Padding.fixed_20( z = Padding.fixed_20(
Color.button(confirm_btn(label="Quit Installer", Color.button(confirm_btn(label="Quit Installer", on_press=self.quit)))
on_press=self.quit),
focus_map='button focus'))
new_focus = len(self.pile.contents) new_focus = len(self.pile.contents)
self.pile.contents.append((w, self.pile.options('pack'))) self.pile.contents.append((w, self.pile.options('pack')))

View File

@ -51,65 +51,49 @@ class IscsiDiskView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("iSCSI Server Host", align="right")), ("weight", 0.2, Text("iSCSI Server Host", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.iscsi_host))
Color.string_input(self.iscsi_host,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Connect anonymously", ("weight", 0.2, Text("Connect anonymously", align="right")),
align="right")), ("weight", 0.3, Color.string_input(Pile(self.connect_anon.group)))
("weight", 0.3,
Color.string_input(Pile(self.connect_anon.group),
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Connect as user", align="right")), ("weight", 0.2, Text("Connect as user", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.connect_username))
Color.string_input(self.connect_username,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Password", align="right")), ("weight", 0.2, Text("Password", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.connect_password))
Color.string_input(self.connect_password,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Require server auth", ("weight", 0.2, Text("Require server auth", align="right")),
align="right")), ("weight", 0.3, Color.string_input(Pile(self.server_auth.group)))
("weight", 0.3,
Color.string_input(Pile(self.server_auth.group),
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Server identity", align="right")), ("weight", 0.2, Text("Server identity", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.server_username))
Color.string_input(self.server_username,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Server password", align="right")), ("weight", 0.2, Text("Server password", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.server_password))
Color.string_input(self.server_password,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
) )
@ -127,8 +111,7 @@ class IscsiDiskView(BaseView):
Color.menu_button( Color.menu_button(
menu_btn(label=label, menu_btn(label=label,
on_press=self.confirm, on_press=self.confirm,
user_data=sig), user_data=sig)))
focus_map="menu_button focus"))
])) ]))
return Pile(items) return Pile(items)

View File

@ -85,8 +85,7 @@ class LVMVolumeGroupView(BaseView):
("weight", 0.2, Text("VolumeGroup Name", ("weight", 0.2, Text("VolumeGroup Name",
align="right")), align="right")),
("weight", 0.3, ("weight", 0.3,
Color.string_input(self.volgroup, Color.string_input(self.volgroup))
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -99,8 +98,8 @@ class LVMVolumeGroupView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -85,9 +85,7 @@ class RaidView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("RAID Level", align="right")), ("weight", 0.2, Text("RAID Level", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.raid_level))
Color.string_input(self.raid_level,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -95,18 +93,14 @@ class RaidView(BaseView):
[ [
("weight", 0.2, Text("Hot spares", ("weight", 0.2, Text("Hot spares",
align="right")), align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.hot_spares))
Color.string_input(self.hot_spares,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
Columns( Columns(
[ [
("weight", 0.2, Text("Chunk size", align="right")), ("weight", 0.2, Text("Chunk size", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.chunk_size))
Color.string_input(self.chunk_size,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
) )
@ -119,8 +113,8 @@ class RaidView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -44,17 +44,14 @@ class WelcomeView(BaseView):
def _build_buttons(self): def _build_buttons(self):
self.buttons = [ self.buttons = [
Color.button(ok_btn(on_press=self.confirm), Color.button(ok_btn(on_press=self.confirm)),
focus_map='button focus'),
] ]
return Pile(self.buttons) return Pile(self.buttons)
def _build_model_inputs(self): def _build_model_inputs(self):
sl = [] sl = []
for lang in self.model.get_menu(): for lang in self.model.get_menu():
sl.append(Color.menu_button( sl.append(Color.menu_button(menu_btn(label=lang, on_press=self.confirm)))
menu_btn(label=lang, on_press=self.confirm),
focus_map="menu_button focus"))
return BoxAdapter(SimpleList(sl), return BoxAdapter(SimpleList(sl),
height=len(sl)) height=len(sl))

View File

@ -36,8 +36,7 @@ class DummyView(WidgetWrap):
def _build_buttons(self): def _build_buttons(self):
buttons = [ buttons = [
Color.button(cancel_btn(label="Back to Start", Color.button(cancel_btn(label="Back to Start",
on_press=self.cancel), on_press=self.cancel)),
focus_map='button focus'),
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -41,8 +41,7 @@ class ErrorView(WidgetWrap):
def _build_buttons(self): def _build_buttons(self):
buttons = [ buttons = [
Color.button(cancel_btn(label="Back to Start", Color.button(cancel_btn(label="Back to Start",
on_press=self.cancel), on_press=self.cancel)),
focus_map='button focus'),
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -133,8 +133,15 @@ def apply_style_map(cls):
Color.frame_header(Text("I'm text in the Orange frame header")) Color.frame_header(Text("I'm text in the Orange frame header"))
Color.body(Text("Im text in wrapped with the body color")) Color.body(Text("Im text in wrapped with the body color"))
""" """
style_names = set()
for k in STYLES: for k in STYLES:
setattr(cls, k[0], partialmethod(AttrMap, attr_map=k[0])) 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))
else:
setattr(cls, k[0], partialmethod(AttrMap, attr_map=k[0]))
return cls return cls

View File

@ -46,8 +46,7 @@ class LoginView(BaseView):
def _build_buttons(self): def _build_buttons(self):
self.buttons = [ self.buttons = [
Color.button(finish_btn(on_press=self.done), Color.button(finish_btn(on_press=self.done)),
focus_map='button focus'),
] ]
return Pile(self.buttons) return Pile(self.buttons)

View File

@ -145,10 +145,8 @@ class NetworkView(BaseView):
self._w = self.orig_w self._w = self.orig_w
def _build_buttons(self): def _build_buttons(self):
cancel = Color.button(cancel_btn(on_press=self.cancel), cancel = Color.button(cancel_btn(on_press=self.cancel))
focus_map='button focus') done = Color.button(done_btn(on_press=self.done))
done = Color.button(done_btn(on_press=self.done),
focus_map='button focus')
self.default_focus = done self.default_focus = done
buttons = [done, cancel] buttons = [done, cancel]
@ -172,9 +170,8 @@ class NetworkView(BaseView):
col_2 = [] col_2 = []
col_1.append( col_1.append(
Color.info_major( Color.menu_button(
menu_btn(label=dev.name, on_press=self.on_net_dev_press), menu_btn(label=dev.name, on_press=self.on_net_dev_press)))
focus_map='button focus'))
if dev.type == 'wlan': if dev.type == 'wlan':
col_2.extend(_build_wifi_info(dev)) col_2.extend(_build_wifi_info(dev))
@ -248,8 +245,7 @@ class NetworkView(BaseView):
Color.menu_button( Color.menu_button(
menu_btn(label=opt, menu_btn(label=opt,
on_press=self.additional_menu_select, on_press=self.additional_menu_select,
user_data=sig), user_data=sig)))
focus_map='button focus'))
from urwid import Padding from urwid import Padding
buttons = [ Padding(button, align='left', width=max_btn_len + 6) for button in buttons ] buttons = [ Padding(button, align='left', width=max_btn_len + 6) for button in buttons ]

View File

@ -74,9 +74,7 @@ class NetworkBondInterfacesView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("Bonding Mode", align="right")), ("weight", 0.2, Text("Bonding Mode", align="right")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.bond_mode))
Color.string_input(self.bond_mode,
focus_map="string_input focus"))
], ],
dividechars=4 dividechars=4
), ),
@ -90,8 +88,8 @@ class NetworkBondInterfacesView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
items = [ items = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
log.debug('buttons: items: {}'.format(items)) log.debug('buttons: items: {}'.format(items))
return Pile(items) return Pile(items)

View File

@ -65,13 +65,13 @@ class NetworkConfigureInterfaceView(BaseView):
buttons = [] buttons = []
btn = menu_btn(label="Use a static IPv4 configuration", btn = menu_btn(label="Use a static IPv4 configuration",
on_press=self.show_ipv4_configuration) on_press=self.show_ipv4_configuration)
buttons.append(Color.menu_button(btn, focus_map="menu_button focus")) buttons.append(Color.menu_button(btn))
btn = menu_btn(label="Use DHCPv4 on this interface", btn = menu_btn(label="Use DHCPv4 on this interface",
on_press=self.enable_dhcp4) on_press=self.enable_dhcp4)
buttons.append(Color.menu_button(btn, focus_map="menu_button focus")) buttons.append(Color.menu_button(btn))
btn = menu_btn(label="Do not use", btn = menu_btn(label="Do not use",
on_press=self.clear_ipv4) on_press=self.clear_ipv4)
buttons.append(Color.menu_button(btn, focus_map="menu_button focus")) buttons.append(Color.menu_button(btn))
padding = getattr(Padding, 'left_{}'.format(button_padding)) padding = getattr(Padding, 'left_{}'.format(button_padding))
buttons = [ padding(button) for button in buttons ] buttons = [ padding(button) for button in buttons ]
@ -84,13 +84,13 @@ class NetworkConfigureInterfaceView(BaseView):
buttons = [] buttons = []
btn = menu_btn(label="Use a static IPv6 configuration", btn = menu_btn(label="Use a static IPv6 configuration",
on_press=self.show_ipv6_configuration) on_press=self.show_ipv6_configuration)
buttons.append(Color.menu_button(btn, focus_map="menu_button focus")) buttons.append(Color.menu_button(btn))
btn = menu_btn(label="Use DHCPv6 on this interface", btn = menu_btn(label="Use DHCPv6 on this interface",
on_press=self.enable_dhcp6) on_press=self.enable_dhcp6)
buttons.append(Color.menu_button(btn, focus_map="menu_button focus")) buttons.append(Color.menu_button(btn))
btn = menu_btn(label="Do not use", btn = menu_btn(label="Do not use",
on_press=self.clear_ipv6) on_press=self.clear_ipv6)
buttons.append(Color.menu_button(btn, focus_map="menu_button focus")) buttons.append(Color.menu_button(btn))
padding = getattr(Padding, 'left_{}'.format(button_padding)) padding = getattr(Padding, 'left_{}'.format(button_padding))
buttons = [ padding(button) for button in buttons ] buttons = [ padding(button) for button in buttons ]
@ -100,13 +100,13 @@ class NetworkConfigureInterfaceView(BaseView):
def _build_wifi_config(self): def _build_wifi_config(self):
btn = menu_btn(label="Configure WIFI settings", on_press=self.show_wlan_configuration) btn = menu_btn(label="Configure WIFI settings", on_press=self.show_wlan_configuration)
return [Padding.left_70(Color.menu_button(btn, focus_map="menu_button focus"))] return [Padding.left_70(Color.menu_button(btn))]
def _build_buttons(self): def _build_buttons(self):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -89,11 +89,8 @@ class BaseNetworkConfigureManualView(BaseView):
captioned = Columns( captioned = Columns(
[ [
("weight", 0.2, text), ("weight", 0.2, text),
("weight", 0.3, ("weight", 0.3, Color.string_input(input)),
Color.string_input(input,
focus_map="string_input focus")),
("weight", 0.5, Text(help)) ("weight", 0.5, Text(help))
], dividechars=2
) )
return ValidatingWidgetSet(captioned, decorated, input, validator) return ValidatingWidgetSet(captioned, decorated, input, validator)
@ -184,7 +181,7 @@ class BaseNetworkConfigureManualView(BaseView):
buttons = [ buttons = [
Toggleable(done, 'button'), Toggleable(done, 'button'),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)

View File

@ -15,8 +15,7 @@ class NetworkList(WidgetWrap):
button = cancel_btn(on_press=self.do_cancel) button = cancel_btn(on_press=self.do_cancel)
ssid_list = [ ssid_list = [
Color.menu_button( Color.menu_button(
Button(label=ssid, on_press=self.do_network), Button(label=ssid, on_press=self.do_network))
focus_map="menu_button focus")
for ssid in ssids] for ssid in ssids]
p = Pile([BoxAdapter(ListBox(ssid_list), height=10), Padding.fixed_10(button)]) p = Pile([BoxAdapter(ListBox(ssid_list), height=10), Padding.fixed_10(button)])
box = LineBox(p, title="Select a network") box = LineBox(p, title="Select a network")
@ -88,8 +87,7 @@ class NetworkConfigureWLANView(BaseView):
def _build_iface_inputs(self): def _build_iface_inputs(self):
if len(self.dev.actual_ssids) > 0: if len(self.dev.actual_ssids) > 0:
networks_btn = Color.menu_button( networks_btn = Color.menu_button(
menu_btn("Choose a visible network", on_press=self.show_ssid_list), menu_btn("Choose a visible network", on_press=self.show_ssid_list))
focus_map="menu_button focus")
else: else:
networks_btn = Color.info_minor(Columns( networks_btn = Color.info_minor(Columns(
[ [
@ -99,8 +97,7 @@ class NetworkConfigureWLANView(BaseView):
], dividechars=1)) ], dividechars=1))
if not self.dev.scan_state: if not self.dev.scan_state:
scan_btn = Color.menu_button( scan_btn = Color.menu_button(
menu_btn("Scan for networks", on_press=self.start_scan), menu_btn("Scan for networks", on_press=self.start_scan))
focus_map="menu_button focus")
else: else:
scan_btn = Color.info_minor(Columns( scan_btn = Color.info_minor(Columns(
[ [
@ -115,9 +112,7 @@ class NetworkConfigureWLANView(BaseView):
Columns( Columns(
[ [
("weight", 0.2, Text("Network name:")), ("weight", 0.2, Text("Network name:")),
("weight", 0.3, ("weight", 0.3, Color.string_input(self.ssid_input)),
Color.string_input(self.ssid_input,
focus_map="string_input focus")),
], dividechars=2 ], dividechars=2
), ),
Columns( Columns(
@ -136,8 +131,7 @@ class NetworkConfigureWLANView(BaseView):
[ [
("weight", 0.2, Text("Password:")), ("weight", 0.2, Text("Password:")),
("weight", 0.3, ("weight", 0.3,
Color.string_input(self.psk_input, Color.string_input(self.psk_input)),
focus_map="string_input focus")),
], dividechars=2 ], dividechars=2
), ),
] ]
@ -154,10 +148,8 @@ class NetworkConfigureWLANView(BaseView):
self.inputs.contents = [ (obj, ('pack', None)) for obj in self._build_iface_inputs() ] self.inputs.contents = [ (obj, ('pack', None)) for obj in self._build_iface_inputs() ]
def _build_buttons(self): def _build_buttons(self):
cancel = Color.button(cancel_btn(on_press=self.cancel), cancel = Color.button(cancel_btn(on_press=self.cancel))
focus_map='button focus') done = Color.button(done_btn(on_press=self.done))
done = Color.button(done_btn(on_press=self.done),
focus_map='button focus')
buttons = [done, cancel] buttons = [done, cancel]
return Pile(buttons, focus_item=done) return Pile(buttons, focus_item=done)

View File

@ -78,8 +78,7 @@ class NetworkSetDefaultRouteView(BaseView):
log.debug('gateway providers: {}'.format(providers)) log.debug('gateway providers: {}'.format(providers))
items = [] items = []
items.append(Padding.center_79( items.append(Padding.center_79(
Color.menu_button(menu_btn(label="None", on_press=self.done), Color.menu_button(menu_btn(label="None", on_press=self.done))))
focus_map="menu_button focus")))
for (gw, ifaces) in providers.items(): for (gw, ifaces) in providers.items():
if gw is None: if gw is None:
continue continue
@ -88,14 +87,12 @@ class NetworkSetDefaultRouteView(BaseView):
label="{gw} ({ifaces})".format( label="{gw} ({ifaces})".format(
gw=gw, gw=gw,
ifaces=(",".join(ifaces))), ifaces=(",".join(ifaces))),
on_press=self.done), on_press=self.done))))
focus_map="menu_button focus")))
items.append(Padding.center_79( items.append(Padding.center_79(
Color.menu_button( Color.menu_button(
menu_btn(label="Specify the default route manually", menu_btn(label="Specify the default route manually",
on_press=self.show_edit_default_route), on_press=self.show_edit_default_route))))
focus_map="menu_button focus")))
return items return items
def _build_buttons(self): def _build_buttons(self):
@ -103,8 +100,8 @@ class NetworkSetDefaultRouteView(BaseView):
done = done_btn(on_press=self.done) done = done_btn(on_press=self.done)
buttons = [ buttons = [
Color.button(done, focus_map='button focus'), Color.button(done),
Color.button(cancel, focus_map='button focus') Color.button(cancel)
] ]
return Pile(buttons) return Pile(buttons)
@ -112,10 +109,9 @@ class NetworkSetDefaultRouteView(BaseView):
log.debug("Re-rendering specify default route") log.debug("Re-rendering specify default route")
self.default_gateway_w = StringEditor( self.default_gateway_w = StringEditor(
caption="Default gateway will be ") caption="Default gateway will be ")
self.gateway_options.contents[-1] = (Padding.center_50( self.gateway_options.contents[-1] = (
Color.string_input( Padding.center_50(Color.string_input(self.default_gateway_w)),
self.default_gateway_w, self.gateway_options.options())
focus_map="string_input focus")), self.gateway_options.options())
def done(self, result): def done(self, result):
log.debug("changing default gw: {}".format(result)) log.debug("changing default gw: {}".format(result))