From f437f17b587d2a05f4c9bd3c6b78933e4007a873 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Thu, 5 Feb 2009 16:33:45 -0500 Subject: [PATCH 1/3] curses/wicd-curses.py: ListBox focus-maintaining code completely debugged --- curses/netentry_curses.py | 10 +++++----- curses/wicd-curses.py | 4 ++-- setup.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/curses/netentry_curses.py b/curses/netentry_curses.py index 805c9a7..7ff07d9 100644 --- a/curses/netentry_curses.py +++ b/curses/netentry_curses.py @@ -343,7 +343,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): return noneToBlankString(wireless.GetWirelessProperty(networkid, label)) # Ripped from netentry.py - def save_settings(self, networkid): + def save_settings(self): # Check encryption info if self.encryption_chkbox.get_state(): #print "setting encryption info..." @@ -358,11 +358,11 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): self.set_net_prop(x, noneToString(encryption_info[x]. get_edit_text())) elif not self.encryption_chkbox.get_state() and \ - wireless.GetWirelessProperty(networkid, "encryption"): + wireless.GetWirelessProperty(self.networkID, "encryption"): error(self.ui, self.overlay, language['enable_encryption']) return False else: - #print 'encryption is ' + str(wireless.GetWirelessProperty(networkid, + #print 'encryption is ' + str(wireless.GetWirelessProperty(self.networkID, # "encryption")) #print "no encryption specified..." self.set_net_prop("enctype", "None") @@ -372,9 +372,9 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): self.set_net_prop('use_settings_globally', True) else: self.set_net_prop('use_settings_globally', False) - wireless.RemoveGlobalEssidEntry(networkid) + wireless.RemoveGlobalEssidEntry(self.networkID) - wireless.SaveWirelessNetworkProfile(networkid) + wireless.SaveWirelessNetworkProfile(self.networkID) return True # More or less ripped from netentry.py diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 1b59b54..5237ea2 100644 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -726,10 +726,10 @@ class appGUI(): @wrap_exceptions() def idle_incr(self): theText = " " - #if self.special != None: - # theText += self.special if self.connecting: theText += "-- "+language['connecting']+' -- '+language["esc_to_cancel"] + else: + theText += "-- Press H or ? for Help" quit_note = ' -- '+language["press_to_quit"] self.footer1 = urwid.Text(str(self.incr) + theText+quit_note,wrap='clip') self.incr+=1 diff --git a/setup.py b/setup.py index da80ea5..2e08fb9 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ import subprocess # VERSIONNUMBER VERSION_NUM = '1.6.0' REVISION_NUM = 'unknown' -CURSES_REVNO = 'r270' +CURSES_REVNO = 'r271' try: if not os.path.exists('vcsinfo.py'): From e5dbf2755fb33fb3a04019702b0c5aac475ce334 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Sun, 8 Feb 2009 12:26:50 -0500 Subject: [PATCH 2/3] curses/wicd-curses.py: Added a mention of the About dialog in the help curses/prefs_curses.py: Fixed mouse support in/man=wicd-curses.8.in Added a mention of the about dialog --- curses/prefs_curses.py | 2 +- curses/wicd-curses.py | 16 +++++++--------- in/man=wicd-curses.8.in | 3 +++ setup.py | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/curses/prefs_curses.py b/curses/prefs_curses.py index b450886..f5c5b4d 100755 --- a/curses/prefs_curses.py +++ b/curses/prefs_curses.py @@ -425,12 +425,12 @@ class PrefsDialog(urwid.WidgetWrap): return False for k in keys: #Send key to underlying widget: + overlay.keypress(dim, k) if urwid.is_mouse_event(k): event, button, col, row = k overlay.mouse_event( dim, event, button, col, row, focus=True) - overlay.keypress(dim, k) # Check if buttons are pressed. if self.CANCEL_PRESSED: return False diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 5237ea2..fc2293c 100644 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -93,16 +93,14 @@ class wrap_exceptions: #raise except DBusException: gobject.source_remove(redraw_tag) - # Quit the loop loop.quit() - # Zap the screen ui.stop() print "\n"+language['dbus_fail'] raise except : # If the UI isn't inactive (redraw_tag wouldn't normally be # set), then don't try to stop it, just gracefully die. - if redraw_tag != -1: + if redraw_tag != None: # Remove update_ui from the event queue gobject.source_remove(redraw_tag) # Quit the loop @@ -166,8 +164,8 @@ def check_for_wireless(iwconfig, wireless_ip, set_status): # working... # Also defunct. # Current list header is STR,ESSID,ENCRYPT,BSSID,TYPE,CHANNEL -def gen_list_header(): - return '%3s %4s %s %19s %s ' % ('NUM','STR','BSSID','CHANNEL','ESSID') +#def gen_list_header(): +# return '%3s %4s %s %19s %s ' % ('NUM','STR','BSSID','CHANNEL','ESSID') # Generate the list of networks. # Mostly borrowed/stolen from wpa_cli, since I had no clue what all of those @@ -245,9 +243,10 @@ def help_dialog(body): ('bold','I')," Scan for hidden networks\n", ('bold','S')," Select scripts\n", ('bold','O')," Set up Ad-hoc network\n", -('bold','C')," Configure Selected Network\n" +('bold','C')," Configure Selected Network\n", +('bold','A')," Display 'about' dialog\n" ] - help = TextDialog(theText,17,62,header=('header',"Wicd-Curses Help")) + help = TextDialog(theText,18,62,header=('header',"Wicd-Curses Help")) help.run(ui,body) def run_configscript(parent,netname,nettype): @@ -545,7 +544,6 @@ class appGUI(): self.prev_state = False self.connecting = False self.screen_locked = False - #self.always_show_wired = daemon.GetAlwaysShowWiredInterface() self.pref = None @@ -908,7 +906,7 @@ def run(): global loop,redraw_tag ui.set_mouse_tracking() - redraw_tag = -1 + redraw_tag = None app = appGUI() # Connect signals and whatnot to UI screen control functions diff --git a/in/man=wicd-curses.8.in b/in/man=wicd-curses.8.in index 06fa930..c38e426 100644 --- a/in/man=wicd-curses.8.in +++ b/in/man=wicd-curses.8.in @@ -39,6 +39,9 @@ Bring up hidden network scanning dialog .TP .BR "H " or " h " or " ?" Bring up a rather simplistic help dialog. Of course, it mentions this man page first. :-) +.TP +.BR A +Raise the "About wicd-curses" dialog .\".PP .\"The following is a work in progress and might not be fully functional as of yet. .TP diff --git a/setup.py b/setup.py index 2e08fb9..3d69126 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ import subprocess # VERSIONNUMBER VERSION_NUM = '1.6.0' REVISION_NUM = 'unknown' -CURSES_REVNO = 'r271' +CURSES_REVNO = 'r272' try: if not os.path.exists('vcsinfo.py'): From f4321d4411c2a277d24ddb2abf1a40a297a783cf Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Wed, 11 Feb 2009 10:44:57 -0500 Subject: [PATCH 3/3] Some minor code cleanup and fixes curses/wicd-curses.py: Fixed lag upon completing connections curses/wicd-curses.py,curses/prefs_curses.py,curses/curses_misc.py: Cleaned up some code, removed/reformatted some comments --- curses/curses_misc.py | 30 ++++++++++++++---------------- curses/prefs_curses.py | 36 ++++++++++-------------------------- curses/wicd-curses.py | 14 +++++++------- setup.py | 2 +- 4 files changed, 32 insertions(+), 50 deletions(-) diff --git a/curses/curses_misc.py b/curses/curses_misc.py index fbe607d..9e641fc 100644 --- a/curses/curses_misc.py +++ b/curses/curses_misc.py @@ -34,8 +34,8 @@ def error(ui,parent,message): return dialog.run(ui,parent) # My savior. :-) -# Although I could have made this myself pretty easily, just want to give credit where -# its due. +# Although I could have made this myself pretty easily, just want to give credit +# where it's due. # http://excess.org/urwid/browser/contrib/trunk/rbreu_filechooser.py class SelText(urwid.Text): """A selectable text widget. See urwid.Text.""" @@ -137,14 +137,14 @@ class MaskingEdit(urwid.Edit): focus. """ # If we aren't masking anything ATM, then act like an Edit. No problems. - if self.mask_mode == "off" or (self.mask_mode == 'on_focus' and focus == True): + if self.mask_mode == "off" or (self.mask_mode == 'on_focus' and focus == True): canv = self.__super.render((maxcol,),focus) - # The cache messes this thing up, because I am totally changing what is - # displayed. + # The cache messes this thing up, because I am totally changing what + # is displayed. self._invalidate() return canv - # Else, we have a slight mess to deal with... + # Else, we have a slight mess to deal with... self._shift_view_to_cursor = not not focus # force bool text, attr = self.get_text() @@ -218,14 +218,13 @@ class TabColumns(urwid.WidgetWrap): ### Combo box code begins here - class ComboBoxException(Exception): pass # A "combo box" of SelTexts # I based this off of the code found here: # http://excess.org/urwid/browser/contrib/trunk/rbreu_menus.py -# This is a hack. It isn't without quirks, but it more or less works. +# This is a hack/kludge. It isn't without quirks, but it more or less works. # We need to wait for changes in urwid's Canvas controls before we can actually # make a real ComboBox. class ComboBox(urwid.WidgetWrap): @@ -342,9 +341,11 @@ class ComboBox(urwid.WidgetWrap): str,trash = self.label.get_text() - self.cbox = DynWrap(SelText([self.list[self.focus]+' vvv']),attrs=self.attrs,focus_attr=self.focus_attr) + self.cbox = DynWrap(SelText([self.list[self.focus]+' vvv']), + attrs=self.attrs,focus_attr=self.focus_attr) if str != '': - w = urwid.Columns([('fixed',len(str),self.label),self.cbox],dividechars=1) + w = urwid.Columns([('fixed',len(str),self.label),self.cbox], + dividechars=1) self.overlay = self.ComboSpace(self.list,parent,ui,self.focus, pos=(len(str)+1,row)) else: @@ -371,7 +372,8 @@ class ComboBox(urwid.WidgetWrap): self.set_focus(self.list.index(retval)) #self.cbox.set_w(SelText(retval+' vvv')) if self.callback != None: - self.callback(self,self.overlay._listbox.get_focus()[1],self.user_args) + self.callback(self,self.overlay._listbox.get_focus()[1], + self.user_args) return self._w.keypress(size,key) def selectable(self): @@ -417,6 +419,7 @@ class Dialog2(urwid.WidgetWrap): #w = urwid.Padding(w, ('fixed left',2), ('fixed right',2)) #w = urwid.Filler(w, ('fixed top',1), ('fixed bottom',1)) #w = urwid.AttrWrap(w, 'body') + # buttons: tuple of name,exitcode def add_buttons(self, buttons): l = [] @@ -509,8 +512,3 @@ class InputDialog(Dialog2): def on_exit(self, exitcode): return exitcode, self.edit.get_edit_text() - -# Pile that has an edit and a label saying that the file at the path specified -# does not exist -#class FileGuessEdit(urwid.WidgetWrap): -# def __init__(self,caption='', diff --git a/curses/prefs_curses.py b/curses/prefs_curses.py index f5c5b4d..992bc84 100755 --- a/curses/prefs_curses.py +++ b/curses/prefs_curses.py @@ -110,7 +110,8 @@ class PrefsDialog(urwid.WidgetWrap): backend_cat_t = ('header',language['backend']) backend_t = language['backend']+':' backend_list = ['spam','double spam','triple spam','quadruple spam'] - #backend_warn_t = ('important','Changes to the backend (probably) requires a daemon restart') + #backend_warn_t = ('important', + # 'Changes to the backend (probably) requires a daemon restart') debug_cat_t = ('header',language['debugging']) debug_mode_t = language['use_debug_mode'] @@ -145,10 +146,10 @@ class PrefsDialog(urwid.WidgetWrap): self.always_show_wired_checkb = urwid.CheckBox(always_show_wired_t) self.wired_auto_l = [] - self.wired_auto_cat = urwid.Text(wired_auto_cat_t) - self.wired_auto_1 = urwid.RadioButton(self.wired_auto_l,wired_auto_1_t) - self.wired_auto_2 = urwid.RadioButton(self.wired_auto_l,wired_auto_2_t) - self.wired_auto_3 = urwid.RadioButton(self.wired_auto_l,wired_auto_3_t) + self.wired_auto_cat= urwid.Text(wired_auto_cat_t) + self.wired_auto_1 = urwid.RadioButton(self.wired_auto_l,wired_auto_1_t) + self.wired_auto_2 = urwid.RadioButton(self.wired_auto_l,wired_auto_2_t) + self.wired_auto_3 = urwid.RadioButton(self.wired_auto_l,wired_auto_3_t) self.auto_reconn_cat = urwid.Text(auto_reconn_cat_t) self.auto_reconn_checkb = urwid.CheckBox(auto_reconn_t) @@ -247,23 +248,10 @@ class PrefsDialog(urwid.WidgetWrap): self.OK_PRESSED = False - self.button_cols = urwid.Columns([ok_button,cancel_button],dividechars=1) - #self.active_tab = self.header0 + self.button_cols = urwid.Columns([ok_button,cancel_button], + dividechars=1) - #self.columns = urwid.Columns([('fixed',len(header0_t),self.header0), - # ('fixed',len(header1_t),self.header1), - # ('fixed',len(header2_t),self.header2), - # urwid.Text(('header',title),align='right')], - # dividechars=1) - - #content = [self.columns,generalPile] - #self._label = urwid.AttrWrap(SelText(titles),attr[0],attr[1]) - #self.walker = urwid.SimpleListWalker(content) - #self.listbox = urwid.ListBox(self.walker) - #self._linebox = urwid.LineBox(self._listbox) self.tabs = TabColumns(headerList,lbList,language['preferences'],self.button_cols) - #overlay = urwid.Overlay(self.tabs, body, ('fixed left', pos[0]), - # width, ('fixed top', pos[1]), height) self.__super.__init__(self.tabs) def load_settings(self): @@ -272,7 +260,7 @@ class PrefsDialog(urwid.WidgetWrap): self.OK_PRESSED = False ### General Settings - # Urwid does not like dbus.Strings as text markups + # ComboBox does not like dbus.Strings as text markups. My fault. :/ wless_iface = unicode(daemon.GetWirelessInterface()) wired_iface = unicode(daemon.GetWiredInterface()) self.wless_edit.set_edit_text(wless_iface) @@ -292,7 +280,6 @@ class PrefsDialog(urwid.WidgetWrap): # Wired Automatic Connection self.wired_auto_l[daemon.GetWiredAutoConnectMethod()-1] - self.auto_reconn_checkb.set_state(daemon.GetAutoReconnect()) ### External Programs @@ -320,7 +307,7 @@ class PrefsDialog(urwid.WidgetWrap): try: self.wpa_cbox.set_focus(self.wpadrivers.index(def_driver)) except ValueError: - pass # It defaults to 0 anyway + pass # It defaults to 0 anyway (I hope) self.backends = daemon.GetBackendList() self.thebackends= [unicode(w) for w in self.backends] @@ -405,9 +392,6 @@ class PrefsDialog(urwid.WidgetWrap): def run(self,ui, dim, display): width,height = ui.get_cols_rows() self.load_settings() - # TODO: The below, if things go 'well' - # If we are small, "tabbify" the interface - # Else, pile it together overlay = urwid.Overlay(self.tabs, display, ('fixed left', 0),width , ('fixed top',1), height-3) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index fc2293c..3fe5994 100644 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -100,7 +100,7 @@ class wrap_exceptions: except : # If the UI isn't inactive (redraw_tag wouldn't normally be # set), then don't try to stop it, just gracefully die. - if redraw_tag != None: + if redraw_tag != -1: # Remove update_ui from the event queue gobject.source_remove(redraw_tag) # Quit the loop @@ -702,9 +702,9 @@ class appGUI(): # something, and we aren't connecting to something, return False # immediately. if from_idle and not self.connecting: - self.update_netlist() + #self.update_netlist() self.update_status() - self.update_ui() + #self.update_ui() return False toAppend = '' # If we are connecting and being called from the idle function, spin @@ -759,11 +759,11 @@ class appGUI(): #canvaso = urwid.CanvasOverlay(self.dialog.render( (80,20),True),canvas,0,1) ui.draw_screen((self.size),canvas) keys = ui.get_input() - # Should make a keyhandler method, but this will do until I get around to - # that stage + + # Handle keystrokes if "f8" in keys or 'Q' in keys or 'q' in keys: loop.quit() - return False + #return False if "f5" in keys or 'R' in keys: self.lock_screen() wireless.Scan(True) @@ -906,7 +906,7 @@ def run(): global loop,redraw_tag ui.set_mouse_tracking() - redraw_tag = None + redraw_tag = -1 app = appGUI() # Connect signals and whatnot to UI screen control functions diff --git a/setup.py b/setup.py index 3d69126..5c88c27 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ import subprocess # VERSIONNUMBER VERSION_NUM = '1.6.0' REVISION_NUM = 'unknown' -CURSES_REVNO = 'r272' +CURSES_REVNO = 'r273' try: if not os.path.exists('vcsinfo.py'):