From 8014a2b16ae2fa764a212a450178f84f9b9808cc Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Tue, 21 Apr 2009 13:16:44 -0400 Subject: [PATCH 1/3] Added support for disabling nonexistent external tools in the pref_curses.py. Added a DynRadioButton in curses_misc.py. --- curses/curses_misc.py | 6 ++++++ curses/prefs_curses.py | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/curses/curses_misc.py b/curses/curses_misc.py index 22b5b12..9639c9a 100644 --- a/curses/curses_misc.py +++ b/curses/curses_misc.py @@ -107,6 +107,12 @@ class DynIntEdit(DynWrap): edit = urwid.IntEdit(caption,edit_text) self.__super.__init__(edit,sensitive,attrs,focus_attr) +class DynRadioButton(DynWrap): + def __init__(self,group,label,state='first True',on_state_change=None, user_data=None, sensitive=True, attrs=('body','editnfc'),focus_attr='body'): + #caption = ('editcp',caption + ':') + button = urwid.RadioButton(group,label,state,on_state_change,user_data) + self.__super.__init__(button,sensitive,attrs,focus_attr) + class MaskingEditException(Exception): pass diff --git a/curses/prefs_curses.py b/curses/prefs_curses.py index 45a2d86..d51c61d 100644 --- a/curses/prefs_curses.py +++ b/curses/prefs_curses.py @@ -24,7 +24,7 @@ import urwid.curses_display from wicd import misc from wicd import dbusmanager -from curses_misc import SelText,DynWrap,ComboBox,TabColumns +from curses_misc import SelText,DynWrap,DynRadioButton,ComboBox,TabColumns daemon = None wireless = None @@ -179,21 +179,24 @@ class PrefsDialog(urwid.WidgetWrap): self.dhcp_l = [] # Automatic self.dhcp0 = urwid.RadioButton(self.dhcp_l,automatic_t) - self.dhcp1 = urwid.RadioButton(self.dhcp_l,dhcp1_t) - self.dhcp2 = urwid.RadioButton(self.dhcp_l,dhcp2_t) - self.dhcp3 = urwid.RadioButton(self.dhcp_l,dhcp3_t) + self.dhcp1 = DynRadioButton(self.dhcp_l,dhcp1_t) + self.dhcp2 = DynRadioButton(self.dhcp_l,dhcp2_t) + self.dhcp3 = DynRadioButton(self.dhcp_l,dhcp3_t) + self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3] self.wired_l = [] self.wired_detect_header = urwid.Text(wired_detect_header_t) self.wired0 = urwid.RadioButton(self.wired_l,automatic_t) - self.wired1 = urwid.RadioButton(self.wired_l,wired1_t) - self.wired2 = urwid.RadioButton(self.wired_l,wired2_t) + self.wired1 = DynRadioButton(self.wired_l,wired1_t) + self.wired2 = DynRadioButton(self.wired_l,wired2_t) + self.wired_l = [self.wired0,self.wired1,self.wired2] self.flush_l = [] self.flush_header = urwid.Text(flush_header_t) self.flush0 = urwid.RadioButton(self.flush_l,automatic_t) - self.flush1 = urwid.RadioButton(self.flush_l,flush1_t) - self.flush2 = urwid.RadioButton(self.flush_l,flush2_t) + self.flush1 = DynRadioButton(self.flush_l,flush1_t) + self.flush2 = DynRadioButton(self.flush_l,flush2_t) + self.flush_l = [self.flush0,self.flush1,self.flush2] externalLB = urwid.ListBox([self.dhcp_header, self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3, @@ -267,13 +270,20 @@ class PrefsDialog(urwid.WidgetWrap): self.wired_auto_l[daemon.GetWiredAutoConnectMethod()-1] self.auto_reconn_checkb.set_state(daemon.GetAutoReconnect()) + def find_avail(apps): + for app in apps[1:]: + app.set_sensitive(daemon.GetAppAvailable(app.get_label())) + ### External Programs + find_avail(self.dhcp_l) dhcp_method = daemon.GetDHCPClient() self.dhcp_l[dhcp_method].set_state(True) + find_avail(self.wired_l) wired_link_method = daemon.GetLinkDetectionTool() self.wired_l[wired_link_method].set_state(True) + find_avail(self.flush_l) flush_method = daemon.GetFlushTool() self.flush_l[flush_method].set_state(True) From 72e6bb73de7b91825b17b43c6a8bf560eb39987c Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Tue, 21 Apr 2009 13:34:01 -0400 Subject: [PATCH 2/3] Fix bug introduced in r356 where wicd would crash upon not finding dhclient. --- wicd/wnettools.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 243fbff..51ad50c 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -296,11 +296,13 @@ class BaseInterface(object): """ self.dhclient_cmd = self._find_program_path("dhclient") - output = misc.Run(self.dhclient_cmd + " --version", include_stderr=True) - if '4.' in output: - self.dhclient_needs_verbose = True - else: - self.dhclient_needs_verbose = False + if self.dhclient_cmd != None: + output = misc.Run(self.dhclient_cmd + " --version", + include_stderr=True) + if '4.' in output: + self.dhclient_needs_verbose = True + else: + self.dhclient_needs_verbose = False self.dhcpcd_cmd = self._find_program_path("dhcpcd") self.pump_cmd = self._find_program_path("pump") From fedd788264ccf8c12bace8373eb080ad4b1532d9 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Tue, 21 Apr 2009 14:09:29 -0400 Subject: [PATCH 3/3] Fixed a problem where if a scan is initiated externally, and wicd-curses doesn't see it, wicd-curses will half-drop a running big dialog. --- curses/wicd-curses.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index a8ce2dfb..db9641a 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -616,7 +616,8 @@ class appGUI(): self.do_diag_lock = False return True self.update_netlist(force_check=True) - self.frame.set_body(self.thePile) + if not self.diag: + self.frame.set_body(self.thePile) self.screen_locked = False self.update_ui()