def update_netlist(self, state=None, x=None, force_check=False, firstrun=False): """ Update the list of networks. """ # Don't even try to do this if we are running a dialog if self.diag: return # Run focus-collecting code if we are not running this for the first # time if not firstrun: self.update_focusloc() self.list_header.set_text(gen_list_header()) # Updates the overall network list. if not state: state, trash = daemon.GetConnectionStatus() if force_check or self.prev_state != state: wiredL, wlessL = gen_network_list() self.wiredCB.get_body().set_list(wiredL) self.wiredCB.get_body().build_combobox(self.frame, ui, 3) if len(wlessL) != 0: if self.wlessLB == self.no_wlan: self.wlessLB = urwid.ListBox(wlessL) else: self.wlessLB.body = urwid.SimpleListWalker(wlessL) else: self.wlessLB = self.no_wlan if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn(): self.thePile = urwid.Pile([('fixed', 1, self.wiredH), ('fixed', 1, self.wiredCB), ('fixed', 2, self.wlessH), self.wlessLB]) if not firstrun: self.frame.body = self.thePile self.thePile.set_focus(self.focusloc[0]) if self.focusloc[0] == self.WIRED_IDX: self.thePile.get_focus(). \ get_body().set_focus(self.focusloc[1]) else: if self.wlessLB != self.no_wlan: self.thePile.get_focus().set_focus(self.focusloc[1]) else: self.thePile.set_focus(self.wiredCB) else: self.thePile = urwid.Pile([('fixed', 2, self.wlessH), self.wlessLB]) if not firstrun: self.frame.body = self.thePile if self.focusloc[1] is None: self.focusloc[1] = 0 if self.wlessLB != self.no_wlan: self.wlessLB.set_focus(self.focusloc[1]) self.prev_state = state if not firstrun: self.update_ui() if firstrun: if wired.GetDefaultWiredNetwork() is not None: self.wiredCB.get_body().set_focus( wired.GetWiredProfileList().index( wired.GetDefaultWiredNetwork()))
def __init__(self): self.conn_status = False self.tcount = 0 # Counter for connection twirl indicator self.size = ui.get_cols_rows() # Happy screen saying that you can't do anything because we're scanning # for networks. :-) self.screen_locker = urwid.Filler( urwid.Text(('important', _('Scanning networks... stand by...')), align='center')) self.no_wlan = urwid.Filler( urwid.Text(('important', _('No wireless networks found.')), align='center')) self.TITLE = _('Wicd Curses Interface') self.WIRED_IDX = 1 self.WLESS_IDX = 3 header = urwid.AttrWrap(urwid.Text(self.TITLE, align='right'), 'header') self.wiredH = urwid.Filler(urwid.Text(_('Wired Networks'))) self.list_header = urwid.AttrWrap(urwid.Text(gen_list_header()), 'listbar') self.wlessH = NSelListBox( [urwid.Text(_('Wireless Networks')), self.list_header]) # Init this earlier to make update_status happy self.update_tag = None # FIXME: This should be two variables self.focusloc = [1, 0] # These are empty to make sure that things go my way. wiredL, wlessL = [], [] self.frame = None self.diag = None self.wiredCB = urwid.Filler(WiredComboBox(wiredL)) self.wlessLB = urwid.ListBox(wlessL) self.update_netlist(force_check=True, firstrun=True) # Keymappings proposed by nanotube in #wicd keys = [ ('H', _('Help'), None), ('right', _('Config'), None), #(' ', ' ', None), ('K', _('RfKill'), None), ('C', _('Connect'), None), ('D', _('Disconn'), None), ('R', _('Refresh'), None), ('P', _('Prefs'), None), ('I', _('Hidden'), None), ('A', _('About'), None), ('Q', _('Quit'), loop.quit) ] self.primaryCols = OptCols(keys, self.handle_keys) self.status_label = urwid.AttrWrap(urwid.Text(''), 'important') self.footer2 = urwid.Columns([self.status_label]) self.footerList = urwid.Pile([self.primaryCols, self.footer2]) self.frame = urwid.Frame(self.thePile, header=header, footer=self.footerList) self.wiredCB.get_body().build_combobox(self.frame, ui, 3) # Init the other columns used in the program self.init_other_optcols() self.frame.set_body(self.thePile) # Booleans gallore! self.prev_state = False self.connecting = False self.screen_locked = False self.do_diag_lock = False # Whether the screen is locked beneath a dialog self.diag_type = 'none' # The type of dialog that is up self.scanning = False self.pref = None self.update_status()