From 4dcb86d6a2ef31e740be5cd1f7f92dcfcf200970 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Tue, 12 May 2009 20:38:48 -0400 Subject: [PATCH 1/7] Added functions to get wicd-curses to run with urwid 0.9.9, not all functionality is tested at the moment. --- curses/curses_misc.py | 4 ++-- curses/wicd-curses.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/curses/curses_misc.py b/curses/curses_misc.py index 9639c9a..82266d4 100644 --- a/curses/curses_misc.py +++ b/curses/curses_misc.py @@ -208,7 +208,7 @@ class TabColumns(urwid.WidgetWrap): ]) if not firstrun: self.frame.set_body(self.pile) - self.set_w(self.frame) + self._set_w(self.frame) def selectable(self): return True @@ -381,7 +381,7 @@ class ComboBox(urwid.WidgetWrap): self.overlay = self.ComboSpace(self.list,parent,ui,self.focus, pos=(0,row)) - self.set_w(w) + self._set_w(w) self.parent = parent self.ui = ui self.row = row diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 315eb2b..2f311d4 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -967,7 +967,7 @@ class appGUI(): if not ui._started: return False ui.draw_screen((self.size),canvas) - keys = ui.get_input() + keys = ui.get_input_nonblocking()[1] self.handle_keys(keys) return True From 1382a111f1d9932a9ab2079dd3789f2de92967df Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Tue, 12 May 2009 22:22:59 -0400 Subject: [PATCH 2/7] Removed the blinking cursor problem by calling get_input_nonblocking appropriately. --- curses/wicd-curses.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 2f311d4..0d2e67c 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -590,6 +590,8 @@ class appGUI(): self.update_status() + self.update_tag = None + #self.max_wait = ui.max_wait #self.dialog = PrefOverlay(self.frame,self.size) def doScan(self, sync=False): @@ -951,9 +953,13 @@ class appGUI(): self.size = ui.get_cols_rows() continue + def call_update_ui(self,source,cb_condition): + self.update_ui(from_key=True) + return True + # Redraw the screen @wrap_exceptions - def update_ui(self): + def update_ui(self,from_key=True,from_alarm=False): #self.update_status() canvas = self.frame.render( (self.size),True ) ### GRRRRRRRRRRRRRRRRRRRRR ->^^^^ @@ -966,9 +972,29 @@ class appGUI(): # rest of the stuff. if not ui._started: return False + # Update the screen ui.draw_screen((self.size),canvas) - keys = ui.get_input_nonblocking()[1] + # Get the input data + input_data = ui.get_input_nonblocking() + max_wait = input_data[0] + keys = input_data[1] + + # Resolve any "alarms" in the waiting + if self.update_tag != None: + gobject.source_remove(self.update_tag) + self.update_tag = gobject.timeout_add(50, \ + self.update_ui,True) + + #self.update_tag = gobject.timeout_add(max_wait*1000.0, \ + # self.update_ui,from_alarm=true) + #print keys + #if keys == []: + # return True self.handle_keys(keys) + + # If we came from the "alarm", die. + if from_alarm: + return False return True @@ -1040,6 +1066,7 @@ def run(): ui.set_mouse_tracking() app = appGUI() + # Connect signals and whatnot to UI screen control functions bus.add_signal_receiver(app.dbus_scan_finished, 'SendEndScanSignal', 'org.wicd.daemon.wireless') @@ -1049,13 +1076,19 @@ def run(): bus.add_signal_receiver(app.update_netlist, 'StatusChanged', 'org.wicd.daemon') # Update what the interface looks like as an idle function - gobject.idle_add(app.update_ui) + #gobject.idle_add(app.update_ui) # Update the connection status on the bottom every 1.5 s. gobject.timeout_add(1500,app.update_status) # This will make sure that it is updated on the second. gobject.timeout_add(500,app.update_time) # DEFUNCT: Terminate the loop if the UI is terminated. #gobject.idle_add(app.stop_loop) + + app.update_ui() + # Get input file descriptors and add callbacks to the ui-updating function + fds = ui.get_input_descriptors() + for fd in fds: + gobject.io_add_watch(fd, gobject.IO_IN,app.call_update_ui) loop.run() # Mostly borrowed from gui.py From 92c43027c9c0255055b832976bef31ee364a818c Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Thu, 14 May 2009 19:19:46 -0400 Subject: [PATCH 3/7] Fixed a crash on startup. --- curses/wicd-curses.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 0d2e67c..f15e9e6 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -844,6 +844,7 @@ class appGUI(): # Handle keystrokes if "f8" in keys or 'Q' in keys or 'q' in keys: loop.quit() + print "blah" #return False if "f5" in keys or 'R' in keys: self.lock_screen() @@ -982,11 +983,13 @@ class appGUI(): # Resolve any "alarms" in the waiting if self.update_tag != None: gobject.source_remove(self.update_tag) - self.update_tag = gobject.timeout_add(50, \ - self.update_ui,True) + if max_wait == None: + max_wait = 50 + else: + max_wait *= 1000 - #self.update_tag = gobject.timeout_add(max_wait*1000.0, \ - # self.update_ui,from_alarm=true) + self.update_tag = gobject.timeout_add(max_wait, \ + self.update_ui,False,True) #print keys #if keys == []: # return True From 6157eb782ace3423b9e7c138483e058585eee471 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Mon, 25 May 2009 12:08:53 -0400 Subject: [PATCH 4/7] Really fix crash on startup if there is no connection present. --- curses/wicd-curses.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index a66f99d..7b93760 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -510,6 +510,9 @@ class appGUI(): self.list_header=urwid.AttrWrap(urwid.Text(gen_list_header()),'listbar') self.wlessH=NSelListBox([urwid.Text("Wireless Network(s)"),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] @@ -564,7 +567,6 @@ class appGUI(): self.update_status() - self.update_tag = None #self.max_wait = ui.max_wait def doScan(self, sync=False): @@ -799,7 +801,6 @@ class appGUI(): # Handle keystrokes if "f8" in keys or 'Q' in keys or 'q' in keys: loop.quit() - print "blah" #return False if "f5" in keys or 'R' in keys: self.lock_screen() From e11f99e4fc3fa956cdbb28edea2eecbe974c8278 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Sat, 30 May 2009 23:15:10 -0400 Subject: [PATCH 5/7] Increased idle screen redraw time to 100 ms. --- curses/wicd-curses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 5e173a6..f3ea888 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -939,7 +939,7 @@ class appGUI(): if self.update_tag != None: gobject.source_remove(self.update_tag) if max_wait == None: - max_wait = 50 + max_wait = 100 else: max_wait *= 1000 From 1930680787390f3c0e21634167dd91097cd63275 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Thu, 6 Aug 2009 23:58:13 -0400 Subject: [PATCH 6/7] Modified 1.6-urwid-0.9.9-compat to be compatible with 0.9.8.4. This should be compatible with 0.9.9 as well. --- curses/curses_misc.py | 6 ++++-- curses/wicd-curses.py | 14 ++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/curses/curses_misc.py b/curses/curses_misc.py index 2972b1c..4affdd6 100644 --- a/curses/curses_misc.py +++ b/curses/curses_misc.py @@ -204,7 +204,8 @@ class TabColumns(urwid.WidgetWrap): ]) if not firstrun: self.frame.set_body(self.pile) - self._set_w(self.frame) + self._w = self.frame + self._invalidate() def selectable(self): return True @@ -375,7 +376,8 @@ class ComboBox(urwid.WidgetWrap): self.overlay = self.ComboSpace(self.list,parent,ui,self.focus, pos=(0,row)) - self._set_w(w) + self._w = w + self._invalidate() self.parent = parent self.ui = ui self.row = row diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index cd920ab..7bf79c4 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -919,14 +919,7 @@ class appGUI(): def update_ui(self,from_key=True,from_alarm=False): #self.update_status() canvas = self.frame.render( (self.size),True ) - ### GRRRRRRRRRRRRRRRRRRRRR ->^^^^ - # It looks like if I want to get the statusbar to update itself - # continuously, I would have to use overlay the canvasses and redirect - # the input. I'll try to get that working at a later time, if people - # want that "feature". - #canvaso = urwid.CanvasOverlay(self.dialog.render( (80,20),True),canvas,0,1) - # If the screen is turned off for some reason, don't even try to do the - # rest of the stuff. + if not ui._started: return False # Update the screen @@ -940,10 +933,11 @@ class appGUI(): if self.update_tag != None: gobject.source_remove(self.update_tag) if max_wait == None: - max_wait = 100 + max_wait = 25 else: - max_wait *= 1000 + max_wait *= 100 + max_wait = int(max_wait) self.update_tag = gobject.timeout_add(max_wait, \ self.update_ui,False,True) #print keys From 61a92a3acc9b4a20e25391104d94843c0056b04c Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 7 Aug 2009 17:10:58 -0400 Subject: [PATCH 7/7] Prevent the progress spinner from spinning like crazy in the urwid tip. --- curses/wicd-curses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 7bf79c4..5dd0e16 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -706,7 +706,7 @@ class appGUI(): if self.connecting: if not self.conn_status: self.conn_status = True - gobject.idle_add(self.set_connecting_status,fast) + gobject.timeout_add(250,self.set_connecting_status,fast) return True else: if check_for_wired(wired.GetWiredIP(''),self.set_status):