Esempio n. 1
0
    def _build_iface_inputs(self):
        visible_ssids = self.dev_info.wlan.visible_ssids
        if len(visible_ssids) > 0:
            networks_btn = menu_btn("Choose a visible network",
                                    on_press=self.show_ssid_list)
        else:
            networks_btn = disabled(menu_btn("No visible networks"))

        scan_state = self.dev_info.wlan.scan_state
        if not scan_state:
            scan_btn = menu_btn("Scan for networks", on_press=self.start_scan)
        elif scan_state.startswith('error'):
            self.error.set_text('scan failed: %s' % (scan_state, ))
            scan_btn = disabled(menu_btn("Scanning for networks failed"))
        else:
            scan_btn = disabled(menu_btn("Scanning for networks"))

        warning = (
            "Only open or WPA2/PSK networks are supported at this time.")
        col = [
            Text(warning),
            Text(""),
            self.ssid_row,
            Text(""),
            Padding.fixed_32(networks_btn),
            Padding.fixed_32(scan_btn),
            Text(""),
            self.psk_row,
        ]
        return col
    def _build_iface_inputs(self):
        if len(self.dev.actual_ssids) > 0:
            networks_btn = menu_btn("Choose a visible network",
                                    on_press=self.show_ssid_list)
        else:
            networks_btn = Color.info_minor(
                Columns([('fixed', 1, Text("")),
                         Text("No visible networks"), ('fixed', 1, Text(">"))],
                        dividechars=1))

        if not self.dev.scan_state:
            scan_btn = menu_btn("Scan for networks", on_press=self.start_scan)
        else:
            scan_btn = Color.info_minor(
                Columns([('fixed', 1, Text("")),
                         Text("Scanning for networks"),
                         ('fixed', 1, Text(">"))],
                        dividechars=1))

        col = [
            Padding.center_79(
                Color.info_minor(
                    Text(
                        "Only open or WPA2/PSK networks are supported at this time."
                    ))),
            Padding.line_break(""),
            self.ssid_row,
            Padding.fixed_30(networks_btn),
            Padding.fixed_30(scan_btn),
            self.psk_row,
        ]
        return col
Esempio n. 3
0
    def _build_iface_inputs(self):
        if len(self.device.info.wlan['visible_ssids']) > 0:
            networks_btn = menu_btn("Choose a visible network",
                                    on_press=self.show_ssid_list)
        else:
            networks_btn = disabled(menu_btn("No visible networks"))

        if not self.device.info.wlan['scan_state']:
            scan_btn = menu_btn("Scan for networks", on_press=self.start_scan)
        else:
            scan_btn = disabled(menu_btn("Scanning for networks"))

        warning = (
            "Only open or WPA2/PSK networks are supported at this time.")
        col = [
            Text(warning),
            Text(""),
            self.ssid_row,
            Text(""),
            Padding.fixed_32(networks_btn),
            Padding.fixed_32(scan_btn),
            Text(""),
            self.psk_row,
        ]
        return col
Esempio n. 4
0
    def _build_model_inputs(self):
        partitioned_disks = []

        def format_volume(label, part):
            size = humanize_size(part.size)
            if part.fs() is None:
                fstype = '-'
                mountpoint = '-'
            elif part.fs().mount() is None:
                fstype = part.fs().fstype
                mountpoint = '-'
            else:
                fstype = part.fs().fstype
                mountpoint = part.fs().mount().path
            if part.type == 'disk':
                part_btn = menu_btn(label, on_press=self._click_disk)
            else:
                part_btn = menu_btn(label,
                                    on_press=self._click_part,
                                    user_arg=part)
            return Columns([
                (25, part_btn),
                (9, Text(size, align="right")),
                Text(fstype),
                Text(mountpoint),
            ], 2)

        if self.disk.fs() is not None:
            partitioned_disks.append(format_volume("entire disk", self.disk))
        else:
            for part in self.disk.partitions():
                partitioned_disks.append(
                    format_volume("Partition {}".format(part.number), part))
        if self.disk.free > 0:
            free_space = humanize_size(self.disk.free)
            if len(self.disk.partitions()) > 0:
                label = "Add another partition"
            else:
                label = "Add first partition"
            add_btn = menu_btn(label, on_press=self.add_partition)
            partitioned_disks.append(
                Columns([
                    (25, add_btn),
                    (9, Text(free_space, align="right")),
                    Text("free space"),
                ], 2))
        if len(self.disk.partitions()) == 0 and \
           self.disk.available:
            text = ("Format or create swap on entire "
                    "device (unusual, advanced)")
            partitioned_disks.append(Text(""))
            partitioned_disks.append(
                menu_btn(label=text, on_press=self.format_entire))

        return partitioned_disks
    def _build_default_routes(self):
        ''' iterate through interfaces collecting
            any uniq provider (aka, gateway) and
            associate the interface name with the gateway

            then generate a line per key in the gateway
            dict and display the keys.

            Upon selection of the gateway entry (ip)
            then we set model.set_default_gateway(ip)

            if manual is selected, then we update
            the second entry into a IPAddressEditor
            and accept the value, submitting it to
            the model.
        '''
        providers = {}

        for iface in self.model.get_all_interfaces():
            if self.family == netifaces.AF_INET:
                ip_providers = iface.ip4_providers
            elif self.family == netifaces.AF_INET6:
                ip_providers = iface.ip6_providers

            for provider in ip_providers:
                log.debug('ipv4 provider: {}'.format(provider))
                gw = provider
                if gw in providers:
                    providers[gw].append(iface.ifname)
                else:
                    providers[gw] = [iface.ifname]

        log.debug('gateway providers: {}'.format(providers))
        items = []
        items.append(
            Padding.center_79(
                Color.menu_button(menu_btn(label="None", on_press=self.done),
                                  focus_map="menu_button focus")))
        for (gw, ifaces) in providers.items():
            if gw is None:
                continue
            items.append(
                Padding.center_79(
                    Color.menu_button(menu_btn(label="{gw} ({ifaces})".format(
                        gw=gw, ifaces=(",".join(ifaces))),
                                               on_press=self.done),
                                      focus_map="menu_button focus")))

        items.append(
            Padding.center_79(
                Color.menu_button(menu_btn(
                    label="Specify the default route manually",
                    on_press=self.show_edit_default_route),
                                  focus_map="menu_button focus")))
        return items
    def _build_ipv4_method_buttons(self):
        button_padding = 70

        buttons = [
            menu_btn(label="    %s" % _("Use a static IPv4 configuration"),
                     on_press=self.show_ipv4_configuration),
            menu_btn(label="    %s" % _("Use DHCPv4 on this interface"),
                     on_press=self.enable_dhcp4),
            menu_btn(label="    %s" % _("Do not use"),
                     on_press=self.clear_ipv4),
        ]
        padding = getattr(Padding, 'left_{}'.format(button_padding))
        buttons = [padding(button) for button in buttons]

        return buttons
Esempio n. 7
0
    def __init__(self, model, controller):
        self.model = model
        self.controller = controller
        self.dev_to_row = {}
        self.cur_netdevs = []
        self.error = Text("", align='center')
        self.device_table = TablePile(self._build_model_inputs(),
                                      spacing=2,
                                      colspecs={
                                          0: ColSpec(rpad=1),
                                          4: ColSpec(can_shrink=True, rpad=1),
                                      })

        self._create_bond_btn = menu_btn(_("Create bond"),
                                         on_press=self._create_bond)
        bp = button_pile([self._create_bond_btn])
        bp.align = 'left'

        self.listbox = ListBox([self.device_table] + [
            bp,
        ])
        self.bottom = Pile([
            Text(""),
            self._build_buttons(),
            Text(""),
        ])
        self.error_showing = False

        self.frame = Pile([('pack', Text("")),
                           ('pack', Padding.center_79(Text(_(self.excerpt)))),
                           ('pack', Text("")),
                           Padding.center_90(self.listbox),
                           ('pack', self.bottom)])
        self.frame.set_focus(self.bottom)
        super().__init__(self.frame)
Esempio n. 8
0
 def show_disk_info_w(self):
     """ Runs hdparm against device and displays its output
     """
     text = _("Show disk information")
     return menu_btn(
             label=text,
             on_press=self.show_disk_info)
Esempio n. 9
0
 def show_disk_info_w(self):
     """ Runs hdparm against device and displays its output
     """
     text = ("Show disk information")
     return Color.menu_button(menu_btn(label=text,
                                       on_press=self.show_disk_info),
                              focus_map='menu_button focus')
Esempio n. 10
0
    def _build_ipv6_method_buttons(self):
        button_padding = 70

        buttons = []
        btn = menu_btn(label="Use a static IPv6 configuration",
                       on_press=self.show_ipv6_configuration)
        buttons.append(Color.menu_button(btn))
        btn = menu_btn(label="Use DHCPv6 on this interface",
                       on_press=self.enable_dhcp6)
        buttons.append(Color.menu_button(btn))
        btn = menu_btn(label="Do not use", on_press=self.clear_ipv6)
        buttons.append(Color.menu_button(btn))

        padding = getattr(Padding, 'left_{}'.format(button_padding))
        buttons = [padding(button) for button in buttons]

        return buttons
Esempio n. 11
0
    def _build_model_inputs(self):
        sl = []
        for lang in self.model.get_menu():
            sl.append(
                Color.menu_button(menu_btn(label=lang, on_press=self.confirm),
                                  focus_map="menu_button focus"))

        return BoxAdapter(SimpleList(sl), height=len(sl))
Esempio n. 12
0
    def __init__(self, model, controller):
        log.debug('FileSystemView init start()')
        self.model = model
        self.controller = controller

        self.mount_list = MountList(self)
        self.avail_list = DeviceList(self, True)
        self.used_list = DeviceList(self, False)
        self.avail_list.table.bind(self.used_list.table)
        self._create_raid_btn = Toggleable(
            menu_btn(label=_("Create software RAID (md)"),
                     on_press=self.create_raid))
        self._create_vg_btn = Toggleable(
            menu_btn(label=_("Create volume group (LVM)"),
                     on_press=self.create_vg))

        bp = button_pile([self._create_raid_btn, self._create_vg_btn])
        bp.align = 'left'

        body = [
            Text(_("FILE SYSTEM SUMMARY")),
            Text(""),
            Padding.push_2(self.mount_list),
            Text(""),
            Text(""),
            Text(_("AVAILABLE DEVICES")),
            Text(""),
            Padding.push_2(self.avail_list),
            Text(""),
            Padding.push_2(bp),
            Text(""),
            Text(""),
            Text(_("USED DEVICES")),
            Text(""),
            Padding.push_2(self.used_list),
            Text(""),
        ]

        self.lb = ListBox(body)
        frame = screen(self.lb,
                       self._build_buttons(),
                       focus_buttons=self.model.can_install())
        frame.width = ('relative', 95)
        super().__init__(frame)
        self.refresh_model_inputs()
        log.debug('FileSystemView init complete()')
Esempio n. 13
0
    def __init__(self, model, controller):
        self.model = model
        self.controller = controller

        self.mount_list = MountList(self)
        self.avail_list = DeviceList(self, True)
        self.used_list = DeviceList(self, False)
        self.avail_list.table.bind(self.used_list.table)
        self._create_raid_btn = Toggleable(
            menu_btn(label=_("Create software RAID (md)"),
                     on_press=self.create_raid))
        self._create_vg_btn = Toggleable(
            menu_btn(label=_("Create volume group (LVM)"),
                     on_press=self.create_vg))

        bp = button_pile([self._create_raid_btn, self._create_vg_btn])
        bp.align = 'left'

        body = [
            Text(_("FILE SYSTEM SUMMARY")),
            Text(""),
            self.mount_list,
            Text(""),
            Text(""),
            Text(_("AVAILABLE DEVICES")),
            Text(""),
            self.avail_list,
            Text(""),
            bp,
            Text(""),
            Text(""),
            Text(_("USED DEVICES")),
            Text(""),
            self.used_list,
            Text(""),
        ]

        self.lb = ListBox(body)
        self.lb.base_widget.offset_rows = 2
        super().__init__(
            screen(self.lb,
                   self._build_buttons(),
                   focus_buttons=self.model.can_install()))
        self.frame = self._w.base_widget
        self.showing_guidance = False
        self.refresh_model_inputs()
Esempio n. 14
0
    def _build_model_inputs(self):
        sl = []
        for ipath, sig in self.model.get_menu():
            log.debug("Building inputs: {}".format(ipath))
            sl.append(
                menu_btn(label=ipath, on_press=self.confirm, user_arg=sig))

        return BoxAdapter(SimpleList(sl), height=len(sl))
Esempio n. 15
0
 def __init__(self, parent, ssids):
     self.parent = parent
     button = cancel_btn(_("Cancel"), on_press=self.do_cancel)
     ssid_list = [menu_btn(label=ssid, on_press=self.do_network)
                  for ssid in ssids]
     p = Pile([BoxAdapter(ListBox(ssid_list), height=10),
               Padding.fixed_10(button)])
     box = LineBox(p, title="Select a network")
     super().__init__(box)
Esempio n. 16
0
    def __init__(self, controller, netdev_infos):
        self.controller = controller
        self.dev_name_to_table = {}
        self.cur_netdev_names = []
        self.error = Text("", align='center')

        self.device_colspecs = {
            0: ColSpec(rpad=1),
            3: ColSpec(min_width=15),
            4: ColSpec(can_shrink=True, rpad=1),
        }

        self.heading_table = TablePile([
            TableRow([
                Color.info_minor(Text(header)) for header in [
                    "",
                    "NAME",
                    "TYPE",
                    "NOTES",
                    "",
                ]
            ])
        ],
                                       spacing=2,
                                       colspecs=self.device_colspecs)

        self.device_pile = Pile([self.heading_table])

        for dev_info in netdev_infos:
            self.new_link(dev_info)

        self._create_bond_btn = menu_btn(_("Create bond"),
                                         on_press=self._create_bond)
        bp = button_pile([self._create_bond_btn])
        bp.align = 'left'

        rows = [
            self.device_pile,
            bp,
        ]

        self.buttons = button_pile([
            done_btn("TBD", on_press=self.done),  # See _route_watcher
            back_btn(_("Back"), on_press=self.cancel),
        ])
        self.bottom = Pile([
            ('pack', self.buttons),
        ])

        self.error_showing = False

        super().__init__(
            screen(rows=rows,
                   buttons=self.bottom,
                   focus_buttons=True,
                   excerpt=_(self.excerpt)))
Esempio n. 17
0
    def _build_ipv4_method_buttons(self):
        dhcp4 = self.iface_obj.dhcp6

        button_padding = 70

        buttons = []
        btn = menu_btn(label="Use a static IPv4 configuration",
                       on_press=self.show_ipv4_configuration)
        buttons.append(Color.menu_button(btn, focus_map="menu_button focus"))
        btn = menu_btn(label="Use DHCPv4 on this interface",
                       on_press=self.enable_dhcp4)
        buttons.append(Color.menu_button(btn, focus_map="menu_button focus"))
        btn = menu_btn(label="Do not use", on_press=self.clear_ipv4)
        buttons.append(Color.menu_button(btn, focus_map="menu_button focus"))

        padding = getattr(Padding, 'left_{}'.format(button_padding))
        buttons = [padding(button) for button in buttons]

        return buttons
Esempio n. 18
0
 def _build_menu(self):
     items = []
     for label, sig in self.model.get_menu():
         items.append(
             Columns([("weight", 0.2, Text("")),
                      ("weight", 0.3,
                       Color.menu_button(
                           menu_btn(label=label,
                                    on_press=self.confirm,
                                    user_data=sig)))]))
     return Pile(items)
Esempio n. 19
0
 def format_volume(label, part):
     size = humanize_size(part.size)
     if part.fs() is None:
          fstype = '-'
          mountpoint = '-'
     elif part.fs().mount() is None:
         fstype = part.fs().fstype
         mountpoint = '-'
     else:
         fstype = part.fs().fstype
         mountpoint = part.fs().mount().path
     if part.type == 'disk':
         part_btn = menu_btn(label, on_press=self._click_disk)
     else:
         part_btn = menu_btn(label, on_press=self._click_part, user_arg=part)
     return Columns([
         (label_width, part_btn),
         (9, Text(size, align="right")),
         Text(fstype),
         Text(mountpoint),
     ], 2)
    def _build_set_as_default_gw_button(self):
        ifaces = self.model.get_all_interface_names()

        self.is_gateway = self.model.v4_gateway_dev == self.ifname

        if not self.is_gateway and len(ifaces) > 1:
            btn = menu_btn(label="Set this as default gateway",
                           on_press=self.set_default_gateway)
        else:
            btn = Text("This will be your default gateway")

        return [btn]
    def _build_set_as_default_gw_button(self):
        devs = self.model.get_all_netdevs()

        self.is_gateway = self.model.v4_gateway_dev == self.dev.name

        if not self.is_gateway and len(devs) > 1:
            btn = menu_btn(label=_("Set this as default gateway"),
                           on_press=self.set_default_gateway)
        else:
            btn = Text(_("This will be your default gateway"))

        return [btn]
Esempio n. 22
0
 def create_swap_w(self):
     """ Handles presenting an enabled create swap on
     entire device button if no partition exists, otherwise
     it is disabled.
     """
     text = ("Format or create swap on entire "
             "device (unusual, advanced)")
     if len(self.disk_obj.partitions) == 0 and \
        self.disk_obj.available:
         return Color.menu_button(menu_btn(label=text,
                                           on_press=self.create_swap),
                                  focus_map='menu_button focus')
Esempio n. 23
0
 def _build_menu(self):
     log.debug('FileSystemView: building menu')
     opts = []
     avail_disks = self.model.get_available_disk_names()
     for opt, sig in self.model.get_menu():
         if len(avail_disks) > 1:
             opts.append(
                 Color.menu_button(menu_btn(label=opt,
                                            on_press=self.on_fs_menu_press,
                                            user_data=sig),
                                   focus_map='menu_button focus'))
     return Pile(opts)
Esempio n. 24
0
    def _build_model_inputs(self):
        netdevs = self.model.get_all_netdevs()
        ifname_width = 8  # default padding
        if netdevs:
            ifname_width += max(map(lambda dev: len(dev.name), netdevs))
            if ifname_width > 20:
                ifname_width = 20

        iface_menus = []

        # Display each interface -- name in first column, then configured IPs
        # in the second.
        log.debug('interfaces: {}'.format(netdevs))
        for dev in netdevs:
            col_1 = []
            col_2 = []

            col_1.append(
                menu_btn(label=dev.name, on_press=self.on_net_dev_press))

            if dev.type == 'wlan':
                col_2.extend(_build_wifi_info(dev))
            if len(dev.actual_ip_addresses) == 0 and (dev.type == 'eth' and
                                                      not dev.is_connected):
                col_2.append(Color.info_primary(Text(_("Not connected"))))
            col_2.extend(_build_gateway_ip_info_for_version(dev, 4))
            col_2.extend(_build_gateway_ip_info_for_version(dev, 6))

            # Other device info (MAC, vendor/model, speed)
            template = ''
            if dev.hwaddr:
                template += '{} '.format(dev.hwaddr)
            # TODO is this to translate?
            if dev.is_bond_slave:
                template += '(Bonded) '
            # TODO to check if this is affected by translations
            if not dev.vendor.lower().startswith('unknown'):
                vendor = textwrap.wrap(dev.vendor, 15)[0]
                template += '{} '.format(vendor)
            if not dev.model.lower().startswith('unknown'):
                model = textwrap.wrap(dev.model, 20)[0]
                template += '{} '.format(model)
            if dev.speed:
                template += '({})'.format(dev.speed)

            col_2.append(Color.info_minor(Text(template)))
            iface_menus.append(
                Columns([(ifname_width, Pile(col_1)),
                         Pile(col_2)], 2))

        return iface_menus
Esempio n. 25
0
    def _build_additional_options(self):
        labels = []
        netdevs = self.model.get_all_netdevs()

        # Display default route status
        if self.model.default_v4_gateway is not None:
            v4_route_source = "via " + self.model.default_v4_gateway

            default_v4_route_w = Color.info_minor(
                Text(_("  IPv4 default route %s." % v4_route_source)))
            labels.append(default_v4_route_w)

        if self.model.default_v6_gateway is not None:
            v6_route_source = "via " + self.model.default_v6_gateway

            default_v6_route_w = Color.info_minor(
                Text("  IPv6 default route " + v6_route_source + "."))
            labels.append(default_v6_route_w)

        max_btn_len = 0
        buttons = []
        for opt, sig in self.model.get_menu():
            if ':set-default-route' in sig:
                if len(netdevs) < 2:
                    log.debug('Skipping default route menu option'
                              ' (only one nic)')
                    continue
            if ':bond-interfaces' in sig:
                not_bonded = [dev for dev in netdevs if not dev.is_bonded]
                if len(not_bonded) < 2:
                    log.debug('Skipping bonding menu option'
                              ' (not enough available nics)')
                    continue

            if len(opt) > max_btn_len:
                max_btn_len = len(opt)

            buttons.append(
                menu_btn(label=opt,
                         on_press=self.additional_menu_select,
                         user_data=sig))

        from urwid import Padding
        buttons = [
            Padding(button, align='left', width=max_btn_len + 6)
            for button in buttons
        ]
        r = labels + buttons
        if len(r) > 0:
            r[0:0] = [Text("")]
        return r
Esempio n. 26
0
    def add_partition_w(self):
        """ Handles presenting the add partition widget button
        depending on if partitions exist already or not.
        """
        text = "Add first GPT partition"
        if len(self.disk_obj.partitions) > 0:
            text = "Add partition (max size {})".format(
                _humanize_size(self.disk_obj.freespace))

        if self.disk_obj.available and \
           self.disk_obj.blocktype not in self.model.no_partition_blocktypes:
            return Color.menu_button(menu_btn(label=text,
                                              on_press=self.add_partition),
                                     focus_map='menu_button focus')
Esempio n. 27
0
    def _build_model_inputs(self):
        log.debug('FileSystemView: building model inputs')
        col_1 = []
        col_2 = []

        avail_disks = self.model.get_available_disk_names()
        if len(avail_disks) == 0:
            return Pile([Color.info_minor(Text("No available disks."))])

        for dname in avail_disks:
            disk = self.model.get_disk_info(dname)
            device = self.model.get_disk(dname)
            btn = menu_btn(label=disk.name,
                           on_press=self.show_disk_partition_view)

            col_1.append(Color.menu_button(btn, focus_map='menu_button focus'))
            disk_sz = _humanize_size(disk.size)
            log.debug('device partitions: {}'.format(len(device.partitions)))
            # if we've consumed some of the device, show
            # the remaining space and percentage of the whole
            if len(device.partitions) > 0:
                free, percent = self._get_percent_free(device)
                disk_sz = "{} ({}%) free".format(free, percent)
            col_2.append(Text(disk_sz))
            for partname in device.available_partitions:
                part = device.get_partition(partname)
                btn = menu_btn(label=partname,
                               on_press=self.show_disk_partition_view)
                col_1.append(
                    Color.menu_button(btn, focus_map='menu_button focus'))
                col_2.append(Text(_humanize_size(part.size)))

        col_1 = BoxAdapter(SimpleList(col_1), height=len(col_1))
        col_2 = BoxAdapter(SimpleList(col_2, is_selectable=False),
                           height=len(col_2))
        return Columns([(16, col_1), col_2], 2)
Esempio n. 28
0
    def _build_additional_options(self):
        labels = []
        ifaces = self.model.get_all_interface_names()

        # Display default route status
        if self.model.default_v4_gateway is not None:
            v4_route_source = "via " + self.model.default_v4_gateway

            default_v4_route_w = Color.info_minor(
                Text("  IPv4 default route " + v4_route_source + "."))
            labels.append(default_v4_route_w)
            
        if self.model.default_v6_gateway is not None:
            v6_route_source = "via " + self.model.default_v6_gateway

            default_v6_route_w = Color.info_minor(
                Text("  IPv6 default route " + v6_route_source + "."))
            labels.append(default_v6_route_w)

        max_btn_len = 0
        buttons = []
        for opt, sig in self.model.get_menu():
            if ':set-default-route' in sig:
                if len(ifaces) < 2:
                    log.debug('Skipping default route menu option'
                              ' (only one nic)')
                    continue
            if ':bond-interfaces' in sig:
                not_bonded = [iface for iface in ifaces
                              if not self.model.iface_is_bonded(iface)]
                if len(not_bonded) < 2:
                    log.debug('Skipping bonding menu option'
                              ' (not enough available nics)')
                    continue

            if len(opt) > max_btn_len:
                max_btn_len = len(opt)

            buttons.append(
                Color.menu_button(
                    menu_btn(label=opt,
                             on_press=self.additional_menu_select,
                             user_data=sig),
                    focus_map='button focus'))

        padding = getattr(Padding, 'left_{}'.format(max_btn_len + 10))
        buttons = [ padding(button) for button in buttons ]
        return Pile(labels + buttons)
Esempio n. 29
0
    def _build_ipv6_method_buttons(self):
        button_padding = 70

        buttons = [
            menu_btn(label="    %s" % _("Use a static IPv6 configuration"),
                     on_press=self.show_ipv6_configuration),
            choice_btn(label="    %s" % _("Use DHCPv6 on this interface"),
                       on_press=self.enable_dhcp6),
            choice_btn(label="    %s" % _("Do not use"),
                       on_press=self.clear_ipv6),
        ]

        for btn in buttons:
            btn.original_widget._label._cursor_position = 1

        padding = getattr(Padding, 'left_{}'.format(button_padding))
        buttons = [padding(button) for button in buttons]

        return buttons
Esempio n. 30
0
    def __init__(self, model, controller):
        self.model = model
        self.controller = controller
        self.dev_to_table = {}
        self.cur_netdevs = []
        self.error = Text("", align='center')

        self.device_colspecs = {
            0: ColSpec(rpad=1),
            3: ColSpec(min_width=15),
            4: ColSpec(can_shrink=True, rpad=1),
        }

        self.device_pile = Pile(self._build_model_inputs())

        self._create_bond_btn = menu_btn(_("Create bond"),
                                         on_press=self._create_bond)
        bp = button_pile([self._create_bond_btn])
        bp.align = 'left'

        rows = [
            self.device_pile,
            bp,
        ]

        self.buttons = button_pile([
            done_btn("TBD", on_press=self.done),  # See _route_watcher
            back_btn(_("Back"), on_press=self.cancel),
        ])
        self.bottom = Pile([
            ('pack', self.buttons),
        ])

        self.controller.network_event_receiver.add_default_route_watcher(
            self._route_watcher)

        self.error_showing = False

        super().__init__(
            screen(rows=rows,
                   buttons=self.bottom,
                   focus_buttons=True,
                   excerpt=_(self.excerpt)))